Skip to content

ENH: Add itkDCMTKGetDicomTagsTest, fix #3820 (supersedes #2796)#6189

Merged
hjmjohnson merged 2 commits intoInsightSoftwareConsortium:mainfrom
hjmjohnson:fix-pr2796-takeover
May 3, 2026
Merged

ENH: Add itkDCMTKGetDicomTagsTest, fix #3820 (supersedes #2796)#6189
hjmjohnson merged 2 commits intoInsightSoftwareConsortium:mainfrom
hjmjohnson:fix-pr2796-takeover

Conversation

@hjmjohnson
Copy link
Copy Markdown
Member

Adds itkDCMTKGetDicomTagsTest exercising every well-formed VR-typed accessor on itk::DCMTKFileReader against Input/DicomSeries/Image0075.dcm, and fixes the include-path issue (#3820) that has blocked DCMTK-reader test coverage for over three years. Supersedes #2796.

Two-commit structure
Commit Δ Purpose
1 COMP: Expose DCMTK headers to ITKIODCMTKTestDriver (issue #3820) +54 lines (Modules/IO/DCMTK/test/CMakeLists.txt) Resolves #3820 — narrowly-scoped target_include_directories() adding the DCMTK ExternalProject's per-library include dirs and the generated config dir to the test driver target only. Public DEPENDS surface of the IODCMTK module unchanged. Gated on NOT ITK_USE_SYSTEM_DCMTK.
2 ENH: Add itkDCMTKGetDicomTagsTest covering DCMTKFileReader::GetElement* +176 lines New test source + CMake registration. Co-Authored-By: jhlegarreta.
Coverage map

The test exercises:

Accessor DICOM tag VR Asserted value
GetElementDA (0008,0021) StudyDate DA "20030625"
GetElementTM (0008,0030) StudyTime TM "152734"
GetElementPN (0010,0010) PatientName PN "Wes Turner"
GetElementCS (0010,0040) PatientSex CS "O"
GetElementDS (0010,1030) PatientWeight DS "68.039"
GetElementIS (0018,0086) EchoNumber IS 1
GetElementFL (0019,105a) AcquisitionDuration FL 414273984.0f
GetElementSL (0021,1057) LocsPer3DSlab SL 124
GetElementUS (0028,0002) SamplesPerPixel US 1
GetElementCS (0028,0004) PhotometricInterpretation CS "MONOCHROME2"
GetElementUS (0028,0010) Rows US 256
GetElementUS (0028,0100) BitsAllocated US 16
GetElementUI (0043,1061) ScannerStudyEntityUID UI "1.2.840.113619.2.133.1762890640.1886.1055165015.961"

Expected values were verified out-of-band with pydicom against the on-disk fixture before authoring. Each assertion uses ITK_TEST_EXPECT_EQUAL so a failure surfaces with a precise diff; the test also writes one tag-value-per-line to argv[2] for diagnostic inspection. No --compare baseline file (the in-process assertions are the source of truth).

What this fixes vs. PR #2796's catalogued problems
# Problem Resolved?
1 unsigned short = "????" compile error ✓ rewrote
2 Missing/redeclared usTarget ✓ rewrote
3 IOPixelEnum missing itk:: qualifier ✓ removed (dropped GetImagePixelType test per @malaterre's earlier feedback that the method is questionable)
4 dcmtk/dcmdata/dcdict.h not found (#3820) ✓ commit 1
5 1304791694 (wrong AcquisitionDuration) ✓ verified actual 414273984.0 via pydicom
6 PhotometricInterpretation as unsigned short (wrong VR) ✓ now reads as CS string "MONOCHROME2"
7 BitsAllocated 8 (wrong) ✓ verified actual 16, fixed
8 3 duplicate itk_add_test names in PR #2796 ✓ reduced to 1 invocation (RGB/RTDose fixtures were never published to ITKTestingData)
9 argv[1] consuming a comma-list DATA{REGEX:...} ✓ single-file fixture
10 CMakeLists wholesale gersemi reformat ✓ minimal additions only
11 WIP: title prefix n/a — fresh PR
Local verification

Built ITKIODCMTKTestDriver against a fresh build-dcmtk/ (with Module_ITKIODCMTK=ON, BUILD_SHARED_LIBS=ON, Release):

694: Trying fileReader.LoadFile()
694: Test finished.
1/1 Test #694: itkDCMTKGetDicomTagsTest .........   Passed    3.59 sec
100% tests passed, 0 tests failed out of 1

pre-commit run --all-files exits 0 against the pushed HEAD.

PR Checklist

  • No API changes were made (or the changes have been approved)
  • No major design changes were made (or the changes have been approved)
  • Added test (or behavior not changed)
  • Updated API documentation (or API not changed)
  • Added license to new files (if any)
  • Added Python wrapping to new files (if any)
  • Added ITK examples for all new major features (if any)

@github-actions github-actions Bot added type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Enhancement Improvement of existing methods or implementation type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct area:IO Issues affecting the IO module labels May 2, 2026
@blowekamp
Copy link
Copy Markdown
Member

Thanks for looking into this! I was just talking about features of GDCM and DCMTK in ITK with @zivy.

@hjmjohnson
Copy link
Copy Markdown
Member Author

@greptileai review this draft before I make it official

@greptile-apps

This comment was marked as resolved.

Comment thread Modules/IO/DCMTK/test/itkDCMTKGetDicomTagsTest.cxx Outdated
Comment thread Modules/IO/DCMTK/test/CMakeLists.txt Outdated
hjmjohnson and others added 2 commits May 2, 2026 10:20
…wareConsortium#3820)

The ITK module ITKIODCMTK declares ITKDCMTK as PRIVATE_DEPENDS so the
DCMTK headers do not leak through the toolkit's public include
surface.  But the public header itkDCMTKFileReader.h transitively
#includes <dcmtk/dcmdata/dcdict.h>, so any test file that includes
itkDCMTKFileReader.h fails to compile with:

  fatal error: 'dcmtk/dcmdata/dcdict.h' file not found

This blocked PR InsightSoftwareConsortium#2796 from landing for over three years and is
tracked as issue InsightSoftwareConsortium#3820.

Add a narrowly-scoped target_include_directories() block in
Modules/IO/DCMTK/test/CMakeLists.txt that adds the DCMTK
ExternalProject's per-library include dirs and the generated
configuration header dir to ITKIODCMTKTestDriver only.  No change
to the public DEPENDS surface of the IODCMTK module --- only the
test driver target acquires the additional include paths.

When ITK is built with ITK_USE_SYSTEM_DCMTK=ON the system-installed
DCMTK headers are already on the default search path, so the block
is gated behind NOT ITK_USE_SYSTEM_DCMTK.
Add a test that exercises every well-formed VR-typed accessor on
itk::DCMTKFileReader against the existing fixture
Input/DicomSeries/Image0075.dcm:

  GetElementDA  StudyDate
  GetElementTM  StudyTime
  GetElementPN  PatientName
  GetElementCS  PatientSex, PhotometricInterpretation
  GetElementDS  PatientWeight
  GetElementIS  EchoNumber
  GetElementFL  AcquisitionDuration (private GE tag)
  GetElementSL  LocsPer3DSlab (private GE tag)
  GetElementUS  SamplesPerPixel, Rows, BitsAllocated
  GetElementUI  ScannerStudyEntityUID

Expected values were verified out-of-band with pydicom against the
on-disk fixture before authoring, fixing several wrong-by-transcription
expectations from the original PR InsightSoftwareConsortium#2796 (e.g. AcquisitionDuration was
recorded there as 1304791694, the integer reinterpretation of the float
bit pattern; the actual scanner-reported FL value is 414273984.0).

Each tag is asserted in-process via ITK_TEST_EXPECT_EQUAL; the test
also writes one tag-value-per-line to argv[2] for diagnostic inspection.
The in-process assertions are the source of truth for correctness, so
no --compare baseline file is needed.

The fixture is the single slice Image0075.dcm rather than the
DicomSeries regex; the test reads exactly one file via SetFileName,
not a series.  Two further test invocations proposed by PR InsightSoftwareConsortium#2796
(against RGBDicomSeries/raw-RGB.dcm and
RTDoseDicomSeries/32bitDoseRTImage.dcm) are dropped for now because
those fixtures were never published to ITKTestingData.

Supersedes PR InsightSoftwareConsortium#2796.

Co-Authored-By: jhlegarreta <jon.haitz.legarreta@gmail.com>
@hjmjohnson hjmjohnson force-pushed the fix-pr2796-takeover branch from ffeeaf2 to 365b2ba Compare May 2, 2026 15:21
@hjmjohnson hjmjohnson requested a review from zivy May 2, 2026 18:03
@hjmjohnson hjmjohnson marked this pull request as ready for review May 2, 2026 18:26
Copy link
Copy Markdown
Member

@jhlegarreta jhlegarreta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot Hans 🥇 .

@hjmjohnson hjmjohnson merged commit 4a7de75 into InsightSoftwareConsortium:main May 3, 2026
16 checks passed
@hjmjohnson hjmjohnson added this to the ITK 6.0.0 milestone May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:IO Issues affecting the IO module type:Enhancement Improvement of existing methods or implementation type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Including itkDCMTKFileReader.h in a test file produces a compiler error

3 participants