Introduction

Neuroimaging data is typically written to memory or storage as a flattened 4-dimensional array. This is true of popular data formats such as Analyze and AFNI's image formats. For example, in an image file consisting of binary data a point (x1,x2,x3,x4) would be stored at offset

x1 + x2*w1 + x3*w1*w2 + x4*w1*w2*w3
where the wi are the spatial dimensions of the data.

However, this layout depends on some choices. In particular, it depends on how the coordinate axes are assigned to the space/time dimensions. The total number of ways spatial dimensions can be assigned is 48: there are 6 possible permutations of the co-ordinate axes, and 2*2*2 = 8 orientations for each coordinate axis. Of these 48 orientations, half of them are right-handed and half of them are left-handed. Though it may seem tempting to discard the left-handed orientations, the Analyze image format specification uses a left-handed coordinate system, so excluding left-handed spatial orientations is impractical.

Another issue to be addressed is the time dimension. In particular, it is possible to map the time dimension to the first coordinate, and the spatial dimensions to the second, third and fourth coordinates, but it is also possible to map the time dimension to the fourth coordinate and the spatial dimensions to the first three co-ordinates. It is reasonable to assume that no-one would want to map the time dimension to the second or third coordinates. We also assume that time points are not in reverse order (ie we make an assumption about the orientation of the time coordinate axis) Most neuroimaging formats map time to the fourth coordinate (we will subsequently call this xyzt coordinates as opposed to txyz). This is in a way unsurprising, because the "intuitive" way to think of the data is as a series of 3-dimensional volumes with points described as (x,y,z,t). But it is also a performance liability. Most traditional algorithms used to process data, such as the general linear model, process each pixel seperately. Caching strategies are much more likely to be efficient if pixels that need to be loaded at a given time are at nearby points in a file.

A Scheme For Representing Orientation

We present a scheme for representing 96 possible choices of coordinates -- the 48 possible choices of spatial coordinates, and a choice between xyzt and txyzt ordering. In particular, we describe a means to assign to any space-time orientation a unique integer. The integer contains the following information:

The fields above are presented in increasing orders of significance. So the information can be stored in an 8 bit integer using this scheme. We now describe the fields in more depth.

Directions of Coordinate Axes

This is a 3 bit field. The bits are determined as possible:

For example, in the Analyze co-ordinate system, the least significant bit has a value of 1, the middle bit has a value of 0, and the most significant bit has a value of 1. So the value of this bit field is 5. In what the author believes to be the most intuitive system, where the observer is facing the patient, the x axis points to the patient's right (hence the observers left), the y axis points to the back of the patient (the front of the observer) and the z axis points from foot to head, the value of this field is 7 (note: this is the same as the Analyze except that the y axis points to the back of the patient. This results in a right-handed coordinate system, whereas analyze coordinates are left-handed.). If we were to adopt the patient's point of view and reverse the directions of the x and y azes, the value would be 4.

The table below summarises. LR denotes left to right ordering (again, from the patient's frame of reference!), RL denotes right to left. Similarly, for HF/FH (foot and head), BR/RB (back and front).
sagcoraxvalue
LR BFHF 0
RL BFHF 1
LR FBHF 2
RL FBHF 3
LR BFFH 4
RL BFFH 5
LR FBFH 6
RL FBFH 7

Permutation of Coordinate Axes

The second bit field consists of 3 bits. The least significant bit has a value of 1 if and only if the perpendicular to the sagital plane is not the first spatial coordinate. The middle bit has a value of 1 if and only if the perpendicular to the sagital plane is not the second spatial coordinate. Note that at least one of the least significant and middle bits is non-zero! The most significant bit has a value of 1 if and only if the perpendicular to the coronal plane precedes the perpendicular to the axial plane. Here is a summary table. Note that S, C and A respectively denote perpendiculars to the sagital, coronal and axial planes.
ASC 1
SAC 2
ACS 3
CSA 5
SCA 6
CAS 7

Note that by far the most popular choice of permutation is the one assigned the number 6, where the XY plane is the axial plane, and the X axis is at right angles to the sagital plane. This is the permutation used by analyze and also the permutation preferred by the author.

The Time Axis

This field has a value of 1 if xyzt order is used, 0 otherwise.

Putting It Together

The above fields were presented in increasing order of significance. So if the axis direction is a, permutation field is b and the xyzt field is c, the magic number is given by

a + 8b + 64c
So for example in Analyze format, a is 5, b is 6, and c is 0. So the number is 53. In the authors preferred order, a is 7, b is 6, and c is 1, so the number is 119.