[vtkusers] Correct anatomical orientation of volumes from Niftii and DICOM

David Gobbi david.gobbi at gmail.com
Thu May 10 13:11:51 EDT 2018


Hi Panos,

It is possible to display NIFTI and DICOM together in the same program,
but this isn't something you can achieve simply by adjusting things with
vtkImageChangeInformation or with FileLowerLeftOn().

Here are some key points:

1) NIFTI is fundamentally a 3D, volumetric, oriented image format.  In
order to properly display a NIFTI file, you must use the orientation info
embedded in the file (the sform or the qform).

2) DICOM is fundamentally a 2D image format, but of course the
meta-data contains info to allow DICOM images to be reconstructed
into a 3D volume and oriented in 3D space.

Since DICOM originated as a 2D format, you can ignore the orientation
meta-data and still display the data reasonably.  For example, if you
show an axial CT or MR head data set, you can reasonably trust that
the nose will point to the top of the image, and that the left ear will be
on the right, even without checking the ImageOrientationPatient info.

This is not true of NIFTI.  If you don't check the sform or the qform in
the NIFTI header, you have no way to know whether left is left or
left is right on the 2D slices, even if you know that the slices are axial.
There is no way to robustly display NIFTI with the correct orientation
unless you use the sform or qform info.

3) The 3D coordinate systems of DICOM and NIFTI differ. The 3D "y"
direction in NIFTI maps to the 3D "-y" direction in DICOM, and
similarly "x" maps to "-x".  Note that I'm talking about the the 3D
directions in the oriented coordinate system, I'm not talking about
the vertical or horizontal direction in the 2D coordinate system.
This isn't something that you can properly account for by flipping the
image.

In order to properly map from DICOM coords to NIFTI coords, so
that you can display DICOM and NIFTI together, you should get the
orientation info from both the DICOM and the NIFTI, and you should
account for the difference in the 3D coordinate systems for each.

If you can be certain that the NIFTI files are from an axial scan, then
at the very least you must check the sform or qform in order to get
left/right and up/down correct.


Read everything that you can find on DICOM and NIFTI orientation,
it's a tricky subject and goes beyond what can be answered on a
mailing list.  Here's a few links:

Here's the Slicer page on coordinate systems:
https://www.slicer.org/wiki/Coordinate_systems

The official NIFTI documentation for orientation:
https://nifti.nimh.nih.gov/nifti-1/documentation/nifti1fields/nifti1fields_pages/qsform.html

The official DICOM documentation for orientation:
http://dicom.nema.org/MEDICAL/dicom/current/output/chtml/part03/sect_C.7.6.2.html

This is a program that I wrote to convert NIFTI images to DICOM,
the code isn't easy to follow but it contains all the needed logic:
https://github.com/dgobbi/vtk-dicom/blob/master/Programs/niftitodicom.cxx#L482

Hope this helps.

 - David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20180510/672ebf98/attachment.html>


More information about the vtkusers mailing list