top of page


Author: Brandon Brewer


SPM or Spatial Parametric Mapping, has aided many neuroimaging researchers in examining differences in brain activity through the use of functional magnetic resonance imaging (fMRI). However, analysis of brain activity is not limited to fMRI and includes PET, SPECT, EEG, and MEG. Toolboxes used for performing analysis are volume-based morphometry and effective connectivity. Volume-based morphometry allows researchers to identify structural abnormalities in the brain by normalizing MRI images and then finding differences between groups. Effective connectivity is the influence of one neural system over another. One of the main purposes of using SPM is to test hypotheses about regionally specific effects. SPM allows a researcher to use T-tests, ANOVA (Analysis of Variance), and a general linear model to aid in either confirming or rejecting a null hypothesis. With SPM researchers are able to perform statistical comparisons on groups and preprocess data, however, one downfall is the use of Matlab(which costs money) on which SPM runs on. 


To begin using SPM, you must have or download Matlab.

Requirements for downloading Matlab:

  • Mathworks account

  • Mathworks license

  • Administrative rights

  • Money, unless your school/university has an account

SPM img 3.png

Steps to download Matlab:

  1. Go to

  2. Sign-in to account

  3. Once logged in, select “my account”

  4. From there, click the download icon

  5. After clicking download, click another download button showing the latest version

  6. Install according to your machine (Windows, Linux, macOS) 

  7. Once installed, open up Matlab and run command “ver” to check that everything has been installed properly

SPM img 4.png

Steps to Download SPM

  1. Go to 

  2. Click “SPM12” as the version, and input your information under “Additional Info”

  3. Click “Download”

  4. After downloading, unzip the zip folder, and move to home-directory

  5. Open Matlab

  6. Click “set path”

  7. Click “add folder” and select SPM12

  8. Click “save” 

  9. On the Matlab terminal type “spm”, then click one of the six options (PET & VBM, M/EEG, fMRI, About SPM, SPMweb, Quit) depending on what you are planning to use SPM for

SPM img 5.png

Statistical Analysis Using SPM (Used to test hypotheses about regionally specific effects):

  1. T-test

    1. Can only test two groups to see if there is a difference in mean. A T-value that is large indicates the mean of the group is significantly different compared to the standard error. A smaller T-value means the two groups are similar. You can use the T-value to compare it to the critical value chart for the T-test and determine whether to reject/accept your null hypothesis. 

    2. Can be used to either accept or reject a null hypothesis if the p-value < 0.05. 

  2. ANOVA

    1. ANOVA stands for Analysis of Variance, and unlike the T-test, it can do multiple group comparisons. It uses F-tests to examine pre-specified sets of standard effects. F-tests provide information about the statistical difference in standard deviation for two sets of data. It is to determine how significantly different the two sets of data are. In the F-test, there is an F-value which will help to determine variations between data. To calculate it you can take the “between-group variation” divided by the “within-group variation”. A larger F value ratio indicates a higher probability that the groups have different means. A high F value but a low p-value means the null hypothesis can be rejected. The null hypothesis means there is no relationship between your two sets of data. If there is no variation between groups, then you can accept the null hypothesis. 

  3. General Linear Model

    1. Data=model plus error(deviation from model)

    2. Includes Linear regression which models the data based on a linear relationship. It can be used to predict both output and input values based on the linear model.

Preprocessing Data:

What is preprocessing data? Preprocessing data is cleaning up the data so it can be analyzed and used. An analogy used by Andrew Jahn is clearing up a blurry picture. Preprocessing data would be the same as applying filters on a blurry picture to make it clearer. For fMRI imaging, this can include realignment, unwarping, co-registration, spatial normalization, and more.

There are a variety of neuroimaging tools to preprocess neuroimaging data, but in this blog, we will be focusing on SPM.

Step 1- Realignment:

One pro of using SPM, compared to other neuroimaging tools is its ease of use. To start preprocessing data open up Matlab along with SPM. To begin preprocessing, the first step is to realign the data. Realigning the data is aligning all the brain scans of the same subject over different times. To do this using SPM, go to your data by typing in “cd ~/(Path of data)”. Go to SPM (the green box), and click on “Realign (Est & Reslice)”. The “estimate”, as well as the “reslice” part of the realignment, lists many options. 

