SPM analysis of a block design
  Introduction

This page describes how to analyze fMRI data from a single individual using SPM. SPM is a powerful and free tool to measure task-related changes in the brain's blood flow. To complete this tutorial you will need:

  • To conduct SPM single subject data processing you will need
    1. SPM installed on your computer (you must install the professional program Matlab to run SPM).
    2. The SPM folder should be in the Matlab path.
    3. The workshop CD includes a sample dataset in the 'software' folder named fmridata.zip. This includes a 120 volume fMRI session (e.g. fds.img), a text file (left_onsets2dum.txt; right_onsets2dum.txt) that describes the events that occurred during the fMRI session, a T1-weighted anatomical scan (ads.img), as well as a skull stripped version of this image (bads.img). Note that my sample dataset is prepared for FSL (which uses 4D images), while SPM requires 3D images. Therefore, you need to convert the functional data fds.img. This is simple: open fds.img with MRIcro,  choose File/SaveAs4D->3D, press Save [Intel], and then press 'Sagment Padded File001, File002...'. This will create a series of images (e.g. fdsx001...fdsx120) that you can analyze. 

About the sample dataset

This was a simple finger tapping task. For periods of 11.2 seconds, the screen rapidly flashed with an arrow (<,> or ^). When the arrow pointed up (^) theparticipant was asked to rest, whenit pointed right (>) they were intstructed to tap their right index finger, and when it pointed left (<) they were requested to push their left index finger. These blocks repeated for the whole scanning session (120 volumes, about 6 minutes). The order of the blocks was randomized, but the task always changed every 11.2 seconds (e.g. a left block was always followed by either a right or rest block). The first 2 fMRI scans will be discarded (as these appear brighter as the T1 effects are not saturated). The onsets of the tasks are recorded in the files left_onsets2dum and right_onsets2dum.  first finger task began 11.3 seconds after the first saved fMRI dataset. The image below shows the three event types (left, right or up arrow) as marks at the top of the image (with blue, red and green indicating the stimuli types). The colored lines show the expected HRF response. Note this figure is for illustration only - the actual block order was a bit different.
Task Design

SPM single subject data processing

