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
itkImageFileReader.hxx
// 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 ?.
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.
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
Sort
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.