SPM99 is old now. Consider using SPM8. If you really want SPM99, then:
The software is available for download, but we ask you to complete a brief registration form prior to downloading. Having completed the form, you will be directed to the download location, via a
keyword enabled URL. You should also periodically check the SPM99 bugs & fixes area.
There was no upgrade path from SPM99b (the beta release) to the full SPM99 release. This was due to the number of files that were updated during the beta testing phase (mainly due to the implementation of the batch system.) You must register for and download the entire SPM99 package.
Although SPM99 still uses the Analyze file format, and will therefore read image files from previous versions of SPM, there are differences in the algorithms, templates and models used in SPM99 over previous releases. Therefore, we recommend you use a single SPM version for any given project.
Although we have tried hard to produce high quality software, in a project of this size and complexity there are certainly some remaining bugs. Please assist us by reporting bugs to: <email@example.com>. Peculiarities, feedback, and general queries on the use and theory of the software should be raised on the Email list.
Bugs and fixes will be posted on the list, and described in the README.txt file in the SPM99_updates anonymous download area, at http://www.fil.ion.ucl.ac.uk/spm/download/spm99_updates, from where updated programs can be downloaded. Note that SPM99 is now very old, so the authors enthusiasm for fixing bugs and making it compatible with more recent MATLAB versions is virtually nill.
SPM is made freely available to the [neuro]imaging community, to promote collaboration and a common analysis scheme across laboratories. The software represents the implementation of the theoretical concepts of Statistical Parametric Mapping in a complete analysis package.
SPM (being the collection of files given in the manifest in the
Contents.m file included with each distribution) is free but copyright software, distributed under the
terms of the GNU General Public Licence as published by the Free
Software Foundation (either version 2, as given in file
at your option, any later version). Further details on "copyleft" can
be found at http://www.gnu.org/copyleft/. In particular, SPM is
supplied as is. No formal support or maintenance is provided or
The authors are research scientists in the fields of neuroscience, statistics and image processing; for whom SPM is the vehicle for implementation and dissemination of ideas. We aren't software engineers, and (unfortunately) don't have the resources to formally support SPM. The SPM Email list <firstname.lastname@example.org> provides an informal forum for discussion of technical and theoretical SPM issues, and is monitored by the authors. We ask that you read the SPM documentation, review past discussion on the email list, and exhaust your local avenues of SPM expertise before contacting us, either directly or via the SPM discussion list.
The SPM software is a suite of MATLAB functions, scripts and data files, with some externally compiled C routines, implementing Statistical Parametric Mapping.
In brief, you need the following to run SPM:
Additional considerations are given below:
*.mexsol), Linux (
*.mexlx), and Windows (
*.dll). For these platforms you only need MATLAB.
spm_MAKE.shis provided with the distribution, configured for various platforms. If you have to tweak the makefile to compile the SPM mex-files for your platform, please send us the details so we can include them in the distributed makefile. Additionally, if you send us the compiled binaries, we would be happy to host archives of compiled mex-files in the user contributions area, for other users benefit.
*.dll's, you don't need to do this to use SPM!
spm_format.manin the distribution], or "Image format" below. SPM can also read MINC & ECAT-7 images.
Before attempting to analyze data using SPM, we recommend you spend some time reading. It is essential to understand the concepts of Statistical Parametric Mapping in order to effectively use the software as a research tool. You should begin with these web pages, particularly the "Documentation" page.
There is no manual for the SPM package. Having familiarised yourself with the concepts, you should familiarise yourself with the package by a thorough review of the on-line help system. SPM is launched from within MatLab by typing spm at the MatLab prompt. (If the
spm.m fuction is not found, make sure the SPM distribution is on your MATLABPATH. Type
path at the MatLab prompt to display the current path.) A splash screen is displayed, welcoming you. Press the "About SPM" button to launch the help facility. The initial help screen describes features of the current version. Press the "Menu" button at the top of the help screen to display a representation of the SPM menu window. Pressing the buttons on this representation leads to appropriate help topics. Press "Help" for information on using the help facility.
To start SPM proper, press "Exit" in the help window to return to the spash screen, and select PET/SPECT or fMRI as appropriate. The three SPM windows will be drawn, a menu window, a blank window for interaction, and a results window. This interface remains constant throughout the SPM session. Begin by displaying images using the "Display" feature.
SPM uses (only) Analyze format images. This format is discussed below. You'll need to convert the images from your scanner to this format. We cannot supply any conversion programs. (Ours are tailored to our sites scanning protocols and network setup, and we are limited by confidentiality agreements.)
Most people learn how to use SPM from a friend. If you're starting from scratch, then it might be worth using the SPM email discussion list to contact fellow SPM'ers in your locality.
spm_format.man v1.2. Check the
spm_format.man in your distribution.
SPM has been written to deal with two or three dimensional data of any size (either image dimensions or voxel size). The data however should be organized with a separate file for each scan, comprising transverse slices running from the bottom to the top of the brain.
Specifically, SPM uses the simple header and flat binary image file format of ANALYZE-7 (Mayo Clinic, Rochester, USA.) http://www.mayo.edu/bir/), with slight customisations to the header. (It can also read MINC & ECAT-7 images.)
More specifically: (and see http://www.mayo.edu/bir/PDF/ANALYZE75.pdf)
*.img: An uninterrupted array of (unsigned integer, signed short, signed integer, float or double) voxel values. Each *.img usually has an associated header file that contains information about the image process in question.
The original images which SPM uses can be in any orientation. However, after spatial normalisation, the images must be in the following orientation:
This is a right handed coordinate system, and is consistent with the Talairach atlas.
In order to sucessfully spatially normalise the images, SPM'96 must be able to determine the initial orientation of the images. The global variable "sptl_Ornt" contains this orientation. This is initially set from the file "
spm_defaults.m" . This can however be changed from within SPM'96 (for the duration of the SPM session) using the `Defaults' button. As a result of this, left-right (radiological v neurological) orientations are no longer prompted for in the statistics module of SPM.
*.hdr: The format of the 348 byte header file is that
adopted by ANALYZE (The Mayo Clinic, Rochester USA, http://www.mayo.edu/bir/). The fields that are necessary in the context of SPM include information about:
*.hdr does not exist then default values are assumed.
Default values can be changed by selecting 'defaults'.
*.hdr can be
created (and can be edited) using the 'Display' facility, or manually using
The 'Display' facility also includes a 'Fix header' module that allows multiple header files to be created and ammended interactively. It is important that these header files are correct. The most common problems with using SPM usually reduce to incomplete or incorrect header files.
This simply contains a 4x4 affine transformation matrix in a variable `M'. These files are normally generated by the `realignment' and `coregistration' modules. What these matrixes contain is a mapping from the voxel coordinates (x0,y0,z0) (where the first voxel is at coordinate (1,1,1)), to coordinates in millimeters (x1,y1,z1). By default, the the new coordinate system is derived from the `origin' and `vox' fields of the image header.
Assuming that image1 has a transformation matrix M1, and image2 has a transformation matrix M2, the mapping from image1 to image2 is: M2\M1 (ie. from the coordinate system of image1 into millimeters, followed by a mapping from millimeters into the space of image2).
These `.mat' files allow several realignment or coregistration steps to be combined into a single operation (without the necessity of resampling the images several times). The `.mat' files are also used by the spatial normalisation module.
SPM is a collection of files that are used by MatLab. These files include:
spm_*.mexsol). These routines implement memory mapping and numerical operations that are called frequently. Precompiled Mex files are provided for Solaris2.x, a Makefile (
spm_MAKE) is included for other platforms.
Where possible the user interface and computational or analytical aspects of
the software have been segregated such that
spm_*_ui.m sets up the
user interface and assembles the appropriate input arguments for
spm_*.m contain the statistical and
mathematical implementation of a generic nature, and would be of greater
interest to those who wish to incorporate SPM into an existing package.
This section describes features of SPM'99, and is derived from
spm.man v2.5, included in the distribution.
The functions for reading and writing images have changed. All writing of images is via the functions spm_create_vol and spm_write_plane (even mex routines now call these functions).
A handle for an image volume is now via the "spm_vol" function:
V = spm_vol('filename.img');
The structure "V" is a structure or a matrix/cell-array of structures taking a similar form to the matrix/cell-array of strings that define the image file names. The form of each element of V is described in spm_vol.m. Sampling the image still involves passing the handle to spm_slice_vol, or spm_sample_vol. Because of the limitation on the amount of virtual memory allowed for a process (either 2 or 4 Gbytes, depending on the OS), the actual mapping is done as the data is required, and not at the spm_vol stage. Because mapping is done on the fly (from the image filename stored in the handle structure), handles from spm_vol.m can be saved and used across Matlab sessions (provided the files haven't moved).
A number of new data types are supported, including signed and unsigned versions of existing types, and also byte-swapped versions. Also, the volume no longer needs to be contiguous, and each slice can have different scalefactor and offset, so formats such as ECAT 6 could in theory be supported.
Byte-swapped Analyze files can now be read, so mixing different computer architectures on the same network should be less of a problem.
ECAT 7 files can now be read, providing that they only contain a single frame (matrix number 1010001). Some MINC files can also be read, although I'm not sure about all the different possible ways of representing images in the MINC format. I'm not 100% sure about the MINC stuff, so it may be worth checking this out properly. Full support for many other formats could be added by modifying:
A number of modifications have been made to the realignment module. Many of these reflect the questions asked on the SPM discussion list. The realignment can be thought of as three components: parameter estimation, image resampling and correction of motion artifacts (adjustment).
fMRI sessions are now handled differently, because of the assumption that there may be systematic differences between the images in different sessions. The first volume of each session is now aligned to the first volume of the first session. Subsequent volumes in each session are then aligned to the first volume of the session. This should acheive increased accuracy within session, since all the images are aligned to an image from the same session. This also saves time, because subject movement between sessions tends to be larger than subject movement within session. The large systematic differences between sessions are therefore removed in the first realignment step. Adjustment is performed separately for each session, but the same mask for writing the realigned images is used for all images of all sessions.
PET realignment is now a two pass procedure. The first pass aligns all the images to the first image in the series. A mean of the realigned images is created, and the second pass aligns all the images to the mean. The second pass effectively matches the images to a less noisy template, and so should result in more accurate movement estimates.
Previously, the estimates of motion continued for a fixed number of iterations. This may be OK for small movements, but was inadequate for large ones. The realignment now continues until a stopping criterion has been achieved.
Movement estimation begins by using (faster but less accurate) tri-linear interpolation to resample the data. The final iterations are done using sinc interpolation in order to obtain the final high accuracy.
The algorithm for the SPM96 motion correction was very similar to that of the previous version (SPM94). However, both these implementations included an assumption about the rate of change of sum of squared difference with respect to parameter changes that only held when the rotations were small. This has been fixed.
Occasionally it may be necessary to attempt to sample voxels that lie outside the field of view of the original image. The parameter estimates in the SPM96 implementation assumed that the values of such voxels should be zero. In SPM99, these voxels are excluded from the computation of motion estimates.
The sinc interpolation has changed. In the previous version, the width of the hanning window was 1 pixel narrower than the optimal width. This has been fixed. Also, the integral under the sinc kernal has been set to one (by a renormalizing step). Both odd and even numbers of neighbours can now be used by the interpolation. Windowed sinc interpolation schemes are acheived by passing a negative hold to functions such as spm_sample_vol. Positive holds will result in polynomial (Lagrange) interpolation being used, whereas negative holds use sinc interpolation. The gradient of the images can also be directly obtained by spm_sample_vol.
A three dimensional Fourier interpolation has been implemented that is based on the paper by Eddy et al. This method is used for resampling fMRI data, but it requires the voxel sizes of the images to all be isotropic (since zooming can not be performed using this method). Preliminary tests showed that this method did not greatly reduce the resampling errors.
The fMRI adjustment has been modified.
Rather than removing signal that is correlated to functions of the six parameters describing the rigid body movement of the subject, the adjustment now uses functions that are dependant upon the displacement of each voxel. This requires three parameters to describe it rather than six, but it is now a different function for each voxel. The functions that are covaried from the data are periodic in terms of the number of voxels displaced, and are based upon sines and cosines of the number of voxels displaced. e.g., the functions for a displacement of two voxels are identical to the functions for a displacement of one voxel. The functions were appropriate for simulated data, and with phantom data that was "moved" by moving the field of view of the scanner. However, the method is not quite so good for real subject movement within the scanner.
The adjustment step is now regularized. This regularization is based upon Bayesian statistics which states that:
p(a|b) \propto p(b|a) \times p(a)
If (a) is the coefficients of the regressors, and (b) is the data, we wish to find the suitable values for (a) which maximize the posteriori probability of (a) given (b). Taking the Gibb's transform of these functions gives us:
H(a|b) = H(b|a) + H(a) + c
which expresses the Bayesian furmulation in terms of energy cost functions. The objective is now to find the coefficients that minimize the cost function. The model assumes that the errors on (b) are normally distributed, and that H(b|a) is proportional to the residual sum of squares between the data and the fitted function. Probability distributions for H(a) are estimated by translating the first image of the series by different amounts, using the windowed sinc function, and Fourier interpolation. This allows an estimate to be made for the a priori distribution of the errors.
A button has been added for correcting fMRI time series data for the differences in image acquisition time between slices. It is based on ACQCORRECT by Mark D'Exposito, Geof Aquirre and Eric Zarahn at U. Penn which was modified (to NMH_ACQCORRECT) by Darren Gitelman at Northwestern U and in turn modified by Rick Henson and Christian Buechel and John Ashburner at the FIL.
Note that there is nothing at all spatial about this procedure! It is included here because it is an optional pre-processing step that should improve results - especially for event related studies.
An error with the a priori probability images has been fixed (see Problem with Templates and Probability Images).
Segmentation now includes a bias correction, but extensive evaluation of this has not been performed. The theory for the bias correction was described by a poster at HBM'98: J. Ashburner and K. J. Friston (1998). "MRI Sensitivity Correction and Tissue Classification". NeuroImage 7(4):S107. The basic partitioning algorithm is described in: Ashburner and Friston (1997), NeuroImage 6(3):209-217.
Inter-modality registration is normally a three step procedure. The
first step involves simultaneous constrained affine registration of the
images to a template. The affine registration in this step is now more
stable because it has been regularized as described in:
J. Ashburner, P. Neelin, D. L. Collins, A. C. Evans and K. J. Friston
(1997). "Incorporating Prior Knowledge into Image Registration".
New templates have been developed for this stage, including an EPI
template for T2* fMRI. The new templates are described in
The second step is segmentation, which has been improved by having more correct images of prior probability. Other tweeks have also been done in order to improve the results slightly. For example, better PET/MR registration is possible when the CSF partition is not used. The method is described and evaluated on a small dataset in: J. Ashburner and K. J. Friston (1997). "Multimodal Image Coregistration and Partitioning - a Unified Framework". NeuroImage 6(3):209-217
The estimation of spatial normalization parameters consists of two parts: affine registration and basis function registration. The affine registration has been made more robust by placing it within a Bayesian framework. Zooms and shears from a large number of different brains provide knowledge of the a priori variability of brain sizes. The full method is described in: J. Ashburner, P. Neelin, D. L. Collins, A. C. Evans and K. J. Friston (1997). "Incorporating Prior Knowledge into Image Registration". NeuroImage 6:344-352.
The basis function registration is now more stable. Part of the problem was because of edge effects due to the smoothing (because values outside the FOV are unknown). Voxels less than 8mm from the edge are now used in the intensity matching. The regularization has been increased in order to improve stability. Improved estimates of the likelihood potential have been made by considering the image smoothness when estimating the degrees of freedom. A bug was found in SPM96 in the computation of the rate of change of the cost function with respect to changes in the parameters. This occured because the gradient computation was based on the gradient computation code from SPM95 (which was also slightly wrong). It has subsequently been fixed.
In principle, the spatial normalization can fit an image to a linear combination of templates. This didn't work in SPM96, but has now been fixed. An error with the templates has also been remedied (see Problem with Templates and Probability Images).
Weighting images can now be used to mask out regions of the images not to be included in the computations. Use of a weighting image to mask out the effects of scalp is described briefly in: J. Ashburner, C. Hutton, R.S.J. Frackowiak, I. Johnsrude, C. Price and K. J. Friston (1998). "Identifying Global Anatomical Differences: Deformation-Based Morphometry". Human Brain Mapping 6(5):348-357 A weighting image can also be used to mask out strokes, tumours etc.
Graphical display of spatially normalized images is improved - (see Check Reg)
New templates for spatial normalization are included with this release.
The basis function spatial normalization is described in: J. Ashburner and K. J. Friston (submitted). "Nonlinear Spatial Normalization using Basis Functions". Human Brain Mapping
A utility has been added that will take grey and white matter segments (from Segment) and clean them up to produce an extracted brain. This will also produce optional rendering images that can be used by the Render button.
Rendering can now display up to three sets of blobs. Each pattern of blobs is displayed in red, green or blue in a semi-transparent brain. The intensity of voxels inside brain decays exponentially with distance. Extra pre-defined rendering images have been included. There is a higher resolution image of a single subject brain, and also a smooth average brain surface (which I prefer because it is not as misleading). Other brain surfaces can also be used (see Brain Extraction) below.
Allows orthogonal sections through any pair of registered images to be displayed. Clicking anywhere in one of the images shifts the centre of the orthogonal sections (see Display). Intended for checking registration and spatial normalization results.
The display utility has been re-written to be an interactive orthogonal image viewer (see Check Reg). It allows images to be viewed in different orientations and to be re-oriented via their ".mat" files. The images can be zoomed and visualized using different interpolation methods. Translucent activation blobs can be superimposed in different colours on the displayed image.
A problem was identified in the conversion of the original MINC files to Analyze format. When the files were converted, we did not realize that all planes in the volumes were scaled to their own maximum values. The affected files were:
The error has been remedied. Also, new gray, white and csf images have
been obtained from Montreal that are based upon 151 subjects (see
templates.man). New template images are now included that are mostly
based on 152 brain averages (see