0001 function write_fsf(fsf)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 fid = fopen(fullfile(fsf.fsldir,'design.fsf'),'wt');
0020
0021 fsf_str = sprintf([ ...
0022 '\n# FEAT version number' ...
0023 '\nset fmri(version) %1.2f\n'], fsf.version);
0024 fprintf(fid,'%s', fsf_str);
0025
0026 fsf_str = sprintf([ ...
0027 '\n# Are we in MELODIC?' ...
0028 '\nset fmri(inmelodic) 0\n']);
0029 fprintf(fid,'%s',fsf_str);
0030
0031 fsf_str = sprintf([...
0032 '\n# Analysis level' ...
0033 '\n# 1 : First-level analysis' ...
0034 '\n# 2 : Higher-level analysis' ...
0035 '\nset fmri(level) %d\n'], fsf.level);
0036 fprintf(fid,'%s', fsf_str);
0037
0038 fsf_str = sprintf([...
0039 '\n# Which stages to run' ...
0040 '\n# 0 : No first-level analysis (registration and/or group stats only)' ...
0041 '\n# 7 : Full first-level analysis' ...
0042 '\n# 1 : Pre-Stats' ...
0043 '\n# 3 : Pre-Stats + Stats' ...
0044 '\n# 2 : Stats' ...
0045 '\n# 6 : Stats + Contrasts, Thresholding, Rendering' ...
0046 '\n# 4 : Contrasts, Thresholding, Rendering' ...
0047 '\nset fmri(analysis) %d\n'], fsf.analysis);
0048 fprintf(fid,'%s', fsf_str);
0049
0050 if fsf.version == 5.4
0051 fsf_str = sprintf([...
0052 '\n# Delay before starting (hours)' ...
0053 '\nset fmri(delay) %d\n'], fsf.delay);
0054 fprintf(fid,'%s', fsf_str);
0055 end
0056
0057 fsf_str = sprintf([...
0058 '\n# Use relative filenames' ...
0059 '\nset fmri(relative_yn) %d\n'], fsf.relative_yn);
0060 fprintf(fid,'%s', fsf_str);
0061
0062 fsf_str = sprintf([...
0063 '\n# Balloon help' ...
0064 '\nset fmri(help_yn) %d\n'], fsf.help_yn);
0065 fprintf(fid,'%s', fsf_str);
0066
0067 fsf_str = sprintf([...
0068 '\n# Run Featwatcher' ...
0069 '\nset fmri(featwatcher_yn) %d\n'], fsf.featwatcher_yn);
0070 fprintf(fid,'%s', fsf_str);
0071
0072 fsf_str = sprintf([...
0073 '\n# Cleanup first-level standard-space images' ...
0074 '\nset fmri(sscleanup_yn) %d\n'], fsf.sscleanup_yn);
0075 fprintf(fid,'%s', fsf_str);
0076
0077 fsf_str = sprintf([...
0078 '\n# Output directory' ...
0079 '\nset fmri(outputdir) "%s"\n'], fsf.outputdir);
0080 fprintf(fid,'%s', fsf_str);
0081
0082 fsf_str = sprintf([...
0083 '\n# TR(s)' ...
0084 '\nset fmri(tr) %1.2f\n'], fsf.tr);
0085 fprintf(fid,'%s', fsf_str);
0086
0087 fsf_str = sprintf([...
0088 '\n# Total volumes' ...
0089 '\nset fmri(npts) %d\n'], fsf.npts);
0090 fprintf(fid,'%s', fsf_str);
0091
0092 fsf_str = sprintf([...
0093 '\n# Delete volumes' ...
0094 '\nset fmri(ndelete) %d\n'], fsf.ndelete);
0095 fprintf(fid,'%s', fsf_str);
0096
0097 if fsf.version == 5.98
0098 fsf_str = sprintf([...
0099 '\n# Perfusion tag/control order' ...
0100 '\nset fmri(tagfirst) %d\n'], fsf.tagfirst);
0101 fprintf(fid,'%s', fsf_str);
0102 end
0103
0104 fsf_str = sprintf([...
0105 '\n# Number of first-level analyses' ...
0106 '\nset fmri(multiple) %d\n'], fsf.multiple);
0107 fprintf(fid,'%s', fsf_str);
0108
0109 fsf_str = sprintf([...
0110 '\n# Higher-level input type' ...
0111 '\n# 1 : Inputs are lower-level FEAT directories' ...
0112 '\n# 2 : Inputs are cope images from FEAT directories' ...
0113 '\nset fmri(inputtype) %d\n'], fsf.inputtype);
0114 fprintf(fid,'%s', fsf_str);
0115
0116 fsf_str = sprintf([...
0117 '\n# Carry out pre-stats processing?' ...
0118 '\nset fmri(filtering_yn) %d\n'], fsf.filtering_yn);
0119 fprintf(fid,'%s', fsf_str);
0120
0121 fsf_str = sprintf([...
0122 '\n# Brain/background threshold, %%' ...
0123 '\nset fmri(brain_thresh) %d\n'], fsf.brain_thresh);
0124 fprintf(fid,'%s', fsf_str);
0125
0126 if fsf.version == 5.98
0127 fsf_str = sprintf([...
0128 '\n# Critical z for design efficiency calculation' ...
0129 '\nset fmri(critical_z) %1.2f\n'], fsf.critical_z);
0130 fprintf(fid,'%s', fsf_str);
0131
0132 fsf_str = sprintf([...
0133 '\n# Noise level' ...
0134 '\nset fmri(noise) %1.6f\n'], fsf.noise);
0135 fprintf(fid,'%s', fsf_str);
0136
0137 fsf_str = sprintf([...
0138 '\n# Noise AR(1)' ...
0139 '\nset fmri(noisear) %1.6f\n'], fsf.noisear);
0140 fprintf(fid,'%s', fsf_str);
0141 end
0142
0143 fsf_str = sprintf([...
0144 '\n# Post-stats-only directory copying' ...
0145 '\n# 0 : Overwrite original post-stats results' ...
0146 '\n# 1 : Copy original FEAT directory for new Contrasts, Thresholding, Rendering' ...
0147 '\nset fmri(newdir_yn) %d\n'], fsf.newdir_yn);
0148 fprintf(fid,'%s', fsf_str);
0149
0150 fsf_str = sprintf([...
0151 '\n# Slice timing correction' ...
0152 '\n# 0 : None' ...
0153 '\n# 1 : Regular up (0, 1, 2, 3, ...)' ...
0154 '\n# 2 : Regular down' ...
0155 '\n# 3 : Use slice order file' ...
0156 '\n# 4 : Use slice timings file' ...
0157 '\n# 5 : Interleaved (0, 2, 4 ... 1, 3, 5 ... )' ...
0158 '\nset fmri(st) %d\n'], fsf.st);
0159 fprintf(fid,'%s', fsf_str);
0160
0161 fsf_str = sprintf([...
0162 '\n# Slice timings file' ...
0163 '\nset fmri(st_file) "%s"\n'], fsf.st_file);
0164 fprintf(fid,'%s', fsf_str);
0165
0166 fsf_str = sprintf([...
0167 '\n# Motion correction' ...
0168 '\n# 0 : None' ...
0169 '\n# 1 : MCFLIRT' ...
0170 '\nset fmri(mc) %d\n'], fsf.mc);
0171 fprintf(fid,'%s', fsf_str);
0172
0173 fsf_str = sprintf([...
0174 '\n# Spin-history (currently obsolete)' ...
0175 '\nset fmri(sh_yn) %d\n'], fsf.sh_yn);
0176 fprintf(fid,'%s', fsf_str);
0177
0178 fsf_str = sprintf([...
0179 '\n# BET brain extraction' ...
0180 '\nset fmri(bet_yn) %d\n'], fsf.bet_yn);
0181 fprintf(fid,'%s', fsf_str);
0182
0183 fsf_str = sprintf([...
0184 '\n# Spatial smoothing FWHM (mm)' ...
0185 '\nset fmri(smooth) %d\n'], fsf.smooth);
0186 fprintf(fid,'%s', fsf_str);
0187
0188 fsf_str = sprintf([...
0189 '\n# Intensity normalization' ...
0190 '\nset fmri(norm_yn) %d\n'], fsf.norm_yn);
0191 fprintf(fid,'%s', fsf_str);
0192
0193 if fsf.version == 5.98
0194 fsf_str = sprintf([...
0195 '\n# Perfusion subtraction' ...
0196 '\nset fmri(perfsub_yn) %d\n'], fsf.perfsub_yn);
0197 fprintf(fid,'%s', fsf_str);
0198 end
0199
0200 fsf_str = sprintf([...
0201 '\n# Highpass temporal filtering' ...
0202 '\nset fmri(temphp_yn) %d\n'], fsf.temphp_yn);
0203 fprintf(fid,'%s', fsf_str);
0204
0205 fsf_str = sprintf([...
0206 '\n# Lowpass temporal filtering' ...
0207 '\nset fmri(templp_yn) %d\n'], fsf.templp_yn);
0208 fprintf(fid,'%s', fsf_str);
0209
0210 fsf_str = sprintf([...
0211 '\n# MELODIC ICA data exploration' ...
0212 '\nset fmri(melodic_yn) %d\n'], fsf.melodic_yn);
0213 fprintf(fid,'%s', fsf_str);
0214
0215 fsf_str = sprintf([...
0216 '\n# Carry out main stats?' ...
0217 '\nset fmri(stats_yn) %d\n'], fsf.stats_yn);
0218 fprintf(fid,'%s', fsf_str);
0219
0220 fsf_str = sprintf([...
0221 '\n# Carry out prewhitening?' ...
0222 '\nset fmri(prewhiten_yn) %d\n'], fsf.prewhiten_yn);
0223 fprintf(fid,'%s', fsf_str);
0224
0225 if fsf.version == 5.98
0226 fsf_str = sprintf([...
0227 '\n# Add motion parameters to model' ...
0228 '\n# 0 : No' ...
0229 '\n# 1 : Yes' ...
0230 '\nset fmri(motionevs) %d\n'], fsf.motionevs);
0231 fprintf(fid,'%s', fsf_str);
0232
0233 fsf_str = sprintf([...
0234 '\n# Robust outlier detection in FLAME?' ...
0235 '\nset fmri(robust_yn) %d\n'], fsf.robust_yn);
0236 fprintf(fid,'%s', fsf_str);
0237 end
0238
0239 fsf_str = sprintf([...
0240 '\n# Higher-level modelling' ...
0241 '\n# 3 : Fixed effects' ...
0242 '\n# 0 : Mixed Effects: Simple OLS' ...
0243 '\n# 2 : Mixed Effects: FLAME (stage 1 only)' ...
0244 '\n# 1 : Mixed Effects: FLAME (full)' ...
0245 '\nset fmri(mixed_yn) %d\n'], fsf.mixed_yn);
0246 fprintf(fid,'%s', fsf_str);
0247
0248 fsf_str = sprintf([...
0249 '\n# Number of EVs' ...
0250 '\nset fmri(evs_orig) %d' ...
0251 '\nset fmri(evs_real) %d\n'], fsf.evs_orig,fsf.evs_real);
0252 fprintf(fid,'%s', fsf_str);
0253
0254 if fsf.version == 5.98
0255 fsf_str = sprintf('set fmri(evs_vox) %d\n', fsf.evs_vox);
0256 fprintf(fid,'%s', fsf_str);
0257 end
0258
0259 fsf_str = sprintf([...
0260 '\n# Number of contrasts' ...
0261 '\nset fmri(ncon_orig) %d' ...
0262 '\nset fmri(ncon_real) %d\n'], fsf.ncon_orig, fsf.ncon_real);
0263 fprintf(fid,'%s', fsf_str);
0264
0265 fsf_str = sprintf([...
0266 '\n# Number of F-tests' ...
0267 '\nset fmri(nftests_orig) %d' ...
0268 '\nset fmri(nftests_real) %d\n'], fsf.nftests_orig, fsf.nftests_real);
0269 fprintf(fid,'%s', fsf_str);
0270
0271 fsf_str = sprintf([...
0272 '\n# Add constant column to design matrix? (obsolete)' ...
0273 '\nset fmri(constcol) %d\n'], fsf.constcol);
0274 fprintf(fid,'%s', fsf_str);
0275
0276 fsf_str = sprintf([...
0277 '\n# Carry out post-stats steps?' ...
0278 '\nset fmri(poststats_yn) %d\n'], fsf.poststats_yn);
0279 fprintf(fid,'%s', fsf_str);
0280
0281 fsf_str = sprintf([...
0282 '\n# Pre-threshold masking?' ...
0283 '\nset fmri(threshmask) "%s"\n'], fsf.threshmask);
0284 fprintf(fid,'%s', fsf_str);
0285
0286 fsf_str = sprintf([...
0287 '\n# Thresholding' ...
0288 '\n# 0 : None' ...
0289 '\n# 1 : Uncorrected' ...
0290 '\n# 2 : Voxel' ...
0291 '\n# 3 : Cluster' ...
0292 '\nset fmri(thresh) %d\n'], fsf.thresh);
0293 fprintf(fid,'%s', fsf_str);
0294
0295 fsf_str = sprintf([...
0296 '\n# P threshold' ...
0297 '\nset fmri(prob_thresh) %1.4f\n'], fsf.prob_thresh);
0298 fprintf(fid,'%s', fsf_str);
0299
0300 fsf_str = sprintf([...
0301 '\n# Z threshold' ...
0302 '\nset fmri(z_thresh) %1.2f\n'], fsf.z_thresh);
0303 fprintf(fid,'%s', fsf_str);
0304
0305 fsf_str = sprintf([...
0306 '\n# Z min/max for colour rendering' ...
0307 '\n# 0 : Use actual Z min/max' ...
0308 '\n# 1 : Use preset Z min/max' ...
0309 '\nset fmri(zdisplay) %d\n'], fsf.zdisplay);
0310 fprintf(fid,'%s', fsf_str);
0311
0312 fsf_str = sprintf([...
0313 '\n# Z min in colour rendering' ...
0314 '\nset fmri(zmin) %d\n'], fsf.zmin);
0315 fprintf(fid,'%s', fsf_str);
0316
0317 fsf_str = sprintf([...
0318 '\n# Z max in colour rendering' ...
0319 '\nset fmri(zmax) %d\n'], fsf.zmax);
0320 fprintf(fid,'%s', fsf_str);
0321
0322 fsf_str = sprintf([...
0323 '\n# Colour rendering type' ...
0324 '\n# 0 : Solid blobs' ...
0325 '\n# 1 : Transparent blobs' ...
0326 '\nset fmri(rendertype) %d\n'], fsf.rendertype);
0327 fprintf(fid,'%s', fsf_str);
0328
0329 fsf_str = sprintf([...
0330 '\n# Background image for higher-level stats overlays' ...
0331 '\n# 1 : Mean highres' ...
0332 '\n# 2 : First highres' ...
0333 '\n# 3 : Mean functional' ...
0334 '\n# 4 : First functional' ...
0335 '\n# 5 : Standard space template' ...
0336 '\nset fmri(bgimage) %d\n'], fsf.bgimage);
0337 fprintf(fid,'%s', fsf_str);
0338
0339 if fsf.version == 5.98
0340 fsf_str = sprintf([...
0341 '\n# Create time series plots' ...
0342 '\nset fmri(tsplot_yn) %d\n'], fsf.tsplot_yn);
0343 fprintf(fid,'%s', fsf_str);
0344 end
0345
0346 fsf_str = sprintf([...
0347 '\n# Registration?' ...
0348 '\nset fmri(reg_yn) %d\n'], fsf.reg_yn);
0349 fprintf(fid,'%s', fsf_str);
0350
0351 fsf_str = sprintf([...
0352 '\n# B0 fieldmap unwarping?' ...
0353 '\nset fmri(regunwarp_yn) %d\n'], fsf.regunwarp_yn);
0354 fprintf(fid,'%s', fsf_str);
0355
0356 if fsf.version == 5.98
0357 fsf_str = sprintf([...
0358 '\n# EPI dwell time (ms)' ...
0359 '\nset fmri(dwell) %d\n'], fsf.dwell);
0360 fprintf(fid,'%s', fsf_str);
0361
0362 fsf_str = sprintf([...
0363 '\n# EPI TE (ms)' ...
0364 '\nset fmri(te) %d\n'], fsf.te);
0365 fprintf(fid,'%s', fsf_str);
0366
0367 fsf_str = sprintf([...
0368 '\n# % Signal loss threshold' ...
0369 '\nset fmri(signallossthresh) %d\n'], fsf.signallossthresh);
0370 fprintf(fid,'%s', fsf_str);
0371
0372 fsf_str = sprintf([...
0373 '\n# Unwarp direction' ...
0374 '\nset fmri(unwarp_dir) %s\n'], fsf.unwarp_dir);
0375 fprintf(fid,'%s', fsf_str);
0376 end
0377
0378 if fsf.version == 5.4
0379 fsf_str = sprintf([...
0380 '\n# Dwell/Asymmetry ratio ' ...
0381 '\nset fmri(dwellasym) %d\n'], fsf.dwellasym);
0382 fprintf(fid,'%s', fsf_str);
0383 end
0384
0385 fsf_str = sprintf([...
0386 '\n# Registration to initial structural' ...
0387 '\nset fmri(reginitial_highres_yn) %d\n'], fsf.reginitial_highres_yn);
0388 fprintf(fid,'%s', fsf_str);
0389
0390 fsf_str = sprintf([...
0391 '\n# Search space for registration to initial structural' ...
0392 '\n# 0 : No search' ...
0393 '\n# 90 : Normal search' ...
0394 '\n# 180 : Full search' ...
0395 '\nset fmri(reginitial_highres_search) %d\n'], fsf.reginitial_highres_search);
0396 fprintf(fid,'%s', fsf_str);
0397
0398 fsf_str = sprintf([...
0399 '\n# Degrees of Freedom for registration to initial structural' ...
0400 '\nset fmri(reginitial_highres_dof) %d\n'], fsf.reginitial_highres_dof);
0401 fprintf(fid,'%s', fsf_str);
0402
0403 if fsf.version == 5.4
0404 fsf_str = sprintf([...
0405 '\n# Do nonlinear registration to initial structural?' ...
0406 '\nset fmri(reginitial_highres_nonlinear_yn) %d\n'], fsf.reginitial_highres_nonlinear_yn);
0407 fprintf(fid,'%s', fsf_str);
0408 end
0409
0410 fsf_str = sprintf([...
0411 '\n# Registration to main structural' ...
0412 '\nset fmri(reghighres_yn) %d\n'], fsf.reghighres_yn);
0413 fprintf(fid,'%s', fsf_str);
0414
0415 fsf_str = sprintf([...
0416 '\n# Search space for registration to main structural' ...
0417 '\n# 0 : No search' ...
0418 '\n# 90 : Normal search' ...
0419 '\n# 180 : Full search' ...
0420 '\nset fmri(reghighres_search) %d\n'], fsf.reghighres_search);
0421 fprintf(fid,'%s', fsf_str);
0422
0423 fsf_str = sprintf([...
0424 '\n# Degrees of Freedom for registration to main structural' ...
0425 '\nset fmri(reghighres_dof) %d\n'], fsf.reghighres_dof);
0426 fprintf(fid,'%s', fsf_str);
0427
0428 if fsf.version == 5.4
0429 fsf_str = sprintf([...
0430 '\n# Do nonlinear registration to main structural?' ...
0431 '\nset fmri(reghighres_nonlinear_yn) %d\n'], fsf.reghighres_nonlinear_yn);
0432 fprintf(fid,'%s', fsf_str);
0433 end
0434
0435 fsf_str = sprintf([...
0436 '\n# Registration to standard image?' ...
0437 '\nset fmri(regstandard_yn) %d\n'], fsf.regstandard_yn);
0438 fprintf(fid,'%s', fsf_str);
0439
0440 fsf_str = sprintf([...
0441 '\n# Standard image' ...
0442 '\nset fmri(regstandard) "%s"\n'], fsf.regstandard);
0443 fprintf(fid,'%s', fsf_str);
0444
0445 fsf_str = sprintf([...
0446 '\n# Search space for registration to standard space' ...
0447 '\n# 0 : No search' ...
0448 '\n# 90 : Normal search' ...
0449 '\n# 180 : Full search' ...
0450 '\nset fmri(regstandard_search) %d\n'], fsf.regstandard_search);
0451 fprintf(fid,'%s', fsf_str);
0452
0453 if fsf.version == 5.98
0454 fsf_str = sprintf([...
0455 '\n# Control nonlinear warp field resolution' ...
0456 '\nset fmri(regstandard_nonlinear_warpres) %d\n'],...
0457 fsf.regstandard_nonlinear_warpres);
0458 fprintf(fid,'%s', fsf_str);
0459 end
0460
0461 fsf_str = sprintf([...
0462 '\n# Degrees of Freedom for registration to standard space' ...
0463 '\nset fmri(regstandard_dof) %d\n'], fsf.regstandard_dof);
0464 fprintf(fid,'%s', fsf_str);
0465
0466 fsf_str = sprintf([...
0467 '\n# Do nonlinear registration to standard space?' ...
0468 '\nset fmri(regstandard_nonlinear_yn) %d\n'], fsf.regstandard_nonlinear_yn);
0469 fprintf(fid,'%s', fsf_str);
0470
0471 fsf_str = sprintf([...
0472 '\n# High pass filter cutoff' ...
0473 '\nset fmri(paradigm_hp) %d\n'], fsf.paradigm_hp);
0474 fprintf(fid,'%s', fsf_str);
0475
0476 fsf_str = sprintf([...
0477 '\n# Number of lower-level copes feeding into higher-level analysis' ...
0478 '\nset fmri(ncopeinputs) %d\n'], fsf.ncopeinputs);
0479 fprintf(fid,'%s', fsf_str);
0480
0481 nfiles = length(fsf.feat_files);
0482 for ifile = 1:nfiles
0483 fsf_str = sprintf([...
0484 '\n# 4D AVW data or FEAT directory (%d)' ...
0485 '\nset feat_files(%d) "%s"\n'], ifile, ifile, fsf.feat_files{ifile});
0486 fprintf(fid,'%s', fsf_str);
0487 end
0488
0489 if fsf.reginitial_highres_yn
0490 nfiles = length(fsf.initial_highres_files);
0491 for ifile = 1:nfiles
0492 fsf_str = sprintf([...
0493 '\n# Session''s structural image for analysis %d' ...
0494 '\nset initial_highres_files(%d) "%s"\n'], ...
0495 ifile, ifile, fsf.initial_highres_files{ifile});
0496 fprintf(fid,'%s', fsf_str);
0497 end
0498 end
0499
0500 if fsf.reghighres_yn
0501 nfiles = length(fsf.highres_files);
0502 for ifile = 1:nfiles
0503 fsf_str = sprintf([...
0504 '\n# Subject''s structural image for analysis %d' ...
0505 '\nset highres_files(%d) "%s"\n'], ifile, ifile, fsf.highres_files{ifile});
0506 fprintf(fid,'%s', fsf_str);
0507 end
0508 end
0509
0510
0511 nev = length(fsf.ev);
0512 for iev = 1:nev
0513 ev = fsf.ev(iev);
0514
0515 if fsf.version == 5.98
0516 fsf_str = sprintf([...
0517 '\n# EV %d title' ...
0518 '\nset fmri(evtitle%d) "%s"\n'], iev, iev, ev.name);
0519 fprintf(fid,'%s', fsf_str);
0520 end
0521
0522 fsf_str = sprintf([...
0523 '\n# Basic waveform shape (EV %d)' ...
0524 '\n# 0 : Square' ...
0525 '\n# 1 : Sinusoid' ...
0526 '\n# 2 : Custom (1 entry per volume)' ...
0527 '\n# 3 : Custom (3 column format)' ...
0528 '\n# 4 : Interaction' ...
0529 '\nset fmri(shape%d) %d\n'], iev, iev, ev.shape);
0530 fprintf(fid,'%s', fsf_str);
0531
0532 fsf_str = sprintf([...
0533 '\n# Convolution (EV %d)' ...
0534 '\n# 0 : None' ...
0535 '\n# 1 : Gaussian' ...
0536 '\n# 2 : Gamma' ...
0537 '\n# 3 : Double-Gamma HRF' ...
0538 '\n# 4 : Gamma basis functions' ...
0539 '\n# 5 : Sine basis functions' ...
0540 '\n# 6 : FIR basis functions' ...
0541 '\nset fmri(convolve%d) %d\n'], iev, iev, ev.convolve);
0542 fprintf(fid,'%s', fsf_str);
0543
0544 fsf_str = sprintf([...
0545 '\n# Convolve phase (EV %d)' ...
0546 '\nset fmri(convolve_phase%d) %d\n'], iev, iev, ev.convolve);
0547 fprintf(fid,'%s', fsf_str);
0548
0549 fsf_str = sprintf([...
0550 '\n# Apply temporal filtering (EV %d)' ...
0551 '\nset fmri(tempfilt_yn%d) %d\n'], iev, iev, ev.tempfilt_yn);
0552 fprintf(fid,'%s', fsf_str);
0553
0554 fsf_str = sprintf([...
0555 '\n# Add temporal derivative (EV %d)' ...
0556 '\nset fmri(deriv_yn%d) %d\n'], iev, iev, ev.deriv_yn);
0557 fprintf(fid,'%s', fsf_str);
0558
0559 switch ev.shape
0560 case 0
0561 fsf_str = sprintf([...
0562 '\n# Skip (EV %d)' ...
0563 '\nset fmri(skip%d) %d\n'], iev, iev, ev.skip);
0564 fprintf(fid,'%s', fsf_str);
0565
0566 fsf_str = sprintf([...
0567 '\n# Off (EV %d)' ...
0568 '\nset fmri(off%d) %1.2f\n'], iev, iev, ev.off);
0569 fprintf(fid,'%s', fsf_str);
0570
0571 fsf_str = sprintf([...
0572 '\n# On (EV %d)' ...
0573 '\nset fmri(on%d) %1.2f\n'], iev, iev, ev.on);
0574 fprintf(fid,'%s', fsf_str);
0575
0576 fsf_str = sprintf([...
0577 '\n# Phase (EV %d)' ...
0578 '\nset fmri(phase%d) %d\n'], iev, iev, ev.phase);
0579 fprintf(fid,'%s', fsf_str);
0580
0581 fsf_str = sprintf([...
0582 '\n# Stop (EV %d)' ...
0583 '\nset fmri(stop%d) %d\n'], iev, iev, ev.stop);
0584 fprintf(fid,'%s', fsf_str);
0585 case {2,3}
0586 fsf_str = sprintf([...
0587 '\n# Custom EV file (EV %d)' ...
0588 '\nset fmri(custom%d) "%s"\n'], iev, iev, ev.fname);
0589 fprintf(fid,'%s', fsf_str);
0590 otherwise
0591 fprintf('Not set up to handle this EV shape yet\n');
0592 end
0593
0594
0595 switch ev.convolve
0596 case 1
0597 fsf_str = sprintf([...
0598 '\n# Gauss sigma (EV %d)' ...
0599 '\nset fmri(gausssigma%d) %1.2f\n'], iev, iev, ev.gausssigma);
0600 fprintf(fid,'%s', fsf_str);
0601
0602 fsf_str = sprintf([...
0603 '\n# Gauss delay (EV %d)' ...
0604 '\nset fmri(gaussdelay%d) %1.2f\n'], iev, iev, ev.gaussdelay);
0605 fprintf(fid,'%s', fsf_str);
0606
0607 end
0608
0609
0610
0611 if ~isempty(ev.ortho)
0612 ortho_vect = [0 ev.ortho];
0613 for jev = 0:nev
0614 fsf_str = sprintf([...
0615 '\n# Orthogonalise EV %d wrt EV %d' ...
0616 '\nset fmri(ortho%d.%d) %d'], iev, jev, iev, jev, ortho_vect(jev+1));
0617 fprintf(fid,'%s', fsf_str);
0618 end
0619 end
0620 end
0621
0622
0623 fsf_str = sprintf([...
0624 '\n# Contrast & F-tests mode' ...
0625 '\n# real : control real EVs' ...
0626 '\n# orig : control original EVs' ...
0627 '\nset fmri(con_mode_old) %s' ...
0628 '\nset fmri(con_mode) %s'], fsf.con_mode_old, fsf.con_mode);
0629 fprintf(fid,'%s', fsf_str);
0630
0631
0632 ncon = length(fsf.con);
0633 nFtest = length(fsf.Ftest);
0634
0635 for icon = 1:ncon
0636 con = fsf.con(icon);
0637
0638 mode = con.type;
0639
0640 fsf_str = sprintf([...
0641 '\n# Display images for contrast_%s %d' ...
0642 '\nset fmri(conpic_%s.%d) %d\n'], mode, icon, mode, icon, con.conpic);
0643 fprintf(fid,'%s', fsf_str);
0644
0645 fsf_str = sprintf([...
0646 '\n# Title for contrast_%s %d' ...
0647 '\nset fmri(conname_%s.%d) "%s"\n'], mode, icon, mode, icon, con.conname);
0648 fprintf(fid,'%s', fsf_str);
0649
0650 for iev = 1:nev
0651 if length(con.con_vect) < iev, continue, end
0652 fsf_str = sprintf([...
0653 '\n# Real contrast_%s vector %d element %d' ...
0654 '\nset fmri(con_%s%d.%d) %d\n'], mode, icon, iev, mode, icon, iev, con.con_vect(iev));
0655 fprintf(fid,'%s', fsf_str);
0656 end
0657
0658 for iftest = 1:length(con.ftest)
0659 fsf_str = sprintf([...
0660 '\n# F-test %d element %d' ...
0661 '\nset fmri(ftest_%s%d.%d) %d\n'], iftest, icon, mode, iftest, icon, con.ftest(iftest));
0662 fprintf(fid,'%s', fsf_str);
0663 end
0664 end
0665
0666
0667 fsf_str = sprintf([...
0668 '\n# Contrast masking - use >0 instead of thresholding?' ...
0669 '\nset fmri(conmask_zerothresh_yn) %d\n'], fsf.conmask_zerothresh_yn);
0670 fprintf(fid,'%s', fsf_str);
0671
0672 fsf_str = sprintf([...
0673 '\n# Do contrast masking at all?' ...
0674 '\nset fmri(conmask1_1) %d\n'], fsf.conmask1_1);
0675 fprintf(fid,'%s', fsf_str);
0676
0677 if fsf.version == 5.98
0678
0679 fsf_str = sprintf([...
0680 '\n#############################################################' ...
0681 '\n# Now options that don''t appear in the GUI\n' ...
0682 '\n# Alternative example_func image (not derived from input 4D dataset' ...
0683 '\nset fmri(alternative_example_func) %s\n' ...
0684 '\n# Alternative (to BETting) mask image' ...
0685 '\nset fmri(alternative_mask) %s\n' ...
0686 '\n# Initial structural space registration initialisation transform' ...
0687 '\nset fmri(init_initial_highres) %s\n' ...
0688 '\n# Structural space registration initialisation transform' ...
0689 '\nset fmri(init_highres) %s\n' ...
0690 '\n# Standard space reigstration initialisation transform' ...
0691 '\nset fmri(init_standard) %s\n' ...
0692 '\n# For full FEAT analysis: overwrite .feat output dir?' ...
0693 '\nset fmri(overwrite_yn) %d\n'],...
0694 fsf.alternative_example_func,fsf.alternative_mask,...
0695 fsf.init_initial_highres,fsf.init_highres,...
0696 fsf.init_standard,fsf.overwrite_yn);
0697 fprintf(fid,'%s', fsf_str);
0698 end
0699
0700 fclose(fid);
0701 return
0702
0703
0704 '\n# Mask real contrast/F-test 1 with real contrast/F-test 2?'
0705 'set fmri(conmask1_2) 0'
0706
0707 '\n# Mask real contrast/F-test 1 with real contrast/F-test 3?'
0708 'set fmri(conmask1_3) 0'
0709
0710 '\n# Mask real contrast/F-test 1 with real contrast/F-test 4?'
0711 'set fmri(conmask1_4) 0'
0712
0713 '\n# Mask real contrast/F-test 2 with real contrast/F-test 1?'
0714 'set fmri(conmask2_1) 0'
0715
0716 '\n# Mask real contrast/F-test 2 with real contrast/F-test 3?'
0717 'set fmri(conmask2_3) 0'
0718
0719 '\n# Mask real contrast/F-test 2 with real contrast/F-test 4?'
0720 'set fmri(conmask2_4) 0'
0721
0722 '\n# Mask real contrast/F-test 3 with real contrast/F-test 1?'
0723 'set fmri(conmask3_1) 0'
0724
0725 '\n# Mask real contrast/F-test 3 with real contrast/F-test 2?'
0726 'set fmri(conmask3_2) 0'
0727
0728 '\n# Mask real contrast/F-test 3 with real contrast/F-test 4?'
0729 'set fmri(conmask3_4) 0'
0730
0731 '\n# Mask real contrast/F-test 4 with real contrast/F-test 1?'
0732 'set fmri(conmask4_1) 0'
0733
0734 '\n# Mask real contrast/F-test 4 with real contrast/F-test 2?'
0735 'set fmri(conmask4_2) 0'
0736
0737 '\n# Mask real contrast/F-test 4 with real contrast/F-test 3?'
0738 'set fmri(conmask4_3) 0'
0739