Wil Irwin prepared this document as part of his presentation for the LfAN Brain Imaging Workshop on AFNI (00-10-19).
Outline
Characteristics of Digital Images
The most common format for storing and manipulating digital images is one in which there is no embedded header and the pixel (voxel) values are stored as 16-bit integers. Aside from this general description, there are many file conventions for ordering the x, y, z and t (time) vectors of the image space.
Headers contain information about the image's space such as the number of pixels, the size of the pixels and scaling factors. The utility of a zero-byte header (no embedded header) file is that the image matrix is generic and, as long as one knows the ordering of the dimension vectors, can be read by virtually any application. With such file formats ?header information? is stored in a separate file, a header file. Header files come in many flavors and are more-or-less application and/or format specific. For example, the ANALYZE image format consists of an image file with a ?.img? extension and a header file with a ?.hdr? extension.
For our purposes, there are two important results from image data being stored as 16-bit integers. The computational unit of a ?byte? is comprised of 8 bits, where each of the 8 bits, indexed 0 7, is the exponent of 2n . Thus, real-world numbers are stored as combinations of bits being on (1) or off (0) as exemplified in Table 1.
2^0=1 | 2^1=2 | 2^2=4 | 2^3=8 | 2^4=16 | 2^5=32 | 2^6=64 | 2^7=128 | Value |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 49 |
1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 255 |
Note that the maximum value than can be stored with 8-bit (one byte) integers is 255 (often indexed at 1 256). This maximum increases to 32767 (or 1-32768) with 16-bit (2 bytes) integers. The maximum value is the reason that appropriate scaling must be applied during image reconstruction as any pixel (voxel) value that is transformed from k--space to image space with a value greater than 32768 will be scaled to fit within the 0-32767 range. Furthermore, a scaling factor must be applied to data that has some actual calibrated or quantitative value, such as PET data, SPM results, etc.
With the knowledge of how the image is stored (i.e., 16-bit integers), the nature of the header (i.e., the size) and the image acquisition parameters we can always confirm the structure and size of images files. This is useful for both troubleshooting and file manipulation. Consider the following example for Echo-planar timeseries data reconstructed off-line:
Header | 0-byte header (when files are written in *.sdt |
Format | 16-bit integer |
Image matrix | x = 64, y = 64 |
Slice | z = 23, orderd posterior-anterior |
Repetitions | 186 images/slice |
With this information we can calculate the file size in bytes,
64 (x dimension) x 64 (y dimension) x 23 (z dimension) x 186 (t dimension) x 2 (2 bytes per pixel)= 35,045,376 bytes
which is confirmed by the file listing:
-rw-rw-rw- 1 lab 35045376 Oct 17 1997 negative-nh.sdt
With reference to Table 2 (and file format specifications described in the various application documentation), we have all of the necessary information for fully describing and manipulating our image data.
File Type | Source | Matrix | Image Header | Header | Orientation | Datum |
I.### | GE reconstruction | x, y | 7904 bytes | Embedded | Acquisition dependent | 16-bit integer |
I.###.s# | Functional NeuroImaging (FNI) | x, y | 80 bytes The files are only (readily) readable by XV version 2.x |
None | Acquisition dependent | 16-bit integer |
*.sdt | epirecon, generate_sdt, merge_sdt | x, y, z, t | 0-byte header (none) | *.spr | Acquisition dependent | 16-bit integer (can be 8-bit or floats) |
*.img | split_sdt, SPAMALIZE, AIR, SPM, ANALYZE | x, z, y, (t) | 0-byte header | *.hdr | ANALYZE convention | 16-bit integer (can be 8-bit or floats) |
*.BRIK | AFNI | x, y, z, t | 0-byte header | *.HEAD | Acquisition dependent | 16-bit integer (can be 8-bit or floats) |
P*.# | GE console | k-space complex | 85552176 byte header (under Lightning) | Embedded | k-space complex | 16-bit integer |
It is often helpful (if not requisite) to verify the contents of header files. Table 3 lists the tools available to do so. Non-embedded headers are easily modifiable; use care when doing so.
File Type | Source | Header | Header Viewer |
I.### | GE MRI reconstruction | Embedded | read_ge_header_Lx |
*.sdt | EPI reconstruction, generate_sdt | *.spr | Any text editor |
*.img | ANALYZE, also split_sdt, SPAMALIZE, AIR, SPM |
*.hdr | Header utilities in SPAMALIZE or AIR; ?DISPLAY? utility in SPM |
*.BRIK | AFNI | *.HEAD | Any text editor |
P*.# | GE MRI console | Embedded | read_raw_header_Lx |
With respect to AFNI, the header files are very verbose and contain a number of variables which are not necessarily self-evident. The utility ?3dinfo? reads out a general summary of the header content based on an input file. The following examples generate self-explanatory header summaries based on the data located in:
/exp/training/T1_T2_Anatomy/AFNI.
Example 1:
irwin @ LAN104 111: 3dinfo T1_SPGR+orig.BRIK
Dataset File: T1_SPGR+orig
Identifier Code: MCW_FTBMZFOAHDS Creation Date: Thu Oct 19 08:29:10 2000
Dataset Type: Spoiled GRASS (-spgr)
Byte Order: MSB_FIRST [this CPU native = MSB_FIRST]
Data Axes Orientation:
first (x) = Right-to-Left
second (y) = Anterior-to-Posterior
third (z) = Inferior-to-Superior [-orient RAI]
R-to-L extent: -119.531 [R] -to- 119.531 [L] -step- 0.938 mm [256 voxels]
A-to-P extent: -119.531 [A] -to- 119.531 [P] -step- 0.938 mm [256 voxels]
I-to-S extent: -86.600 [I] -to- 61.000 [S] -step- 1.200 mm [124 voxels]
Number of values stored at each pixel = 1
-- At sub-brick #0 '#0' datum type is short: 0 to 558
Example 2:
irwin @ LAN104 113: 3dinfo T2_SPGR+orig.BRIK
Dataset File: T2_SPGR+orig
Identifier Code: MCW_EJOPZAIEYBR Creation Date: Thu Oct 19 08:36:18 2000
Dataset Type: Spoiled GRASS (-spgr)
Byte Order: MSB_FIRST [this CPU native = MSB_FIRST]
Data Axes Orientation:
first (x) = Right-to-Left
second (y) = Anterior-to-Posterior
third (z) = Inferior-to-Superior [-orient RAI]
R-to-L extent: -119.531 [R] -to- 119.531 [L] -step- 0.938 mm [256 voxels]
A-to-P extent: -119.531 [A] -to- 119.531 [P] -step- 0.938 mm [256 voxels]
I-to-S extent: -85.400 [I] -to- 61.600 [S] -step- 1.500 mm [ 99 voxels]
Number of values stored at each pixel = 1
-- At sub-brick #0 '#0' datum type is short: 0 to 1656
With the above information in mind, there exist tools and scripts available for converting, in these examples, GE reconstructed images typically acquired as 3D-SPGR and related anatomical acquisitions. In addition to the information contained in format-specific headers, additional information about the acquisition is needed. This can be found either on the MR protocol sheet or the exam README file. The examples below demonstrate how to convert image files reconstructed on-line from the GE proprietary format for a 3D-SPGR (T1-weighted) and whole-brain T2-weighted acquisitions. The details of these acquisitions are not discussed here, but are detailed on the MR protocol. The examples assume the data have already been transferred from the scanner console to some local workspace.
Example 1:
irwin @ LAN104 121: pwd
/exp/training/T1_T2_Anatomy/T1_raw
[A listing of this directory will reveal 124 I.xxx files.]
irwin @ LAN104 136: /fmri1/fmriapps/mk_whole_brain
*************************************************************************
This script will put GE whole-brain image
files into the ANFI 3D BRIK format.
IT IS ASSUMED THAT THE ACQUISITION WAS A ?STANDARD?
INFERIOR-SUPERIOR AXIAL IN A 24 x 24 FIELD OF VIEW.
*************************************************************************
Directory containing the GE image files [/da/exp/training/T1_T2_Anatomy/T1_raw]:
/da/exp/training/T1_T2_Anatomy/T1_raw
Image files are compressed. Uncompressing files now.
Is there an A/P offset [Y]? N
Enter the INFERIOR coordinate: 86.6
Enter the SUPERIOR coordinate: 61.0
Enter the exam number or alternative file name: E806_T1
to3d: 2D slices into 3D datasets for MCW AFNI, by R.W. Cox, 1996.
decoded 120R-120L to give xincode=100 bot=120.000000 top=120.000000
decoded 119.53125A-119.53125P to give yincode=203 bot=119.531250 top=119.531250
decoded 86.6I-61.0S to give zincode=204 bot=86.599998 top=61.000000
Reading images: 123456789012
3D dataset written to disk
E806_whole_brain+orig+BRIK has been saved in:
/da/exp/training/T1_T2_Anatomy/AFNI
Compressing image files.
Example 2:
irwin @ LAN104 121: pwd
/exp/training/T1_T2_Anatomy/T1_raw
[A listing of this directory will reveal 99 I.xxx files.]
irwin @ LAN104 169: /fmri1/fmriapps/mk_whole_brain
*************************************************************************
This script will put GE whole-brain image
files into the ANFI 3D BRIK format.
IT IS ASSUMED THAT THE ACQUISITION WAS A ?STANDARD?
INFERIOR-SUPERIOR AXIAL IN A 24 x 24 FIELD OF VIEW.
*************************************************************************
Directory containing the GE image files [/da/exp/training/T1_T2_Anatomy/T2_raw]:
/da/exp/training/T1_T2_Anatomy/T2_raw
Image files are compressed. Uncompressing files now.
Is there an A/P offset [Y]? N
Enter the INFERIOR coordinate: 85.4
Enter the SUPERIOR coordinate: 61.6
Enter the exam number or alternative file name: E806_T2
to3d: 2D slices into 3D datasets for MCW AFNI, by R.W. Cox, 1996.
decoded 120R-120L to give xincode=100 bot=120.000000 top=120.000000
decoded 119.53125A-119.53125P to give yincode=203 bot=119.531250 top=119.531250
decoded 85.4I-61.6S to give zincode=204 bot=85.400002 top=61.599998
Reading images: 123456789
3D dataset written to disk
E806_T2_whole_brain+orig+BRIK has been saved in:
/da/exp/training/T1_T2_Anatomy/AFNI
Compressing image files.
Landmark Identification & Talairach Transformation in AFNI
The following is not meant to serve as a comprehensive users manual for Analysis of Functional NeuroImages (AFNI); Cox, 1996; Cox & Hyde, 1997). Rather, this outlines the steps which should be followed for the accurate identification of anatomical landmarks and subsequent transformation into the Talairach and Tournoux (1988) coordinate system. Before attempting to use AFNI for this purpose, the user should thoroughly read pages 1-18 of the Talairach & Tournoux atlas.
It is important to underscore that the approach to stereotaxic normalization implemented in AFNI is:
This approach is decidedly different that that of, for example SPM, were an algorithm automatically matches the user?s data to a canonical template.
General User Notes
Notes About Cortical Landmarks
See http://psyphz.psych.wisc.edu/~irwin/cortical.html for a detailed discussion and annotated examples of cortical landmarks.
Most anterior point: Locate in axial and sagittal views, tissue disappears in the coronal view.
Most posterior point: Locate in axial and sagittal views, tissue disappears in the coronal view.
Most superior point: Locate in the coronal and sagittal views, tissue disappears in the axial view. This is the most difficult point to identify and you must be sure that to landmark on tissue and not the lateral fissure.
Most inferior point: Locate in the axial and coronal views, tissue disappears in the axial view. The most inferior point will be in the temporal lobes, not the cerebellum, because the cerebellum was not included in the original work by Talairach and Tournoux.
Most left point: Locate in the axial and coronal views, tissue disappears in the sagittal view.
Most right point: Locate in the axial and coronal views, tissue disappears in the sagittal view.
7. QUALITY check
Front to anterior commissure: x.xx mm (atlas 70.0 mm)
Intercommissural distance: x.xx mm (atlas 23.0 mm)
Posterior cornmissure to back:x.xx mm (atlas 79.0 mm)
Bottom to anterior commissure: x.xx mm (atlas 42.0 mm)
Anterior commissure to top: x.xx mm (atlas 74.0 mm)
Anterior commissure to left: x.xx mm (atlas 68.0 mm)
Anterior cornmissure to right:x.xx mm (atlas 68.0 mm)
8. TRANSFORM DATA
9. QUIT (twice)
Cox, R. (1996) AFNI: Software for Analysis and Visualization of Functional Magnetic Resonance Neuroimages, Computers and Biomedical Research, 29, 162-173.
Cox, R. & Hyde, J. S. (1997). Software tools for analysis and visualization of fMRI data. NMR in Biomedicine, 10, 171-178.
DeArrnond, S. J., Fusco, M. M., and Dewey, M. M. (1989). Structure of the human brain: A photographic atlas (3rd ed.). New York: Oxford University Press
Talairach, J. and Tournoux, P. (1988). Co-Planar stereotaxic atlas of the human brain. New York: Thieme Medical Publishers.