Skip to content

Commit

Permalink
count the ROI volume information
Browse files Browse the repository at this point in the history
  • Loading branch information
zclhit committed Apr 6, 2017
1 parent 2e98c30 commit 101d435
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions ROI_volmue.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
%function:统计一个目录下所有分割结果中286个脑区的ROI大小,放到一个txt文档中
clc;clear all;close all;
pathname_G1 = 'G:\韩璎课题组数据\NC\NC_分割结果';
cd(pathname_G1);
dirs_G1=dir([pathname_G1, '\*.*']);
dircell_G1=struct2cell(dirs_G1)' ;
filenames_G1=dircell_G1(3:length(dircell_G1),1);
%file_path_G1=fullfile(pathname_G1,filenames_G1); %保存各网络参数的全路径
dirs_G2=dir([pathname_G1, '\*.*']);
dircell_G2=struct2cell(dirs_G2)' ;
filenames_G2=dircell_G2(3:length(dircell_G2),1);
savemat = zeros(length(filenames_G1),286);
for i=1:length(filenames_G1)
cd(char(filenames_G1(i)));
cd output;
clear dirs_G2;clear dircell_G2;clear filenames_G2;
dirs_G2=dir;
dircell_G2=struct2cell(dirs_G2)' ;
filenames_G2=dircell_G2(3:length(dircell_G2),1);
len = length(filenames_G2);
for j = 1:len

filenamesIS = char(filenames_G2(j));
jamar = strfind(filenamesIS,'286Labels_MNI.img');
if length(jamar) ~= 0

[hdr,filetype,fileprefix,machine] = load_nii_hdr(filenamesIS);
[img,hdr] = load_nii_img(hdr,filetype,fileprefix,machine);
for k = 1:286
counter = length(find(img==k));
savemat(i,k)= counter;
end
end

end


cd(pathname_G1);
end
save wholeBrain_voxel.txt -ascii savemat;

0 comments on commit 101d435

Please sign in to comment.