Skip to content

Commit 63204d5

Browse files
authored
Add files via upload
1 parent 2887ec3 commit 63204d5

File tree

2 files changed

+12
-30
lines changed

2 files changed

+12
-30
lines changed

partialbrain_preprocessing_pipeline2020_nx/epi_split.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function epi_split(subjectdir, filename, scans_subj, prefix, fsldir, Ntime)
44
cd(subjectdir);
55
system('pwd');
66

7-
for scan_num=1:length(scans_subj)
7+
parfor scan_num=1:length(scans_subj)
88
cmd = [fsldir 'fslroi ' filename ' ' char(scans_subj(scan_num)) ...
99
prefix ' ' num2str(Ntime * (scan_num - 1)) ' ' num2str(Ntime)];
1010
disp(cmd);

partialbrain_preprocessing_pipeline2020_nx/preprocess_functional_parcellation_zscore.m

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,20 @@ function preprocess_functional_parcellation_zscore(subjectdir, atlas_filename, f
1414
T = datetime('now'); time = whatsthetime(T);
1515
fprintf([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
2118
filename1=[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'])';
4930
voxel_per_roi=[voxel_per_roi1, voxel_per_roi2];
31+
5032
save([filename '_on_parcel_' atlas '.mat'],'ts_parcel', 'ts_zscore','voxel_per_roi');
5133
fprintf('Done\n')

0 commit comments

Comments
 (0)