Repository navigation
fix: keep empty sequence items when reading (port of #608) - #660
Merged
Merged
Conversation
SequenceOfItems.readBytes skipped an item with no bytes, so later items
moved to a lower index. It now pushes {} for an empty item. The async
reader, fromPart10 and fromPart10Stream already kept empty items; a new
test checks all four readers in both VR modes with defined and
undefined lengths.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
wayfarer3130
added a commit
that referenced
this pull request
Nov 25, 2026
…662 The combined build measures x1.0841 (dcmjs.js) and x1.0665 (dcmjs.es.js). The ceiling comment is now one line. Co-Authored-By: Claude Opus 5.5 <[email protected]>
wayfarer3130
marked this pull request as ready for review
November 25, 2026 14:05
wayfarer3130
added a commit
that referenced
this pull request
Nov 25, 2026
…oups (port of #603) (#662) * fix(normalizers): normalize multiframe datasets missing functional groups (port of #603) normalizeMultiframe dereferenced a missing SharedFunctionalGroupsSequence and threw a TypeError. When the groups are missing, fill the shared PlaneOrientationSequence / PixelMeasuresSequence and the per-frame PlanePositionSequence from the top-level attributes, through the static ImageNormalizer.sharedImagePlaneGroups and planePositionGroup that convertToMultiframe now also uses. Lower NumberOfFrames to the whole frames PixelData holds (never raise it), with a warning. A per-frame sequence that is already an array is no longer wrapped again, so a one-frame item is an object and not [[item]]. log.error becomes log.warn. Raise the bundle-size ceilings to 1.084 and 1.067 for the ~1.7 KB added. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(normalizers): keep the declared NumberOfFrames when functional groups are missing The normalizer no longer lowers NumberOfFrames to the frames that PixelData appears to hold. Encapsulated PixelData can have more or fewer fragments than frames, so a byte count says nothing about the frame count. framesInPixelData is removed. A dataset with no PerFrameFunctionalGroupsSequence now gets one per-frame item for each declared frame, each with PlanePositionSequence from the top-level ImagePositionPatient and its own FrameContentSequence. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(bundle-size): set the ceilings from a build with #660, #659 and #662 The combined build measures x1.0841 (dcmjs.js) and x1.0665 (dcmjs.es.js). The ceiling comment is now one line. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
|
🎉 This PR is included in version 1.0.0-beta.18 🎉 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 PR is the 1.0 port of #608 from 0.x.
Summary
The sync reader dropped an empty item of a sequence. Thus, the later items moved to a lower index. This PR keeps each empty item as
{}in its position. The PR also adds tests for all four 1.x readers.Cause
SequenceOfItems.readBytesinpackages/core/src/ValueRepresentation.jscallsreadOptions.readItemonly when the item has bytes. When the item had no bytes, the method pushed nothing. #606 reported the same bug in 0.x.Changes
packages/core/src/ValueRepresentation.js:SequenceOfItems.readBytespushes{}for an empty item (else { elements.push({}); }). This is the same fix as fix: preserve empty sequence items when reading #608.test/SequenceOfItems.test.js: the port of the fix: preserve empty sequence items when reading #608 tests. The tests read the items[{}, item, {}]in explicit and implicit VR, with defined and undefined lengths for the sequence and for the items (8 cases). The old test "returns an empty elements array sinnce the item is empty" expected the reader to drop the empty item. Now the test expects[{}], as in fix: preserve empty sequence items when reading #608.test/sync-async-parser-equivalency.test.js: a new test writes a Part 10 file that has the same sequence. The test reads the file with the sync reader (DicomMessage.readFile), the async reader (AsyncDicomReader),fromPart10andfromPart10Stream(32 cases).test/helper/sequenceItems.js: a new helper that writes the bytes of the sequence for the two test files.Verified
readBytescases: "Expected length: 3, Received length: 1";fromPart10andfromPart10Streampassed. Thus, only the sync reader had the bug in 1.x.npx jest --runInBand(121 tests):SequenceOfItems,sync-async-parser-equivalency,defined-length-sequence,async-data,eventStream/fromPart10,readBufferStream.lossless-read-writeanddata-encodingalso pass (84 tests).test/bundle-size.test.jspasses with a new build.dcmjs.es.jsis 1445632 bytes, and the ceiling is 1445650 bytes. The PR does not change the limit. The fix has no inline comment, because the ESM consumer bundle keeps the source comments and a comment put the bundle over the limit.pnpm run buildpass.Release note
The sync reader now keeps an empty sequence item. An empty item now comes back as
{}in its position, and the later items keep their index. Before this change, the reader dropped the empty item. Code that expected the shorter array must change.Not ported, and why
packages/legacy,fromPart10andfromPart10Stream(parseSqItems) need no change. The new tests show that these readers already keep the empty items.🤖 Generated with Claude Code