Repository navigation
fix: resolve the xs meta-VR via PixelRepresentation and quiet the unknown-VR fallback - #537
Merged
Merged
Conversation
…nown-VR fallback Co-Authored-By: Claude Fable 5 <[email protected]>
This was referenced Sep 30, 2026
|
🎉 This PR is included in version 1.0.0-beta.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two fixes to the eager reader, both taken from the review map's regression list: correct signed-vs-unsigned resolution for the "xs" meta-VR, and much quieter logging in the unknown-VR fallback.
First, some vocabulary. A VR (value representation) is the two-letter code that says how an element's bytes are interpreted. A few DICOM dictionary entries don't pin down a single VR — the entry "xs" means "US or SS", i.e. unsigned or signed 16-bit. Per the standard (PS3.5), the right choice depends on PixelRepresentation (0028,0103), a flag that says whether the image's pixel values are signed (1) or unsigned (0).
The first fix: dcmjs used to give up on "xs" and always read those elements as unsigned. A stored value of -2000 came back as 63536. Now
DicomMessage._readremembers the PixelRepresentation value as it walks the dataset and threads it through to_readTag, which resolves "xs" to SS when PixelRepresentation is 1 and US otherwise. This works because (0028,0103) precedes every "xs"-typed tag in tag order, so the flag is always parsed before it's needed. The streaming reader's equivalence gate is what exposed this — it compares the new reader's output element-for-element against the eager reader's, so the eager reader had to be right first. Here's the before/after, straight from the regression test:The second fix is about log noise.
ValueRepresentation.createByTypeStringused to log an error for every element whose VR type wasn't in its instance table. But "xs" and "ox" ("OB or OW") are expected dictionary meta-VRs, not errors — that's the literal complaint in issue #368, where OHIF consoles filled with "Invalid vr type xs - using US" (and the log-spam half of issue #437 is the same thing for "ox"). Issue #457 adds the other case: files carrying many elements of a genuinely unregistered VR (OL/OV/SV) produced one log line per element. Now the xs/ox fallbacks log at debug level, and genuinely unknown types warn once per type instead of once per element.The two issue suites the test bank had to leave out land here as the regression tests:
test/issues/issue368-xs-ox-vr-resolution.test.jsandtest/issues/issue457-vr-instances.test.js, with their known-gap skips now green and unskipped. Both fixes look applicable to master as 0.52.x hotfixes.🤖 Generated with Claude Code