Correct Order for Dimensions in the Volume Anatomies

In general, if you want to check whether your volumes have the right orientation, try to load it into mlrVol. The instructions here are a bit out-of-date and specific to volume anatomies from Center for Brain Imaging at NYU and can be ignored by other users.

[Please Note: this should not be relevant for most users. It is only relevant for those who want to align across subjects, using the Talairach transformation. The script that calculates the transformation requires a particular order for the dimensions.].


There are 3 dimensions to any volume anatomy : L-R, P-A, I-S (left to right; posterior to anterior; inferior to superior). Our standard is for them to be saved in that order. This order is called 'LPI'.

To be specific, the data matrix (M(x,y,z)) that contains the values that make up the volume anatomy, should:

1) Have dimensionality 176 x 256 x 256

2) The first dimension (x) should move through the anatomy from left to right

3) The second dimension (y) should move through the anatomy from back to front

4) The third dimension (z) should move through the anatomy from bottom to top

How to check your volume anatomy

To check your volume anatomy, you will load it using cbiReadNifti, and then view one slice at a time from each dimension.

1: Load it

First, load it into matlab:

[d, h] = cbiReadNifti('Your3DAnatomy.hdr');

Check the dimension sizes of d. d should be 176 x 256 x 256. I usually do this by using the command


2: Visually examine it

You want to look at a slice through each dimension in order:

figure(1), imagesc(squeeze(45,:,:)));
figure(2), imagesc(squeeze(:,70,:)));
figure(3), imagesc(squeeze(:,:,70)));

Figure 1 should be sagittal, with the top of the head on the right, nose down;

Figure 2 should be coronal, with the top of the head on the right, moving from L to R;

Figure 3 should be axial, with the nose to the right, moving from bottom to top

For example, they should look something like this:

Figure 1

Figure 2

Figure 3

3: Change things around

If your volume does not match the volume shown here, you will need to use the Matlab functions for swapping dimensions. Some helpful functions are fliplr, flipud, permute, transpose

4: Save your changes

Once you have it right, copy the Q-form and S-form from a correct volume header.

Replace your current Q form and S form, using cbiSetNiftiQform and cbiSetNiftiSform.

goodQform = [0.9994   -0.0349    0.0000  -81.5687;
  0.0349    0.9994    0.0000 -131.4221;
 -0.0000   -0.0000    1.0000 -132.7831;
       0         0         0    1.0000]

goodSform = goodQform;

% (you have already loaded the original header file (h) in the first step, so I won't repeat it.)
h = cbiSetNiftiQform(h,goodQform);
h = cbiSetNiftiSform(h,goodSform);

[b h] = cbiWriteNifti('Your3DAnatomy.hdr', d, h);
[IMPORTANT NOTE: you will have to redo any alignments that were based on this volume.]

5: Check that it's correct

It's always a good idea to start over with this volume, follow the steps above, and make sure it all looks right

Click here to return to the step by step instructions.