Of course, spm batch mode is known as "SPM crash mode" to its friends.SPM 99 batch mode requires a considerable amount of know-how to get working from scratch. However, you can get a long way with some examples, as provided in the SPM batch directory. Here's a few files I've been using, in the hope that they help someone else.
The files are to analyze 24 near identical sets of data. Each set of data consists of 64 scans, from a single session, in a BABABA design, where B is activation (lasting 8 scans) and A is rest (lasting 8 scans). Each set is from a different subject, and is in its own subdirectory. All the scans have been corrected for slice timing, and aligned roughly to the MNI template with translations, rotations etc, via the SPM display feature. The first six sets have slice timing corrected scans beginning with aa... and the subsequent sets of slice timing corrected scans begin with ae... One of the subjects has only had 55 scans, thus missing off the last scan of activation and the last rest epoch; they therefore need a slighlty different statistical model.
So, to run the analysis, I put the following files in the directory containing the subjects' subdirectories (in this case "/home/matthew/subject_ana"):
Then started the analysis by selecting and saving the names of the subdirectories, in the analysis directory (/home/matthew/subject_ana)
>> sdirs = spm_get(-24, '', 'Select subject directories'); >> nsubs = size(sdirs, 1); >> save sdirs sdirs nsubs
Then ran the realignment normalization and smoothing:
Incidentally, it is often dangerous to run the normalization in batch mode like this, and it is essential, in our experience, to check the normalization output carefully before proceeding. In the case of this analysis, for example, several normalizations did not work well, and this can have a dramatic effect on the subsequent statistics.Last, I ran the statistics on the individual subjects:
Note that the realignment above was for one session per subject. If you have more than one session per subject, beware, this can be confusing, because the batch structures for realignment are called 'sessions', but in fact they refer to subjects. Specifically, you will need an array of session structures (one structure per subject). The structures contain one field, 'images', containing a cell array of file names, one cell for each session, each cell containing a string array, specifying the file names for that session. Have a look at the examples of a two session per subject batch realignment:
You might well want to check out some other links; the KULeuven automation scripts for SPM are an alternative to SPM batch mode, and may be easier to use. Russ Poldrack has written an excellent page on using batch mode.
Matthew Brett 5/2/00