Auditory fMRI data ¶
This experiment was conducted by Geraint Rees under the direction of Karl Friston and the FIL methods group. The purpose was to explore equipment and techniques in the early days of our fMRI experience. As such, it has not been formally written up, and is freely available for personal education and evaluation purposes.
This data set was the first ever collected and analysed in the Functional Imaging Laboratory (FIL) and is known locally as the mother of all experiments (MoAE).
This data set comprises whole brain BOLD/EPI images acquired on a modified 2T Siemens MAGNETOM Vision system. Each acquisition consisted of 64 contiguous slices (64\(\times\)64\(\times\)64 3\(\times\)3\(\times\)3 mm\(^3\) voxels). Acquisition took 6.05s, with the scan to scan repeat time (TR) set arbitrarily to 7s.
96 acquisitions were made (TR=7s) from a single subject, in blocks of 6,
giving 16 42s blocks. The condition for successive blocks alternated
between rest and auditory stimulation, starting with rest. Auditory
stimulation was bi-syllabic words presented binaurally at a rate of 60
per minute. The functional data starts at acquisition 4, image
fM00223_004.{hdr,img}
, and are stored in folder fM00223
. Due to T1
effects it is advisable to discard the first few scans (there were no
“dummy” lead-in scans). A structural image was also acquired:
sM00223_002.{hdr,img}
, stored in folder sM00223
. These images are
stored in Analyze format (now superseded by the NIfTI format, but SPM
reads natively both formats and always saves images as NIfTI) and are
available from the SPM site 1.
To analyse the data, first create a new directory DIR
, eg.
C:
\(\backslash\)data
\(\backslash\)auditory
, in which to place the
results of your analysis. Then create 3 subdirectories (i) dummy
, (ii)
jobs
and (iii) classical
. As the analysis proceeds these directories
will be filled with dummy scans, job-specification files, design
matrices and models estimated using classical inference.
Start up MATLAB, enter your jobs
directory and type spm fmri
at the
MATLAB prompt. SPM will then open in fMRI mode with three windows (see
Figure 1.1): (1) the top-left or “Menu”
window, (2) the bottom-left or “Interactive” window and (3) the
right-hand or “Graphics” window. Analysis then takes place in three
major stages (i) spatial pre-processing, (ii) model specification,
review and estimation and (iii) inference. These stages organise the
buttons in SPM’s Menu window.

Preamble (dummy scans)¶
To avoid T1 effects in the initial scans of an fMRI time series we
recommend discarding the first few scans. To make this example simple,
we’ll discard the first complete cycle (12 scans, 04-15
), leaving 84
scans, image files 16-99
. This is best done by moving these files to a
different directory, dummy
, that we created earlier.
Spatial pre-processing¶
Realignment¶
Under the spatial pre-processing section of the SPM Menu window select Realign (Est & Res) from the Realign pulldown menu. This will call up a realignment job specification in the batch editor. Then
-
Highlight “Data”, select “New Session”, then highlight the newly created “Session” option.
-
Press “Select Files” and use the SPM file selector to choose all of the functional images eg. (“
fM000*.img
”). There should be 84 files. -
Press “Resliced images” in the “Reslice Options” and select “Mean Image Only”.
-
Save the job file as eg.
DIR
\(\backslash\)jobs
\(\backslash\)realign.mat
. -
Press the
RUN
button in the batch editor (green arrow).
This will run the realign job which will estimate the 6 parameter (rigid
body) spatial transformation that will align the times series of images
and will modify the header of the input images (*.hdr
), such that they
reflect the relative orientation of the data after correction for
movement artefacts. SPM will then plot the estimated time series of
translations and rotations shown in
Figure 1.2. These data are also saved to a
file eg. rp_fM00223_016.txt
, so that these variables can be later used
as regressors when fitting GLMs. This allows movements effects to be
discounted when looking for brain activations.
SPM will also create a mean image eg. meanfM00223_016.img
which will
be used in the next step of spatial processing - coregistration.

