spm12 starters’ guide - ernohermans.com · different from the old img/hdr images that were used...

43
SPM12 STARTERS’ GUIDE (c) Erno Hermans

Upload: others

Post on 31-Aug-2019

12 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 STARTERS’ GUIDE

(c) Erno Hermans

Page 2: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 1

General Information

File Type and File SelectionThe NIfTI-1 formatSPM12 uses a standard 3D (or 4D in some cases) image format called NIfTI-1.1. Each NIfTI format image consists of one file with an extension “.nii”. The “.nii” file contains:- A bitmap containing all the data in the image (i.e., grey values of each voxel)- A transformation matrix placing the bitmap in a 3D coordinate system (a so-called affine transformation: rotation, translation, zoom, and/or shear).A time series of, e.g., 300 scans thus consists of 300 .nii files. When you manipu-late scans using SPM, mostly the only thing that is changed in the NIfTI file is the matrix containing the affine transformation. It is important to understand that the actual data, the bitmap, is not changed until one chooses to “reslice” in whatever stage of data processing. When an image is resliced (after realignment, or when “written normalized”), the affine transformation matrix in the NIfTI file is reset, a new bitmap is calculated, and a letter is prepended to the old filename (e.g., OLDFILE.nii > rOLDFILE.nii) so that the old file is never overwritten.

Note: SPM12 can also use header (“.hdr”) and and image (“.img”) files like previous (before SPM5) versions. When made in SPM12, these are also NIfTI compliant and contain essentially the same information as “.nii” images. These files are therefore different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not load properly in SPM12, so do not switch SPM versions within projects.

See http://nifti.nimh.nih.gov/ for more information on NIfTI-1.1.

SPM12 (Statistical Parametric Mapping) was developed at the Functional Imaging Laboratory at University College London, by a team led by Karl Friston. It is a free and open-source package that runs within the Matlab environment.This beginner’s guide was first written for SPM99, for students in the MSc program “Neuroscience and Cognition” at Utrecht University. The second edition was updat-ed for SPM2, the third for SPM5, the fourth edition for SPM8, and the fifth for SPM12 (with help from Bas Neggers and Mitzy Kennis of Utrecht University / UMC).This guide is by no means comprehensive as only the most important functions of SPM12 are described that are necessary to complete the course. Although things have been simplified to a certain extent, this guide requires some background knowledge in order to properly understand spatial pre-processing, and especially

statistics.Among the most important topics that have been left undescribed in this guide are more advanced or newer features such as DARTEL, Bayesian inference, dynamic causal modeling, and M/EEG functions. The best starting point for more infor-mation is the SPM website at www.fil.ion.ucl.ac.uk/spm.

Page 3: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 2

Browsing and selecting files:All SPM12 functions use the same file browse dialog box shown here. In the left panel, you can select a directory to go to. The right panel will show the contents of a directory. Clicking once is enough to switch to a different directory. As is com-mon in Unix-like environments, “..” stands for “one level up”. Scans can be selected by clicking them one by one, which will make their names move to the box at the bottom. Instead of clicking them all manu-ally, you can right-click in the right panel

and subsequently click “select all”. Often, however, you will not want to select every file, but only a large subset of files within a directory. In order to do this, you can specify a filter (next to the button “Filt”). This filter works different from most com-mon file filters. Here are the most important uses:- “.*” : List all contents of a directory (but restricted to the type of image that your SPM function requires).- “funx” : list all files that contain “funx” in the filename.- “^funx” : list all files with names that start with “funx”.After selecting images, you can click the “Ed” button to edit the list of selected files. Right-clicking in this window will take you back.

You can also click the question mark button for a more thorough explanation of the file browse dialog.

Page 4: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 3

SPM12 main window

Spatial Pre-processing functionsPage 9

Statistical functionsPage 21

VisualizationPage 4

Page 5: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 4

Visualization

The visualization tools Display and Check Reg are used to:- Look at scans- Manually manipulate scans to set starting points for spatial preprocessing- Check all spatial pre-processing steps.

DisplayThe display function allows you to view and manipulate a single image.

Use the dialog to browse to your files and select one (see page 2 for explanation). When you select a “.nii” file it will appear at the bottom of the dialog box. Clicking this file again will deselect it.You don’t have to double click to enter directories. Clicking “..” takes you one directory level up.

Click “Done” to continue.

Page 6: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 5

Page 7: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 6

The most important buttons in the display window are:

Crosshair position: the position of the blue line in the scans in either mm or voxels.

Right, forward and up: Move the scan in three directions. These directions only make sense when your scan is in the same orientation as MNI standard space.

Pitch, roll, yaw: rotate the scan around the X, Y, or Z axis respectively.

Reorient images: Click here to save changes to the scan you are manipulating and to apply the same changes to other scans. NOTE: here you have to select the image you are working on again in order to save changes (see below).

On the right you can see some useful information about your scan: voxel size, ori-gin, etc.

Except for just viewing images, the display function is used to manually match your images before starting automatic spatial preprocessing. The reason to do this is that if your scans do not approximately match, the algorithms that are used to make exact matches can get stuck in a local minimum, resulting in scans that do not match at all. It is advisable to put all your scans approximately into standard MNI space and orientation before doing anything else, even when you are not going to normalize them. Some scanners or conversion tools may already take care of this, but it is wise to check anyway. In order to do this, use display to view a canonical T1 image (e.g. located in the “canonical” subdirectory of the SPM12 directory, called “single_subj_T1.nii”) and set the “mm” field under the “Crosshair position” to “0 0 0” to move the crosshair to the origin of the coordinate system. Note the orientation of the scan and its origin (the anterior commissure). Then display your own scans, set the crosshair to “0 0 0” again, and use the right, forward, up, pitch, roll, and yaw settings to manipulate your scan until you are satisfied with the result (note: rota-tions are given in radials; 180 degrees is 3.1416 radials). Do not forget to leave the crosshair at mm 0,0,0 to be able to see where your origin is.

When you made adjustments to your scan, you can apply these changes to any scan you like. Any scan that is to be reoriented has to be entered here, including the one you worked on. You can add files by clicking on them. Lists of files can be selected by specifying a filter (e.g., “^funx”) to show only the files you want, and subsequently adding all of them by right-click-ing in the box containing the names (“select all”). Lists of selected files can also be edited by clicking “Ed”.

Page 8: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 7

Check RegThe Check Registration function can be used to check if two or more scans are matched onto each other. This check should be performed after each step of spatial pre-processing.

Select all the files you want to compare before pressing “done”. (see page 2 for explanation)

Click in the scans at different posi-tions to see if all locations in the scans match.

Here you see an MNI space canonical (upper left), an individual T1 anatomical image (upper right), and an example functional image (bottom left).

Note that the individual T1 and functional scans are in the same orientation as the MNI space canonical. However, the origins (where blue lines cross) do not match. When at least the orienta-tions match, SPM will mostly be able to align the images using automated functions (see next part), but be sure to check.

