By members and collaborators of the Functional Imaging Laboratory
SPM99 is very old now. Consider usingSPM12. If you really want SPM99, then:
The software is available for download, but we ask you to complete a briefregistration form prior to downloading. Having completed the form, you will be directed to the download location, via akeyword
enabled URL. You should also periodically check theSPM99 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 mustregister 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: <spm@fil.ion.ucl.ac.uk>. Peculiarities, feedback, and general queries on the use and theory of the software should be raised on theEmail list.
Bugs and fixes will be posted on the list, and described in theREADME.txt file in theSPM99_updates anonymous download area, athttp://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 promotecollaboration and a common analysis scheme across laboratories. The softwarerepresents the implementation of the theoretical concepts of StatisticalParametric Mapping in a complete analysis package.
SPM (being the collection of files given in the manifest in theContents.m
file included with each distribution) is free but copyright software, distributed under theterms of the GNU General Public Licence as published by the FreeSoftware Foundation (either version 2, as given in filespm_LICENCE.man
, orat your option, any later version). Further details on "copyleft" canbe found athttp://www.gnu.org/copyleft/. In particular, SPM issupplied as is. No formal support or maintenance is provided orimplied.
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 SPMEmail list <spm@jiscmail.ac.uk> 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.sh
is 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.man
in the distribution], or "Imageformat" below. SPM can also read MINC & ECAT-7 images.Before attempting to analyze data using SPM, we recommend you spend some timereading. It is essential to understand the concepts of Statistical ParametricMapping in order to effectively use the software as a research tool. You shouldbegin 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 typingspm at the MatLab prompt. (If thespm.m
fuction is not found, make sure the SPM distribution is on your MATLABPATH. Typepath
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 fromscratch, then it might be worth using the SPMemaildiscussion list to contact fellow SPM'ers in your locality.
Derived fromspm_format.man
v1.2. Check thespm_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 ofANALYZE-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 seehttp://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 theTalairach 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 thatadopted 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:
spm_type.m
v1.1*.img
{in bytes}If*.hdr
does not exist then default values are assumed.Default values can be changed by selecting 'defaults'.*.hdr
can becreated (and can be edited) using the 'Display' facility, or manually usingspm_hwrite.m
The 'Display' facility also includes a 'Fix header' module that allowsmultiple header files to be created and ammended interactively. It isimportant that these header files are correct. The most common problemswith using SPM usually reduce to incomplete or incorrect header files.
*.mat
' fileThis 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 inmillimeters (x1,y1,z1). By default, the the new coordinate system is derivedfrom the `origin' and `vox' fields of the image header.
Assuming that image1 has a transformation matrix M1, and image2 has atransformation matrix M2, the mapping from image1 to image2 is: M2\M1 (ie. fromthe coordinate system of image1 into millimeters, followed by a mapping frommillimeters into the space of image2).
These `.mat' files allow several realignment or coregistration steps to becombined into a single operation (without the necessity of resampling the imagesseveral times). The `.mat' files are also used by the spatial normalisationmodule.
SPM is a collection of files that are used by MatLab. These filesinclude:
spm_*.m files
spm_*.c
spm_*.mex4
,spm_*.mexsol
). Theseroutines implement memory mapping and numerical operations that are calledfrequently. Precompiled Mex files are provided for Solaris2.x, a Makefile(spm_MAKE
) is included for other platforms.spm_*.man
*.mat
Where possible the user interface and computational or analytical aspects ofthe software have been segregated such thatspm_*_ui.m
sets up theuser interface and assembles the appropriate input arguments forspm_*.m
. Thespm_*.m
contain the statistical andmathematical implementation of a generic nature, and would be of greaterinterest to those who wish to incorporate SPM into an existing package.
This section describes features of SPM'99, and is derived fromspm.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:spm_vol.m
,spm_get_space.m
,spm_create_vol.m
andspm_write_plane.m
.
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 lieoutside the field of view of the original image. The parameterestimates in the SPM96 implementation assumed that the values of suchvoxels should be zero. In SPM99, these voxels are excluded from thecomputation of motion estimates.
The sinc interpolation has changed. In the previous version, the widthof the hanning window was 1 pixel narrower than the optimal width. Thishas been fixed. Also, the integral under the sinc kernal has been setto one (by a renormalizing step). Both odd and even numbers ofneighbours can now be used by the interpolation. Windowed sincinterpolation schemes are acheived by passing a negative hold tofunctions such as spm_sample_vol. Positive holds will result inpolynomial (Lagrange) interpolation being used, whereas negative holdsuse sinc interpolation. The gradient of the images can also be directlyobtained by spm_sample_vol.
A three dimensional Fourier interpolation has been implemented that isbased on the paper by Eddy et al. This method is used for resamplingfMRI data, but it requires the voxel sizes of the images to all beisotropic (since zooming can not be performed using this method).Preliminary tests showed that this method did not greatly reduce theresampling errors.
The fMRI adjustment has been modified.
Rather than removing signal that is correlated to functions of the sixparameters describing the rigid body movement of the subject, theadjustment now uses functions that are dependant upon the displacementof each voxel. This requires three parameters to describe it ratherthan six, but it is now a different function for each voxel. Thefunctions that are covaried from the data are periodic in terms of thenumber of voxels displaced, and are based upon sines and cosines of thenumber of voxels displaced. e.g., the functions for a displacement oftwo voxels are identical to the functions for a displacement of onevoxel. The functions were appropriate for simulated data, and withphantom data that was "moved" by moving the field of view of thescanner. However, the method is not quite so good for real subjectmovement 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, wewish to find the suitable values for (a) which maximize the posterioriprobability of (a) given (b). Taking the Gibb's transform of thesefunctions gives us:
H(a|b) = H(b|a) + H(a) + c
which expresses the Bayesian furmulation in terms of energy costfunctions. The objective is now to find the coefficients that minimizethe cost function. The model assumes that the errors on (b) arenormally distributed, and that H(b|a) is proportional to the residualsum of squares between the data and the fitted function. Probabilitydistributions for H(a) are estimated by translating the first image ofthe series by different amounts, using the windowed sinc function, andFourier interpolation. This allows an estimate to be made for the apriori distribution of the errors.
A button has been added for correcting fMRI time series data for thedifferences in image acquisition time between slices. It is based onACQCORRECT by Mark D'Exposito, Geof Aquirre and Eric Zarahn at U. Pennwhich was modified (to NMH_ACQCORRECT) by Darren Gitelman atNorthwestern U and in turn modified by Rick Henson and Christian Buecheland John Ashburner at the FIL.
Note that there is nothing at all spatial about this procedure! It isincluded here because it is an optional pre-processing step that shouldimprove results - especially for event related studies.
An error with the a priori probability images has been fixed (seeProblem with Templates and Probability Images).
Segmentation now includes a bias correction, but extensive evaluationof this has not been performed. The theory for the bias correction wasdescribed by a poster at HBM'98:J. Ashburner and K. J. Friston (1998). "MRI Sensitivity Correction andTissue Classification".NeuroImage7(4):S107.The basic partitioning algorithm is described in:Ashburner and Friston (1997),NeuroImage6(3):209-217.
Inter-modality registration is normally a three step procedure. Thefirst step involves simultaneous constrained affine registration of theimages to a template. The affine registration in this step is now morestable 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".NeuroImage6:344-352.New templates have been developed for this stage, including an EPItemplate for T2* fMRI. The new templates are described intemplates.man
.
The second step is segmentation, which has been improved by having morecorrect images of prior probability. Other tweeks have also been donein order to improve the results slightly. For example, better PET/MRregistration is possible when the CSF partition is not used. The methodis described and evaluated on a small dataset in:J. Ashburner and K. J. Friston (1997). "Multimodal Image Coregistrationand Partitioning - a Unified Framework".NeuroImage6(3):209-217
The estimation of spatial normalization parameters consists of twoparts: affine registration and basis function registration. The affineregistration has been made more robust by placing it within a Bayesianframework. Zooms and shears from a large number of different brainsprovide knowledge of the a priori variability of brain sizes. The fullmethod is described in:J. Ashburner, P. Neelin, D. L. Collins, A. C. Evans and K. J. Friston(1997). "Incorporating Prior Knowledge into Image Registration".NeuroImage6:344-352.
The basis function registration is now more stable. Part of theproblem was because of edge effects due to the smoothing (becausevalues outside the FOV are unknown). Voxels less than 8mm from theedge are now used in the intensity matching. The regularization hasbeen increased in order to improve stability. Improved estimates ofthe likelihood potential have been made by considering the imagesmoothness when estimating the degrees of freedom. A bug was found inSPM96 in the computation of the rate of change of the cost functionwith respect to changes in the parameters. This occured because thegradient computation was based on the gradient computation code fromSPM95 (which was also slightly wrong). It has subsequently been fixed.
In principle, the spatial normalization can fit an image to a linearcombination of templates. This didn't work in SPM96, but has now beenfixed. An error with the templates has also been remedied (see Problemwith Templates and Probability Images).
Weighting images can now be used to mask out regions of the images notto be included in the computations. Use of a weighting image to maskout the effects of scalp is described briefly in:J. Ashburner, C. Hutton, R.S.J. Frackowiak, I. Johnsrude, C. Price andK. J. Friston (1998). "Identifying Global Anatomical Differences:Deformation-Based Morphometry".Human Brain Mapping6(5):348-357A weighting image can also be used to mask out strokes, tumours etc.
Graphical display of spatially normalized images is improved - (seeCheck 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 SpatialNormalization 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. Thiswill also produce optional rendering images that can be used by theRender button.
Rendering can now display up to three sets of blobs. Each pattern ofblobs 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 ahigher resolution image of a single subject brain, and also a smoothaverage 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 bedisplayed. Clicking anywhere in one of the images shifts the centre ofthe orthogonal sections (see Display). Intended for checkingregistration and spatial normalization results.
The display utility has been re-written to be an interactive orthogonalimage viewer (see Check Reg). It allows images to be viewed in differentorientations and to be re-oriented via their ".mat" files. The imagescan be zoomed and visualized using different interpolation methods.Translucent activation blobs can be superimposed in different colours onthe displayed image.
A problem was identified in the conversion of the original MINC files toAnalyze format. When the files were converted, we did not realize thatall 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 havebeen obtained from Montreal that are based upon 151 subjects (seetemplates.man). New template images are now included that are mostlybased on 152 brain averages (seespm_templates.man
).
In construction...