Anatomical/EPI Plane Change Help


I am running into an issue with a dataset where the anatomical and EPI planes do not match-up. For example, when overlayed, the EPI’s sagital plane overlays the horizontal plane, and the data face different directions. This is likely due to the EPI being collected using spiral acquisition.

The left/right I have corrected using 3dLRflip. Is there any way to change the planes of the data? Any help would be much appreciated…


It seems likely you have the orientation wrong. This occasionally comes up with new types of acquisitions or data that has been transferred and process through other software. The data header needs to be “refit” with the correct orientation. Here is a somewhat manual procedure to handle this problem that I just wrote up for another user, so I’m posting it here:

In similarly confusing situations like this, this is what I have done. It’s a little bit of detective work to find the right orientation…, so do this, copy to afni format or use the original DICOM files.

3dcopy wonky_data.nii test_wonky

If you have output, test_wonky+orig.BRIK.gz, gunzip that file. If AFNI_COMPRESSOR is not set, then you won’t have that.

gunzip test_wonky+orig.BRIK.gz

Now use to3d to read the dataset back in with the sizes from test_wonky/wonk_data+orig / .nii (discovered with 3dinfo)

to3d '3D:0:0:192:128:56:test_wonky+orig.BRIK" (replace the 192,128,56 with the values from 3dinfo above, and be sure to use the BRIK file here.
also the 3D is for 16-bit short integer data. If bytes needs to be swapped,use 3Ds. If your data is 32-bit
float, use 3Df. See to3d’s help for other options)

In the to3d GUI, click the “View images” button in the lower right. Now fill out the orientation by using the three buttons in the upper left, noting how the data changes across the screen, down the screen and as you increase the slice number. The first letters of each direction are what AFNI uses as the orientation. If you like, you can finish filling out the form for irregular voxel sizes and save with a prefix, but you can just exit out once you have the orientation code.

Armed with the orientation, update the dataset with

3drefit -orient RAI test_wonky+orig (Change the code in the command to the one you found in the to3d GUI)

Major warning here: the left and right are not obvious in many cases. You can verify if the left and right are consistent with another dataset (which you may trust more to be correct) by alignment and corresponding cost metrics for the original and flipped versions with the -check_flip option for

Thank you very much Daniel!