Page 9: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 8

MRIcronMRIcron is another free program. It is not part of SPM and does not run within Matlab like SPM. MRIcron is oriented towards visualization of statistical results and is more flexible for this purpose than SPM. The two can be used alongside. For download and manual, see http://www.cabiatl.com/mricro/mricron/index.html (note: do not use the older “MRIcro” in combination with SPM12 because it does not han-dle the NIFTI file format properly). This is an example of an individual T1 in mricron:

To visualize your group-statistics results using MRIcron, load an anatomical back-ground image from the “open templates” submenu in the “file” drop-down menu. Next, pick “add” from the “overlay” menu to load your statistical results (e.g., files called “spmT_000n.img”).

The resulting image will look strange until you set the threshold properly. You can do this by altering the values in the middle two boxes (here set to 3.68 and 13). This means that all statistical (T) values above 3.68 will be plotted onto the image, and that value of 8 or higher will yield the brightest color. Thus, in MRIcron you have to set threshold levels to the appropriate values manually (e.g., choose the ones that SPM has determined for you).

Page 10: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 9

Spatial pre-processing functions

The goals of spatial pre-processing are:

1. To match all scans of an individual subject.2. To match scans of all subjects into standard space.

The most important tools are: realign (and unwarp), slice timing correction, coregister, normalize, and smooth. These are described below.

RealignRealign is the most basic function to match images. It uses a rigid body transforma-tion to manipulate the scans. This means that it allows only translations (moving the image in X, Y, or Z direction) and rotations (over the X, Y, and Z axis). By trial and error it tries to find the manipulation that minimizes the difference between two scans. The cost function that is minimized is the sum of squared differences between the two scans. As a consequence, it can only be used within modalities, i.e., on scans that have been acquired with the same pulse sequence. It is mostly used to correct for motion of the subject during the functional scans (hence the name realign). Realignment results in changes to the (affine) transformation that is incorporated into your “.nii” files. You can also “reslice” these images into new files containing altered (interpolated) bitmaps.

In the SPM12 main window, under Realign, use the drop down menu to select:Estimate: determine parameters for rigid body transformation and incorporate these changes into the “.nii” file.Reslice: create new bitmap image files (an r will be added at the beginning of the filename).Estimate and reslice: do both in one go. You are now taken to SPM12’s batch manager.

Reslicing after every transformation is not always necessary and can reduce quality. However, reslicing is necessary before starting statistical analysis.

Translations Rotations

Page 11: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 10

Suppose you chose estimate and reslice. You can now see that a job called “Realign: Estimate & Reslice” is shown in the module list in the left panel. Note that you can add more modules to create a batch using the menu bar (mainly under "SPM").

One thing needs to be specified, namely, the images that need to be realigned. Note that ini-tially, “<-X” is shown to the right of the item “Data”. This means that fields within this item still need to be completed. This is not neces-sary for the other options, which contain set-tings that are taken from the defaults, but may be altered here. For instance, you can change the letter that is prepended to your filenames after reslicing under "filename prefix".

When you double-click “Data”, you get the option to add sessions to your “Data” item. This can be used when multiple time-series of a single subject were scanned. Subsequently, you can specify “.nii” files for each session by double clicking “Select Files”. You then get to the file browser dialog box that you should now be familiar with (or see page 2). Browse to your files, and use the filter or the mouse to select the right images; right-click to select all. You can edit lists of entered files using “Ed”.

UnwarpEPI-based functional pulse sequences may exhibit strong spatial distortions around air-filled cavities in the head which are caused by inhomogeneities in the magnetic field. Unwarp can be used 1) to correct the resulting static deformations based on a B0 field map and 2) correct changes in these deformations that occur because of movement. Such deformations can be thought of as comparable to moving up and down in front of a funny mirror. Thus, not only the position, but also the shape of the volume changes as a function of time. When these distortions are present, realignment using rigid body transfor-mations as described above is insufficient to remove motion artifacts. When you choose unwarping, these deformations are accounted for by (un)warping the imag-es so that they match onto each other again. Note, however, that you should only use unwarping when there is reason to believe that your scans are warped in the first place. The default option in SPM12 is to unwarp only with respect to pitch and roll movements, which correspond to nodding yes and no, respectively. These are the most common types of movement inside a scanner.

Page 12: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 11

Slice TimingMost functional pulse sequences (like 2D EPI, as opposed to three dimensional pulse sequences such as 3D EPI or PRESTO) do not acquire every slice in a vol-ume at the same moment. Because the time it takes to scan a volume is typically in the order of seconds, substantial timing differences can occur as a function of acquisition order of the slices within a scan. In fMRI models where timing is an important factor (i.e., in event related designs), this timing difference should there-fore be taken into account. SPM solves this problem by allowing the opportunity to correct (i.e., equalize) the timing of your functional series.

In the batch editor window you now get the options for “Slice Timing”.The first field that needs to be com-pleted is the “Data” field. This works exactly the same as specifying file-names for realignment. You can also use multiple sessions here.

The second field can be completed by first clicking “Number of Slices” and then “Edit value”. Here you must enter the number of EPI slices you acquired.

The third field will ask you for the (vol-ume) TR, i.e., the acquisition duration of each of your functional scans. Enter this value in seconds.

In the next field, TA, you have to enter the time between acquisition of the first slice and the last slice. As stated, this is usually given by:TR - (TR / NumberofSlices)

Page 13: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 12

Here you are asked to enter the Slice Order of you scans. You will have to make absolutely sure what this order was by checking the settings during scanning. Two types are common:

Ascending or descending: Slices were acquired one by one from top to bot-tom or the other way around. In the slice order field, enter:[1:30]: for 30 slices, bottom to top.[30:-1:1]: for 30 slices, top to bottom.(note: these are Matlab expressions)

Interleaved: In interleaved EPI scans, first all even-numbered slices are acquired, after which odd-numbered slices are done (or reversed).These orders can be entered as:[2:2:30,1:2:29]: ascending, even first[29:-2:1,30:-2:2]: descending, odd first.

You can check these Matlab expressions by typing them in the Matlab command window first. Alternatively, you can enter any order manually: [1,3,5,7,2,4,6,8]: ascending, odd first.

Finally, enter the reference slice. This is the slice that the others are corrected to. Most people will opt for the slice that was acquired halfway the scan. This way you minimize the timing corrections that are made to your data.

Optionally, you can alter the prefix that is prepended to your file names after slice timing correction by altering the Filename Prefix".

Page 14: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 13

CoregisterThe Coregister function is used to match scans of different modalities. For instance, when these two scans (T1 and T2 weighted) need to be matched:

As this example shows, minimization of the sum of squared differences will not work because the difference is very high when the scans match. Therefore, a differ-ent cost function is used, called Mutual Information:

This is the mutual information 2D-histogram of the above two scans when perfectly matched. For each gray level of the first scan, represented as the X-axis, the distri-bution of gray levels of the other scan (in the voxels that have this grey level) is plotted vertically. Two identical images would thus result in a diagonal line from bot-tom left to upper right. In this case, you can see there is partly a positive relation between the two scans (line one above) in the darker gray levels. This is because both images have a black background, gray skin and black skull. There is also, however, a negative relation between the grey levels in cerebrospinal fluid of the two images (black in the left scan, white in the right scan, see line two above). Simply said, the final degree of fit of two images is determined by the “sharpness” of the lines in the 2D histogram. This sharpness is roughly the measure that SPM maximizes when coregistering.

- =

1

2

Page 15: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 14

Just like realign, coregister allows only rigid body transformations (translations and rotations) by default.

Translations Rotations

In the main window drop down menu under coregistration, select:

Estimate: To determine rigid body transformation parameters, and incorporate them into the “.nii” file of the scan without actually chang-ing the bitmap.

Reslice: To apply this transforma-tion to a scan and create new bit-map image files.

Estimate & Reslice: both at once

For estimate, you will be asked for:- a reference image: The scan to which another scan should be matched.- a source image: The scan that should be manipulated onto the reference scan.- (optionally) other images: these will undergo the same manipulation as the source image.Note: the other images should thus already be registered (or realigned) with the source image.

Page 16: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 15

SPM will also allow you to change the options taken from default for both estimation and reslicing. For most cases the defaults settings will be fine.In case you choose to reslice during this step, you may con-sider changing the “Interpolation” field to, e.g., 4th degree B-Spline, which is slow-er but better than trilinear inter-polation. This is especially rec-ommended when reslicing was not performed after realingment.

NormalizeThe Normalize function is used to manipulate scans into standard stereotactic (MNI) space. MNI space as used in SPM12 is defined by a template that was created by nonlinear registration of 152 T1-weighted images.The (new) default in SPM12 is to use a procedure called “unified segmentation” for spatial normalization. This procedure combines three steps into one model: seg-mentation, bias correction, and spatial normalization. Segmentation (see also the description of the Segment function below) refers to the separation of different tis-sue classes within an image, such as grey matter, white matter, and CSF, in ana-tomical scans. Bias correction is procedure for removing smoothly varying intensity differences across images (e.g., a darker area in the middle of the brain). Spatial normalization is achieved by generating “deformation fields”. This is an example of the deformation fields for spatial normalization of a T1-weighted scan:

Deformation fields are images that quantify the amount of displacement for each location in 3D space. For example, in the X deformation field above, a bright color indicates that the location needs to be shifted to the right, while a dark color indi-cates a shift to the left. Thus, a dark to bright gradient across the plane indicated in red quantifies an enlargement (zoom) across the left-right direction in the coronal plane. Once these deformation fields have been generated, they can be applied to other images of different modalities (e.g., the functional scans), as long as these have previously been coregistered with the anatomical image of that subject.

T1-weighted scan X deformation field Y deformation field Z deformation field

Page 17: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 16

In the main window, use the drop down menu under normalise to select:

Estimate: To calculate the defor-mation fields for spatial normal-ization and save them for later use.Write: Similar to “reslice”, apply deformation fields that have been determined previously to specific scans, and make new bitmaps. This creates new files with “w” (or other optional prefix) before the original filename.Mostly, both are done at once using Estimate and Write.

Suppose you choose Estimate&Write. The following fields need to be completed:

First go to data, add a subject, then click “Image to align” and specify the file that is to be used for calculating the deformation fields for matching onto MNI space. These can subsequently be applied to other images. Usually, the highest quality image is used for this.If you wish, you can use a “Source weighting image” in order to mask lesions in dam-aged brains.

Next, you need to specify which images should be resliced after applying the trans-formation ("Images to write"). This will create new bitmap images with a “w” (or optional other prefix selected in the writing options) before the original filename.

Next, take a look at the “estimation options”. The default settings usually give opti-mal results. However, problems in normalization may arise, for instance, in case of strong smooth variation of signal intensity across an image ("bias"). In such case, one may try to decrease the bias regularisation setting.

Page 18: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 17

Before starting normalization, you may consider changing some of the default "writing" options. One important setting is the “bounding box”. This setting defines the portion of MNI space that is to be incorporated in your new files. The default setting contains the entire brain, so if you did not scan the entire brain you may choose to use a smaller bounding box (by looking at an MNI space template).

Bounding boxes are specified with two rows and three columns of numbers. The two rows define the starts and ends, respectively, and columns stand for dimen-sions in X (left-right), Y (posterior-anterior), and Z (bottom to top) directions.

Next, you may alter the voxel size of your new scans. By default, SPM will reslice your new normalized images at a voxel size of 2*2*2 mm. In some circumstances, it is advisable to change this setting to your original voxel size or the closest round number. Smaller voxels will substantially increase the size of your dataset and the time required for statistical calculations, but may be beneficial for smoothness esti-mations that SPM uses for multiple comparisons corrections.

Also, make sure your voxels fit into the bounding box. For instance, 4*4*4 voxels fit into a -80 to 80,-112 to 76, -68 to 88] bounding box, because all these boundaries can be devided by four.

Finally, consider changing the interpolation method that is used when reslicing the images, that is, the method that is used when calculating the voxel values of your new MNI space images. The default option is 4th degree B-spline interpolation. When computational time is critical, the faster trilinear interpolation could be suffi-cient, in particular when reslicing with 4th degree B-splines is already used after realignment.

Page 19: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 18

SmoothThe Smooth function is used as a final step in spatial pre-processing to blur the functional images. The reason to do this is to correct for slight remaining functional/anatomical differences between subjects. The trade-off, however, is that you lose resolution by smoothing. Thus, the amount of smoothing that you should use is determined partly by the question you want answered. When you are interested in very small structures, for instance, you should not use much smoothing.

Smoothing is achieved by averaging every voxel with a weighted sum of its neigh-bors, with the weighting defined by a Gaussian kernel:

The size of the Gaussian is given by its Full Width at Half Maximum (FWHM). The larger the FWHM, the more smoothing you get. As a rule of thumb, most fMRI researchers use a Gaussian with a FWHM that is twice (a single dimension of) the voxel size.

First, click “images to smooth“ and “select files” to choose the files you want to be smoothed.In the field below, the FWHM can be entered. It is set to 8 mm in all direc-tions by default.

Page 20: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 19

Segment Segment can be used to separate tissue classes such as grey matter, white matter, CSF, in anatomical scans. Segmenting an anatomical scan thus results in a set of different images, which can be used, e.g., for varying purposes, such as volumetry (voxel based morphometry). Segmentation is also used for normalization (see above). Segmentation is achieved by using tissue probability maps, which quantify the probability of the presence of a certain tissue type for each voxel. These look as follows:

To perform segmentation, first choose your “Data”: normally, this should be an anatomical (T1-weighted) image. Below, options can be set to produce different types of output images.

Under "Warping & MRF" and "deforma-tion fields", you can choose to generate deformation fields for spatial normaliza-tion, and also deformation fields for reverse normalization.

Below is an example of segmented grey and white matter images of a single indi-vidual. These images are in native space (i.e., in alignment with the original T1 image of that individual).

Grey matter White matter CSF Skull/bones Soft tissue Air

Grey matter White matter

Page 21: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 20

Statistical Analysis Functions

The statistical analysis functions are used to:

- Create a model of the expected BOLD signal during your experiment using multiple regressors.- Estimate and test the fit of this model independently in every voxel in the brain, by specifying contrasts.

During design specification, SPM12 will allow you to set numerous options to speci-fy your design, so make sure you have all information available. If you need infor-mation stored on your computer (e.g. onsets of stimuli), you may need to use Matlab commands to load and / or manipulate your data. Make sure to do all this after starting up SPM, because SPM empties the workspace at startup. Before actually running your model specification / estimation, be sure to save everything you have entered into a batch file. This will allow you to return to your model speci-fication without starting from scratch when something went wrong.The first thing you’ll need is to assign the onsets of your trials to variables for each condition. When these are very few, such as in slow block designs, you may enter them manually in the graphical interface of SPM12. Otherwise, make sure SPM is running, and switch to the Matlab command window (which can be “docked” in the main Matlab window, or have its own window). Here you can enter commands in the Matlab programming language (which is not unlike Unix/Linux). Here are a few important commands:

pwdlscdload trialdataonsets=load(‘onsets.txt’)

whos

[type variable name][pressing arrow up]some_variable(4,2)

some_variable(:,1)

: Print Working Directory: List (contents of a directory): Change Directory: Loads a Matlab data file called “trialdata.mat”: Loads an ascii file called ”onsets.txt” into a variable called “onsets”. Works fine for single column files with numbers.: Shows all variables presently in the workspace: Shows the contents of a variable: Copy previous command: Shows the content of the cell at row 4, column 2 of a variable called “some_variable”.: Shows contents of all rows of column 1 of this variable

Page 22: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 21

Specify 1st-level“Specify 1st level” (or fMRI model specification) is used for model specification at the single subject time-series level. In the steps below, the most important options you can set are described.

Directory: Specify the directory in which your design specification and all related files will be stored. It is very useful to create a new directory for this purpose. This way you can keep your data and analyses separated.

Timing parameters: The units for design indicate if you spec-ify your design (i.e., the onsets of your events/blocks) in either seconds or scans. On either scale, the (start of the) first scan will be timepoint zero (not 1!). When choosing scans, the (start of the) second scan will be timepoint 1, etc.The interscan interval refers to the peri-od between the start of subsequent scans. Normally, this should be the (vol-ume) TR.