Coregistration¶
Select Coregister (Estimate) from the Coregister pulldown. This will call up the specification of a coregistration job in the batch editor.
-
Highlight “Reference Image” and then select the mean fMRI scan from realignment eg.
meanfM00223_016.img
. -
Highlight “Source Image” and then select the structural image eg.
sM00223_002.img
. -
Press the Save button and save the job as
DIR
\(\backslash\)jobs
\(\backslash\)coregister.mat
. -
Then press the
RUN
button.
SPM will then implement a coregistration between the structural and
functional data that maximises the mutual information. The image in
figure 1.3 should then appear in the Graphics
window. SPM will have changed the header of the source file which in
this case is the structural image sM00223_002.hdr
.

The Check Reg facility is useful here, to
check the results of coregistration. Press the
Check Reg button in the lower section of
the Menu window and then select the “Reference” and “Source” Images
specified above ie meanfM00223_016.img
and sM00223_002.img
. SPM will
then produce an image like that shown in
Figure 1.4 in the Graphics window. You can
then use your mouse to navigate these images to confirm that there is an
anatomical correspondence.

Segmentation¶
Press the Segment button. This will call
up the specification of a segmentation job in the batch editor.
Highlight the “Volumes” field and then select the subject’s registered
anatomical image eg. sM00223_002.img
. Highlight “Save Bias Corrected”
and select “Save Bias Corrected”. Highlight “Deformation Fields” t͡he
bottom of the list and select “Forward”. Save the job file as
segment.mat
and then press RUN
. SPM will segment the structural
image using the default tissue probability maps as priors (Ashburner and
Friston 2005).
SPM will create gray and white matter images and bias-field corrected
structural image. These can be viewed using the
CheckReg facility as described in the
previous section. Figure 1.5 shows the gray matter image,
c1sM0023_002.nii
along with the original structural.
Figure 1.6 shows the structural and
bias-corrected image, msM0023_002.nii
.


SPM will also write a deformation field, file y_sM00223_002.nii
in the
original structural directory. It contains 3 volumes to encode the x, y
and z coordinates. Given that the structural and functional data are in
alignment, this can be used to spatially normalise the functional data.
Normalise¶
Select Normalise (Write) from the Normalise pulldown menu. This will call up the specification of a normalise job in the batch editor.
-
Highlight “Data”, select New “Subject”,
-
Highlight “Deformation Field” and select the
y_sM00223_002.nii
file that you created in the previous section, -
Highlight “Images to Write” and select all of the realigned functional images
fM000*.img
. You can right click over the listed files, choose “Select all” and press “Done”. -
In the “Writing Options”, change “Voxel sizes” from [2 2 2] to [3 3 3]. This step is not strictly necessary: it will write images out at a resolution closer to that at which they were acquired.
-
Press “Save”, save the job as
normalise_functional.mat
and then press theRUN
button.
SPM will then write spatially normalised files to the functional data
directory. These files have the prefix w
.
If you wish to superimpose a subject’s functional activations on their own anatomy2 you will also need to apply the spatial normalisation parameters to their (bias-corrected) anatomical image. To do this
-
Select Normalise (Write), highlight “Data”, select “New Subject”.
-
Highlight “Deformation Field”, select the
y_sM00223_002.nii
file that you created in the previous section, press “Done”. -
Highlight “Images to Write”, select the bias-corrected structural eg.
msM00223_002.nii
, press “Done”. -
Open “Writing Options”, select voxel sizes and change the default [2 2 2] to [1 1 3] which corresponds to the original resolution of the images.
-
Save the job as
normalise_structural.mat
and press theRUN
button.
Smoothing¶
Press the Smooth button. This will call up the specification of a smooth job in the batch editor.
-
Select “Images to Smooth” and then select the spatially normalised files created in the last section eg.
wf*.img
. This can be done efficiently by changing the filter in the SPM file selector to^wf.*
. SPM will then only list those files beginning with letterswf
ie. those that have been spatially normalised. -
Highlight “FWHM” and change [8 8 8] to [6 6 6]. This will smooth the data by 6mm in each direction.
-
Save the job as
smooth.mat
and press theRun
button.
An example of functional image and its smoothed version is displayed on Figure 1.7.

