Getting started with SPM
SPM is free, Matlab-based fMRI analysis software. It was originally created by a few researchers at UCL for analyzing PET data, and over the decades has evolved into the most widely-used fMRI analysis software, to which a large group of researchers have contributed code. One advantage is its versatility, as it still has a module for analyzing PET data and also has new modules for MEG/EEG data, voxel-based morphometry studies in aphasia, and functional connectivity in fMRI.
The main SPM website is here. Here is where you can download the software and find links to other resources like the mailing list. Subscribing to the mailing list can be a good idea, but you will get a million emails so you should definitely filter them to a separate folder.
Accessing and running SPM
From the website, you download an SPM directory. The software consists of a lot of Matlab scripts, organized into different toolboxes. The nice thing about this is that if you want to understand how some process works, you can just open up a script in the text editor and try to figure it out yourself.
To get started, you need to open Matlab and then File -> Set Path, navigate to the SPM directory and 'Add with Subfolders' to your path. Then go to the command window and just type spm, and after a few moments the user interface will pop up.
The best and almost only way to do analysis in SPM8 is to use the Batch editor. You can access it by pressing the batch button at the bottom of the fMRI menu interface. From there you can pull down different analysis routines and add it to an overall batch. Then you can save all the routines and parameters you've put together, so that you can recover or change what you did later.
When you're doing SPM operations, you will need to tell it what Nifti files contain your fMRI data. Doing this through the GUI is a little tricky. When you get to the directory that has your Nifti file, you will see apparently just one file, which contains all your volumes. However, SPM needs to pretend that it has separate files for each volume. So what you need to do is at the bottom right where it says filt, and by default there is a 1 in the box underneath, you need to change the 1 to something like 1:200 (if you have 200 volumes or less in your run) and press the filt button. Then you should see files listed for all the functional volumes in this run. Now, if you are on a Mac, press Ctrl and then click on the window with all the files; if you are on a PC, right-click on that window, and click 'Select all'. This should bring the right number of volumes to the selection window.
This is where you can use a field map (if you collected one) to correct geometrical problems in the image. This is a two-step process in SPM. First you need to load the field map data and use it to create a voxel displacement map (VDM). Then you use this VDM as input to the unwarp step. You can also choose to unwarp at the same time as you do motion correction, which can be a good idea since motion and magnetic distortion can interact so much.
Inputting the Field Map
The following instructions are predicated on using a Siemens scanner. In the batch editor, go to SPM->Tools->FieldMap->Presubtracted Phase and Magnitude Data. Start out by clicking out on Data and edit value. Now you need to specify the field map files you collected for phase and magnitude data. You should have had two files output. The phase data looks like the classic 'field map' pictures of the magnetic field, showing distortion around sinuses etc. The magnitude data just looks like a fuzzy image.
Now click on FieldMap defaults and say edit values->default values. Here is where you need to enter a lot of parameters. The short and long echo times should be in your field map protocol. You can choose 'no brain masking' next. Blip direction should be -1 for Siemens scanners. Total EPI readout time can be calculated from values listed in your functional EPI protocol (not your field map protocol). You can tell whether your field map was collected with a gradient echo or EPI sequence based on the field map protocol. The rest of the values should be fairly self-explanatory.
Note that you need to make a decision when you're collecting data about whether you want to use one field map for all your runs or multiple field maps, to get somewhat better estimation.
Realigning and Unwarping
You can unwarp and realign at the same time by choosing SPM->Spatial->Realign->Realign and Unwarp. Then you select the VDM file you created.
Slice Timing Correction
See the main MRI-fMRI page for a discussion of the theory behind slice time correction. In SPM from the GUI you can access the Slice Timing module through the Batch Editor, under SPM->Temporal. Here you need to provide 1) the functional datafiles to correct, 2) the number of slices, 3) a formula called TA (different from the TA (time to acquire) listed on some scanning protocols), 4) the order in which the slices were acquired, and 5) what slice you want to use as a reference.
You can read the standard formula for TA in the SPM help box at the bottom of the screen. You also need to enter the slice order; you can just enter the number of every slice, or you can enter it like you would a 1-D matrix in Matlab, as the examples in the help box indicate. Everything else is pretty straightforward.
You go to SPM->Spatial->Realignment. You might want to change the Separation value to make it equal to your voxel size (in mm). If you choose register to mean, it will do the two-step process described on the MRI-fMRI page, first registering to the first image and then re-registering everything to the mean image. If you enter multiple sessions, it will register the other sessions to the mean of the first session. You may want to increase the default b-spline value from 2 to 4 to slightly increase accuracy.
In this step, you create a statistical map for the individual subject, to illustrate the effect of your conditions on the BOLD signal.
A very important thing to be aware of is that by default, SPM will completely omit from the resulting statistical map voxels that are below a given threshold. This can be annoying if you are feeding in images that have a different scale than what SPM expects, and it can be dangerous in the sense that if you don't see a blob light up in a given area, it could be because it was analyzed and did not show an effect, or it could be because it was not even included in the analysis--two very different interpretations.
You should always check out the mask.img file that is created in the directory with your statistical maps, to make sure that it is covering the brain area that you think it is.
If you decide that the SPM threshold is not doing a good job, you cannot change it using the standard analysis menu. You might think that 'Specify Explicit Mask' will allow you to choose the mask that SPM uses rather than the standard threshold, but this is not the case; choosing this just applies an explicit mask on top of the voxels that passed SPM's threshold. So what you need to do first is actually go in and edit the spm.defaults.m file that is in your SPM directory. There is a parameter called defaults.mask.thresh, that in Oct2011 is by default set to .8. If you change it to -Inf, it will turn off the threshold. Now if you run the analysis, the entire cube of voxels in MNI space will go into the statistical analysis. This is probably going to take you too far in the other direction, as you'll now be analyzing voxels that are clearly not in the head. So now you can choose an appropriate Explicit Mask, created through some other procedure.