<?xml version="1.0" encoding="utf-8"?><!DOCTYPE article  PUBLIC '-//OASIS//DTD DocBook XML V4.4//EN'  'http://www.docbook.org/xml/4.4/docbookx.dtd'><article><articleinfo><title>FormatSpmAnalyze</title><revhistory><revision><revnumber>2</revnumber><date>2013-03-07 21:24:04</date><authorinitials>localhost</authorinitials><revremark>converted to 1.6 markup</revremark></revision><revision><revnumber>1</revnumber><date>2006-07-04 14:59:58</date><authorinitials>Scripting Subsystem</authorinitials></revision></revhistory></articleinfo><section><title>The SPM / Analyze data format</title><para>This page has been copied from the help system of SPM99 with the kind permission of John Ashburner. </para><section><title>Image Format</title><para>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.SPM uses the simple header and flat binary image file format of <ulink url="http://www.mayo.edu/bir/PDF/ANALYZE75.pdf">ANALYZE-7 (Mayo Clinic, Rochester, USA</ulink> ), with slight customisations to the header. </para></section><section><title>The image file.</title><para>*.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 questionThe original images which SPM uses can be in any orientation. However, after spatial normalisation, the images must be in the following orientation: </para><para>X increases from Left to Right </para><para>Y increases from Posterior to Anterior </para><para>Z increases from Inferior to Superior This is a right handed coordinate system, and is consistent with the Talairach atlas. </para><para>In order to sucessfully spatially normalise the images, SPM must be able to determine the initial orientation of the images. The global variable &quot;sptl_Ornt&quot; contains this orientation. This is initially set from the file &quot;spm_defaults.m&quot;. This can however be changed from within SPM (for the duration of the SPM session) using the `Defaults' button. For instance, left-right (radiological v neurological) orientations can easily be specified. </para></section><section><title>The header file.</title><para>*.hdr: The format of the 348 byte header file is that adopted by ANALYZE (<ulink url="http://www.mayo.edu/bir/PDF/ANALYZE75.pdf"/>). The fields that are necessary in the context of SPM include: </para><informaltable><tgroup cols="2"><colspec colname="col_0"/><colspec colname="col_1"/><tbody><row rowsep="1"><entry colsep="1" rowsep="1"><para><emphasis role="strong">Field</emphasis></para></entry><entry colsep="1" rowsep="1"><para><emphasis role="strong"> [SPM default global variable] </emphasis></para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para>image size {in voxels for x, y and z}</para></entry><entry colsep="1" rowsep="1"><para> [DIM] </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para>voxel size {in mm for x, y and z}</para></entry><entry colsep="1" rowsep="1"><para> [VOX] </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para>data type {see spm_type.m}</para></entry><entry colsep="1" rowsep="1"><para> [TYPE] </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para>a scaling coefficient {applied during memory mapping}</para></entry><entry colsep="1" rowsep="1"><para> [SCALE] </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para>offset of voxel values in *.img {in bytes}</para></entry><entry colsep="1" rowsep="1"><para> [OFFSET] </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para>the origin {(x,y,z) in voxels} {e.g. the anterior commissure}</para></entry><entry colsep="1" rowsep="1"><para> [ORIGIN] </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para>description {a short string}</para></entry><entry colsep="1" rowsep="1"><para> [DESCRIP] </para></entry></row></tbody></tgroup></informaltable><para>If *.hdr does not exist then the default values are assumed. Default values can be changed by selecting 'defaults'. *.hdr can be created (and can be edited) using the 'Display' facility. </para><para>It is important that these header files are correct. The most common problems with using SPM usually reduce to incomplete or incorrect header files. </para><para><anchor id="matfile"/> </para></section><section><title>The `.mat' file.</title><para>This simply contains a 4x4 affine transformation matrix in a variable <code>M'. These files are normally generated by the </code>realignment' and <code>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 </code>origin' and `vox' fields of the image header.x1 = M(1,1)*x0 + M(1,2)*y0 + M(1,3)*z0 + M(1,4) </para><para>y1 = M(2,1)*x0 + M(2,2)*y0 + M(2,3)*z0 + M(2,4) </para><para>z1 = M(3,1)*x0 + M(3,2)*y0 + M(3,3)*z0 + M(3,4) </para><para>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). </para><para>These <code>.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 </code>.mat' files are also used by the spatial normalisation module. </para><!--rule (<hr>) is not applicable to DocBook--><para> Copied from (#)spm_format.man 2.1 John Ashburner 99/05/16 </para><!--rule (<hr>) is not applicable to DocBook--></section></section></article>