Repository navigation
Description
On main since the gdcm::IPPSorter backend (50dfb13, #6467), GDCMSeriesFileNames fails to order ordinary MR series whose per-slice ImageOrientationPatient strings differ only by floating-point rounding. The read then throws, or with SetFailOnAmbiguousOrdering(false) falls back to Instance Number order, which can produce a left-handed volume with the slices reversed relative to ITK 5.4. ITK 5.4.x is not affected. Fixed by #7177.
Minimal example
A three-slice axial series, slices 7 mm apart; each file stores its own ImageOrientationPatient, rounded independently by the scanner:
| File | Instance Number | Position (z) | ImageOrientationPatient |
|---|---|---|---|
| a.dcm | 1 | 14 mm | 1\0\0\0\1\0 |
| b.dcm | 2 | 7 mm | 1\0\0\0\1\0.00000002 |
| c.dcm | 3 | 0 mm | 1\0\0\0\1\0 |
- ITK 5.4 (
SerieHelper): normal from the first file, sorted by position: c, b, a. Right-handed volume. main(IPPSorter, direction-cosine tolerance 0): the differing strings count as different orientations, so sorting fails. Default: exception. WithFailOnAmbiguousOrdering(false): Instance Number order a, b, c, negative slice spacing, and (since 5fdb32d) det(direction) = -1. Physically consistent, but the voxel array is reversed along z compared with 5.4, so anything that reads voxels directly sees a different image.- Expected: the same geometric order as 5.4 (c, b, a), right-handed.
Real-data impact
Found while testing NeuroPred's stroke MR pipeline on ITK 6 (155 clinical sessions, four vendors). Series rejected only because of IOP rounding:
| Scanner | Series | Sessions |
|---|---|---|
| GE Genesis Signa | 7 | 2 |
| GE SIGNA Voyager | 4 | 1 |
Example: five 20-slice oblique axial series, uniform 7.0 mm spacing, no gantry-tilt tag, one frame of reference, three distinct IOP strings per series differing by at most 1.6e-8. On main all five fell to the Instance Number fallback and read left-handed with reversed slices, which changed downstream brain masks, lesion masks, and outcome predictions. No other vendor's series failed this way.
Measured on the same set, worst-slice 1 - n . n0 on unit normals for series with more than one IOP string: rounding-only series 0 to 4.8e-13 (11 series); genuinely different orientations 7.6e-5 to 2 (100 series).
Root cause and fix
itkGDCMSeriesFileNames.cxxsorts withgdcm::IPPSorterat its defaultDirectionCosinesToleranceof 0, which requires byte-identical IOP strings ("More than one IOP ... Try changing DirCosTolerance").- A nonzero
IPPSortertolerance is not a drop-in fix: it compares unnormalized normals, so identical six-decimal orientations whose normal is slightly off unit length would be rejected instead. - BUG: Accept rounding in ImageOrientationPatient when ordering series #7177 keeps the exact-match sort first; when it fails, ITK checks that every slice's unit row and column cosines are within
1 - cos <= 1e-6(about 0.08 deg) of the first slice's, and only then sorts again with a looseIPPSortertolerance. Rounded series order as in 5.4; tilted, in-plane rotated, and different-plane slices are still rejected. The migration guide'sGDCMSeriesFileNamessection documents the behavior. - No
release-5.4backport is needed: 5.4 does not useIPPSorter.
Related:
- Modernize itk::GDCMSeriesFileNames onto gdcm::IPPSorter/Scanner (drop deprecated gdcm::SerieHelper) #6467 (closed) and ENH: Reimplement GDCMSeriesFileNames on gdcm::IPPSorter/Scanner (drop deprecated SerieHelper) #6469 (merged): the
IPPSorter/Scannerbackend that introduced this (50dfb13, 7cb3bbe). - Discussion: GDCMSeriesFileNames ordering edge cases (duplicate IPP, gantry tilt) and whether SerieHelper's permissive strategy is correct #6468 (closed): ordering edge cases (duplicate IPP, gantry tilt); GDCMSeriesFileNames: support gantry-tilt CT ordering by default (follow-up to #6468) #6656 (open): gantry-tilt ordering follow-up.
- BUG: Fix case where DICOM series order has negative spacing #5357 (merged): negative-spacing direction fix (5fdb32d), which makes the fallback order left-handed.
- ENH: set a flag when DICOM ambiguous ordering fallback is used #6766 (merged):
GetDidUseAmbiguousOrdering(), which flags the fallback this issue triggers. - ENH: Address Greptile findings on GDCM series direction tests #6940 (merged): GDCM series direction tests.
- BUG: Read private series restriction tags from the file, not the scanner #7152 (open): also edits
itkGDCMSeriesFileNames.cxxand its contract test; whichever of BUG: Read private series restriction tags from the file, not the scanner #7152 and BUG: Accept rounding in ImageOrientationPatient when ordering series #7177 merges second needs a rebase. - itk::DCMTKSeriesFileNames orders slices by InstanceNumber only, not geometrically like GDCMSeriesFileNames #6463 (closed) and WIP: BUG: Throw on repeated slice positions in DCMTKSeriesFileNames #7064 (open): the analogous
DCMTKSeriesFileNamesordering work.
Activity