DICOM Enhanced CT with GDCM_IO


I’m working on an existing code base that uses ITK/Gdcm ITK 4.12

I have a Toshiba ct multi frame.

ITK is returning direction cosines

1 0 0 0 1 0 0 0 -1

And I need to swap the z axis and reset the direction cosines to identity to get the slices so that the software can access the voxels correctly
the software prefers LPS → ijk

Ok that’s fine, but I need to document this for a report and I’m trying to understand the code where this is handled.

It seems that in gdcmImageHelper ComputeZSpacingFromIPP() the spacing for Z is computed negative.

Since its negative, later in


// Spacing is expected to be greater than 0

// If negative, flip image direction along this axis.

it sets the direction cosine to -1 for the z access. But it doesn’t flip the voxels.

I’m wondering who’s “correct” here?

If spacing is a “distance”, it shouldn’t be negative I would think ?.

The only place I see negative spacing i https://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_C.8.4.15.htmls

That would lead me to think it’s a defect in GDCM.

Let me know what the consensus is on this. I just need to document the behavior.



@mathieu.malaterre and @mihail.isakov might provide explanations.

As far as I remember ITK does handle “negative” spacing quite well. This was a trick to load an Enhanced format in the file order. The fact that ITK tolerate negative spacing is out of scope with regards to DICOM standard.

You may try dcm2niix (maybe prefer Nrrd output), dcm2niix process every frame in per frame group and is tolerant even to randomly ordered slices in enhanced IODs, s. this discussion with D. Clunie examples. With ITK/GDCM if the volume is not uniform and frames are not sorted ascending by IPP/IOP there may be issues. You can also load such files in Slicer using dcm2niix plugin. Also you can view most multi-frame files in the program, incl. non-uniform, 3D+, etc.

P.S. If you export to Nifti or Nrrd with dcm2niix and load into ITK, the orientation may be not the original one (possible different reference spaces), but should be correct, AFAIK.


Link doesn’t work, corrected link is

I also don’t know other IOD where negative spacing is allowed.

1 Like

Generally ITK doesn’t tolerate negative spacing in SetSpacing if legacy code is removed, BTW.

the code where this is handled.

But in the file reader it is done before SetSpacing here: itkImageFileReader.hxx


I’m looking to add the capability of reading the enhanced CT to this code base.

I’m reading the spec, etc.

So looking at the tags in the files, I have a 2 file series- 2 files with the same series uid. There are in the order of 300 images in each file based on number of frames. So, I assume there’s an “index” located somewhere in these files. The way I envision it:

Read image position patient tags
Read Other meta data
Read images

But where is this “index”? In what tags or tags is the structure of the file “described”? I don’t know where to start ¯_(ツ)_/¯

With a file by file series, the “index” is the file system, but I need the same “index” for these files…


A structure of Enhanced CT Image instance is described in Multi-frame Dimension Module and Frame Content Sequence in Per-frame Functional Groups Sequence. The module may be absent in a Legacy Converted instance. There is also no guarantee that e.g. Stack ID and In-Stack Position Number order will be the same as the result of ascending IPP/IOP sorting of frames of the stack. All this is very difficult stuff unfortunately.
Not sure how to sort series of enhanced instances, maybe Instance Number, Acquisition or other time.


It seems like the images I have are best described by

This tag exists in the files I’m working with, but it’s a 1C