Repository navigation
fix: bring AsyncDicomReader into the xs meta-VR resolution contract - #544
Merged
awatson1978 merged 1 commit intoSep 30, 2026
Merged
Conversation
…epresentation contract The async reader took the raw dictionary VR "xs" without resolving it, so every xs element fell back to US and signed pixel-value tags came back as their unsigned reinterpretation (-2 read as 65534) while the sync reader (fixed for issue #368) returned -2. The old xs branch in readTagHeader was dead — it sat on the unknown-tag path where vrType is always undefined — and its signedness test was inverted besides. Both readers now resolve xs through one shared helper, DicomMessage.resolveXsVrType (SS when PixelRepresentation is 1, US otherwise), on the implicit path and the explicit-VR UN fallback alike. The async reader feeds it the PixelRepresentation value the listener's information filter already tracks. Review finding 25. Co-Authored-By: Claude Fable 5 <[email protected]>
awatson1978
added a commit
that referenced
this pull request
Sep 30, 2026
…ne and event-stream findings Engine findings 1/3/4/24/25/27/28/32 landed as PRs #544-#551; the writers wave (#552-#557) fixed 5/6/7/11/22/23 in the ports and retired 14 by trimming the video factories from the core facade. Master verdicts are now verified against origin/master, not just triaged. Co-Authored-By: Claude Fable 5 <[email protected]>
|
🎉 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.
The async reader was the one read path left outside the "xs" contract that PR #537 established: it read every "xs"-typed element as unsigned, so an async read and a sync read of the same signed pixel data disagreed on both the VR and the values.
Quick recap of the contract. The dictionary meta-VR "xs" means "US or SS" — unsigned or signed 16-bit — and per PS3.5 the right choice hangs on PixelRepresentation (0028,0103): signed when it's 1, unsigned otherwise. PR #537 taught the eager reader to thread that value through to
_readTagand resolve "xs" accordingly. AsyncDicomReader never got the same treatment; this is review finding 25.What was actually in the async reader was worse than a missing feature — it was a dead branch.
readTagHeaderdid a barevrType = elementData.vrwhenever the tag was in the dictionary, so "xs" sailed straight intocreateByTypeString("xs")and fell back to US every time. ThevrType == "xs"check sat on the unknown-tag path, wherevrTypeis alwaysundefined, so it could never run — and even if it had, its signedness test was inverted (pixelRepresentation === 0meaning signed). The explicit-VR UN fallback had the same gap.When it bites: any Implicit VR LE file with PixelRepresentation 1 and a signed value in an "xs" tag like (0028,0106) SmallestImagePixelValue. The two readers returned different answers for the same bytes:
The fix shares #537's code path rather than copying it: the resolution now lives in one helper,
DicomMessage.resolveXsVrType(pixelRepresentation), used by the eager reader's two sites and byreadTagHeader's implicit and explicit-UN branches alike. The async side feeds it the PixelRepresentation value the listener's information filter already tracks (which is what the dead branch was reaching for all along), and the dead branch itself is gone — the same deletion #537 made inDicomMessage.Two tests pin it in
test/issues/issue368-xs-ox-vr-resolution.test.js, the suite that owns the xs contract: an async read with PixelRepresentation 1 must return SS with the negative values intact and agree element-for-element with the sync read, and the PixelRepresentation 0 case must agree on US. The signed one failed with exactly the 65534-for--2 disagreement above before the fix. Full suite: 612 passed, 20 skipped.The same dead branch, inverted test and all, is on master's AsyncDicomReader verbatim — so like #537, this looks applicable to master as a 0.52.x hotfix.
🤖 Generated with Claude Code