Model specification, review and estimation¶
Press the “Specify 1st-level” button. This will call up the specification of an fMRI specification job in the batch editor. Then
-
Open the “Timing parameters” option.
-
Highlight “Units for design” and select “Scans”.
-
Highlight “Interscan interval” and enter 7. That’s the TR in seconds.
-
Highlight “Data and Design” and select “New Subject/Session”. Then open the newly created “Subject/Session” option.
-
Highlight “Scans” and use SPM’s file selector to choose the 84 smoothed, normalised functional images ie
swfM00223_016.img
toswfM00223_099.img
. These can be selected easily using the^sw.*’
filter, and select all. Then press “Done”. -
Highlight “Condition” and select “New condition”.
-
Open the newly created “Condition” option. Highlight “Name” and enter “listening”. Highlight “Onsets” and enter “6:12:84”. Highlight “Durations” and enter “6”.
-
Highlight “Directory” and select the
DIR/classical
directory you created earlier. -
Save the job as
specify.mat
and press theRun
button.
SPM will then write an SPM.mat
file to the DIR/classical
directory.
It will also plot the design matrix, as shown in
Figure 1.8.

Design matrix
: The filenames on the
right-hand side of the design matrix indicate the scan associated with
each row.At this stage it is advisable to check your model specification using SPM’s review facility which is accessed via the “Review” button. This brings up a “design” tab on the interactive window clicking on which produces a pulldown menu. If you select the first item “Design Matrix” SPM will produce the image shown in Figure 1.8. If you select “Explore” then “Session 1” then “listening”, SPM will produce the plots shown in Figure 1.9.

Exploring the design matrix in Figure
1.8: This shows the time series of the
"listening" regressor (top left), a frequency domain plot of the
"listening" regressor (top right) and the basis function used to convert
assumed neuronal activity into hemodynamic activity. In this model we
used the default option - the canonical basis function. The frequency
domain plot shows that the frequency content of the "listening"
regressor is above the set frequencies that are removed by the High Pass
Filter (HPF) (these are shown in gray - in this model we accepted the
default HPF cut-off of 128s or 0.008Hz). If you select the second item on the “Design” tab, “Design Orthogonality”, SPM will produce the plot shown in Figure 1.10. Columns \(x_1\) and \(x_2\) are orthogonal if the inner product \(x_1^T x_2=0\). The inner product can also be written \(x_1^T x_2 = |x_1||x_2| cos \theta\) where \(|x|\) denotes the length of \(x\) and \(\theta\) is the angle between the two vectors. So, the vectors will be orthogonal if \(cos \theta=0\). The upper-diagonal elements in the matrix at the bottom of figure 1.10 plot \(cos\theta\) for each pair of columns in the design matrix. Here we have a single entry. A degree of non-orthogonality or collinearity is indicated by the gray shading.

Design Orthogonality
: The description above
the first column in the design matrix Sn(1)Listening*bf(1)
means that this column refers to the first session of data (in this
analysis there is only 1 session), the name of this condition/trial is
‘listening’ and the trial information has been convolved with the first
basis function (the canonical hemodynamic response). The constant
regressor for session 1 is referred to as Sn(1)Constant.
The orthogonality matrix at the bottom indicates a degree of
collinearity between regressors. Estimate¶
Press the Estimate button. This will call up the specification of an fMRI estimation job in the batch editor. Then
-
Highlight the “Select SPM.mat” option and then choose the
SPM.mat
file saved in theclassical
subdirectory. -
Save the job as
estimate.mat
and press theRun
button.
SPM will write a number of files into the selected directory including
an SPM.mat
file.
Inference¶
After estimation:
-
Press “Results”.
-
Select the
SPM.mat
file created in the last section.

