You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
itk::DCMTKSeriesFileNames orders slices by InstanceNumber only, not geometrically like GDCMSeriesFileNames #6463
itk::DCMTKSeriesFileNames orders slices only by InstanceNumber (0020,0013) using an unstable std::sort, whereas itk::GDCMSeriesFileNames orders geometrically by ImagePositionPatient projected on the slice normal. When InstanceNumber is absent or constant across a series, every sort key is equal and the resulting order is implementation-defined (seeded by directory-glob order), producing a scrambled volume with a meaningless, machine-dependent z-spacing.
Compare with itk::GDCMSeriesFileNames → gdcm::SerieHelper::OrderFileList() → ImagePositionPatientOrdering() (Modules/ThirdParty/GDCM/.../gdcmSerieHelper.cxx:308-438): slice normal = cross-product of the two ImageOrientationPatient (0020,0037) cosine vectors; sort by IPP (0020,0032) dotted with that normal; fall back to ImageNumber.
Impact
Any DICOM series whose InstanceNumber does not monotonically track geometric position (or is unset) is read in the wrong slice order by DCMTKSeriesFileNames. This surfaced in PR #6456 (itkDCMTKTransformIOResampleTest), whose synthetic fixtures all carry InstanceNumber 0: the same inputs produce a different z-spacing on every machine, so no committed baseline can stabilize the test.
DCMTK has no helper to delegate to
DCMTK ships no directory-scanning series sorter analogous to gdcm::SerieHelper::OrderFileList. FGPlanePosPatient (dcmfg) is an enhanced-multiframe accessor; ConcatenationLoader sorts by InConcatenationNumber; dcddirif/dcdicdir build DICOMDIRs. The geometric ordering must be implemented in ITK using the existing DCMTKFileReader accessors (GetDirCosArray, GetOrigin, GetFileNumber).
Fix
Order by IPP-projected-on-normal as the primary key, with InstanceNumber then file name as deterministic fallbacks, using a stable sort. PR forthcoming.
Fixed by #6464 (merged 2026-06-18): DCMTKSeriesFileNames now orders slices geometrically using the first valid slice orientation, matching GDCMSeriesFileNames behavior.
Activity
ENH: Order DCMTKSeriesFileNames using first valid slice orientation
hjmjohnson commentedon Jul 10, 2026
Fixed by #6464 (merged 2026-06-18): DCMTKSeriesFileNames now orders slices geometrically using the first valid slice orientation, matching GDCMSeriesFileNames behavior.