If your timing is not critical, as in slower block designs, you may leave the microtime resolution and microtime onset settings at default and skip the following.When SPM creates a model of your expected signal, it will need to know when you acquired your data exactly. Often, this will time point will correspond to the middle of your interscan interval. This can be because you have adjusted the timing yourself (using slice timing correction) to correspond to the slice that was acquired halfway the interscan interval. Whichever you chose there, you’ll need to tell SPM.Now you’ll be asked for the microtime resolution, or number of time bins and the microtime onset, or the sampled bin. The number of bins can be set to correspond with the number of EPI slices you acquired. The “microtime onset” then is the one that the timing was adjusted to. So, if you have a 30 slice EPI dataset that has been acquired in, e.g., interleaved mode (slice order 1,3,5,...etc, 2,4,6, ...etc), that has been slice timing corrected to the slice halfway your interscan interval (that is, slice #2, counting bottom-up), you have to enter 30 for microtime resolution, and 15 for “microtime onset”. You can also leave the microtime resolution at default and esti-mate the right value for the onset (note that exact timing is not very crucial because of the inherently low temporal resolution of the BOLD signal).

Page 23: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 22

Data & Design: Here, you should first click “New Subject/Session” until you have the number of sessions in your design. A session usually is a repetition of an experiment within a subject. For example, in drug studies, the drug and placebo conditions, even though scanned on separate days, can be entered as two sessions. An exam-ple of a three sessions design would be an experiment that consisted of three runs, separat-ed by two short rest periods. Make sure to never enter scans that were acquired in separate runs as a single session!Within each session, you first have to specify the scans that belong to this session using the regular file select dialog. For “conditions”, you need to click “New Condition” once for each condition you want to have in your model. In the most basic experiment possible, an on-off stimu-lation paradigm, the answer would be 1 (not 2), because only one regressor is necessary to model the difference between two conditions. For a design with two conditions plus resting blocks, you would need two regressors, etc.For each “Condition”, you will need to set a number of parameters. First, enter a name for your condition. For “onsets”, enter the vector of onsets for this condition. You can do two things here:1. Enter a comma separated vector manually, e.g., [10,60,100,130,160]. Make sure you enter these onsets in terms of scans if you selected this option before.2. Enter a name of a variable in Matlab work-space that contains a vector of numbers repre-senting the onsets of this condition.

For durations, enter the duration(s) the events/blocks in this condition. In block designs, this will be the length of your blocks. For event relat-ed designs, the duration of all events can be set to zero. If all events/blocks have the same dura-tion, you can enter a single value. Otherwise, enter a vector with the same length as the vec-tor describing the onsets.

Time and Parametric modulations are explained shortly on the next page.

Page 24: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 23

Time / parametric modulations are used to relate the size of a response in a certain condition throughout the experiment to a third variable. This third variable can be, e.g., be a linear downward trend (e.g., when responses are expected to habituate - this is an example of a time modulation), or reaction time measurements (when, e.g., a shorter reaction time is expected to accompany a larger BOLD response - this is an example of a parametric modulation).When you choose a time or parametric modulation for a certain condition, SPM12 will add one or more regressors to your model. Consider this example of a time modulation:

The upper figure shows a typical block design. In the middle figure, its time modula-tion regressor is depicted. When you sum these two regressors, you get the lower figure. As you can see, this models a habituating response. The more this response habituates, the larger the contribution of the middle regressor will be. This is reflect-ed in high parameter estimates for this regressor when you fit the model. You can choose “time modulation” and subsequently “1st order” for the example here. In more advanced designs, you may wish to use higher order polynomials as well. If you want to use, e.g., reaction time as a modulator, you will need to choose “para-metric modulations”, add a new “Parameter”, and enter a name and a vector of numbers representing the reaction time per trial of that condition. Again, you may assume a linear (i.e., first order polynomial) or higher order polynomial relation between reaction time and response size.

Page 25: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 24

Multiple Conditions: Instead of using the condi-tions option described in the previous section, you can refer to a file that contains all this infor-mation. Using this option requires some Matlab experience and is beyond this guide. Read the instructions at the bottom of the windows for more information.

Regressors and Multiple regressors: Here you can add more regressors to your model. Mostly, these will be variables that model additional variance due to causes such as movement of the subject in the scanner. Alternatively, in connectivity analy-ses, regressors can be added that contain a representative time course of a certain region. To add a single regressor, click “regressors” and choose “new regressor”. Then enter a name and (variable containing) a vector of numbers with the length as your number of scans. In case you want to enter the parameters of realignment (i.e., the movement of the subject in the scanner) into your model, it is easier to use the “multiple regressors” option. During realignment, a file was created in the directory of the first image that was entered into realignment. This file is named after this first image, but starts with “rp_” and ends with “.txt”. The file contains six columns. These represent position (not movement) of the subject in terms of X, Y, and Z dis-placement and X, Y, and Z axis rotation with respect to the first scan entered. If this file has the same number of rows (scans) as the number of functional scans in this session, you can enter the entire file right away into SPM by choosing “multiple regressors” and pointing at this file.If not, for instance because you have used realignment to align another scan such as a reference scan with your functional scans, you will need to manipulate the file in the Matlab command window. To do this, load it into Matlab workspace (e.g., type “ rp=load(‘rp_[scan name].txt’) ”), and select the columns you need one by one (e.g., rp_column1 = rp(1:488,1) for scan 1 through 488, column 1). Then use the “regressor” option six times to enter these variable names (in this example, “rp_col-umn1”).It is generally recommended to include the realignment parameters in your model. However, the use of realignment parameters as additional regressors is not unques-tioned. One should bear in mind that not all movement-related artefacts are properly modeled using these six parameters.

The regressors option can also be used for a simple seed region-based functional connectivity analysis. To enter extracted data stored in a VOI file (see last para-graph of this guide), load the VOI file into matlab workspace and enter "Y" as a value under "regressor".

Page 26: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 25

High-pass filter: Next, enter the high-pass filter that you want to use (in order to remove low frequencies from your signal). Filtering in SPM works by adding a discrete cosine set to your model. Although this set of regressors is hid-den, it is fitted onto your signal together with the rest of the model (which is orthogonalized with respect to your filter).This cosine set consists of any number of cosine functions, starting with a half cosine, a full cosine, 1.5 cosines, etc., and ending at (or before) the cut-off frequency that you entered.The figure to the left shows five such cosine waves. The cut-off period in this case is calcu-lated as: session duration in secs / 2.5 periods. Note that, for instance, the left column is capa-ble of filtering linear drifts out of your signal.A lower cut-off period will yield more regressors (each one will cost you one degree of freedom in your statistics). Although the cost of adding more regressors does not weigh up to the ben-efits of better noise filtering, you should be careful not to include cosines at a frequency in the range of your task. If so, task related acti-vation can be filtered out, resulting in decreased power. SPM12 has a default cut-off of 128 secs. Although this may be fine for most designs, it is worthwhile to consider lowering the cut-off in fast event-related designs.(More advanced users are advised to calculate correlations between filters and task regressors manually)

Factorial design: Using this option, you can assign the “conditions” specified earlier to cells in a multifactorial design. For instance, suppose your design consists of two factors: “presenta-tion time” (three levels, 1, 5, or 10 sec) and “familiarity” (two levels: familiar picture versus novel picture). This means that you need to have entered (3*2=) 6 conditions in the condi-tions option above. If you have entered them as “familiar 1sec”, “novel 1sec”, “familiar 5sec”,

“novel 5sec”, “familiar 10sec”, and “familiar 10sec”, enter “presentation time” as the first level and familiarity as the second factor here.Note that the factorial design option will only add contrasts testing for main and interaction effects. You can also specify these manually in the contrast manager (see below).

Page 27: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 26

Basis functions: As you will probably know, neuronal activity does not translate directly to the Blood Oxygen Level Dependent (BOLD) signal that you measure in fMRI. Therefore, you need a model of how the BOLD response relates to neuronal activity. By far the most widely used is the hemodynamic response function (HRF). Thus, most people will choose the upper option in the upper right panel, namely “Canonical HRF”. The other options are beyond the scope of this guide.

Boxcar function

Convolved with HRF

Example block model with three blocks (X axes in seconds)

When you choose one of these, all blocks or events that you have specified will be “convolved” with the “canonical” (i.e., standardly assumed) HRF. Above you can see an example of a block design. The upper graph shows the expected neuronal activi-ty (on during a certain condition, off in between). Below you can see the expected hemodynamic changes as a result of this neuronal activity. During statistical analy-sis, SPM will determine for every voxel in the brain to what extent it exhibits this pattern. It is important to understand that in fMRI (in the context of SPM analyses), the dif-ference between event related designs and block designs is only a matter of the width of the input function. You can easily see this by looking at the example of an event related design on the next page. Here, neural activity is modeled as a so-called delta function which assumes a short burst of activity at the time of each event (upper graph). Convolution with the HRF results in a model of the BOLD response triggered by this burst (second graph).

Page 28: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 27

Of course, using convolution with the HRF makes certain assumptions about the shape of the BOLD response. In order to introduce some freedom in shape of responses that you can model, other regressors can be added that can alter the shape of the HRF. To do this, click “canonical HRF”, “Model derivatives”, and “Specify menu item”. The time derivative is used to allow subtle shifts in time (see third graph). Mathematically, this function is the partial derivative with respect to

time of the convolved delta function. Instead of one regressor, your signal is now mod-eled by a linear combination of two regressors: b1*X+b2*Y, where X is the convolved HRF, Y is the time derivative and b1 and b2 are the betas (parameter estimates) that give the best fit onto your data. On the left you can see what happens when b2 increases: this results in a shift back in time of your model (red dots).You can also choose to add another regressor: the dispersion derivative (see fourth graph above).

This is the partial derivative with respect to the duration of the pulse you have con-volved with the HRF. In practice, this regressor can be used to allow alterations of the width of a response, as you can see below: when its beta decreases, the HRF will get wider.Note that adding more regressors to a model comes at a (small) cost: each regressor will decrease the degrees of freedom in your statistical tests with one. In block designs, timing errors in the onsets of the blocks, or the width of the blocks, become such a minor factor that it does not weigh up to the cost of losing degrees of freedom. Therefore, time and dispersion derivatives are not useful for block designs.

Delta function

Convolved with HRF

Time Derivative

Dispersion Derivative

Example Event-related model with three events (X axes given in seconds)

Page 29: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 28

Model Interactions (Volterra): This can be used to model interactions among trials or condi-tions, e.g. because a BOLD response to a stim-ulus of a certain condition is expected to be larger when preceded by a trial of a certain other condition. This option is rarely used and will not be described in detail here.

Global Normalisation: Choose “scale” if you want to scale each voxel value of each scan to the global (overall) mean of that scan (thus, equalize the global mean of all scans in your time series).Caution should be taken when conditions you want to compare are expected to show large differences across the whole brain, as in that case, task related activation may be scaled out.Global normalization may also cause artifacts related to motion or other effects that cause large scale signal changes. Most researchers therefore agree not to use global normalisation.

Explicit mask: This option allows you to specify a mask that is used for your analyses, which means that the analyses can be restricted to certain part of the brain. Example uses are:1) An image describing where in the brain grey matter voxels are located. Such an image can be created using “segmentation” (see above).2) Restricting your analyses to only the area you are interested in, e.g., the frontal lobe. This requires that you have an image that describes the location of this area (which is not standard in SPM). Statistics outside of this area will not be calculated. Alternatively, you can use region of interest analyses described further below.Most people will opt to calculate all statistics across the brain, and thus not to mask at this stage.

