Batch scripts 2012
We now have several high-level functions that will construct SPM batch jobs for building and estimating 1st-level GLMs and contrasts. The batch scripts linked below run all stages of the 1st and second level model processes.
**Click here to download the batch scripts** Updated Aug 20, 2012
What the scripts do
The script prep_model1.m does the following things, and you can control which are run when you execute the script (1 = run, 0 = skip):
set_up_onsets - First level: Construct and save onset files for each subject build_spm_batch_job - Construct and save SPM batch for 1st level GLM specify_and_estimate - Run the batch job spec_est_only_if_missing - run the spec/est only if files are missing specify_and_estimate_contrasts - Build and estimate contrasts for each subject
review_designs - Save an HTML webpage with design matrices and diagnostics for each participant
robust_regression_setup - Second level: Collect files for robust regression and save EXPTm structure robust_regression_run - Run robust regression for each contrast robust_regression_results - Create and save and HTML webpage with diagnostics and montages of results. (Also saves clusters with extracted data for each contrast and .png images.)
The function publish_model publishes design matrices and/or robust regression results to HTML websites. It is called in prep_model?.m scripts. It runs robust_regression_batch.m and requires two other scripts as well, which are included in the .zip file.
Before you run...
Before you run the scripts, you need to: 1. create a directory structure similar to the one called in the batch script: base directory → first_level → modelX → SubjIDCode base directory → second_level → modelX (model subdiectories and below will be created if necessary) See below!
2. Create files that store your behavioral/task onsets for each subject in a way that can be consistently loaded, named, and called. In the examples, they are saved in the trialinfo and nuisance folders, and are named per subject.
3. Update the CANlab matlab code repository (or download from the lab website) and make sure you have the latest versions.
4. Modify the script: Modify certain marked portions of the script (usually marked with *) to create the onset, duration, parametric modulator, etc. vectors for your particular experiment. You would also modify the places in the script where you input image filename lists (for 1st level) and specify contrasts. The rest should be general to most SPM models.
5. Then, make sure you modify spm_defaults.m and load the new defaults by typing:
spm('Defaults', 'fMRI') % <- get current defaults; otherwise will not reload from .m
6. Make sure the “scripts” directory for your experiment (where you save the batch scripts) is on your matlab path. Then you are ready to run.