Voxel Based Morphometry Analysis of DTI Data Using the General Linear Model

Written by Liberty Hamilton, June 27, 2007. Email Dr. Katherine Narr if you have any questions. For more information, see the protocols page.

To run voxel-based analyses on DTI data using SPM5, follow the instructions below:

Starting up SPM5

  1. Start up matlab by typing matlab at the command prompt. If matlab and spm are installed on your local computer, you may run spm locally. Otherwise, you will have to run on one of the cerebro or cerebellum nodes.
  2. Type spm pet in the matlab terminal to start up SPM5 in the PET/SPECT mode (although we're not looking at PET data, we are using 4D data, so this option is most appropriate).

Some Tips on Clicking

  • Although it may seem silly, there is a lot of clicking involved in SPM, and it can become confusing to figure out when to double-click and when to single-click.
  • In general, when you see a plus-sign (+) to the left of a menu item, it means that that menu item can be expanded to show more submenu items. Double-click on (+) items to get to the submenu items, and double click on expanded items (with a minus-sign (–) to the left of them) to collapse.
  • Single clicks will select files and menu items without expanding them.

Smoothing your images


  1. Click the "Smooth" button. Select your FA (or mean diffusivity, etc.) images for all of the subjects by clicking on "Smooth", and then clicking on "Images to Smooth<-X". Then click on "Specify Files" and select the FA images in the pop-up dialog box. Note that to select things in SPM, you must move through directories by clicking on the names in the left side of the popup window, and you may select the files by clicking to the right. To de-select an item, simply click on the item in the list of files at the bottom. Click "Done" to finish.
  2. Select smoothing width by clicking "FWHM", then "Specify Text", and type: 8x8x8.
  3. Leave "Data Type" as SAME (default).
  4. Click the "Run" button to start the smoothing. This can take quite a while (30 minutes-1 hour).

Setting Up the Design Matrix

Specifying factors and scans for analysis

  1. When your smoothing is done, you may begin setting up the design matrix.
  2. To run an analysis using the General Linear Model (GLM), click the Basic models button. Double-click on "Factorial Design Specification", then click once on Design and select Choose "Full-factorial" to the right.
    basic models
  3. Double-click on "Full factorial <-X" to specify the factors in the model and your corresponding scans.
  4. Add new factors by clicking on "Factors <-X", then click once on "New Factor" in the right window.
  5. Double-click on "Factor" in the left window, and the submenus should appear for "Name" and "Levels". If you wish to look at the effect of schizophrenia, for example, then you will create a factor called "diagnosis", so click on "Name", then click once on "Specify Text" to the right, and enter "diagnosis". Hit enter to complete.
  6. For the "Levels" submenu, specify the number of levels within the factor--for diagnosis, there are two levels, control and patient. Enter 2.
  7. Leave Independence, Variance, Grand mean scaling, and ANCOVA as is.
  8. You will enter your FA images in the "Scans" submenu of "Specify Cells". First double click on "Specify Cells" and choose New "Cell" twice (one will be controls, one will be patients).
  9. For the first Cell entry, double-click on the first "Cell <-X". Then click on "Levels" and enter 1 (for controls). Enter 2 (for patients) in the second Cell under "Levels"".
  10. Specify the smoothed scans for the controls in the first cell by clicking on "Scans <-X", and then clicking on "Specify Files".

Entering Covariates

  1. To enter covariates, double-click on "Covariates", then click New "Covariate".
  2. Double-click on "Covariate <-X", then click "Name". Let's say we're covarying for sex, so type "sex" after clicking "Specify Text".
  3. Our covariate values will be listed under "Vector <-X", and must be in the order in which we entered our scans. Since in this example, we specified all of the controls first in Cell 1, and then all of the patients in Cell 2, we must use the exact same ordering (ordering by subject ID is usually the easiest way to do this).
  4. To enter the covariate values, you can either paste columns from your spreadsheet (be sure that they are in the same order as your scans! First controls, then patients, for example), or use awk to grab columns from a tab-delimited text file which can then be pasted into SPM. You can paste text as columns, and it will show up as a 1xN matrix, but note that you cannot enter covariates separated by carriage-returns if you are entering them one-by-one. If you choose to enter the covariates manually, enter the numbers separated by spaces.
  5. Your matrix should look something like this: (you do not have to enter the square brackets, those will show up automatically after you enter your values)

    covariate vector
  6. Note that in the image above, the covariates include only 1s and 0s as we are looking at sex. The matrix could look like [24 25 30 23 50 42] for age.

Mini "Awk" Tutorial

awk is a command-line pattern scanning and processing language which can be useful for many things, including, in our case, extracting data from a tab-delimited text file.

Let's say we have a tab-delimited text file with covariate data for our subjects that looks something like this:

Subj    Diag    Age    Sex    CSF_vol
10230    0    22    0    159930
12311    0    25    1    122344
12125    1    23    0    124232
12111    1    24    1    232353

Now, if we are using a UNIX computer without a nice spreadsheet-type program from which we can paste columns, how can we extract columns from this data without creating new textfiles with only the columns we wish to read? Use awk!

If we wanted to print only the first column of the textfile (let's name it subjs.txt), we could do the following on the command line:

% awk '{print $1}' subjs.txt

The result would then be:


Then we could select this text (excluding the first line, Subj) and paste straight into SPM, or wherever we desired.

Similarly, if we wanted only the column for "CSF_vol", we could enter the following to print the 5th column:

% awk '{print $5}' subjs.txt

It is possible to do more complex scripting in awk (see the Wikipedia page), but it's probably easier to use shell scripting or perl.

Thresholding and Threshold Masking

  1. Select "Absolute" under "Masking". Enter a value of 0.2 for FA, or around 0.00001 for MD. Alternatively, you can select smoothed white matter masks under "Explicit Mask".
  2. If absolute masking is chosen, only voxels at which all images exceed the threshold will be included.

Setting an Output Directory

  1. Select "Directory <-X." Select the directory where you would like the output files to go. This must be a directory for which you have write permission.
  2. Select "Run". A window will pop up showing the design matrix for your sample.


  1. When this is complete, click the "Estimate" button. Choose the spm.mat file in the directory you just chose for output. Then click the "Results" button, and choose this spm.mat file again.

  2. Estimation often takes a long time, so you may want to do something else while you wait for estimation to complete.

Viewing Results

  1. When Estimation is complete (you will see "Done" in the lower left window), you can run T- and F-contrasts to look at your data. Click the "Results" button to start, and select the SPM.mat file that was created in the Design Matrix step.

  2. Enter t-contrasts in the SPM contrast manager. First click the "t-contrasts" radio button, then click the button "Define new contrast...".
  3. Enter a name for the contrast (controls>patients, for example), and then type the contrast weights vector. Since controls are our first group, controls>patients would be [1 -1]. For patients>controls, you would enter [-1 1]. You can see your contrasts in the Design matrix image to the right. In the image below, you can see the first two columns represent patients and controls, and the following three columns are covariates.

    define contrast
  4. Click OK.
  5. Select "no" on masking with other contrasts.
  6. Select FDR and enter a value of 0.05. (Or select none, if your effect doesn't survive FDR). FWE (Family-wise Error) is the most conservative of the correction methods.
  7. Use the "volume" and "overlays" options to investigate results.

Creating Results Figures

When you've mastered the basics here, be sure to check out the results figures protocol, which explains how to change the color bar, how to interpret the information in the Graphics window, how to overlay significant results on 3D renders and orthogonal section views, and more.

Output Files and What They're For

  • spmT_...hdr/img: Images of T-statistics.
  • Mask.img: image indicating which voxels were included in the analysis.
  • Con_0001, etc.: images of weighted parameter estimates.
  • RPV.img: estimated resels (resolution elements) per voxel. This describes the actual spatial image resolution of the volume.