Page 30: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 29

Because regular statistics assume that your observations are independent (uncorre-lated serially), a correction needs to be applied for fMRI time-series. SPM12 uses the AR(1) (autoregression) model to achieve this and lower your resulting T value if such correlations exist. Using this correction is necessary when you want to report statistics from a regular single subject time-series analysis. It will, however, not affect your parameter estimates (betas), and therefore, is not relevant for group studies where normally (contrasts of) betas are tested across a group.

You are now ready specifying your first level model. Make sure to save all your set-tings into a batch file. This will allow you to re-load it and make changes without starting from scratch again. After running the model, you will get a file called “SPM.

mat” in the directory you specified for the analysis (see above). You will also see a screen like the one to the left here. What you see in the middle is the so-called design matrix. In this case, the design is very simple and consists of one session and one condition (stimulation vs. rest).Columns of a design matrix represent regressors, and rows represent scans. Values are represent-ed by grey levels, the brighter the grey level, the higher the value.Here, the first regressor depicts a block design with rest periods in between. The six regressors next to it are the realignment parameters of that subject. By clicking your mouse in the design matrix you can view its values. Below it, you’ll find a list of the choices you made during model specification.

Serial correlations: In the BOLD signal that is measured using fMRI, the measured signal is mostly slower than the sample rate (scans/sec). As a consequence, your data is “oversampled”, or in other words, your subsequent datapoints are not fully independent observations. To make this problem more understandable, consider this example: When you want to cal-culate the correlation between age and income, and you “measure” only two people, it will be impossible to find a statistically significant rela-tion. You might, however, if you measure the same people 10 times, acting as if they were separate persons. Doing so, you wrongfully overestimate the number of independent obser-vations in your test.

Page 31: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 30

Specify 2nd-level“Specify 2nd-level” is used exclusively for group analyses. So skip this paragraph if you are currently working on the single subject (first) level and continue to the next.In many ways, second level analyses are less complicated than first-level analyses. Before starting a 2nd level design specification, make sure you fulfill all of the fol-lowing requirements:1) You have preprocessed your data in such a way that all your images are now in the same space (usually MNI space). Thus, all your subjects need to have been normalized.2) You have successfully specified and estimated a first-level model, and have specified and calculated contrasts of interest for each subject. For instance, in a design with two conditions, e.g., left versus right, you could calculate the left versus right contrast at the first level. This would result in contrast images that contain one value for each voxel, namely the percentage signal difference between those condi-tions. Now if every subject has a positive value here, you can claim that there is an effect in this voxel across the group. As you probably know, testing if a group of subjects score consistently different from zero can be done using a simple one sample t-test. So the 2nd level analysis in this example would consist of a one sam-ple t-test for every voxel in the brain. This is the most simple 2nd level statistic, but you’ll learn that many questions can be answered using this simple 2nd level design by calculating the proper contrasts at the first level. More complicated designs, involving paired samples t-tests, two (independent) samples t-tests, and full factorial ANOVAs can also be used in SPM, and follow essentially the same logic.

Below factorial design specification you can set a number of options

Design: Here, you can enter the type of statistical test that you want to perform across subjects. The following tests are available:1) One sample t-test. This will test the null-hypothesis of a population mean of zero. Simply enter the contrast images of all subjects (as “Scans”).

2) Two sample t-test. This will test the null hypothesis of a zero difference between the means of two separate groups. Because usually separate groups are involved, you may assume independence. However, assuming equal variance may not be warranted when testing, e.g., patients versus con-trol subjects.

Page 32: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 31

3) Paired t-test. This will test the null hypothesis of a zero difference between pairs of scans, usually repetitions of a certain measurement within a subject. A paired t-test is mathematically identical to a one-sample t-test over differences between pairs.

4) Multiple regression. This option will allow you to test the null hypothesis of zero correlation between your series of scans and one or more covariates (e.g., age, questionnaire scores, etc).

5) Full factorial. This option allows you to specify a full factorial analysis of variance with any combination of within (repeated measures) and between group factors. First click “new factor” for each factor you want to add. Now you need to enter a name and a number of levels. Subsequently, choose “yes” for “independence” if your factor is a between-group factor. For within group factors like repetitions of a certain measurement, pick “no”. For variance, you can leave the default at “unequal” if you’re not sure you can assume that all your cells have equal variance.Note that a full factorial model with only one two-level independent factor is actually identical to a 2-sample t-test.

6) Flexible factorial. This option allows you to specify a factorial model in a more flexible way, namely, with the option of not including the full set of main effects and interactions. A detailed description of this is beyond the scope of this guide.

Covariates: Here you can enter any covariates that may be of interest or may explain additional variance. For instance, when testing an effect across a single group, you may want to control for factors such as age, personality characteristics, etc., or explicitly test for effects of these.

Masking, Global calculation, and Global normalisation: Masking out voxels outside of the brain is usually not done at this stage and will not be described here. The other three options are used for PET.

Directory: In this field you have to enter a directory where the files will be stored that belong to your analysis. It is advisable to separate your datafiles from your analyses.

Page 33: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 32

ReviewThe review function is used to review the specifications of a design. It allows you to view all parameters necessary to check the efficiency / accuracy of your design. Review can be used for both first and second level models. Below, only first level review will be shown, but options are similar for second level.

After selecting “review”, choose the SPM.mat file that was created during design specification in the previous step.

After clicking “design” in the window to the left, you have three options:

Design matrix: This will show the design matrix again, exactly as depicted on the previous page.

Design orthogonality: When you choose this option, you will see your design matrix again, but now with a triangular figure below it. This figure depicts the orthogonal-ity of your design: the degree to which your regressors correlate with one another (regressors are orthogonal when they are not correlated). Higher correlations are depicted by darker grey-levels.Orthogonality is an important issue, because when two regressors are highly correlated, they will explain almost the same variance in your signal, which decreases your power and causes instabili-ty in the model fit. Mostly, however, this issue is dealt with while constructing a design, that is, prior to scanning. Once scanned, there is not much you can do about it anymore. So the message is: specify your design in SPM already before running your first subject.

Page 34: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 33

