0001 function data = prt_cfg_design
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 covar = cfg_files;
0014 covar.tag = 'covar';
0015 covar.name = 'Covariates';
0016 covar.help = {['Select a .mat file containing '...
0017 'your covariates (i.e. any other data/information '...
0018 'you would like to include in your design). This file '...
0019 'should contain a variable ''R'' with a matrix of '...
0020 'covariates.']};
0021 covar.val{1} = {''};
0022 covar.filter = 'mat';
0023 covar.ufilter = '.*';
0024 covar.num = [0 1];
0025
0026
0027
0028
0029 rt_subj = cfg_entry;
0030 rt_subj.tag = 'rt_subj';
0031 rt_subj.name = 'Regression targets (per scans)';
0032 rt_subj.help = {['Enter one regression target per scan. '...
0033 'or enter the name of a variable. '...
0034 ' This variable should be a vector '...
0035 '[Nscans x 1], where Nscans is the number of '...
0036 'scans/images.']};
0037 rt_subj.strtype = 'e';
0038 rt_subj.val = {[]};
0039 rt_subj.num = [Inf 0];
0040
0041
0042
0043
0044 rt_trial = cfg_entry;
0045 rt_trial.tag = 'rt_trial';
0046 rt_trial.name = 'Regression targets (trials)';
0047 rt_trial.help = {['Enter one regression target per trial. '...
0048 'This vector should have the following dimensions: '...
0049 '[Ntrials x 1], where Ntrials is the number of trials.']
0050 };
0051 rt_trial.strtype = 'e';
0052 rt_trial.val = {[]};
0053 rt_trial.num = [Inf 0];
0054
0055
0056
0057
0058 TR = cfg_entry;
0059 TR.tag = 'TR';
0060 TR.name = 'Interscan interval';
0061 TR.help = {'Specify interscan interval (TR). The units should be seconds.'};
0062 TR.strtype = 'e';
0063 TR.num = [Inf 1];
0064
0065
0066
0067
0068 unit = cfg_menu;
0069 unit.tag = 'unit';
0070 unit.name = 'Units for design';
0071 unit.help = {['The onsets of events or blocks can be specified in '...
0072 'either scans or seconds.']};
0073 unit.labels = {
0074 'Scans'
0075 'Seconds'
0076 }';
0077 unit.values = {0 1};
0078 unit.val = {1};
0079
0080
0081
0082
0083 review = cfg_menu;
0084 review.tag = 'review';
0085 review.name = 'Review';
0086 review.help = {['Choose ''Yes'' if you would like to review your '...
0087 'data and design in a separate window.']};
0088 review.labels = {
0089 'No'
0090 'Yes'
0091 }';
0092 review.values = {0 1};
0093 review.val = {0};
0094
0095
0096
0097
0098 hrfover = cfg_entry;
0099 hrfover.tag = 'hrfover';
0100 hrfover.name = 'HRF overlap';
0101 hrfover.help = {['If using fMRI data please specify the width of the '...
0102 'hemodynamic response function (HRF). This will be '...
0103 'used to calculate the overlap between events. '...
0104 'Leave as 0 for other modalities (other than fMRI).']};
0105 hrfover.strtype = 'e';
0106 hrfover.num = [1 1];
0107 hrfover.def = @(val)prt_get_defaults('datad.hrfw', val{:});
0108
0109
0110
0111
0112 hrfdel = cfg_entry;
0113 hrfdel.tag = 'hrfdel';
0114 hrfdel.name = 'HRF delay';
0115 hrfdel.help = {['If using fMRI data please specify the delay of the '...
0116 'hemodynamic response function (HRF). This will be '...
0117 'used to calculate the overlap between events. Leave '...
0118 'as 0 for other modalities (other than fMRI).']};
0119 hrfdel.strtype = 'e';
0120 hrfdel.num = [1 1];
0121 hrfdel.def = @(val)prt_get_defaults('datad.hrfd', val{:});
0122
0123
0124
0125
0126 mod_name = cfg_entry;
0127 mod_name.tag = 'mod_name';
0128 mod_name.name = 'Name';
0129 mod_name.help = {['Name of modality. Example: ''BOLD''. The names '...
0130 'should be consistent accross subjects/groups '...
0131 'and the same names specified in the masks.']};
0132 mod_name.strtype = 's';
0133 mod_name.num = [1 Inf];
0134
0135
0136
0137
0138 scans = cfg_files;
0139 scans.tag = 'scans';
0140 scans.name = 'Scans';
0141 scans.help = {['Select scans (images) for this modality. They must '...
0142 'all have the same image dimensions, orientation, '...
0143 'voxel size etc.']};
0144 scans.filter = 'image';
0145 scans.ufilter = '.*';
0146 scans.num = [1 Inf];
0147
0148
0149
0150
0151 subjects = cfg_files;
0152 subjects.tag = 'subjects';
0153 subjects.name = 'Files';
0154 subjects.help = {['Select scans (images) for this modality. They must '...
0155 'all have the same image dimensions, orientation, '...
0156 'voxel size etc.']};
0157 subjects.filter = 'image';
0158 subjects.num = [0 Inf];
0159
0160
0161
0162
0163 modality = cfg_branch;
0164 modality.tag = 'modality';
0165 modality.name = 'Modality';
0166 modality.val = {mod_name, subjects, rt_subj, covar };
0167 modality.help = {'Specify modality, such as name and data.'};
0168
0169
0170
0171
0172 images = cfg_repeat;
0173 images.tag = 'images';
0174 images.name = 'Scans';
0175 images.values = {modality };
0176 images.help = {['Depending on the type of data at hand, you may have many images (scans) '...
0177 'per subject, such as a fMRI time series, or you may have many '...
0178 'subjects with only one or a small number of images (scans) per subject, '...
0179 'such as PET images. ',...
0180 'Select this option if you have many subjects per modality to spatially ',...
0181 'normalise, but there is one or a small number of scans for '...
0182 'each subject. This is a faster option with less information to specify '...
0183 'than the ''select by subjects'' option. Both options create the same '...
0184 '''PRT.mat'' but ''select by scans'' is optimised for modalities '...
0185 'with no design.']};
0186
0187
0188
0189
0190 fmask = cfg_files;
0191 fmask.tag = 'fmask';
0192 fmask.name = 'File';
0193 fmask.filter = 'image';
0194 fmask.ufilter = '.*';
0195 fmask.num = [1 1];
0196 fmask.help = {['Select one first-level mask (image) for each modality. ',...
0197 'This mask is used to optimise the prepare data step. ',...
0198 'In ''specify model'' there is an option to enter a ',...
0199 'second-level mask, which might be used to select only ',...
0200 'a few areas of the brain for subsequent analyses.']};
0201
0202
0203
0204 mask = cfg_branch;
0205 mask.tag = 'mask';
0206 mask.name = 'Modality';
0207 mask.help = {['Specify name of modality and file for each mask. ',...
0208 'The name should be consistent with the names chosen ',...
0209 'for the modalities (subjects/scans).']};
0210 mask.val = {mod_name, fmask };
0211
0212
0213
0214
0215 masks = cfg_repeat;
0216 masks.tag = 'masks';
0217 masks.name = 'Masks';
0218 masks.help = {['Select first-level (pre-processing) mask for each ',...
0219 'modality. The name of the modalities should be the same ',...
0220 'as the ones entered for subjects/scans.']};
0221 masks.num = [1 Inf];
0222 masks.values = {mask };
0223
0224
0225
0226
0227 load_SPM = cfg_files;
0228 load_SPM.tag = 'load_SPM';
0229 load_SPM.name = 'Load SPM.mat';
0230 load_SPM.help = {['Load design from SPM.mat (if you have previously '...
0231 'specified the experimental design with SPM).']};
0232 load_SPM.filter = '^SPM\.mat$';
0233 load_SPM.num = [1 1];
0234
0235
0236
0237
0238 cond_name = cfg_entry;
0239 cond_name.tag = 'cond_name';
0240 cond_name.name = 'Name';
0241 cond_name.help = {'Name of condition (alphanumeric strings only).'};
0242 cond_name.strtype = 's';
0243 cond_name.num = [1 Inf];
0244
0245
0246
0247
0248 onsets = cfg_entry;
0249 onsets.tag = 'onsets';
0250 onsets.name = 'Onsets';
0251 onsets.help = {'Specify a vector of onset times for this condition type. '};
0252 onsets.strtype = 'e';
0253 onsets.num = [Inf 1];
0254
0255
0256
0257
0258 durations = cfg_entry;
0259 durations.tag = 'durations';
0260 durations.name = 'Durations';
0261 durations.help = {['Specify the event durations. Epoch and '...
0262 'event-related responses are modeled in exactly '...
0263 'the same way but by specifying their different '...
0264 'durations. Events are specified with a duration '...
0265 'of 0. If you enter a single number for the '...
0266 'durations it will be assumed that all trials '...
0267 'conform to this duration. If you have multiple '...
0268 'different durations, then the number must match '...
0269 'the number of onset times.']};
0270 durations.strtype = 'e';
0271 durations.num = [Inf 1];
0272
0273
0274
0275
0276 conds = cfg_branch;
0277 conds.tag = 'conds';
0278 conds.name = 'Condition';
0279 conds.help = {'Specify condition: name, onsets and duration.'};
0280 conds.val = {cond_name, onsets, durations};
0281
0282
0283
0284
0285 conditions = cfg_repeat;
0286 conditions.tag = 'conditions';
0287 conditions.name = 'Conditions';
0288 conditions.help = {['Specify conditions. You are allowed to combine '...
0289 'both event- and epoch-related responses in '...
0290 'the same model and/or regressor. Any number of '...
0291 'condition (event or epoch) types can be '...
0292 'specified. Epoch and event-related responses '...
0293 'are modeled in exactly the same way by '...
0294 'specifying their onsets [in terms of onset '...
0295 'times] and their durations. Events are specified '...
0296 'with a duration of 0. If you enter a single '...
0297 'number for the durations it will be assumed that '...
0298 'all trials conform to this duration.For factorial '...
0299 'designs, one can later associate these experimental '...
0300 'conditions with the appropriate levels of experimental '...
0301 'factors.']};
0302 conditions.values = {conds};
0303
0304
0305
0306
0307 multi_conds = cfg_files;
0308 multi_conds.tag = 'multi_conds';
0309 multi_conds.name = 'Multiple conditions';
0310 multi_conds.val{1} = {''};
0311 multi_conds.help = {
0312 'Select the *.mat file containing details of your multiple experimental conditions. '
0313 ''
0314 'If you have multiple conditions then entering the details a condition at a time is very inefficient. This option can be used to load all the required information in one go. You will first need to create a *.mat file containing the relevant information. '
0315 ''
0316 'This *.mat file must include the following cell arrays (each 1 x n): names, onsets and durations. eg. names=cell(1,5), onsets=cell(1,5), durations=cell(1,5), then names{2}=''SSent-DSpeak'', onsets{2}=[3 5 19 222], durations{2}=[0 0 0 0], contain the required details of the second condition. These cell arrays may be made available by your stimulus delivery program, eg. COGENT. The duration vectors can contain a single entry if the durations are identical for all events.'
0317 ''
0318 'Time and Parametric effects can also be included. For time modulation include a cell array (1 x n) called tmod. It should have a have a single number in each cell. Unused cells may contain either a 0 or be left empty. The number specifies the order of time modulation from 0 = No Time Modulation to 6 = 6th Order Time Modulation. eg. tmod{3} = 1, modulates the 3rd condition by a linear time effect.'
0319 ''
0320 'For parametric modulation include a structure array, which is up to 1 x n in size, called pmod. n must be less than or equal to the number of cells in the names/onsets/durations cell arrays. The structure array pmod must have the fields: name, param and poly. Each of these fields is in turn a cell array to allow the inclusion of one or more parametric effects per column of the design. The field name must be a cell array containing strings. The field param is a cell array containing a vector of parameters. Remember each parameter must be the same length as its corresponding onsets vector. The field poly is a cell array (for consistency) with each cell containing a single number specifying the order of the polynomial expansion from 1 to 6.'
0321 ''
0322 'Note that each condition is assigned its corresponding entry in the structure array (condition 1 parametric modulators are in pmod(1), condition 2 parametric modulators are in pmod(2), etc. Within a condition multiple parametric modulators are accessed via each fields cell arrays. So for condition 1, parametric modulator 1 would be defined in pmod(1).name{1}, pmod(1).param{1}, and pmod(1).poly{1}. A second parametric modulator for condition 1 would be defined as pmod(1).name{2}, pmod(1).param{2} and pmod(1).poly{2}. If there was also a parametric modulator for condition 2, then remember the first modulator for that condition is in cell array 1: pmod(2).name{1}, pmod(2).param{1}, and pmod(2).poly{1}. If some, but not all conditions are parametrically modulated, then the non-modulated indices in the pmod structure can be left blank. For example, if conditions 1 and 3 but not condition 2 are modulated, then specify pmod(1) and pmod(3). Similarly, if conditions 1 and 2 are modulated but there are 3 conditions overall, it is only necessary for pmod to be a 1 x 2 structure array.'
0323 ''
0324 'EXAMPLE:'
0325 'Make an empty pmod structure: '
0326 ' pmod = struct(''name'',{''''},''param'',{},''poly'',{});'
0327 'Specify one parametric regressor for the first condition: '
0328 ' pmod(1).name{1} = ''regressor1'';'
0329 ' pmod(1).param{1} = [1 2 4 5 6];'
0330 ' pmod(1).poly{1} = 1;'
0331 'Specify 2 parametric regressors for the second condition: '
0332 ' pmod(2).name{1} = ''regressor2-1'';'
0333 ' pmod(2).param{1} = [1 3 5 7]; '
0334 ' pmod(2).poly{1} = 1;'
0335 ' pmod(2).name{2} = ''regressor2-2'';'
0336 ' pmod(2).param{2} = [2 4 6 8 10];'
0337 ' pmod(2).poly{2} = 1;'
0338 ''
0339 'The parametric modulator should be mean corrected if appropriate. Unused structure entries should have all fields left empty.'
0340 }';
0341 multi_conds.filter = 'mat';
0342 multi_conds.ufilter = '.*';
0343 multi_conds.num = [0 1];
0344
0345
0346
0347
0348 new_design = cfg_branch;
0349 new_design.tag = 'new_design';
0350 new_design.name = 'Specify design';
0351 new_design.help = {'Specify design: scans (data), onsets and durations.'};
0352 new_design.val = {unit conditions multi_conds covar};
0353
0354
0355
0356
0357 no_design = cfg_const;
0358 no_design.tag = 'no_design';
0359 no_design.name = 'No design';
0360 no_design.val = {0};
0361 no_design.help = {['Do not specify design. This option can be used '...
0362 'for modalities (e.g. structural scans) that do not '...
0363 'have an experimental design.']};
0364
0365
0366
0367
0368 design = cfg_choice;
0369 design.tag = 'design';
0370 design.name = 'Data & Design';
0371 design.help = {'Specify data and design.'};
0372 design.values = {load_SPM, new_design, no_design };
0373 design.val = {load_SPM };
0374
0375
0376
0377
0378 subject = cfg_branch;
0379 subject.tag = 'subject';
0380 subject.name = 'Modality';
0381 subject.val = {mod_name, TR, scans, design };
0382 subject.help = {'Add new modality.'};
0383
0384
0385
0386
0387 gr_name = cfg_entry;
0388 gr_name.tag = 'gr_name';
0389 gr_name.name = 'Name';
0390 gr_name.help = {'Name of the group. Example: ''Controls''.'};
0391 gr_name.strtype = 's';
0392 gr_name.num = [1 Inf];
0393
0394
0395
0396
0397 ind_subj = cfg_repeat;
0398 ind_subj.tag = 'ind_subj';
0399 ind_subj.name = 'Subject';
0400 ind_subj.help = {'Add new modality for this subject.'};
0401 ind_subj.values = {subject };
0402
0403
0404
0405
0406 subjs = cfg_repeat;
0407 subjs.tag = 'subjs';
0408 subjs.name = 'Subjects';
0409 subjs.help = {'Add subjects/scans.'};
0410 subjs.values = {ind_subj };
0411
0412
0413
0414
0415 select = cfg_choice;
0416 select.tag = 'select';
0417 select.name = 'Select by';
0418 select.values = {subjs, images};
0419 select.help = {...
0420 ['Depending on the type of data at hand, you may have many images (scans) '...
0421 'per subject, such as a fMRI time series, or you may have many '...
0422 'subjects with only one or a small number of images (scans) per subject '...
0423 ', such as PET images. If you have many scans per subject select the '...
0424 'option ''subjects''. If you have one scan for many subjects select '...
0425 'the option ''scans''.']};
0426
0427
0428
0429
0430 group = cfg_branch;
0431 group.tag = 'group';
0432 group.name = 'Group';
0433 group.help = {'Specify data and design for the group.'};
0434 group.val = {gr_name, select };
0435
0436
0437
0438
0439 groups = cfg_repeat;
0440 groups.tag = 'groups';
0441 groups.name = 'Groups';
0442 groups.help = {['Add data and design for one group. Click ''new'' '...
0443 'or ''repeat'' to add another group.']};
0444 groups.num = [1 Inf];
0445 groups.values = {group };
0446
0447
0448
0449
0450 dir_name = cfg_files;
0451 dir_name.tag = 'dir_name';
0452 dir_name.name = 'Directory';
0453 dir_name.help = {['Select a directory where the PRT.mat file '...
0454 'containing the specified design and data matrix '...
0455 'will be written.']};
0456 dir_name.filter = 'dir';
0457 dir_name.ufilter = '.*';
0458 dir_name.num = [1 1];
0459
0460
0461
0462
0463 data = cfg_exbranch;
0464 data.tag = 'data';
0465 data.name = 'Data & Design';
0466 data.val = {dir_name groups masks hrfover hrfdel review};
0467 data.help = {'Specify the data and design for each group (minimum one group).'};
0468 data.prog = @prt_run_design;
0469 data.vout = @vout_data;
0470
0471
0472
0473
0474 function cdep = vout_data(job)
0475
0476
0477 cdep(1) = cfg_dep;
0478 cdep(1).sname = 'PRT.mat file';
0479 cdep(1).src_output = substruct('.','files');
0480 cdep(1).tgt_spec = cfg_findspec({{'filter','mat','strtype','e'}});
0481