This will invoke the contrast manager.
Contrast manager¶
The contrast manager displays the design matrix (surfable) in the right panel and lists specified contrasts in the left panel. Either “t-contrast” or “F-contrast” can be selected. To examine statistical results for condition effects
- Select “Define new contrast”
One sided main effects for the listening condition (i.e., a one-sided t-test) can be specified (in this example) as “1” (listening \(>\) rest) and “-1” (rest \(>\) listening). SPM will accept estimable contrasts only. Accepted contrasts are displayed at the bottom of the contrast manager window in green, incorrect ones are displayed in red. To view a contrast
-
Select the contrast name e.g., “listening \(>\) rest”.
-
Press “Done”.
Masking¶
You will then be prompted with
-
Apply masking ? [none/contrast/image].
-
“Specify none”.
Masking implies selecting voxels specified by other contrasts. If “yes”, SPM will prompt for (one or more) masking contrasts, the significance level of the mask (default p = 0.05 uncorrected), and will ask whether an inclusive or exclusive mask should be used. Exclusive will remove all voxels which reach the default level of significance in the masking contrast, inclusive will remove all voxels which do not reach the default level of significance in the masking contrast. Masking does not affect p-values of the “target” contrast, it only includes or excludes voxels.
Thresholds¶
You will then be prompted with
-
p value adjustment to control: [FWE/none].
-
Select “FWE”.
-
p value(family-wise error).
-
Accept the default value, 0.05.
A Family Wise Error (FWE) is a false positive anywhere in the SPM. Now, imagine repeating your experiment many times and producing SPMs. The proportion of SPMs containing FWEs is the FWE rate. A value of 0.05 implies that on average 1 in 20 SPMs contains one or more false positives somewhere in the image.
If you choose the “none” option above this corresponds to making statistical inferences at the “voxel level”. These use “uncorrected” p values, whereas FWE thresholds are said to use “corrected” p-values. SPM’s default uncorrected p-value is p=0.001. This means that the probability of a false positive at each voxel is 0.001. So if, you have 50,000 voxels you can expect \(50,000 \times 0.001 = 50\) false positives in each SPM.
You will then be prompted with
-
Extent Threshold {voxels} [0].
-
Accept the default value, “0”.
Entering a value \(k\) here will produce SPMs with clusters containing at least \(k\) voxels. SPM will then produce the SPM shown in Figure 1.11.

Files¶
A number of files are written to the working directory at this time.
Images containing weighted parameter estimates are saved as
con_0001.nii
, con_0002.nii
, etc. in the working directory. Images of
T-statistics are saved as spmT_0001.nii
, spmT_0002.nii
etc., also in
the working directory.
Maximum Intensity Projections¶
SPM displays a Maximum Intensity Projection (MIP) of the statistical map in the Graphics window. The MIP is projected on a glass brain in three orthogonal planes. The MIP is surfable: right-clicking in the MIP will activate a pulldown menu, left-clicking on the red cursor will allow it to be dragged to a new position.

Design matrix¶
SPM also displays the design matrix with the selected contrast. The design matrix is also surfable: right-clicking will show parameter names, left-clicking will show design matrix values for each scan.
In the SPM Interactive window (lower left panel) a button box appears with various options for displaying statistical results (p-values panel) and creating plots/overlays (visualisation panel). Clicking “Design” (upper left) will activate a pulldown menu as in the “Explore design” option.
Statistical tables¶
To get a summary of local maxima, press the “whole brain” button in the p-values section of the Interactive window. This will list all clusters above the chosen level of significance as well as separate (\(>\)8mm apart) maxima within a cluster, with details of significance thresholds and search volume underneath, as shown in Figure 1.12

