(Conventions gathered from e-mail with support@AnalyzeDirect.com, see above) 

hdr.hist.orient:       The slice orientation for this dataset. 

0  transverse unflipped 
      X direction first,  progressing from patient right to left, 
      Y direction second, progressing from patient posterior to anterior, 
      Z direction third,  progressing from patient inferior to superior. 
1  coronal unflipped 
      X direction first,  progressing from patient right to left, 
      Z direction second, progressing from patient inferior to superior, 
      Y direction third,  progressing from patient posterior to anterior. 
2  sagittal unflipped 
      Y direction first,  progressing from patient posterior to anterior, 
      Z direction second, progressing from patient inferior to superior, 
      X direction third,  progressing from patient right to left. 
3  transverse flipped 
      X direction first,  progressing from patient right to left, 
      Y direction second, progressing from patient anterior to posterior, 
      Z direction third,  progressing from patient inferior to superior. 
4  coronal flipped 
      X direction first,  progressing from patient right to left, 
      Z direction second, progressing from patient superior to inferior, 
      Y direction third,  progressing from patient posterior to anterior. 
5  sagittal flipped 
      Y direction first,  progressing from patient posterior to anterior, 
      Z direction second, progressing from patient superior to inferior, 
      X direction third,  progressing from patient right to left. 

Dr John Nixon comments:

For 'coronal unflipped' images on disk, the 'x' axis varies fastest
(patient right to left).  This is followed by the 'z' axis (inferior
to superior), which is then followed by the slice direction 'y'.

For 'sagittal unflipped' images on disk, the 'y' axis varies fastest
(patient posterior to anterior).  This is followed by the 'z' axis
(inferior to superior), which is then followed by the slice
direction 'x'.

The file format description (see below) does not state the order of 
array storage in the ".img" file for any of the slice orientations:

  0 - transverse unflipped
  1 - coronal unflipped
  2 - sagittal unflipped
  3 - transverse flipped
  4 - coronal flipped
  5 - sagittal flipped

Assuming the first listed above is the default (seeing as the
appropriate flag may be unknown, as the "data_history" structure in the
".hdr" file is optional), my assumption is as follows.

For a "transverse unflipped" image, the data is stored in transverse slices,
each of which is in "row order" (the natural ordering in the C programming
language).  That is, pseudo-code of the form:

	for k = 1, dim[3]
         for i = 1, dim[1]
           for j = 1, dim[2]
             READ_or_WRITE data(i,j,k)
           end
         end
	end

where "dim[]" is the dimensions of the ".img" image file, obtained from
the ".hdr" header file, and the "rightmost subscript varies the fastest"
(allowing for the fact that we read one transverse slice at a time), will
perform a READ or WRITE operation and preserve the desired ordering.


ANALYZE support reply:
The order of voxels as stored in the .img file is really independent of the
representation you may choose in code.  When you read the data from
the image file, you have the option to place it in memory in any way you
wish, including reading the non-transverse volumes in such a way that
the resulting order of representation in memory is again transverse (which
is what Analyze does).  The issue here is the order of voxels as stored in
the file itself for each of the orientation types.

For the 'transverse unflipped' type, the voxels are stored as transaxial
slices with the 'x' direction first (varies fastest), which is oriented such
that it progresses from patient right to patient left; followed by the 'y'
axis, which goes from patient posterior to anterior; followed by the
'z' axis, which is the slice direction and moves from inferior to
superior.  When data is loaded by the Analyze software, this is the
default order of voxels and anatomic orientation in the coordinate
system (left-handed coordinate system with the origin in the right,
posterior, inferior position relative to the body).

The 'transverse flipped' type simply has the 'y' axis flipped, with
voxels that move from anterior to posterior.

Note that the labels for the axes are also arbitrary here.  Only
after loading the data into memory is there a defined 3-D coordinate
system that provides a fixed reference for the orientation of anatomy.
Because of this, Analyze enforces a consistent 3-D coordinate system
for all data loaded into memory.  When non-transverse image data is
loaded, it is reordered in storage order to place it in a consistent
3-D coordinate system in memory.


From an ANALYZE 7.5 file format web page:

The coordinate system employed by the ANALYZE programs is left-handed, 
with the coordinate origin in the lower left corner. Thus, with the 
subject lying supine, the coordinate origin is on the right side of 
the body (x), at the back (y), and at the feet (z).

A major advantage of this convention is that the coordinate origin of 
each orthogonal orientation (transverse, coronal, and sagittal) lies 
in the lower left corner of the slice as it is displayed.

Orthogonal slices are numbered from one to the number of slices in 
that orientation. For example, a volume (x, y, z) dimensioned 
128, 256, 48 has: 

   48 transverse  slices numbered 1 through  48 
  128 sagittal    slices numbered 1 through 128 
  256 coronal     slices numbered 1 through 256 

Pixel coordinates are made with reference to the slice numbers from 
which the pixels come. Thus, the first pixel in the volume is 
referenced p(1,1,1) and not at p(0,0,0).

Transverse slices are in the XY plane.
Sagittal slices are in the ZY plane. 
Coronal slices are in the ZX plane. 

Origin/Order Consistency
We refer to the ANALYZE coordinate system as an origin/order system 
because it is based on an unambiguous single 3-D origin in the image 
data, and on the idea that the order of pixels in one line of a section, 
the order of lines in a section, and the order of sections in a volume 
all proceed from the origin. As shown in Figure 2, the projection of the 
origin is always displayed at the lower left of the screen, and the order 
of slices is always from the origin outward. Image data in any of these 
three orientations (if properly identified) will be correctly rendered as 
a 3D image (i.e. left-sided defects will appear on the left side of the 
3-D rendering). Flipping data in any of the three orientations about two 
axes will also result in a correctly rendered 3-D image, but the two axis 
flip will move the effective location of the origin, and the orthogonal 
sections may appear upside down or left/right reversed when displayed. 
Flipping the data about one or three axes will ruin the integrity of the 
data and cause 3-D renderings to appear mirror-reversed (i.e. right-sided 
lesions will appear to be on the left). Mislabeling transverse data sets 
as sagittal or vice-versa will not destroy the coherence of the data, and 
renderings will be correct although the labelling of axes will be in error. 
However, mislabeling transverse or sagittal images as coronal (or vice-versa) 
will cause renderings to be mirror reversed.

The header information

hdr.dime.dim;      /* Array of the image dimensions */ 

dim[0]      Number of dimensions in database; usually 4. 
dim[1]      Image X dimension; number of pixels in an image row. 
dim[2]      Image Y dimension; number of pixel rows in slice. 
dim[3]      Volume Z dimension; number of slices in a volume. 
dim[4]      Time points; number of volumes in database.

hdr.dime.pixdim     Parallel array to dim[], 
              giving real world measurements in mm and ms. 
pixdim[0];    Pixel dimensions? 
pixdim[1];    Voxel width in mm. 
pixdim[2];    Voxel height in mm. 
pixdim[3];    Slice thickness in mm. 
pixdim[4];    timeslice in ms. 

hdr.dime.vox_units[4]    Specifies the spatial units of measure for a voxel. 
hdr.dime.roi_scale; Specifies the Region Of Interest scale? 

