Repository navigation
COMP: Switch IOTransformDCMTK test from GDCMImageIO to DCMTKImageIO - #6456
hjmjohnson merged 2 commits into
Conversation
|
| Filename | Overview |
|---|---|
| Modules/IO/IOTransformDCMTK/itk-module.cmake | Removes ITKIOGDCM from TEST_DEPENDS; ITKIODCMTK (already present) covers the new DCMTKImageIO/DCMTKSeriesFileNames requirement. |
| Modules/IO/IOTransformDCMTK/test/itkDCMTKTransformIOResampleTest.cxx | GDCMImageIO/GDCMSeriesFileNames replaced with DCMTKImageIO/DCMTKSeriesFileNames; all three used methods (SetInputDirectory, GetInputFileNames, GetSeriesUIDs) are present in the DCMTK API, and the metadata key format is identical between both IO implementations. |
| Modules/IO/IOTransformDCMTK/test/Baseline/DicomTransformResampledMovingOutputBaseline.mha.cid | CID updated to match the DCMTK-resampled baseline; expected given DCMTKSeriesFileNames sorts by InstanceNumber rather than ImagePositionPatient, yielding different geometry. |
| Testing/Data/content-links.manifest | New CID registered for the regenerated baseline; entry has two spaces instead of one between the CID and the path, inconsistent with every other line in the file and with what upload.py writes. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[itkDCMTKTransformIOResampleTest] --> B[DCMTKSeriesFileNames\nGetInputFileNames / GetSeriesUIDs]
B --> C[ImageSeriesReader\nSetImageIO DCMTKImageIO]
C --> D[fixedReader / movingReader Update]
D --> E[DCMTKImageIO MetaDataDictionary\nFrameOfReferenceUID lookup]
E --> F[DCMTKTransformIO\nSetFrameOfReferenceUID]
F --> G[TransformFileReader Update x2]
G --> H[ResampleImageFilter\nfixed to moving]
H --> I[ImageFileWriter\nresampledMovingOutput]
I --> J[Baseline comparison\nDicomTransformResampledMovingOutputBaseline.mha]
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[itkDCMTKTransformIOResampleTest] --> B[DCMTKSeriesFileNames\nGetInputFileNames / GetSeriesUIDs]
B --> C[ImageSeriesReader\nSetImageIO DCMTKImageIO]
C --> D[fixedReader / movingReader Update]
D --> E[DCMTKImageIO MetaDataDictionary\nFrameOfReferenceUID lookup]
E --> F[DCMTKTransformIO\nSetFrameOfReferenceUID]
F --> G[TransformFileReader Update x2]
G --> H[ResampleImageFilter\nfixed to moving]
H --> I[ImageFileWriter\nresampledMovingOutput]
I --> J[Baseline comparison\nDicomTransformResampledMovingOutputBaseline.mha]
Reviews (1): Last reviewed commit: "COMP: Switch IOTransformDCMTK test from ..." | Re-trigger Greptile
b364926 to
5508aab
Compare
itk::DCMTKSeriesFileNames ordered slices solely by InstanceNumber (0020,0013) via an unstable std::sort. When InstanceNumber is absent or constant across a series, every sort key is equal, so the resulting order is implementation-defined and seeded by the directory-glob order. This scrambles the reconstructed volume and yields a meaningless, machine-dependent z-spacing -- in contrast to itk::GDCMSeriesFileNames, which orders by ImagePositionPatient projected on the slice normal via gdcm::SerieHelper. Order by the same geometric criterion (ImagePositionPatient dotted with the slice normal derived from ImageOrientationPatient), falling back to InstanceNumber and then file name when orientation/position is unavailable, using a stable sort so ties never scramble. Add a GoogleTest (built only when both ITKIOGDCM and ITKIODCMTK are present) asserting that GDCMSeriesFileNames and DCMTKSeriesFileNames produce identical slice ordering on the rect-centered / rect-offset fixtures, which all carry InstanceNumber 0 and previously triggered the scramble. DCMTK provides no directory-scanning series sorter analogous to gdcm::SerieHelper::OrderFileList, so the geometric ordering is implemented in ITK using the existing DCMTKFileReader accessors.
itkDCMTKTransformIOResampleTest used GDCMImageIO/GDCMSeriesFileNames to read DICOM series because DCMTKImageIO was not in ITK proper at the time the test was written. PR InsightSoftwareConsortium#6310 ingested ITKIODCMTK; switch the test to use the same reader as the rest of the module. This depends on the preceding geometric-ordering fix to itk::DCMTKSeriesFileNames: with correct ImagePositionPatient ordering, DCMTKImageIO reproduces the existing GDCM baseline byte-for-byte (0 error), so the baseline is unchanged. ITKIOGDCM remains a test dependency because the companion ordering GoogleTest compares the two readers. Resolves InsightSoftwareConsortium#6309
5508aab to
335877b
Compare
|
Force-pushed ( Now depends on #6464 (fixes #6463). This PR is stacked on that branch. What changed and whyThe original approach (regenerate the baseline from DCMTKImageIO output) could never pass CI: #6464 fixes This PR is therefore reduced to just the GDCM→DCMTK source swap:
Verified locally: full Merge orderMerge #6464 first, then this PR rebases cleanly onto |
The geometric slice ordering (added via PR InsightSoftwareConsortium#6456 for issue InsightSoftwareConsortium#6463) derived the slice normal from headers.front() alone. If the first file returned by the directory glob lacks ImageOrientationPatient (e.g. a localizer or a corrupt slice that sorted first), geometric ordering was silently suppressed for the entire series. Scan for the first slice carrying a valid orientation instead. Also correct the regression-test comment to cite issue InsightSoftwareConsortium#6463 rather than the downstream PR InsightSoftwareConsortium#6456. Addresses the greptile review on PR InsightSoftwareConsortium#6464.
Switch
itkDCMTKTransformIOResampleTestfromGDCMImageIO/GDCMSeriesFileNamesto
DCMTKImageIO/DCMTKSeriesFileNamesnow thatITKIODCMTKis in ITK proper(PR #6310). Removes the unused
ITKIOGDCMtest dependency.Resolves #6309
Baseline regeneration
DCMTKSeriesFileNamessorts slices by InstanceNumber (0020,0013) rather thanImagePositionPatient, so the resampled output has different geometry from the
old GDCM-generated baseline (origin_z −12.5 vs −49.5, spacing_z 0.626 vs 1.0).
Baseline regenerated from DCMTKImageIO output; comparison reports 0 image error.
New CID uploaded to ITKTestingData (commit cb41220 on gh-pages).