Home > fmri > simulate > simulate_batch.m

simulate_batch

PURPOSE ^

Specifications for batch processing data for simulate_batch

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 
  Specifications for batch processing data for simulate_batch

  This can be viewed as a template batch specification file, though in the
  simulate context it is being used only to create design matrices

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %
0002 %  Specifications for batch processing data for simulate_batch
0003 %
0004 %  This can be viewed as a template batch specification file, though in the
0005 %  simulate context it is being used only to create design matrices
0006 %
0007 
0008 %
0009 %  GLOBAL variables
0010 %
0011 
0012 global subject_ids proc_subs use_model_proto sinfo model_action
0013 global rootpath dataroot batch_root
0014 global group_analyses
0015 
0016 global SCAN_OFFSET                % has to be specified in get_subject_info.m
0017                                   % number of volumes at the start of
0018                   % each run that were "hidden" from
0019                   % view, i.e. excluded from the analysis
0020                     
0021 % Regressor globals
0022 global REGRESS_MOTION_CORRECTION_PARAMS ADD_LINEAR_TREND_REGRESS ADD_RT_REGRESS
0023 REGRESS_MOTION_CORRECTION_PARAMS = 0;
0024 ADD_LINEAR_TREND_REGRESS = 0;
0025 ADD_RT_REGRESS =0;
0026 
0027 global COREG_WITH_MUTUAL_INFO        % Perform coregistration using mutual
0028                                         % information method rather than the
0029                                         % standard method.  This hopefully
0030                                         % overcomes some of the distortions due
0031                                         % to the FIL EPI template.
0032 
0033 rootpath = dataroot; % dataroot is specified in simulate_start.m
0034 
0035 %
0036 %  STRUCTURE CONTAINING LIST OF ANALYSES TO PERFORM
0037 %
0038 %  The analyses structure is created dynamically based on the list of desired
0039 %  analyses
0040 %
0041 
0042 SET_GENERAL_DEFS = 1;
0043 SET_F_EQUAL1 = 1;
0044 
0045 %
0046 % PREPROCESSING OPTIONS
0047 %
0048 
0049 REALIGN_EPI = 0;
0050 CREATE_MEAN_EPI = 0;
0051 
0052 COREG_WITH_MUTUAL_INFO = 0;
0053 COREG_MEAN_EPI = 0;
0054 COREG_FIRST_EPI = 0;
0055 
0056 COREG_COPLANAR_2_HIRES = 0;
0057 
0058 COREG_HIRES_2_TEMPLATE = 0;
0059 RESLICE_EPI = 0;
0060 
0061 NORM_COPLANAR_2_TEMPLATE = 0;
0062 
0063 NORM_EPI_2_TEMPLATE = 0;
0064 NORM_EPI_2_TEMPLATE_CUST_BB = 0;
0065 NORM_EPI_2_TEMPLATE_SPM99_DEF_BB = 0; %USE this
0066 NORM_EPI_2_TEMPLATE_SPM99_BB4 = 0;
0067 
0068 NORM_HIRES_2_TEMPLATE = 0;
0069 
0070 SMOOTH_rEPI = 0;
0071 SMOOTH_nEPI = 0;
0072 
0073 %
0074 % MODELLING OPTIONS
0075 %
0076 
0077 RUN_MODEL_INDIV = 0;            % Create and evaluate model of single
0078                                         % subject, unnormalized data
0079 RUN_MODEL_NORM = 1;            % Create and evaluate model of single
0080                                         % subject, normalized data (for group analyses)
0081 use_model_proto = 1;  
0082 model_action = 'specify';
0083 
0084 COMPUTE_CONTRASTS_INDIV = 0;
0085 COMPUTE_CONTRASTS_NORM = 0;
0086 
0087 COMPUTE_GROUP = 0;   % tw implemented _ only for t-contrasts
0088 group_analyses = {'RC-UC_hrf', 'RD-UD_hrf', 'RC-RD_hrf', 'UC-UD_hrf'};
0089 
0090 THRESH_SUM = 0; THRESHSUM_CONTRAST=2;
0091 
0092 %
0093 %  SUBJECT INFO
0094 %
0095 subject_ids = cellstr(char(sinfo(:).id))
0096 
0097 nsub = length(subject_ids);
0098 proc_subs = [1]            % Indices of subjects to process
0099 
0100 
0101 %
0102 %  LIST OF ANALYSIS TYPES
0103 %
0104 
0105 % This is a list of the analysis types supported by SPM99
0106 type = {'defaults_edit','model','contrasts','headers',...
0107 'means','realign','coreg','normalize','smooth','display','threshsum', 'stats'};
0108 
0109 %
0110 %  GROUP ANALYSIS PARAMETERS
0111 %
0112 
0113 anal_list = strvcat(type);
0114 
0115 % SPM99 expects to find a structure called 'analyses' that contains the 4
0116 % fields specified in the following line of code
0117 analyses = struct('type',[],'index',[],'work_dir',[],'mfile',[]);
0118 
0119 na = length(analyses.type);
0120 
0121 %
0122 %  LIST OF WORK DIRECTORIES
0123 %
0124 
0125 work_dir = {rootpath, fullfile(rootpath, 'group_deriv'), ...
0126       };
0127 
0128 for isub = 1:nsub
0129   work_dir{end+1} = fullfile(rootpath, subject_ids{isub}, 'single');
0130 end
0131  
0132 for isub = 1:nsub
0133   work_dir{end+1} = fullfile(rootpath, subject_ids{isub}, 'stats');
0134 end
0135 
0136 %
0137 %  SPECIFY ANALYSES TO RUN
0138 %
0139 
0140 if SET_GENERAL_DEFS
0141   disp('Will set general defaults ...')
0142   na = na+1;
0143   analyses.type(na) = strmatch('defaults_edit', anal_list,'exact');
0144   analyses.index(na) = 1;
0145   analyses.work_dir(na) = 1;
0146   analyses.mfile(na) = 1;   
0147 end
0148 
0149 if REALIGN_EPI
0150   disp('Will realign EPI runs ...')
0151   na = na+1;
0152   analyses.type(na) = strmatch('realign', anal_list,'exact');
0153   analyses.index(na) = 1;
0154   analyses.work_dir(na) = 1;
0155   analyses.mfile(na) = 2;
0156 end
0157 
0158 if CREATE_MEAN_EPI
0159   disp('Will create mean resliced EPI image ...')
0160   na = na+1;
0161   analyses.type(na) = strmatch('realign', anal_list,'exact');
0162   analyses.index(na) = 2;
0163   analyses.work_dir(na) = 1;
0164   analyses.mfile(na) = 2;
0165 end
0166 
0167 if COREG_MEAN_EPI
0168   disp('Will coregister mean EPI with coplanars ...')
0169   na = na+1;
0170   analyses.type(na) = strmatch('coreg', anal_list,'exact');
0171   analyses.index(na) = 1;
0172   analyses.work_dir(na) = 1;
0173   analyses.mfile(na) = 2;
0174 end
0175 
0176 if COREG_FIRST_EPI
0177   disp('Will coregister first EPI of first run with coplanars ...')
0178   na = na+1;
0179   analyses.type(na) = strmatch('coreg', anal_list,'exact');
0180   analyses.index(na) = 2;
0181   analyses.work_dir(na) = 1;
0182   analyses.mfile(na) = 2;
0183 end
0184 
0185 if COREG_COPLANAR_2_HIRES
0186    disp('Will coregister the coplanars to the hires  ...')
0187    na = na+1;
0188    analyses.type(na) = strmatch('coreg', anal_list,'exact');
0189    analyses.index(na) = 3;
0190    analyses.work_dir(na) = 1;
0191    analyses.mfile(na) = 2;
0192 end  
0193 
0194 if COREG_HIRES_2_TEMPLATE
0195    disp('Will coregister the hires to the template ...')
0196    na = na+1;
0197    analyses.type(na) = strmatch('coreg', anal_list,'exact');
0198    analyses.index(na) = 4; 
0199    analyses.work_dir(na) = 1;
0200    analyses.mfile(na) = 2;
0201 end
0202    
0203 if RESLICE_EPI
0204   disp('Will reslice EPI images ...')
0205   na = na+1;
0206   analyses.type(na) = strmatch('realign', anal_list, 'exact');
0207   analyses.index(na) = 3;
0208   analyses.work_dir(na) = 1;
0209   analyses.mfile(na) = 2;
0210 end
0211 
0212 
0213 if NORM_COPLANAR_2_TEMPLATE
0214   disp('will normalize coplanars to template (parameter&reslice) ... ')
0215   na = na+1;
0216   analyses.type(na) = strmatch('normalize', anal_list, 'exact');
0217   analyses.index(na) = 2;
0218   analyses.work_dir(na) = 1;
0219   analyses.mfile(na) = 2;
0220 end
0221 
0222 if NORM_EPI_2_TEMPLATE
0223   disp('will normalize EPIs to template (parameters&reslice) ... ')
0224   na = na+1;
0225   analyses.type(na) = strmatch('normalize', anal_list, 'exact');
0226   analyses.index(na) = 3;
0227   analyses.work_dir(na) = 1;
0228   analyses.mfile(na) = 2;
0229 end
0230 
0231 if NORM_EPI_2_TEMPLATE_CUST_BB
0232   disp('will normalize EPIs to template using custom bounding box(parameters&reslice) ... ')
0233   na = na+1;
0234   analyses.type(na) = strmatch('normalize', anal_list, 'exact');
0235   analyses.index(na) = 4;
0236   analyses.work_dir(na) = 1;
0237   analyses.mfile(na) = 2;  
0238 end
0239 
0240 if NORM_EPI_2_TEMPLATE_SPM99_DEF_BB
0241   disp('will normalize EPIs to template using SPM99 default bounding box (parameters&reslice) ... ')
0242   na = na+1;
0243   analyses.type(na) = strmatch('normalize', anal_list, 'exact');
0244   analyses.index(na) = 5;
0245   analyses.work_dir(na) = 1;
0246   analyses.mfile(na) = 2;  
0247 end
0248 
0249 if NORM_EPI_2_TEMPLATE_SPM99_BB4
0250   disp('will normalize EPIs to template using SPM99 bounding box 4 (parameters&reslice) ... ')
0251   na = na+1;
0252   analyses.type(na) = strmatch('normalize', anal_list, 'exact');
0253   analyses.index(na) = 6;
0254   analyses.work_dir(na) = 1;
0255   analyses.mfile(na) = 2;  
0256 end
0257 
0258 if NORM_HIRES_2_TEMPLATE 
0259   disp('will normalize hires to template (parameter&reslice) ... ')
0260   na = na+1;
0261   analyses.type(na) = strmatch('normalize', anal_list, 'exact');
0262   analyses.index(na) = 1;
0263   analyses.work_dir(na) = 1;
0264   analyses.mfile(na) = 2;
0265 end
0266   
0267 if SMOOTH_rEPI
0268   disp('will smooth resliced EPIs (individuals) ... ')
0269   na = na+1;
0270   analyses.type(na) = strmatch('smooth', anal_list, 'exact');
0271   analyses.index(na) = 1;
0272   analyses.work_dir(na) = 1;
0273   analyses.mfile(na) = 3;
0274 end
0275 
0276 if SMOOTH_nEPI 
0277   disp('will smooth normalized EPIs ... ')
0278   na = na+1;
0279   analyses.type(na) = strmatch('smooth', anal_list, 'exact');
0280   analyses.index(na) = 2;
0281   analyses.work_dir(na) = 1;
0282   analyses.mfile(na) = 3;
0283 end
0284 
0285 if RUN_MODEL_INDIV
0286   disp('will run model - individual data ...')
0287 
0288   if SET_F_EQUAL1
0289     disp('Will set F=1 for storing data to Y.mad ...')
0290     na = na+1;
0291     analyses.type(na) = strmatch('defaults_edit', anal_list,'exact');
0292     analyses.index(na) = 2;
0293     analyses.work_dir(na) = 1;
0294     analyses.mfile(na) = 1;   
0295   end
0296   
0297   %use_model_proto = 1;
0298   nsub_proc = length(proc_subs);
0299   
0300   for isub = 1:nsub_proc
0301     na = na+1;
0302     analyses.type(na) = strmatch('model', anal_list, 'exact');
0303     analyses.index(na) = proc_subs(isub);
0304     work_dir_idx = 2*length(work_dir) - nsub + proc_subs(isub);
0305     analyses.work_dir(na) = work_dir_idx;
0306     analyses.mfile(na) = 4;
0307 
0308     % Create analysis directory for single subject data if necessary
0309     if ~exist(work_dir{work_dir_idx},'dir')
0310       disp(sprintf('Creating directory: %s', work_dir{work_dir_idx}))
0311       unix(['mkdir ' work_dir{work_dir_idx}]);
0312     end
0313   end
0314 end
0315 
0316 if RUN_MODEL_NORM
0317   disp('will run model - normalized data...')
0318 
0319   if SET_F_EQUAL1
0320     disp('Will set F=1 for storing data to Y.mad ...')
0321     na = na+1;
0322     analyses.type(na) = strmatch('defaults_edit', anal_list,'exact');
0323     analyses.index(na) = 2;
0324     analyses.work_dir(na) = 1;
0325     analyses.mfile(na) = 1;   
0326   end
0327   
0328   %use_model_proto = 1;
0329   nsub_proc = length(proc_subs)
0330   
0331   for isub = 1:nsub_proc
0332     na = na+1;
0333     analyses.type(na) = strmatch('model', anal_list, 'exact');
0334     analyses.index(na) = proc_subs(isub);
0335     work_dir_idx = length(work_dir) - nsub + proc_subs(isub);
0336     analyses.work_dir(na) = work_dir_idx;
0337     analyses.mfile(na) = 5;
0338 
0339     % Make sure we have a subject directory
0340     sub_dir_name = fullfile(rootpath, subject_ids{proc_subs(isub)});
0341     if ~exist(sub_dir_name,'dir')
0342       disp(sprintf('Creating directory: %s', sub_dir_name))
0343       unix(['mkdir ' sub_dir_name]);
0344     end
0345     
0346     % Create normalized directory if necessary
0347     if ~exist(work_dir{work_dir_idx},'dir')
0348       disp(sprintf('Creating directory: %s', work_dir{work_dir_idx}))
0349       unix(['mkdir ' work_dir{work_dir_idx}]);
0350     end
0351   end
0352 end
0353 
0354 if COMPUTE_CONTRASTS_INDIV
0355   disp('will compute contrasts - individual data ...')
0356 
0357   nsub_proc = length(proc_subs);
0358   
0359   for isub = 1:nsub_proc
0360     na = na+1;
0361     analyses.type(na) = strmatch('contrasts', anal_list, 'exact');
0362     analyses.index(na) = proc_subs(isub);
0363     work_dir_idx = 2*length(work_dir) - nsub + proc_subs(isub);
0364     analyses.work_dir(na) = work_dir_idx;
0365     analyses.mfile(na) = 6;                 
0366 %   analyses.mfile(na) = 6+use_model_proto-1;
0367   end
0368 
0369 end
0370 
0371 if COMPUTE_CONTRASTS_NORM
0372   disp('will compute contrasts - normalized data ...')
0373 
0374   nsub_proc = length(proc_subs);
0375   
0376   for isub = 1:nsub_proc
0377     na = na+1;
0378     analyses.type(na) = strmatch('contrasts', anal_list, 'exact');
0379     analyses.index(na) = proc_subs(isub);
0380     work_dir_idx = length(work_dir) - nsub + proc_subs(isub);
0381     analyses.work_dir(na) = work_dir_idx;
0382     analyses.mfile(na) = 6;                 
0383 %   analyses.mfile(na) = 6+use_model_proto-1;
0384   end
0385 
0386 end
0387 
0388 % NOTE: COMPUTE_GROUP has to come after models and contrasts otherwise working
0389 % directories get screwed up
0390 if COMPUTE_GROUP
0391     disp('will compute group statistics - normalized data ...')
0392     ngroup_anal = length(group_analyses);
0393   
0394   for ig = 1:ngroup_anal
0395     
0396     % Set up the stats
0397     na = na+1;
0398     analyses.type(na) = strmatch('stats', anal_list, 'exact');
0399     analyses.index(na) = ig;
0400     work_dir{end+1} = fullfile(rootpath, 'group_deriv',group_analyses{ig});
0401     work_dir_idx = length(work_dir);
0402     analyses.work_dir(na) = work_dir_idx;
0403     if ~exist(work_dir{work_dir_idx},'dir')
0404       disp(sprintf('Creating directory: %s', work_dir{work_dir_idx}))
0405       unix(['mkdir ' work_dir{work_dir_idx}]);
0406     end
0407     analyses.mfile(na) = 10;
0408     
0409     % Compute the associated contrasts
0410     na = na+1;
0411     analyses.type(na) = strmatch('contrasts', anal_list, 'exact');
0412     analyses.index(na) = nsub+ig;
0413     analyses.work_dir(na) = work_dir_idx;
0414     analyses.mfile(na) = 6;
0415   end
0416 end
0417 
0418 
0419 if THRESH_SUM
0420     disp('will sum thresholded images ...')
0421     na = na+1;
0422     analyses.type(na) = strmatch('threshsum', anal_list, 'exact');
0423     analyses.index(na) = THRESHSUM_CONTRAST;
0424     analyses.work_dir(na) = 2;
0425     analyses.mfile(na) = 9;
0426 end
0427 
0428 %
0429 % SPECIFY MFILES ASSOCIATED WITH EACH ANALYSIS TYPE
0430 %
0431 % file names are either full pathname or relative to work_dir
0432 
0433 mfile = ...
0434     { fullfile(batch_root, 'simulate_defaults.m'), ...
0435       fullfile(batch_root, 'simulate_realign.m'), ...      
0436       fullfile(batch_root, 'simulate_smooth.m'), ...      
0437       fullfile(batch_root, 'simulate_model_indiv.m'), ...      
0438       fullfile(batch_root, 'simulate_model_protos.m'), ...      
0439       fullfile(batch_root, 'simulate_contrasts.m'), ...   
0440       fullfile(batch_root, 'simulate_group.m'), ...      
0441       fullfile(batch_root, 'simulate_display.m'), ...      
0442       fullfile(batch_root, 'simulate_threshsum.m'), ... 
0443       fullfile(batch_root, 'simulate_stats.m') ... 
0444       };
0445

Generated on Wed 20-Sep-2023 04:00:50 by m2html © 2003