Skip to Content
CRNL

SPM Script

Introduction


SPM is a popular tool for analyzing brain imaging data. The most recent versions make scripting very straightforward. Cambridge Neuroimaging provides a great tool for automated analysis. However, few scripts exist to take advantage of some of the powerful features includes lesion-masked normalization and motion correction with fieldmap undistortion. We have created simple scripts that allow efficient processing of neuroimaging data using these features.

The flowchart for image processing is shown in the figure. My scripts require a T1 anatomical scan an session[s] of T2* fMRI data as input (with each fMRI session saved a single 4D image with all the timepoints in a single file). Optionally you can include a fieldmap (to undistort data) and a lesion map (typically drawn on a diffusion or FLAIR image, depending on whether injury is acute). I generally recommend drawing lesion extent manually on these pathological scans (as lesion extent is difficult to determine on T1 scans), but note that automated methods exists (Seghier et al., 2008).

You could describe the processing pipeline like this: The images were processed using SPM8 (http://www.fil.ion.ucl.ac.uk/spm/software/spm8/). The T2* data was motion-corrected with spatial unwarping based on the field maps (Hutton et al., 2002). The images were then slice-time corrected to adjust for the temporal order of acquisition. The mean T2* image was coregistered to the T1 anatomical scan, and unified segmentation normalization of the T1 image was computed (Ashburner and Friston, 2005) using a lesion-masked cost function (Brett et al., 2001; Rorden et al., 2012) and used to reslice the T2* data to standard stereotaxic space (3mm isotropic). The T2* images were then spatially smoothed with a 6mm full-width-half-maximum Gaussian kernel.

A block design example


Consider the block-design fMRI data described and available for download (though note the automated script will generate slightly different results for the manual method described, as the script uses a more sophisticated normalization procedure). The downloadable dataset includes the necessary batch scripts. Note that this sample script does not employ a field map (little spatial distortion) or lesion map (data from a healthy individual).

  • We need to set the origin of each scan to roughly match the anterior commissure. We use a custom version of ACPCdetect to do this automatically, but you can also do this manually (make sure to apply the correction to the T1 scan and ALL the fMRI volumes). Manual instructions are provided in the “Lets set the origin” step of my manual block design analysis web page.
  • Preprocess the fMRI data, using the T1 scan to aid normalization. From the Matlab command line type: “nii_preprocess(‘fmriblocks009.nii’,’T1s005.nii’)”
  • Run the statistics by typing the following from the Matlab command line: “nii_stat_1st_block(‘swafmriblocks009.nii’,’1′)” Note we provide the filename for the processed data (the ‘swa’ prefix reminds us it has been smoothed, normalized and slice-time-aligned). Also, we provide a statistics folder name. Typically, we will need to create a statistics folder for each individual. In this case, I am created a folder named ‘1’, since this is the first participant’s data.
  • Note we can combine the two steps in a simple batch script (see enclosed nii_batch_block”). In general the preprocess script does not have to be changed (only make sure the TR and slice order for slice timing correction is correct), but the statistical script needs to be edited for each study (and if event timing varies between participants, for each participant).
  • We can now look at our results – simply follow the manual instructions from “Now we can look at our results” step of my manual block design analysis web page. The results are already computed so you simply need to click on the statistical contrast you are interested in.

An event-related design example


Consider the event-related design fMRI data described and available for download. The downloadable file includes the neuroimaging data, the scripts to automatically process the data, and a set of web pages that describe how to analyze the data manually. Note that this sample script does not employ a field map (little spatial distortion) or lesion map (data from a healthy individual).

  • We need to set the origin of each scan to roughly match the anterior commissure. We use a custom version of ACPCdetect to do this automatically, but you can also do this manually (make sure to apply the correction to the T1 scan and ALL the fMRI volumes). Manual instructions are provided in the “Lets set the origin” step of my manual block design analysis web page.
  • Preprocess the fMRI data, using the T1 scan to aid normalization. From the Matlab command line type: “nii_preprocess(‘fmrievent008.nii’,’T1s005.nii’)”
  • Run the statistics by typing the following from the Matlab command line: “nii_stat_1st_event(‘swafmrievents009.nii’,’1′)” Note we provide the filename for the processed data (the ‘swa’ prefix reminds us it has been smoothed, normalized and slice-time-aligned). Also, we provide a statistics folder name. Typically, we will need to create a statistics folder for each individual. In this case, I am created a folder named ‘1’, since this is the first participant’s data.
  • Note we can combine the two steps in a simple batch script (see enclosed nii_batch_event”). In general the preprocess script does not have to be changed (only make sure the TR and slice order for slice timing correction is correct), but the statistical script needs to be edited for each study (and if event timing varies between participants, for each participant).
  • We can now look at our results – simply follow the manual instructions from “Now we can look at our results” step of my manual block design analysis web page. The results are already computed so you simply need to click on the statistical contrast you are interested in.

References

  • Ashburner J, Friston KJ. (2005) Unified segmentation. Neuroimage. 26:839-51.
  • Brett M, Leff AP, Rorden C, Ashburner J. (2001) Spatial normalization of brain images with focal lesions using cost function masking. NeuroImage 14: 486–500.
  • Hutton C, Bork A, Josephs O, Deichmann R, Ashburner J, Turner R. (2002) Image Distortion Correction in fMRI: A Quantitative Evaluation, NeuroImage 16:217-240.
  • Rorden C, Bonilha L, Fridriksson J, Bender B, Karnath HO (2012) Age-specific CT and MRI templates for spatial normalization. NeuroImage.
  • Seghier ML, Ramlackhansingh A, Crinion J, Leff AP, Price CJ. (2008) Lesion identification using unified segmentation-normalisation models and fuzzy clustering. Neuroimage. 41(4):1253-66.

Links

© 2012 University of South Carolina Board of TrusteesPrivacy Policy