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
To check your volume anatomy, you will load it using cbiReadNifti, and then view one slice at a time from each dimension.
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
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:
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
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);
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.