0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 global subject_ids proc_subs use_model_proto sinfo
0018 global rootpath
0019
0020 global COREG_WITH_MUTUAL_INFO
0021
0022
0023
0024
0025
0026 global model_action regressors2add created_model_specs
0027 global group_analyses
0028
0029 rootpath = '/data1/ts1/';
0030
0031
0032
0033
0034
0035
0036
0037
0038 SET_GENERAL_DEFS = 1;
0039
0040
0041
0042
0043
0044 REALIGN_EPI = 0;
0045 CREATE_MEAN_EPI = 0;
0046
0047 COREG_WITH_MUTUAL_INFO = 1;
0048 COREG_MEAN_EPI = 0;
0049 COREG_FIRST_EPI = 0;
0050
0051 COREG_COPLANAR_2_HIRES = 0;
0052 COREG_HIRES_2_TEMPLATE = 0;
0053
0054 RESLICE_EPI = 0;
0055
0056 NORM_COPLANAR_2_TEMPLATE = 0;
0057
0058 NORM_EPI_2_TEMPLATE = 0;
0059 NORM_EPI_2_TEMPLATE_CUST_BB = 0;
0060 NORM_EPI_2_TEMPLATE_SPM99_DEF_BB = 0;
0061 NORM_EPI_2_TEMPLATE_SPM99_BB4 = 0;
0062
0063 NORM_HIRES_2_TEMPLATE = 0;
0064
0065
0066
0067 SMOOTH_rEPI = 0;
0068 SMOOTH_nEPI = 0;
0069
0070
0071
0072
0073
0074 RUN_MODEL_INDIV = 0;
0075
0076 RUN_MODEL_NORM = 0;
0077
0078
0079 model_action = 'spec_and_estimate';
0080 regressors2add = {'linear','motion'};
0081
0082 COMPUTE_CONTRASTS_INDIV = 0;
0083 COMPUTE_CONTRASTS_NORM = 1;
0084
0085 COMPUTE_GROUP = 1;
0086 group_outdir = 'group';
0087 group_analysis_list = {'_all_t'};
0088
0089 THRESH_SUM = 0; THRESHSUM_CONTRAST=2;
0090
0091
0092
0093
0094 sinfo = get_ts1_sinfo;
0095
0096 subject_ids = cellstr(char(sinfo(:).id))
0097
0098 nsub = length(subject_ids);
0099 proc_subs = [1:12]
0100
0101
0102
0103
0104
0105
0106
0107 type = {'defaults_edit','model','contrasts','headers',...
0108 'means','realign','coreg','normalize','smooth','display','threshsum','stats'};
0109
0110
0111
0112
0113
0114 anal_list = strvcat(type);
0115
0116 analyses = struct('type',[],'index',[],'work_dir',[],'mfile',[]);
0117
0118 na = length(analyses.type);
0119
0120
0121
0122
0123
0124 work_dir = {rootpath, fullfile(rootpath, 'group'), ...
0125 };
0126
0127 for isub = 1:nsub
0128 work_dir{end+1} = fullfile(rootpath, subject_ids{isub}, 'single');
0129 end
0130
0131 for isub = 1:nsub
0132 work_dir{end+1} = fullfile(rootpath, subject_ids{isub}, 'normalized');
0133 end
0134
0135
0136
0137
0138
0139 if SET_GENERAL_DEFS
0140 disp('Will set general defaults ...')
0141 na = na+1;
0142 analyses.type(na) = strmatch('defaults_edit', anal_list,'exact');
0143 analyses.index(na) = 1;
0144 analyses.work_dir(na) = 1;
0145 analyses.mfile(na) = 1;
0146 end
0147
0148 if REALIGN_EPI
0149 disp('Will realign EPI runs ...')
0150 na = na+1;
0151 analyses.type(na) = strmatch('realign', anal_list,'exact');
0152 analyses.index(na) = 1;
0153 analyses.work_dir(na) = 1;
0154 analyses.mfile(na) = 2;
0155 end
0156
0157 if CREATE_MEAN_EPI
0158 disp('Will create mean resliced EPI image ...')
0159 na = na+1;
0160 analyses.type(na) = strmatch('realign', anal_list,'exact');
0161 analyses.index(na) = 2;
0162 analyses.work_dir(na) = 1;
0163 analyses.mfile(na) = 2;
0164 end
0165
0166 if COREG_MEAN_EPI
0167 disp('Will coregister mean EPI with coplanars ...')
0168 na = na+1;
0169 analyses.type(na) = strmatch('coreg', anal_list,'exact');
0170 analyses.index(na) = 1;
0171 analyses.work_dir(na) = 1;
0172 analyses.mfile(na) = 2;
0173 end
0174
0175 if COREG_FIRST_EPI
0176 disp('Will coregister first EPI of first run with coplanars ...')
0177 na = na+1;
0178 analyses.type(na) = strmatch('coreg', anal_list,'exact');
0179 analyses.index(na) = 2;
0180 analyses.work_dir(na) = 1;
0181 analyses.mfile(na) = 2;
0182 end
0183
0184 if COREG_COPLANAR_2_HIRES
0185 disp('Will coregister the coplanars to the hires ...')
0186 na = na+1;
0187 analyses.type(na) = strmatch('coreg', anal_list,'exact');
0188 analyses.index(na) = 3;
0189 analyses.work_dir(na) = 1;
0190 analyses.mfile(na) = 2;
0191 end
0192
0193 if COREG_HIRES_2_TEMPLATE
0194 disp('Will coregister the hires to the template ...')
0195 na = na+1;
0196 analyses.type(na) = strmatch('coreg', anal_list,'exact');
0197 analyses.index(na) = 4;
0198 analyses.work_dir(na) = 1;
0199 analyses.mfile(na) = 2;
0200 end
0201
0202 if RESLICE_EPI
0203 disp('Will reslice EPI images ...')
0204 na = na+1;
0205 analyses.type(na) = strmatch('realign', anal_list, 'exact');
0206 analyses.index(na) = 3;
0207 analyses.work_dir(na) = 1;
0208 analyses.mfile(na) = 2;
0209 end
0210
0211
0212 if NORM_COPLANAR_2_TEMPLATE
0213 disp('will normalize coplanars to template (parameter&reslice) ... ')
0214 na = na+1;
0215 analyses.type(na) = strmatch('normalize', anal_list, 'exact');
0216 analyses.index(na) = 2;
0217 analyses.work_dir(na) = 1;
0218 analyses.mfile(na) = 2;
0219 end
0220
0221 if NORM_EPI_2_TEMPLATE
0222 disp('will normalize EPIs to template (parameters&reslice) ... ')
0223 na = na+1;
0224 analyses.type(na) = strmatch('normalize', anal_list, 'exact');
0225 analyses.index(na) = 3;
0226 analyses.work_dir(na) = 1;
0227 analyses.mfile(na) = 2;
0228 end
0229
0230 if NORM_EPI_2_TEMPLATE_CUST_BB
0231 disp('will normalize EPIs to template using custom bounding box(parameters&reslice) ... ')
0232 na = na+1;
0233 analyses.type(na) = strmatch('normalize', anal_list, 'exact');
0234 analyses.index(na) = 4;
0235 analyses.work_dir(na) = 1;
0236 analyses.mfile(na) = 2;
0237 end
0238
0239 if NORM_EPI_2_TEMPLATE_SPM99_DEF_BB
0240 disp('will normalize EPIs to template using SPM99 default bounding box (parameters&reslice) ... ')
0241 na = na+1;
0242 analyses.type(na) = strmatch('normalize', anal_list, 'exact');
0243 analyses.index(na) = 5;
0244 analyses.work_dir(na) = 1;
0245 analyses.mfile(na) = 2;
0246 end
0247
0248 if NORM_EPI_2_TEMPLATE_SPM99_BB4
0249 disp('will normalize EPIs to template using SPM99 bounding box 4 (parameters&reslice) ... ')
0250 na = na+1;
0251 analyses.type(na) = strmatch('normalize', anal_list, 'exact');
0252 analyses.index(na) = 6;
0253 analyses.work_dir(na) = 1;
0254 analyses.mfile(na) = 2;
0255 end
0256
0257 if NORM_HIRES_2_TEMPLATE
0258 disp('will normalize hires to template (parameter&reslice) ... ')
0259 na = na+1;
0260 analyses.type(na) = strmatch('normalize', anal_list, 'exact');
0261 analyses.index(na) = 1;
0262 analyses.work_dir(na) = 1;
0263 analyses.mfile(na) = 2;
0264 end
0265
0266 if SMOOTH_rEPI
0267 disp('will smooth resliced EPIs (individuals) ... ')
0268 na = na+1;
0269 analyses.type(na) = strmatch('smooth', anal_list, 'exact');
0270 analyses.index(na) = 1;
0271 analyses.work_dir(na) = 1;
0272 analyses.mfile(na) = 3;
0273 end
0274
0275 if SMOOTH_nEPI
0276 disp('will smooth normalized EPIs ... ')
0277 na = na+1;
0278 analyses.type(na) = strmatch('smooth', anal_list, 'exact');
0279 analyses.index(na) = 2;
0280 analyses.work_dir(na) = 1;
0281 analyses.mfile(na) = 3;
0282 end
0283
0284 if RUN_MODEL_INDIV
0285 disp('will run model - individual data ...')
0286
0287 use_model_proto = 1;
0288
0289 nsub_proc = length(proc_subs);
0290
0291 for isub = 1:nsub_proc
0292 na = na+1;
0293 analyses.type(na) = strmatch('model', anal_list, 'exact');
0294 analyses.index(na) = proc_subs(isub);
0295 work_dir_idx = 2*length(work_dir) - nsub + proc_subs(isub);
0296 analyses.work_dir(na) = work_dir_idx;
0297 analyses.mfile(na) = 4;
0298
0299
0300 if ~exist(work_dir{work_dir_idx},'dir')
0301 disp(sprintf('Creating directory: %s', work_dir{work_dir_idx}))
0302 unix(['mkdir ' work_dir{work_dir_idx}]);
0303 end
0304 end
0305 end
0306
0307 if RUN_MODEL_NORM
0308 disp('will run model - normalized data...')
0309
0310 use_model_proto = 2;
0311
0312 created_model_specs = 0;
0313
0314 nsub_proc = length(proc_subs);
0315
0316 for isub = 1:nsub_proc
0317 na = na+1;
0318 analyses.type(na) = strmatch('model', anal_list, 'exact');
0319 analyses.index(na) = proc_subs(isub);
0320 work_dir_idx = length(work_dir) - nsub + proc_subs(isub);
0321 analyses.work_dir(na) = work_dir_idx;
0322 analyses.mfile(na) = 5;
0323
0324
0325 if ~exist(work_dir{work_dir_idx},'dir')
0326 disp(sprintf('Creating directory: %s', work_dir{work_dir_idx}))
0327 unix(['mkdir ' work_dir{work_dir_idx}]);
0328 end
0329 end
0330 end
0331
0332 if COMPUTE_CONTRASTS_INDIV
0333 disp('will compute contrasts - individual data ...')
0334
0335 nsub_proc = length(proc_subs);
0336
0337 for isub = 1:nsub_proc
0338 na = na+1;
0339 analyses.type(na) = strmatch('contrasts', anal_list, 'exact');
0340 analyses.index(na) = 1;
0341 work_dir_idx = 2*length(work_dir) - nsub + proc_subs(isub);
0342 analyses.work_dir(na) = work_dir_idx;
0343 analyses.mfile(na) = 6;
0344 end
0345
0346 end
0347
0348 if COMPUTE_CONTRASTS_NORM
0349 disp('will compute contrasts - normalized data ...')
0350
0351 nsub_proc = length(proc_subs);
0352
0353 for isub = 1:nsub_proc
0354 na = na+1;
0355 analyses.type(na) = strmatch('contrasts', anal_list, 'exact');
0356 analyses.index(na) = proc_subs(isub);
0357 work_dir_idx = length(work_dir) - nsub + proc_subs(isub);
0358 analyses.work_dir(na) = work_dir_idx;
0359 analyses.mfile(na) = 6;
0360 end
0361
0362 end
0363
0364
0365
0366 if COMPUTE_GROUP
0367 disp('will compute group statistics - normalized data ...')
0368
0369
0370 groupdir = fullfile(rootpath, group_outdir);
0371 if ~exist(groupdir,'dir')
0372 disp(sprintf('Creating directory: %s', groupdir))
0373 unix(['mkdir ' groupdir]);
0374 end
0375
0376
0377
0378
0379
0380 ts1_contrasts
0381
0382 if strmatch('_all_t', group_analysis_list, 'exact')
0383 ng = 0;
0384 for ic = 1:length(contrasts(1).names)
0385 if contrasts(1).types{ic} == 'T'
0386 ng = ng+1;
0387 group_analyses{ng} = contrasts(1).names{ic};
0388 end
0389 end
0390 else
0391 group_analyses = group_analysis_list;
0392 end
0393
0394 ngroup_anal = length(group_analyses);
0395
0396 for ig = 1:ngroup_anal
0397
0398
0399 na = na+1;
0400 analyses.type(na) = strmatch('stats', anal_list, 'exact');
0401 analyses.index(na) = ig;
0402 work_dir{end+1} = fullfile(groupdir,group_analyses{ig});
0403 work_dir_idx = length(work_dir);
0404 analyses.work_dir(na) = work_dir_idx;
0405 if ~exist(work_dir{work_dir_idx},'dir')
0406 disp(sprintf('Creating directory: %s', work_dir{work_dir_idx}))
0407 unix(['mkdir ' work_dir{work_dir_idx}]);
0408 end
0409 analyses.mfile(na) = 10;
0410
0411
0412 na = na+1;
0413 analyses.type(na) = strmatch('contrasts', anal_list, 'exact');
0414 analyses.index(na) = nsub+ig;
0415 analyses.work_dir(na) = work_dir_idx;
0416 analyses.mfile(na) = 6;
0417 end
0418 end
0419
0420 if THRESH_SUM
0421 disp('will sum thresholded images ...')
0422 na = na+1;
0423 analyses.type(na) = strmatch('threshsum', anal_list, 'exact');
0424 analyses.index(na) = THRESHSUM_CONTRAST;
0425 analyses.work_dir(na) = 2;
0426 analyses.mfile(na) = 9;
0427 end
0428
0429
0430
0431
0432
0433
0434 mfile = ...
0435 { '/data1/matlab/ts1/ts1_defaults.m', ...
0436 '/data1/matlab/ts1/ts1_realign.m', ...
0437 '/data1/matlab/ts1/ts1_smooth.m', ...
0438 '/data1/matlab/ts1/ts1_model_indiv.m', ...
0439 '/data1/matlab/ts1/ts1_model_norm.m', ...
0440 '/data1/matlab/ts1/ts1_contrasts.m', ...
0441 '/data1/matlab/ts1/ts1_group.m', ...
0442 '/data1/matlab/ts1/ts1_display.m', ...
0443 '/data1/matlab/ts1/ts1_threshsum.m', ...
0444 '/data1/matlab/ts1/ts1_stats.m' ...
0445 };
0446