The columns in volume table show, from right to left:
-
x, y, z (mm): coordinates in MNI space for each maximum.
-
peak-level: the chance (p) of finding (under the null hypothesis) a peak with this or a greater height (T- or Z-statistic), corrected (FWE or FDR)/ uncorrected for search volume.
-
cluster-level: the chance (p) of finding a cluster with this many (k) or a greater number of voxels, corrected (FWE or FDR)/ uncorrected for search volume.
-
set-level: the chance (p) of finding this (c) or a greater number of clusters in the search volume.
It is also worth noting that:
-
The table is surfable: clicking a row of cluster coordinates will move the pointer in the MIP to that cluster, clicking other numbers will display the exact value in the MATLAB window (e.g. 0.000 = 6.1971e-07).
-
To inspect a specific cluster (e.g., in this example data set, the right auditory cortex), either move the cursor in the MIP (by left-clicking and dragging the cursor, or right-clicking the MIP background which will activate a pulldown menu).
-
Alternatively, click the cluster coordinates in the volume table, or type the coordinates in the coordinates section of the Interactive window.
It is also possible to produce tables of statistical information for a single cluster of interest rather than for the whole volume. Firstly, select the relevant cluster in the MIP and then press the “current cluster” button in the p-values section of the Interactive window. This will show coordinates and voxel-level statistics for local maxima (\(>\)4mm apart) in the selected cluster. This table is also surfable.
Plotting responses at a voxel¶
A voxel can be chosen with coordinates corresponding to those in the Interactive window. The responses at this voxel can then be plotted using the “Plot” button in the visualisation section of the Interactive window. This will provide you with five further options:
-
Contrast estimates and 90% CI: SPM will prompt for a specific contrast (e.g., listening\(>\)rest). The plot will show effect size and 90% confidence intervals. See eg. Figure 1.13.
-
Fitted responses: Plots adjusted data and fitted response across session/subject. SPM will prompt for a specific contrast and provides the option to choose different ordinates (“an explanatory variable”, “scan or time”, or “user specified”). If “scan or time”, the plot will show adjusted or fitted data with errors added as shown in Figure 1.14.
-
Event-related responses: Plots adjusted data and fitted response across peri-stimulus time.
-
Parametric responses.
-
Volterra kernels.


For plotting event-related responses SPM provides three options
-
Fitted response and PSTH (peri-stimulus time histogram): plots mean regressor(s) (ie. averaged over session) and mean signal +/- SE for each peri-stimulus time bin.
-
Fitted response and 90% CI: plots mean regressor(s) along with a 90% confidence interval.
-
Fitted response and adjusted data: plots regressor(s) and individual data (note that in this example the data are shown in columns due to the fixed TR/ISI relationship).
Its worth noting that
-
The values for the fitted response across session/subject for the selected plot can be displayed and accessed in the window by typing “Y”. Typing “y” will display the adjusted data.
-
“Adjusted” data = adjusted for confounds (e.g., global flow) and high- and low pass filtering.
Overlays¶
The visualisation section of the Interactive window also provides an overlay facility for anatomical visualisation of clusters of activation. Pressing “Overlays” will activate a pulldown menu with several options including:
-
Slices: overlay on three adjacent (2mm) transaxial slices. SPM will prompt for an image for rendering. This could be a canonical image (see
spm_templates.man
) or an individual T1/mean EPI image for single-subject analyses. Beware that the left-right convention in the display of that option will depend on how your data are actually stored on disk. -
Sections: overlay on three intersecting (sagittal, coronal, axial) slices. These renderings are surfable: clicking the images will move the crosshair.
-
Render: overlay on a volume rendered brain.
Thresholded SPMs can be saved as NIfTI image files in the working
directory by using the “Save” button in the Interactive window. In
Figures 1.15,
1.16 and
1.17 the ‘listening \(>\) rest’ activation
has been superimposed on the spatially normalised, bias-corrected
anatomical image wmsM00223_002.nii
created earlier.


For the “Render” option we first created a rendering for this subject. This was implemented by
-
“Normalise (Write)” the two images
c1sM00223_002.nii
andc2sM00223_002.nii
using the “Deformation Field”y_sM00223_002.nii
and a voxel size of [1 1 1]. -
Selecting “Extract Surface” from the “Render” pulldown menu.
-
Selecting the gray and white matter images
wc1sM00223_002.nii
andwc2sM00223_002.nii
created in the first step. -
Saving the results using the default options (Rendering and Surface).
SPM plots the rendered anatomical image in the graphics window and saves
it as render_wc1sM00223_002.mat
. The surface image is saved as
surf_wc1sM00223_002.mat
.

It is also possible to project and display the results on a surface
mesh, we are going to use here one of the canonical mesh distributed
with SPM (in MNI space). Press “Overlays” and choose “Render”, then go
in the canonical
folder of your SPM installation and select file
cortex_20484.surf.gii
(this is a surface mesh stored using the GIfTI
format) and you will obtain a figure similar to
1.18.
-
Auditory fMRI dataset: http://www.fil.ion.ucl.ac.uk/spm/data/auditory/ ↩
-
Beginners may wish to skip this step, and instead just superimpose functional activations on an “average structural image”. ↩