Repository navigation
fix(normalizers): normalize multiframe datasets missing functional groups (port of #603) - #662
Merged
Merged
Conversation
…oups (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]>
…oups 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]>
…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:06
wayfarer3130
added a commit
that referenced
this pull request
Nov 25, 2026
…oups 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. Same change as the 1.x port #662. 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 📦🚀 |
wayfarer3130
added a commit
that referenced
this pull request
Nov 26, 2026
…magePositionPatient array per frame (#665) * fix(normalizers): treat an empty per-frame sequence as missing; one ImagePositionPatient array per frame An empty PerFrameFunctionalGroupsSequence no longer reduces the number of frames: the normalizer builds one item per declared frame, as for a missing sequence. Each generated item gets its own ImagePositionPatient copy. Port of the 0.x fix in #664 (follow-up to #662). Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(normalizers): treat an empty shared sequence as missing; complete the per-frame sequence - An empty SharedFunctionalGroupsSequence array counts as missing, and a one-item array is used as its item, so the shared groups the normalizer sets (PixelValueTransformationSequence and the others) are written. - The per-frame sequence is filled up to NumberOfFrames, and each item gets its FrameContentSequence, not only the first item. - planePositionGroup passes a non-array ImagePositionPatient through. - Raise the dcmjs.js bundle ceiling to x1.091 (measured x1.09014). Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(normalizers): keep an existing FrameContentSequence; replace a null per-frame item - The normalizer adds a FrameContentSequence only to a per-frame item that has none; an existing item keeps its own (dimension index values, temporal position, stack ID). - A null or missing per-frame item becomes an empty item again, so [null, {}] no longer throws a TypeError. - Tests: an existing item keeps its FrameContentSequence, and the shared groups survive a denaturalize/naturalize round trip. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(normalizers): keep the shared group accessors and skip null items after NumberOfFrames - Call addAccessors on the SharedFunctionalGroupsSequence item, so that both SharedFunctionalGroupsSequence.X and SharedFunctionalGroupsSequence[0].X work, also for a hand-built one-item array. - The window guess skips a null per-frame item after NumberOfFrames and does not throw. - Tests: a [null, {}] case in the completes-a-per-frame-sequence it.each, a null item after NumberOfFrames, a one-item shared array. The test "keeps a complete multiframe dataset unchanged" now uses NumberOfFrames 1. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
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 #603 from 0.x. The PR also changes the
NumberOfFramesrule of #603 (see "Maintainer edits").Summary
normalizeMultiframeinsrc/normalizers.jsread a missingSharedFunctionalGroupsSequenceand threw aTypeError(OHIF #6307). This PR ports the merged fix of #603 to the 1.x line. The normalizer now fills the missing functional groups from the top-level attributes. A SEG derivation on the result does not throw.Cause
normalizeMultiframelogged an error whenSharedFunctionalGroupsSequencewas missing, and then wrotePixelValueTransformationSequenceinto the missing sequence.NumberOfFrameswas 1, the frame loop wrappedPerFrameFunctionalGroupsSequencein an array, also when the value was already an array. A missing sequence became[undefined], and the loop threw onFrameContentSequence.Changes
src/normalizers.jsis the only copy of the normalizer in 1.x. No package inpackages/*has a copy, so this PR changes that one file.ImageNormalizer.sharedImagePlaneGroups(dataset, pixelMeasures)andImageNormalizer.planePositionGroup(dataset), build the image plane groups from the top-level attributes.convertToMultiframenow calls both methods. The output ofconvertToMultiframedoes not change.SharedFunctionalGroupsSequenceis missing,normalizeMultiframebuildsPlaneOrientationSequence(ImageOrientationPatient) andPixelMeasuresSequence(PixelSpacing,SliceThickness,SpacingBetweenSlices).PerFrameFunctionalGroupsSequenceis missing,normalizeMultiframebuilds one item for each frame ofNumberOfFrames. Each item hasPlanePositionSequence(the top-levelImagePositionPatient) and its ownFrameContentSequence(InStackPositionNumberandDimensionIndexValues1 to N). A sequence that is not an array gets one wrap. A sequence that is an array stays as it is.log.errorbecomeslog.warn: "Missing SharedFunctionalGroupsSequence; using the top-level image plane attributes".test/segIncompleteMultiframe.test.jsis new.test/bundle-size.test.js: the ceilings change from 1.083 to 1.085 (dcmjs.js) and from 1.065 to 1.067 (dcmjs.es.js). The ceiling comment is now one line.The
NumberOfFramesruleNumberOfFrames. The normalizer does not count the frames inPixelData.PixelDatadoes not tell the number of frames. EncapsulatedPixelDatacan have more fragments than frames. EncapsulatedPixelDatacan also have fewer fragments than frames, for example in the video transfer syntaxes.NumberOfFramesN and noPerFrameFunctionalGroupsSequence, the result has N per-frame items.Bundle size
The ceilings come from a local build of
1.0-betawith #660, #659 and this PR merged, in that order. The intended merge order is #660, #659, #662, and #658 last.dcmjs.jsdcmjs.es.jsVerified
test/segIncompleteMultiframe.test.jswith thesrc/normalizers.jsof1.0-betagives 3 failures and 1 pass (the control). The failures areTypeError: Cannot set properties of undefined (setting 'PixelValueTransformationSequence')(the SEG test withincludeSliceSpacingtrue and false) andTypeError: Cannot set properties of undefined (setting 'FrameContentSequence')(theNumberOfFrames: 1test).NumberOfFrameschange: the updated test file gives 4 failures and 2 passes. The SEG tests gotNumberOfFrames1, not 4. The test with 2 fragments of 10 bytes gotNumberOfFrames2, not 8. The test with 10 fragments kept 8 frames, but got 1 per-frame item, not 8.npx jest --runInBandpasses on these files:segIncompleteMultiframe(6 tests),normalizers,derivations,compat-052,data,package-exports,bundle-size.eslintandprettier --checkon the changed files: no findings.pnpm run build: pass.Behaviour changes
TypeError.[item]. Before this PR, the result was[[item]], andFrameContentSequencewent on the inner array, not on the item.Maintainer edits
NumberOfFrames. The 0.x fix fix(normalizers): normalize multiframe datasets missing functional group sequences #603 loweredNumberOfFramesto the frames thatPixelDataholds. That rule gave a wrong count for compressed data. This PR removesframesInPixelData.NumberOfFrames8 stays 8 for encapsulatedPixelDatawith 2 fragments and with 10 fragments.Not ported and why
framesInPixelDataand its inline comment are removed (see "Maintainer edits").🤖 Generated with Claude Code