Volume orientation (dcm vs nii.gz)

Hi all,

I am working with cardiac CT data in two formats: DICOM and NIfTI (.nii.gz).

I am trying to automate some processes related to the placement of fiducials, but I’ve noticed an unexpected behavior:

  • When I load a DICOM volume, the largest K index (IJK axial coordinate) corresponds to the superior end of the body (closest to the neck).
  • When I load a NIfTI (.nii.gz) volume, the superior slice has index 0 instead.

My question is: How can I reliably determine the slice order in the K (axial) dimension, regardless of the input format?

Thanks in advance!

They are in a different orientation (RAS vs LPS). I suggest reading this page:

There is a section about nifti on the bottom.

Let us know if you have further questions.

How can I reliably determine the slice order in the K (axial) dimension, regardless of the input format?

You cannot do this independently from the input format, because for DICOM images this may be impossible. Each slice in a DICOM series has arbitrary orientation: they don’t have to be parallel, they can intersect each other, you can even have many slices at the same spatial position.

Many software packages can reconstruct regularly spaced 3D Cartesian volumes from the arbitrarily set of DICOM image slices. This operation may be a simple ordering of the slices, or it can be a complex non-linear reconstruction if the slices are irregularly spaced, tilted, or not parallel. The result of the 3D reconstruction is a voxel array and a homogeneous transformation matrix that maps between IJK indices of the array and the anatomical coordinate system. All you need to interpret the image data is this transformation matrix.