Explore: Using explore, you can take a closer look at individual regressors. In the graphics win-dow you’ll see three graphs that characterize a single condition in your design.

Upper left is the hemodynamic response model over the total duration of the currently selected session. Next to it, you will find the frequency spectrum of this model. Note that the grey area in the frequency spectrum indicate the frequen-cies that are being filtered out by the high-pass filter.

Below is a depiction of the basis set (here, the hemodynamic response function) you have cho-sen. Here, a six-second block is convolved with the canonical HRF to result in this model for the response to each block.

Once you have specified your model and reviewed the design, you can continue to actually fit the entire design onto the data. This may take some time, depending on the size of your dataset and model. Second-level models usually take less time to estimate.In the window to the left, enter the SPM.mat file again (it is in the directory that you specified above). For method, we assume here that you choose “Classical”. The other options, using Bayesian statistics, are beyond the scope of this guide.

Estimate

Page 35: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 34

Now you are ready to start looking at results. Press “results” and load your SPM.mat file again. This will bring you into the contrast manager, which looks like this:

Here, by selecting ‘define new contrast’, you can specify which comparisons, or contrasts, you want to test. The index listed before the {T} corresponds to the index of the filename in your workdirectory your results will be written to (e.g., spmT_0001.img for contrast #1).Remember that, when a model is fitted, each regressor (in each voxel of the brain), gets a beta, a parameter estimate that determines the amount of variance explained by that regressor. By defining contrasts, you simply make combinations of these betas. In the example above, where on/off periods of a certain condition are mod-eled using a single regressor, a simple [1] contrast will suffice to test whether the beta attached to the first regressor differs from zero. In cases where you model responses to two different conditions (vs. rest), modeled by two different regressors, you can use a [1,-1] contrast to compare the two conditions. This will subtract the second beta from the first before testing against zero. Another example would be to look at the sum of these two betas (represented by a [1,1] contrast). In that case, you will test in each voxel in the brain if it is activated during the two conditions of the task combined.After defining T-contrasts, the statistical test SPM will perform is a T-test. To simplify things a little bit, this last step of the creation of a T-map is that SPM calculates T values for the whole brain by assessing the ratio of explained variance (the con-trasted betas) and unexplained variance (the amount of variance that could not be fitted into your model).

Results

Page 36: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 35

Now consider an event-related design with 2 canonical hrf functions and their tem-poral derivatives. The proper test for this situation is not a [1,1,-1,-1] contrast, because in such a T-contrast, the betas of the HRF and temporal derivative are summed. Thus, when you have a high positive beta for the HRF and an equally negative beta for the temporal derivative (i.e., a shift forward in time), the sum of these two can be zero, which means that you will get a T value of zero. Therefore, you need a test that can assess whether any of two betas, regardless of directions, explains a significant amount of the variance. Such a test is provided by the F-contrasts. Using these contrasts, you simultaneously specify a number of T-contrasts (which are entered in different rows). The test subsequently assesses if this contrast as a whole explains a significant amount of variance.

Now you can select if you want to mask your contrast, which means that you can use another contrast to restrict the areas in which you per-form your test to those that are significant in another contrast. If you choose to do so, you will be asked for a contrast and an uncorrected p level threshold for your mask (see below for thresholding). Finally it will ask if you want to per-form your new test only inside (inclusive) or out-side (exclusive) of this masking area.In the remainder it is assumed that you do not use masking.

To give an example: if your design contains two event-related conditions, and both have a temporal derivative, the proper F contrast to compare these two conditions is (like in the figure):[1,0,-1,0][0,1,0,-1]The first row of this contrast compares the canonical hrf’s, and the second the temporal derivatives. The resulting F value represents the combination of these two.After you are finished specifying contrasts, you can proceed to have SPM calculate the T or F-maps, by selecting one and pressing OK and ‘done’.

Page 37: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 36

The next step is to determine the threshold you are going to use. This question is related to the so-called problem of multiple comparisons. Normally, in statistical testing, an alpha level of .05 is used, which means that you regard a result as significant when there is a chance of less then 5 percent that your effect occurs merely by chance. In fMRI how-ever, you often perform 20.000 tests all at once. Using the alpha of .05, this means that an expect-ed 20000*.05=1000 voxels will show a "significant" result. The solution to this problem is to lower your alpha. There are, however, different approaches as to what a proper correction is. The simplest solu-

tion is to divide your alpha by your number of tests, a procedure referred to as a Bonferroni correction. In SPM, you can use this correction by answering "none" here. Subsequently, you will be asked for a p threshold. As mentioned above, you can calculate your threshold by dividing .05 by the number of voxels you are test-ing. The Bonferroni correction, however, is an overly conservative correction (i.e., biased towards misses instead of false positives). The reason for this is that Bonferroni assumes that all your tests are independent, while in reality they are not. This means that while you may be performing 20.000 T-tests, you do not actually have 20.000 independent possibilities to find an effect, because your images are spatially correlated. In other words, you are often testing almost the same thing. Therefore, SPM has implemented a different correction that is based on so-called random field theory to estimate the true number of independent tests, and correct the threshold accordingly (an exact explanation of random field theory is beyond this guide). In order to use this correction, select 'FWE’ (family wise error) here, and subsequently enter the corrected alpha (where you can enter the normal alpha of .05, because it's now corrected). This alpha of .05 now means that you allow a five percent chance to identify a single voxel across the brain as being activated while it is actually not.Another method to solve the problem of multiple comparisons is to simply restrict the number of tests that you perform. If, for instance, you have a specific hypothesis about a certain small brain area, it does not make sense to correct for the whole brain (doing so would increase the risk of type II error - or false negatives). In these cases, a more liberal uncorrected p threshold can be chosen here (e.g., p < .001, uncorrected for multiple comparisons, depending on the size of the hypothesized region). Subsequently, regional hypotheses can be tested from within the next win-dow (see below). To do so, choose “none” in this window, and subsequently enter the requested threshold.

Page 38: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 37

After entering either a corrected or uncorrected alpha or t threshold, you can enter an extent threshold. This means that you can restrict your results to clusters of vox-els of at least the specified size (in number of voxels). The default is option here is zero, which allows single activated voxels to be detected. After this, you will finally see your results, for instance:

Above, you see a so-called glass brain, arguably not the best way to visualize your results, but after some practice you'll get used to it. The activation shown here is located in the temporal lobe. Note that only activation that exceeds your threshold is drawn. You can navigate the glass brain dragging and dropping the little red arrow or right-clicking in it. In this way you can select a cluster or voxel you are interested in. Next to the glass brain, your design matrix will appear, above which the chosen contrast is depicted graphically (here simply [1,0,0,0,0,0,0,0]).

Also, you get a window such as the one here on the left.In the section p-values you can click whole brain or current cluster to see statistical infor-mation on all clusters in the brain, or the cho-sen cluster, respectively.

Page 39: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 38

When you click "whole brain", you will see a table like this one:

The following information can be found here (starting with the bottom table): Height threshold: The p-level that you have chosen as uncorrected alpha, or that has been calculated by SPM as a corrected one. The T-threshold is the T value in a T distribution with your number of degrees of freedom that corresponds to the given p-value. Statistical images such as shown in the glass brain usually consist of T (or F) values. You will therefore only see T values above your T threshold.Extent threshold: The minimum number of adjacent supra-threshold voxels.Degrees of freedom: Normally, the degrees of freedom in a general linear model are calculated as the number of observations minus the number of regressors in the model. Smoothness FWHM: Only relevant if you have chosen corrected alphas. This is an estimation of the smoothness of you statistical image, from which SPM calculates the size of ResEls (resolution elements) and the true number of independent statis-tical tests.Finally, you'll see the total volume, number of voxels and resels, and voxel size.In the table above, a summary is shown of all statistics.In fMRI research papers, mostly voxel-level statistics are reported. The values you see here are p levels that are corrected (left) or uncorrected (right) for multiple com-parisons. As explained above, the p value depends upon the T level and the num-ber of degrees of freedom. The Z value shown here, however, is directly derived from the p value. This value is often reported as it is easier (than T values) to inter-pret across studies with widely varying degrees of freedom.

Page 40: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM5 starters guide - Erno Hermans - 39

In many cases, a researcher will not perform a blind search across the entire brain to identify areas that respond to a certain task, but will aim to test a specific hypoth-esis about the regional response in a certain a priori region of interest (ROI). In those cases, it is appropriate to apply a small volume correction, i.e., a correction that is restriced to the multiple tests performed within the ROI. Suppose, in the cur-rent example, we wished to test the hypothesis that the inferior frontal gyrus would respond to the auditory stimulation paradigm. We now first need a definition of this region of interest. A proper way to do this would be to create an anatomical mask consisting of this region, which can, for instance, be made using an SPM add-on toolbox called the WFU pickatlas. This would work as follows. After selecting "tool-boxes" and "wfu pickatlas" from the SPM12 main window (if installed), double click

"TD labels" in the panel shown on the left here. Now select the inferior frontal gyrus, click "add" in the upper middle, and then click "save mask" to save the ROI mask. Now use "check reg" (see visualization, above) to check whether your mask matches your ROI on an MNI-space image.There are also other methods to define ROIs. Some examples are masks based on results of an independent statistical contrast or ROIs defined as a spherical search region around peak coordinates previously reported in literature.

To view results within your ROI, select your contrast, and use a liberal initial threshold (e.g., P < .001). In the window show to the left, now select "small vol-ume". You can then select "image" and continue to select your ROI mask image, and click "done". The table with statistics (bottom left) now contains only voxels that are significant after correcting for your search region (note that they need to reach your ini-tial threshold as well). The peak voxel in IFG is sig-nificant when correcting for IFG, even though it did

not reach whole-brain correction.Alternatively, you may use a sphere (or box) to define your ROI. To do this, enter your hypothesized coordinates into the X, Y, and Z boxes at the bottom of the middle left window. Then click "small volume", select "sphere", and enter a radius for the sphere to be used for small volume correc-tion. The size of the sphere needs to cho-sen considering the size of the hypothe-sized region and the amount of smoothing applied to the images. Again, any results now shown in the table are corrected only for the spherical ROI.

Page 41: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 40

The SPM results window also offers various possibilities for data visualization and extrac-tion. The two most important options will be described here.Data visualization: If you want to visualize your results spatially, in order to facilitate anatomical localization of activity, you can click “overlays” and select, for instance, “slic-es”. You will then be asked to select an image for rendering on, which may be any anatomical image, provided that it is in the same stereotactic space as your T-map. When you have normalized your functional images during spatial pre-processing, you can project the activity onto any MNI space image, yielding nice pictures such as the ones below. You can also use MRIcron (see above) for this type of visualization.

SPM12 can also visualize your data temporally, which means that you can plot the changes in BOLD signal over time. For this, you can use single voxels or clusters of voxels.

When you click “plot” in the visualization sec-tion, you can choose various options for visual-ization of your activity. Now, choosing “fitted responses” (followed by the contrast of your interest) will allow you to view the changes in activation throughout the whole session. Choose “adjusted” to view the fit of your entire model, and plot it against “scan or time”.

Page 42: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 41

Ideally, the result will look some-what like this. Note that the grey line does not represent the actual signal that was measured, but the entire fitted model, including the contribution of other regressors such as high pass filters and realignment parameters. Although this may look like a realistic BOLD signal, the reality of the BOLD sig-nal is very noisy, as you can see from the dotted line in the back-ground.

The option shown here is more useful for block designs. For event related designs, choose “event related responses” and “fitted response and PSTH” to view fitted BOLD responses to your stimuli.

When you choose to use F-contrasts for your comparisons, note that F values have no sign, i.e., they are positive regardless of the direction of your effect. Thus, when you find a statistically significant effect in a certain voxel, it may be useful to view

the directions of the actual effects. To do this, go to the voxel you are interested in, a then press “plot” and select “con-trast estimates and 90%CI” from the drop-down menu. You are then asked for a contrast. If you choose “effects of interest” here, you’ll get to see the parameter estimates for all regressors separately. One the left is an example with only two.

Data extraction: SPM12 also allows you to extract data from an activated voxel or cluster of voxels. This can be done by clicking the "eigenvariate" button in the window shown on the left. First, specify a name for the region to extract data from. Then specify an adjustment contrast. This allows you to remove task-relat-ed (or other) effects from the extracted time series data. Finally, you can select how to define the region: either using a sphere, a box, a cluster, or a mask. Select cluster to extract data from a cluster of significantly acti-vated voxels.

Page 43: SPM12 STARTERS’ GUIDE - ernohermans.com · different from the old img/hdr images that were used in previous SPM versions. Analyze 7.5 format images made in SPM2 or older may not

SPM12 starters guide - Erno Hermans - 42

In the graphics window, you will now see the extracted time series from the selected cluster.

Note that this time series is not simply based on the average time series across all voxels in the cluster. SPM calculates the first eigenvariate of the these time courses, i.e., the first princi-ple component resulting from a principle component analysis.SPM will now save a .mat file

into your current directory which contains this eigenvariate in a variable called "Y". This variable can, for instance, subsequently be used perform connectivity analyses such as simple seed region functional connectvity analyses. To do such an analysis, simply enter the time course in the Y variable as an additional regressor into a first-level statistical analysis.Extracted data can also be used for more complicated (effective) connectivity analy-ses, for instance, analyses that assess interactions between a task and interregion-al connectivity. Such models are called "psycho-physiological interaction" models. Similar procedures are also used for dynamic causal modelling. These models, however, are beyond the scope of this guide.

The SPM results window offers various other possibilities which needed to be left undescribed here. Hopefully, the topics that have been described in this guide will get you started with doing your first analyses!