Estimation Options:

  1. Quality: Provides a number 0 to 1 on how precise your results will be with 1 being the most precise

  2. Separation: The difference in distance (mm) of sampled points in the reference image

  3. Smoothing (FWHM): Gaussian smoothing kernel- transforms points to Gaussian function

  4. Num Passes: Specify if volumes are aligned to the mean of all the volumes, or to the first session

  5. Interpolation: How images get sampled

  6. Wrapping: Returning variables in volume back to min value

  7. Weighting: can weight voxels differently for the reference image

Reslice Options:

  1. Resliced Images: selecting the scans you want to reslice

  2. Interpolation: How images get sampled

  3. Wrapping: Returning variables in volume back to min value

  4. Masking: For voxels not in the original images, they are set to zero 

  5. Filename Prefix: default - ‘r’

You may change these options based on what you think best works for your data.

To add sessions to your data click on “Data” → “New: Session”. Depending on your data, you can add as many or as few sessions as you want. To add files to your session, click “Sessions” under “Data” and add the files you want. After adding your files, you should see the number of files you added next to “Sessions”. You can then click “Run Batch” or the green button on the top left which will begin the realignment. 

Step 2- Slice Timing Correction:

The next step of preprocessing data using SPM is slice timing correction. Slice timing correction is correcting the data or the delays in the data when the slices were acquired. To do this in SPM, just like when realigning, go to SPM (the green box), and click on “Slice timing”. From here you will be able to see a list of inputs:

  1. Data

  2. Number of Slices: The number of slices in data, can be found by going to the Matlab terminal and typing in V = spm_vol(‘sub-##name of data’) → “V(1).dim” to load dimensions on x-y-z. 

  3. TR: Time of repetition

  4. TA: TR-(TR/# of slices)

  5. Slice order: enter slice order (enter in brackets)

  6. Reference Slice: enter which slice will be the reference slice (ex. 1 ← the first image as the reference)

  7. Filename Prefix: Default prefix: “a”

To add sessions, click on “Data” → ”New: Session”. Create as many or as few sessions as needed depending on your data. Just like you did when realigning the data, input your files into the session to analyze, and input the required information as shown above. Click the “Run Batch” or green button on the top left which will begin the slice timing correction.

Step 3- Co-registration:

The next step is co-registration. Co-registration refers to aligning the anatomical and functional images of the data. To begin, go to SPM (the green box), and click on “Coregister” → “Coregister (Est & Res)”. From here you will be able to see a list where you input the required information:

  1. Reference image: the image that is not changed or moved, the one that is going to be referenced (func data)

  2. Source image: The images that are going to be moved/changed to best fit the reference image (anat data)

  3. Other images

  4. Estimation Options

    1. Objective Function

    2. Separation: Avg distance in mm between sampled points

    3. Tolerance: Accuracy of Parameters 

    4. Histogram Smoothing: Gaussian Smoothing

  5. Reslice Options

    1. Interpolation: How images get sampled

    2. Wrapping: Returning variables in volume back to min value

    3. Masking: For voxels not in the original images, they are set to zero 

    4. Filename Prefix: Default prefix: “r”   

Input the required information into each field to start the coregistration of the data. Then click “Run Batch” or the green button that will coregister the data. A window will pop up with the func data on the left and the anat data on the right.

Step 4- Segmentation:

The next step is segmentation which is just simplifying the data down so that it can be easily analyzed. To segment your data, go to SPM (the green box) and click “segment” which will only need the anat files. After clicking “segment” click “volumes” and select your anat files. Then click “save bias corrected” on the same place where you clicked “volumes” and on the lower left box underneath the title: “Current Item: Save Bias Corrected” change “save nothing” to “save bias corrected”. After changing it, scroll down to the bottom and click on “Deformation Fields” and change it to “forward”. Click “Run batch” or the green button to finish segmentation. 

Step 5- Normalization:

The final step of preprocessing the data using SPM is normalization which is essentially converting your data to another format to allow it to be processed easily. To start, go to SPM (the green box) and click on “Normalise (Write)”. From here you will see another list of options. Click on “data” → “new subject”. Click “deformation field” and add your specific file. Do the same for “Images to write”. You can make it easier to find certain files by inputting specific names of files in the “filter” option. After inputting in your specific files, click on “Run Batch” or the green button and you have successfully normalized your files. 


This blog is meant to provide a quick overview of what SPM is and how to use it to preprocess data. If you would like more information on every minute detail of SPM you can use the SPM manual.

bottom of page