Skip to content

BUG: Read private series restriction tags from the file, not the scanner - #7152

Open
hjmjohnson wants to merge 1 commit into
InsightSoftwareConsortium:mainfrom
hjmjohnson:gdcm-series-restriction-private-tags
Open

hjmjohnson wants to merge 1 commit into
InsightSoftwareConsortium:mainfrom
hjmjohnson:gdcm-series-restriction-private-tags

Conversation

@hjmjohnson

@hjmjohnson hjmjohnson commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

GDCMSeriesFileNames::AddSeriesRestriction() with a private tag made GetSeriesUIDs() throw a GDCM assertion (Tags.find( t ) != Tags.end()) after the gdcm::Scanner rewrite in #6469. Private tags are now read from each file, with their private creators, through gdcm::StringFilter, as gdcm::SerieHelper did in ITK 5.4, so they refine series again in explicit and implicit VR files.

Root cause

gdcm::Scanner::AddTag() discards any tag whose dictionary VR is INVALID, which includes every private tag, with only a GDCM warning. BuildSeriesMap() then calls Scanner::GetValue() for that tag, which asserts. In ITK 5.4, gdcm::SerieHelper::CreateUniqueSeriesIdentifier() read every restriction tag with gdcm::StringFilter::ToString() on the fully read file, so private tags worked.

Found through dcm_classifier, which restricts on vendor diffusion tags (GE 0043|1039, Siemens 0019|100c, Philips 2001|1003, and others) to split DWI sub-volumes. On ITK main, every call to its study classifier throws.

Change and tests
  • Tags with a dictionary VR still go through the scanner. The others are read per file with Reader::ReadSelectedTags() and StringFilter, only when such a tag was requested.

  • For a private tag, its private creator (gggg,00xx) is read too. Without it, StringFilter cannot find the element's VR in an implicit VR file and returns an empty string, so the restriction would silently stop splitting the series.

  • Identifiers are built in the same tag order as before.

  • Including gdcmStringFilter.h/gdcmDicts.h compiles gdcm::PrivateDict::AddDictEntry, which copies gdcm::PrivateTag (user-provided copy assignment, implicit copy constructor) and warns under clang -Wdeprecated-copy-with-user-provided-copy and GCC -Wdeprecated-copy. That one warning is suppressed around this file's GDCM includes. itkGDCMImageIO.cxx avoids it only because itkImageIOBase.h is included first; upstream GDCM still lacks the copy constructor. The clang branch was verified locally; CI is the first executor of the GCC branch.

  • New tests vary the GE b-value (0043,1039) that the DicomSeries fixture carries under its (0043,0010) creator, alternating two values across the slices:

    • SeriesRestrictionOnPrivateTagsRefinesSeries (explicit VR little endian copies)
    • SeriesRestrictionOnPrivateTagsInImplicitVRFiles (implicit VR little endian copies)

    Each expects two series covering every file, and checks that a private tag absent from every file (2001,1003) leaves the grouping unchanged. Both throw on main; the implicit VR test finds one series instead of two if the creator is not read. All 39 ITKGDCMImageIOGTestDriver tests pass locally at this head (macOS arm64, AppleClang), with no compiler warnings in the touched files.

@github-actions github-actions Bot added type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances 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 Nov 11, 2026
@hjmjohnson

Copy link
Copy Markdown
Member Author

/azp run ITK.Linux.Python

@hjmjohnson
hjmjohnson force-pushed the gdcm-series-restriction-private-tags branch 3 times, most recently from 3128bbd to 1be751b Compare November 11, 2026 14:33
@hjmjohnson

Copy link
Copy Markdown
Member Author

/azp run ITK.Linux.Python

2 similar comments
@hjmjohnson

Copy link
Copy Markdown
Member Author

/azp run ITK.Linux.Python

@hjmjohnson

Copy link
Copy Markdown
Member Author

/azp run ITK.Linux.Python

@hjmjohnson
hjmjohnson marked this pull request as ready for review November 11, 2026 22:46
@greptile-apps

greptile-apps Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Fixes private series restrictions in GDCMSeriesFileNames without changing how known public tags are scanned.

  • Private DICOM tags can split series without stopping enumeration.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Requested restriction tag] --> B{Dictionary type known?}
  B -->|Yes| C[Read through Scanner]
  B -->|No| D[Select tag and private creator]
  D --> E[Read from each file]
  E --> F[Convert with StringFilter]
  C --> G[Append values in restriction order]
  F --> G
  G --> H[Group files by identifier]
Loading

Reviews (2) · Last reviewed commit: "BUG: Read private series restriction tag..." · Reviewed by Greptile

GDCMSeriesFileNames::AddSeriesRestriction() with a private tag, such as
the vendor diffusion b-value tags (0019|100c, 0043|1039) that DWI tools
use to split sub-volumes, made GetSeriesUIDs() throw:

  An invalid logic behavior occurred: Tags.find( t ) != Tags.end()

gdcm::Scanner::AddTag() discards any tag without a dictionary VR, which
includes every private tag, and Scanner::GetValue() then asserts on it.
ITK 5.4 read these values with gdcm::StringFilter on each file.

Add only dictionary tags to the scanner. Read the rest from each file,
with their private creators so implicit VR files resolve, through
Reader::ReadSelectedTags() and StringFilter. The GDCM headers this needs
warn on gdcm::PrivateTag's implicit copy constructor, so suppress that
one warning around the GDCM includes.
@hjmjohnson
hjmjohnson force-pushed the gdcm-series-restriction-private-tags branch from 1be751b to ee90899 Compare November 18, 2026 12:18
@hjmjohnson

Copy link
Copy Markdown
Member Author

Force-push 1be751b30aa..ee90899060b is a rebase only, onto current main. The conflict was with c77f723 (ImageOrientationPatient rounding): both added includes, a test helper, and tests at the same places, and the resolution keeps both sides. The GDCM tests pass locally (82/82).

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:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances 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.

1 participant