Repository navigation
fix: readFile allowMissingHeader opt-in accepts preamble-less and bare datasets - #536
Merged
Merged
Conversation
…e datasets Co-Authored-By: Claude Fable 5 <[email protected]>
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.
This is the fix for issue #93: an explicit way to read DICOM data that's missing its file header.
Some background for readers who don't live in Part 10. A standard DICOM file starts with a 128-byte preamble followed by the four ASCII bytes "DICM". After that comes the File Meta Information — a small group-0002 header that, among other things, names the transfer syntax of the dataset. But files in the wild sometimes have the preamble stripped off. And data captured straight from the network (DIMSE) never had a file header in the first place — it's just a bare dataset.
DicomMessage.readFilehas always refused both, and issue #93 asked for a way to force-read them anyway.This PR adds an explicit opt-in,
allowMissingHeader, toDicomMessage.readFile:The mechanics live in
src/DicomMessage.js. When the opt-in is set and there's no DICM marker,readFilechecks whether the first element belongs to group 0002. If it does, File Meta parsing simply starts at byte 0. If it doesn't, there is no meta group to read — so a small sniffer,_detectBareSyntax, looks at bytes 4-5 of the first element header. If they form a valid explicit VR code (VR = value representation, the two-letter type code an explicit-VR file stores inline), the dataset is treated as Explicit Little Endian; otherwise Implicit Little Endian. The opt-in also extends the existing leniency for meta groups that start directly at (0002,0010) without a (0002,0000) group-length element.Nothing changes without the opt-in. The default path throws exactly the errors it always has, and the regression suite (
test/issues/issue93-missing-preamble.test.js) pins both sides: the old refusals — including thatignoreErrorsdoes not bypass the DICM check — and the new opt-in behavior for all three input shapes. Two tests in the suite are skipped placeholders for the streaming reader's half of the issue-93 contract; they unskip in the streaming reader PR. The streaming reader depends on this option for its raw-dataset fallback, which is why this PR lands first.🤖 Generated with Claude Code