@@ -14,38 +14,20 @@ function preprocess_functional_parcellation_zscore(subjectdir, atlas_filename, f
1414T = datetime(' now' ); time = whatsthetime(T );
1515fprintf([time ,sub , scan ' : ' ,' Functional Parcellation & Zcoring ... ' ])
1616
17- %% Parcellation & Z-scoring
18- nii_tmp= load_untouch_nii(atlas_filename );
19- TMP= nii_tmp .img ; ROI_ids= unique(TMP(: ));
20-
17+ %% Parcellation & Z-scoring
2118filename1= [filename , ' .nii.gz' ];
19+ cmd= [' 3dROIstats -mask ' atlas_filename ' -nomeanout -nzmean -quiet ' ...
20+ filename1 ' > ' filename ' _seed_' atlas ' .txt' ]; system(cmd );
21+ ts_parcel= dlmread([filename ' _seed_' atlas ' .txt' ])' ; ts_zscore= zscore(ts_parcel ,[],2 );
2222
23- % cmd=['3dROIstats -mask ' atlas_filename ' -nomeanout -nobriklab -nzmean -quiet ' ...
24- % filename1 ' > ' filename '_seed_' atlas '.txt'];
25- % system(cmd) ;
23+ cmd= [' 3dROIstats -mask ' atlas_filename ' -nomeanout -nzvoxels -quiet ' ...
24+ atlas_filename ' > ' atlas ' _voxelNum .txt' ]; system( cmd );
25+ voxel_per_roi1 = dlmread([ atlas ' _voxelNum.txt ' ]) ' ;
2626
27- nii_img= load_untouch_nii(filename1 );
28- IMG0= nii_img .img ; % IMG_parcel=zeros(size(IMG0)); IMG_zscore=zeros(size(IMG0));
29- Ntime= size(IMG0 ,4 );
30-
31- ts_parcel= zeros(length(ROI_ids )-1 ,Ntime );
32- ts_zscore= zeros(length(ROI_ids )-1 ,Ntime );
33-
34- voxel_per_roi1= zeros(length(ROI_ids )-1 ,1 );
35- voxel_per_roi2= zeros(length(ROI_ids )-1 ,1 );
36- parfor roi_ct= 1 : length(ROI_ids )-1
37- mask_roi= zeros(size(TMP ));
38- roi= ROI_ids(roi_ct + 1 );
39- mask_roi(TMP == roi )=1 ;
40- voxel_per_roi1(roi_ct )=length(nonzeros(mask_roi ));
41-
42- IMG_masked= bsxfun(@times , mask_roi , IMG0 );
43- v_roi = nonzeros(IMG_masked(: ,: ,: ,1 ));
44- voxel_per_roi2(roi_ct )=length(v_roi );
45- IMG_masked_2D= reshape(nonzeros(IMG_masked ),[voxel_per_roi2(roi_ct ), Ntime ]);
46- ts_parcel(roi_ct ,: )=mean(IMG_masked_2D ,1 );
47- ts_zscore(roi_ct ,: ) = zscore(ts_parcel(roi_ct ,: ));
48- end
27+ cmd= [' 3dROIstats -mask ' atlas_filename ' -nomeanout -nzvoxels -quiet ' ...
28+ filename1 ' [0] > ' filename ' _voxelNum_' atlas ' .txt' ]; system(cmd );
29+ voxel_per_roi2= dlmread([filename ' _voxelNum_' atlas ' .txt' ])' ;
4930voxel_per_roi= [voxel_per_roi1 , voxel_per_roi2 ];
31+
5032save([filename ' _on_parcel_' atlas ' .mat' ],' ts_parcel' , ' ts_zscore' ,' voxel_per_roi' );
5133fprintf(' Done\n ' )
0 commit comments