Skip to content

Commit c41240d

Browse files
authored
Add files via upload
1 parent ec6e2a5 commit c41240d

6 files changed

+38
-32
lines changed

Diff for: Script_to_Run.m

+15-8
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,16 @@
2727
%Please set the following parameters for rest fMRI data preprocessing
2828

2929
% Data Directory (Be sure your data structure is correct!!)
30-
workingDir='/home/wkgong/MATLAB/mycode/Rest_Preprcessing/example';
30+
workingDir='/home/gongweikang/Depression/xinan';
3131

32-
% Slice Timing TR (in second)
33-
TR=2.5;
3432

35-
% Slice order (1: bottom up, 2: top down, 3: interleaved+bottem up, 4: interleaved+top down)
33+
% whether do slicetiming
34+
Is_slicetiming=1;
35+
36+
% Slice Timing TR (in second) (useful for filter)
37+
TR=2;
38+
39+
% Slice order (1: bottom up, 2: top down, 3: interleaved+bottem up, 4: interleaved+top down, 'file.txt': specify slice direction)
3640
slice_order=3;
3741

3842
% Spatial Gaussian Kernel Full-Width at Half Maximum (in mm)
@@ -44,29 +48,32 @@
4448
% bandpass ([low,high] in Hz)
4549
bandpass=[0.01,0.1];
4650

51+
52+
% The standard space to which each image is mapped.
53+
resolution='3mm';
54+
4755
% Maximum Memory allowed for Wavelet Despiking (in GB)
4856
memory=3;
4957

5058
% Number of processors
51-
n_core=20;
59+
n_core=19;
5260

5361
%Be sure that memory*n_core < maximum memory allowed!!
5462

5563

5664

5765
%% Main Function
66+
options.Is_slicetiming=Is_slicetiming;
5867
options.TR=TR;
5968
options.slice_order=slice_order;
6069
options.FWHM=FWHM;
6170
options.motion=motion;
6271
options.memory=memory;
6372
options.n_core=n_core;
6473
options.bandpass=bandpass;
65-
74+
options.resolution=resolution;
6675
g_MainFunction(workingDir,options);
6776

6877

6978

7079

71-
72-

Diff for: g_Func2std_mapping.m

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
11

2-
function g_Func2std_mapping(infile1,infile2)
2+
function g_Func2std_mapping(infile1,infile2,resolution)
33

44
disp('Mapping FunImg to Standard Space...')
55

6+
%resolution='3mm';
67

78
d1=which('g_Func2std_mapping');
89
d1=strrep(d1,'g_Func2std_mapping.m','');
9-
reff1=[d1,'MNI152_T1_3mm_brain'];
10+
reff1=[d1,'MNI152_T1_',resolution,'_brain'];
1011
folder='7_FunImg_to_Std';
1112
mkdir(folder);
1213
unix(['mv Func2std.nii.gz ',folder]);
1314
unix(['mv std2Func.nii.gz ',folder]);
1415
unix(['mv Fun2strBBR ',folder]);
1516

16-
command=['applywarp --ref=',reff1,' --in=',infile1,' --warp=./7_FunImg_to_Std/Func2std --rel --out=FunImg_3mmStdSpace --interp=sinc'];
17+
command=['applywarp --ref=',reff1,' --in=',infile1,' --warp=./7_FunImg_to_Std/Func2std --rel --out=FunImg_',resolution,'StdSpace --interp=sinc'];
1718
unix(command);
1819

19-
command=['applywarp --ref=',reff1,' --in=',infile2,' --warp=./7_FunImg_to_Std/Func2std --rel --out=FunImg_3mmStdSpace_NoGlobalSignal --interp=sinc'];
20+
command=['applywarp --ref=',reff1,' --in=',infile2,' --warp=./7_FunImg_to_Std/Func2std --rel --out=FunImg_',resolution,'StdSpace_NoGlobalSignal --interp=sinc'];
2021
unix(command);
2122

2223

2324

24-
movefile('FunImg_3mmStdSpace.nii.gz',folder);
25-
movefile('FunImg_3mmStdSpace_NoGlobalSignal.nii.gz',folder);
25+
movefile(['FunImg_',resolution,'StdSpace.nii.gz'],folder);
26+
movefile(['FunImg_',resolution,'StdSpace_NoGlobalSignal.nii.gz'],folder);
2627

2728
disp('Finished!');
2829

2930

3031

31-
end
32+
end

Diff for: g_MainFunction.m

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function g_MainFunction(workingDir,options)
4242
outfile='Slice_Timing_Corrected';
4343
else
4444
infile=['./',folder,'/',outfile];
45-
[outfile,folder]=g_slicetiming(infile,options.TR,options.slice_order);
45+
[outfile,folder]=g_slicetiming(infile,options.Is_slicetiming,options.TR,options.slice_order);
4646
end
4747

