This page describes how BrainSuite handles NIfTI formatted files (

We designed BrainSuite to be fast and efficient. One way we achieve this is by having a consistent approach to how brain MRI volumes are stored in memory. Specifically, our code is designed assuming the data are stored in RAS order, which is that the data is ordered from left to right (x), then posterior to anterior (y), then inferior to superior (z). This facilitates our image registration procedure because we can assume the head is oriented in the same fashion as our reference atlases. When we read NIFTI data into BrainSuite, we reorder it in memory such that its layout is in approximate RAS order.

NIFTI provides a convenient way of describing the orientation of the data in the image file, from which we can derive an orientation matrix. When this matrix is the identity matrix, it indicates that data are stored in RAS orientation. Small tilts off axis can shift the orientation away from identity, but these are still generally tolerable by our algorithms. If the shifts are more severe, then the orientation may be closer to some other ordering, or the data may be flipped left-right. Thus, our file readers determine the permutation and flipping of the orientation matrix that will yield a near-identity matrix (i.e., one with the largest elements on the diagonal). These operations can be achieved without resampling the data, i.e., simply by reordering it. For any permutation or flipping, we update the coordinate transforms so that the world coordinate for each voxel remains the same.

When we read files, we check first for the q-form, then for the s-form. When we write files, we write an identical transform in both the q-form and s-form.

For efficiency of our various processing steps, we keep the data in RAS order when we save it. While this may differ from the original s-form or q-form matrix, the voxel positions remain the same.