-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJC_normc123.m
72 lines (63 loc) · 2.22 KB
/
JC_normc123.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
% check SPM version
%%
% CREATED BY: JOCHEN WEBER
% CREATED ON: 11/22/16
% MODIFIED BY: JASON CRAGGS
%
% USAGE: PREPROCESS JASON'S R01 DATA
% I wrote a second script to only normalize the c1/c2/c3
% files to then perform the FCprepro step (which uses the
% GM/WM/CSF files *in the functional space* as global
% signal sources).
% MODIFIED TO: JASON IS PREPROCESSING ADDITIONAL SUBJECTS
%
%
% MODIFIED ON: 2017_09_27
% MODIFIED ON: 2017_12_07
% MODIFIED ON: 2017_12_12
%%
if ~strcmpi(spm('ver'), 'spm12')
error('spm:version:wrongSPMVersion', 'This script requires SPM12.');
end
% initialize SPM defaults and job manager
% spm12path = '/cluster/folder/craggs/software/spm12';
spm12path = '/Users/jcraggs/Applications/spm12';
spm('defaults','FMRI');
spm_jobman('initcfg');
clear matlabbatch;
% configure root path and subject pattern, as well as file patterns
%rootpath = '/cluster/folder/craggs/study/preprocessed/';
%rootpath = '/Volumes/Data/Imaging/R01/preprocessed/_Jason_0/';
%rootpath = '/Volumes/Data/Imaging/R01/preprocessed/_Jason/';
rootpath = '/Volumes/Data/Imaging/R01/preprocessed/';
subpattern = 'Sub*_v*';
% get subjects
dirinfo = dir([rootpath subpattern]);
subjlist = {dirinfo.name};
% iterate over subjects
for sc = 1:numel(subjlist)
% find warpfield
cd([rootpath filesep subjlist{sc}]);
deffield = dir('y_*.nii');
wcfiles = dir('wc*.nii');
if isempty(deffield) || ~isempty(wcfiles)
continue;
end
deffield = [pwd filesep deffield.name];
% find c1/c2/c3 files
c123 = [dir('c1T*.nii'); dir('c2T*.nii'); dir('c3T*.nii')];
if numel(c123) ~= 3
continue;
end
c123 = {c123.name};
for c = 1:3
c123{c} = [pwd filesep c123{c} ',1'];
end
% resample job
matlabbatch{1}.spm.spatial.normalise.write.subj.def = {deffield};
matlabbatch{1}.spm.spatial.normalise.write.subj.resample = c123(:);
matlabbatch{1}.spm.spatial.normalise.write.woptions = ...
struct('bb', [-78, -112, -70; 78, 76, 85], 'vox', [2, 2, 2], 'interp', 1, 'prefix', 'w');
spm_jobman('run', matlabbatch);
clear matlabbatch;
end