4848

@@ -122,15 +122,15 @@ function g_MainFunction(workingDir,options)
122122
end
123123

124124
%fun2str2std
125-
f9=dir('./7_FunImg_to_Std/FunImg_4mmStdSpace.nii.gz');
125+
f9=dir(['./7_FunImg_to_Std/FunImg_',options.resolution,'StdSpace.nii.gz']);
126126
if length(f9)==1
127127
disp('FunImg has been normalized, omit this step...');
128128
unix('rm Func2std.nii.gz');
129129
unix('rm std2Func.nii.gz');
130130
else
131131
infile1=['./',folder,'/',outfile1];
132132
infile2=['./',folder,'/',outfile2];
133-
g_Func2std_mapping(infile1,infile2)
133+
g_Func2std_mapping(infile1,infile2,options.resolution)
134134
end
135135

136136
%plot picture

Diff for: g_T1preprocessing.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
disp('Done...');
2323
%bet
2424
disp('Brain extraction...');
25-
command3=['bet cc_',f1,' bet_cc_',f1,' -m'];
25+
command3=['bet cc_',f1,' bet_cc_',f1,' -m -f 0.3'];
2626
unix(command3);
2727
disp('Done...');
2828

Diff for: g_regressWmCsf_and_filter.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@
8080

8181
if TR~=0
8282
%regress them out and do temporal filtering
83-
command10=['3dTproject -ort csf_wm_motion.1D -prefix regressed_and_filtered.nii.gz -passband ',num2str(bandpass(1)),' ',num2str(bandpass(2)),' -input ',infile,'.nii.gz -dt ',TR];
83+
command10=['3dTproject -ort csf_wm_motion.1D -prefix regressed_and_filtered.nii.gz -passband ',num2str(bandpass(1)),' ',num2str(bandpass(2)),' -input ',infile,'.nii.gz -dt ',num2str(TR)];
8484
unix(command10);
85-
command10=['3dTproject -ort csf_wm_motion_global.1D -prefix regressed_and_filtered_NoGlobalSignal.nii.gz -passband ',num2str(bandpass(1)),' ',num2str(bandpass(2)),' -input ',infile,'.nii.gz -dt ',TR];
85+
command10=['3dTproject -ort csf_wm_motion_global.1D -prefix regressed_and_filtered_NoGlobalSignal.nii.gz -passband ',num2str(bandpass(1)),' ',num2str(bandpass(2)),' -input ',infile,'.nii.gz -dt ',num2str(TR)];
8686
unix(command10);
8787
else
8888
command10=['3dTproject -ort csf_wm_motion.1D -prefix regressed_and_filtered.nii.gz -passband ',num2str(bandpass(1)),' ',num2str(bandpass(2)),' -input ',infile,'.nii.gz'];

Diff for: g_slicetiming.m

+9-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
function [outfile,folder]=g_slicetiming(infile,TR,slice_order)
1+
function [outfile,folder]=g_slicetiming(infile,Is_slicetiming,TR,slice_order)
22

33

44

55
%slice timing
66
disp('Slice timing correction...');
77

8-
if TR==0
8+
if Is_slicetiming==0
99
disp(['TR is ',num2str(TR),'...']);
1010
outfile='Slice_Timing_Corrected';
1111
folder='2_Slice_Timing_Corrected';
@@ -29,24 +29,22 @@
2929
disp('Slice order is bottom-up..')
3030
command=['slicetimer -i ',infile,' -o ',outfile,' -r ',TR];
3131
unix(command);
32-
end
33-
34-
if slice_order==2
32+
elseif slice_order==2
3533
disp('Slice order is top-down..')
3634
command=['slicetimer -i ',infile,' -o ',outfile,' --down -r ',TR];
3735
unix(command);
38-
end
39-
40-
if slice_order==3
36+
elseif slice_order==3
4137
disp('Slice order is interleaved and bottom up..')
4238
command=['slicetimer -i ',infile,' -o ',outfile,' --odd -r ',TR];
4339
unix(command);
44-
end
45-
46-
if slice_order==4
40+
elseif slice_order==4
4741
disp('Slice order is interleaved and top down..')
4842
command=['slicetimer -i ',infile,' -o ',outfile,' --odd --down -r ',TR];
4943
unix(command);
44+
else
45+
disp('Slice order is specified elsewhere..')
46+
command=['slicetimer -i ',infile,' -o ',outfile,' -r ',TR,' --ocustom=',slice_order];
47+
unix(command);
5048
end
5149

5250
movefile([outfile,'.nii.gz'],folder);

0 commit comments

Comments
 (0)