Steps for functional MRI analysis using SPM2

  1. Start SPM by typing 'spm fmri' from the Matlab command prompt - if this fails, SPM is not in your Matlab path. This will bring up the command window - we will start with spatial preprocessing:
    SPM commands
  2. Slice Timing Correction is often the first step of fMRI data processing. Our data is a block design, so there is little benefit of completing this stage. 
    1. Press Slice Timing
    2. Select number of subjects/sessions to correct 1
    3. Select images [Choose your raw images]
    4. Select Acquisition order (ascending, descending or custom). 1 2 3 4 5 6 … 36
    5. References slice (middle slice of volume) = 18
    6. Interscan Inteval (TR) sec = 3
    7. TA (acquisition time)  Unless Sparse design, this = [(nSlices-1)/(nSlices)]*TR = 2.9167
    • Note: If you conduct STC, time zero effectively is the moment when the middle slice of the first volume was collected. In our example, at the statistics stage you would have to adjust the onset vectors for all events by 1.5secs. In this tutorial, I assume you do not slice time correct your data.
  3. The next step would be to motion correct our data.
    1. Choose [Realign & Unwarp]  Note unwarping is SLOW, you may just want to realign your data
    2. Choose number of subjects 1 (only analyzing one person)
    3. Choose Number of sessions per subject 1 [all scans collected in one session]
    4. You will be asked to select images: Choose your  images fdsx001...fdsx120 (or afdsx001...afdsx120 if you slice time corrected your data)
    5. Choose dimensions (if Unwarping) All
    6. Create what All + Mean
  4. The next step is to normalize our data (make the shape, size and orientation match a generic shape similar to other individuals).
    1. Press Normalize
    2. Select ‘Determine Parameters and Write Normalized
    3. Select Template EPI for fMRI data (T1 for anatomical scan).
    4. Select your data Choose your  realigned images rfdsx001...rfdsx120
    • Note – you may want to change defaults for normalizing – Press Defaults button, Spatial Normalization
    • Estimation: use brain mask (no for fMRI, yes for T1)
    • Estimation: Cutoff 25mm is standard, Affine only for no nonlinear
    • Writing: Voxel size – default is 2mm. 1mm more appropriate for T1, 3mm for most fMRI
  5. The next step is to smooth our data
    1. Press ‘Smooth’
    2. FWHM = full width half maximum 8 (typically x2..x3 image resolution, so 8mm as originals were 3x3x3mm)
    3. Select images to smooth Choose your  realigned images wrfdsx001...wrfdsx120
  6. The previous preprocessing steps created smoothed, normalized and realigned data swrfdsx001..swrfdsx120. We want to discard the first two volumes, as these tend to appear brighter 
    1. Use your file browser to delete swrfdsx001 and swrfdsx002
  7. Now we can conduct statistics
    1. Click fMRI button in the middle of the SPM  window.
    2. Choose Design
    3. Interscan interval TR sec 3.0
    4. Scans 118
    5. Specify in SECS
    6. Convolution: HRF (for event related: "HRF w derivative"
    7. volterra No
    8. Conditions: 2 - now we have to report when the different stimuli appeared.
      1. Name LEFT
        Onset 18 51.6 74 107.6 152.4 186 242 264.4 309.2 331.6
        Duration 11.2 11.2 11.2 11.2 11.2 11.2 11.2 11.2 11.2 11.2
        No modulation
      2. Name RIGHT
        Onset 6.8 40.4 85.2 130 174.8 208.4 230.8 253.2 286.8 320.4
        Duration 11.2 11.2 11.2 11.2 11.2 11.2 11.2 11.2 11.2 11.2
        No Modulation
    9. Now we have described the design. Lets estimate it
      1. Click ‘fMRI’ 
      2. Choose Data
      3. Select your 118 scans swrfdsx003..swrfdsx120
      4. Choose whether you wish to remove global effects No
      5. Choose a high pass filter (default = 128, or x4 block length for block design = 44.8sec): 44.8
      6. AR(1) correlations
    10. Now we can estimate the results
      1. Press the 'Results' button and click on the 'SPM.mat' file you created you created in the previous steps. 
      2. In the 'Select contrasts' window, press 'Define new contrast…', next set the type to 'F-contrast', give the contrast the name 'motor>other' and in the contrast window type '1' (this is the same as 1 0 0, SPM pads the unnamed cells), This informs SPM that we want to look for voxel's whose activity is modulated during the blocks. Press done to return to the Select contrasts' window.
      3. Select the 'motor>other' contrast and press 'Done'.
        stats
      4. Press 'No' for 'Mask with other contrast. (This function allows us to only look for regions that are also active in other tasks, or for regions that are active in this comparison but were not active in other  comparisons).
      5. Press 'enter' when you are asked whether 'motor>other' is a good title. 
      6. For 'p-value adjustment' choose 'FWE' - this selects the very conservative 'Family wise error' correction for multiple comparisons: this has very low statistical power but we can be confident in values that survive this threshold. FDR is more liberal, and is gaining popularity (False Discovery Rate).
      7. For the p value, choose 0.05. The FWE correction is very severe, so using p < 0.01 would be very conservative indeed and would have verylittle statistical power.
        results
      8. For extent threshold, choose 0. If we were only interested in large clusters of activity, we could set a value like 16.
      9. A glass brain should appear with activity on it. 
      10. You can drag the red '<' to look at different brain regions, the coordinates and value of this location are shown at the bottom of the design window. 
      11. You can right click on the glass brain to go to local/global maxima.
      12. Press the 'volume' or 'cluster' button to see a statistics table with p-values.
      13. Right click on the table and select 'Print text table': the table will appear in the Matlab command window where you can copy/paste the data.
      14. Press the 'Plot' button. Choose 'Fitted responses', with the contrast 'motor>other', use the 'predicted' values and plot against 'scan or time'. You can then see how the voxel currently selected in the glass brain behaved. (Note you can only see these plots for voxels with significant values, if your '<' mark is near a region of the brain that is not statistically significant, spm2 will move the marker to the nearest significant voxel).
      15. Click on the 'overlays' pulldown menu. Choose 'sections' and then select the image 'wmeanfds001.img'. You will then see the statistics overlaid onto the mean fMRI data for this participant.
      16. Press the 'Save' button to export the dataset (in this case thresholded to only show voxels that surve a FEW-corrected p< 0.05). For an output name, write 'fds_FWE'. This will generate an image that you can show on a rendered brain with MRIcro.

20 February 2006:  Chris Rorden

logo