Skip to content

GDCMSeriesFileNames rejects series whose ImageOrientationPatient differs only by rounding #7181

Closed

Description

@hjmjohnson

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. With FailOnAmbiguousOrdering(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.cxx sorts with gdcm::IPPSorter at its default DirectionCosinesTolerance of 0, which requires byte-identical IOP strings ("More than one IOP ... Try changing DirCosTolerance").
  • A nonzero IPPSorter tolerance 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 loose IPPSorter tolerance. Rounded series order as in 5.4; tilted, in-plane rotated, and different-plane slices are still rejected. The migration guide's GDCMSeriesFileNames section documents the behavior.
  • No release-5.4 backport is needed: 5.4 does not use IPPSorter.

Related:

Activity

  1. added
    type:Bug
    area:IO
    on Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:IOtype:Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions