The Analyze data format
This page gives some information and links about the the Analyze image data format. Analyze images are the primary image format used in SPM up to version SPM2. SPM5 uses FormatNifti. SPM also uses some extensions to the basic format, which are described below.
What is Analyze?
Analyze is an image processing program, written by The Biomedical Imaging Resource at the Mayo Foundation. The Analyze data format is used by the Analyze program, and now by a wide variety of other software, including SPM.
The basic Analyze (7.5) format
There are two Analyze formats. One, by much the more common, is Analyze 7.5. This is the format used by SPM, and discussed on this page. The other is Analyze AVW, the format used in the latest version of the Analyze program. We won't discuss AVW format any further, as it not used by many programs other than Analyze AVW itself. An Analyze (7.5) format image consists of two files, and image and a header file. If the image is for example named "brain", then the files for that image will be called "brain.img" and "brain.hdr". The .img file contains the numbers that make up the information in the image. The .hdr file contains information about the img file, such as the volume represented by each number in the image (voxel size) and the number of pixels in the X, Y and Z directions. This header contains fields of text, floating point, integer and other information.
The SPM99 help system describes the SPM / Analyze image format - see an html version of the SPM99 help on image format.
These links also describe the Analyze format in more detail:
SPM/FIL description of format (this is a less detailed description that the SPM99 help system provides - see above). However, note that the SPM version of the Analyze format uses a couple of the header fields in an unconventional way (see below)
SPM modifications of the basic analyze format
SPM uses the basic Analyze 7.5 format, but with three modifications / extensions. These are:
SPM extends the Analyze format by using a scaling factor for the image from the header. The purpose of the scale factor is to allow values in images that cannot be stored using the data type of the .img file. For example, with an 8 bit image (.img file), all the values in the file have to be between 0 and 255. SPM extends this, by using the scale factor to 'scale' the values in the img file. Thus, to get actual voxel values for the image, you read in the numbers from the .img file (0-255 in an 8 bit image), then multiply these values by the value from the scale factor, from the header.
The field in the header that SPM uses for the scale factor is image_dimension.funused1 (see the header field definitions at the Mayo/Analyze site ).
The scale factor is useful if the voxel values in the individual images have meaning either relative to other images, or in some physiological sense. For example, water activation PET images may have voxel values in counts per voxel per second, and binding maps calculated for ligands may be physiological values. These numbers are unlikely to range from 0-255 (which is the range of an image with values stored in 8 bit), but can be rescaled to this range by using the scale factor. An alternative would be floating point images, but these are a) larger and b) not displayable in the earlier (pre AVW) versions of Analyze.
Voxel coordinates of image origin
SPM uses one of the Analyze header fields in an unorthodox way. This is the Originator field (data_history.originator - see Mayo/Analyze site ). In the basic format, this is meant to be 10 bytes of text. In SPM, this space is used to contain three short (two byte) integers. These numbers describe the current centre or 'Origin' of the image. Specifically, they give the coordinate of the central voxel, in voxels, in X, then Y then Z. For example, for images that are aligned to the templates, this Origin field would contain the coordinates of the voxel nearest to the midline of the Anterior Commisure. Note that if the Origin is set to 0 0 0, then SPM routines will assume that the origin is in fact the central voxel of the image.
The .mat file
This is an addition to the Analyze format. It is another file to add to the imagename.hdr / imagename.img pair - a imagename.mat file. The file is in matlab .mat file format, and contains information on the orientation of the image, generated by realignments, coregistration etc. See the SPM99 help on file format, or in rather less detail, see the SPM/FIL Analyze format description, under the heading "The *.mat file".
MatthewBrett, Chris Rorden 17/6/99