Repository navigation
fix(normalizers): normalize multiframe datasets missing functional group sequences - #603
Merged
wayfarer3130 merged 7 commits intoNov 24, 2026
Conversation
✅ Deploy Preview for dcmjs2 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…iframe-seg Co-Authored-By: Claude Opus 5.5 <[email protected]>
✅ Deploy Preview for dcmjs2 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
wayfarer3130
approved these changes
Nov 24, 2026
…set has none When SharedFunctionalGroupsSequence is missing, normalizeMultiframe now fills PlaneOrientationSequence and PixelMeasuresSequence from the top-level attributes, and the per-frame PlanePositionSequence from ImagePositionPatient. The code is shared with convertToMultiframe. NumberOfFrames is reduced to the number of frames that PixelData holds, so the SEG derivation no longer throws on one frame taken from a multiframe instance (OHIF #6307). A missing per-frame sequence with NumberOfFrames 1 now gives an object item, not [[]]. The missing-groups message is a warning. Co-Authored-By: Claude Opus 5.5 <[email protected]>
wayfarer3130
approved these changes
Nov 24, 2026
|
🎉 This PR is included in version 0.53.4 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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 normalizes a multiframe dataset that has no functional group sequences. Before this PR, the normalizer threw
TypeError: Cannot set properties of undefined (setting 'PixelValueTransformationSequence').Problem
ImageNormalizer.normalizeMultiframedetects a missingSharedFunctionalGroupsSequence. The method only logs an error, and then it uses the missing sequence. Later, the method indexesPerFrameFunctionalGroupsSequence, and that sequence can also be missing.A single dataset with a multiframe SOP class and no functional groups makes the normalizer crash. An example of such a dataset is one frame that a caller extracts from an enhanced multiframe instance.
OHIF/Viewers#6307 reports this crash with this stack:
SEGImageNormalizer.normalizeMultiframe→normalize→_createMultiframeSegmentationFromReferencedImages. cornerstonejs/cornerstone3D#2919 tracks the fix on the caller side. This PR makes the dcmjs side safe. The reported input now normalizes, and the SEG derivation (SegmentationandaddSegmentFromLabelmap) that follows also completes on that input.Root cause
src/normalizers.js:330-334(onmaster) logs "Can only process multiframe data with SharedFunctionalGroupsSequence". The code does not initialize the sequence before line 350 writesPixelValueTransformationSequence.PerFrameFunctionalGroupsSequence[frameNumber - 1]exists.SharedFunctionalGroups.Fix
When
SharedFunctionalGroupsSequenceis missing,normalizeMultiframenow does these steps:PlaneOrientationSequence(ImageOrientationPatient) andPixelMeasuresSequence(PixelSpacing,SliceThickness, andSpacingBetweenSliceswhen present) from the top-level attributes.NumberOfFramesto the number of whole frames thatPixelDataholds, whenPixelDataholds fewer frames. A caller that extracts one frame can keep theNumberOfFramesof the source instance. The OHIF #6307 input hadNumberOfFrames: 4and 1 frame of pixels.When
PerFrameFunctionalGroupsSequenceis missing, the normalizer builds one item withPlanePositionSequence(ImagePositionPatient). The normalizer wraps the sequence in an array only when the sequence is not an array. Thus a dataset withNumberOfFrames: 1gets an object as the per-frame item, and not an array.convertToMultiframealready built these groups from the top-level attributes. The two methods now share the code inImageNormalizer.sharedImagePlaneGroupsandImageNormalizer.planePositionGroup.For a complete multiframe dataset, the result does not change, with one exception. Before this PR, a per-frame sequence that was already an array, with
NumberOfFrames: 1, got a second array around it ([[item]]). Now the sequence stays[item].Tests
test/segIncompleteMultiframe.test.jshas these tests:NumberOfFrames: 4, 1 frame of pixels, and no functional group sequences. The test runsSEGImageNormalizer.normalize(). The test assertsNumberOfFrames: 1, the shared orientation and pixel spacing, and the per-frame position. Then the test runsnew Segmentation(...)andaddSegmentFromLabelmap, withincludeSliceSpacingtrue and false. The test asserts the position in the SEG per-frame item.NumberOfFrames: 1and no per-frame sequence. The test asserts that the per-frame item is an object, and not an array.On
master, the first test fails withCannot set properties of undefined (setting 'PixelValueTransformationSequence')atsrc/normalizers.js:350. On the earlier head of this PR, the first two tests fail. With this change, all tests pass, andtest/normalizers.test.jsandtest/derivations.test.jsalso pass.Maintainer edits
masterinto the branch, after fix(orientation): allocate matrix transform output with the input typed array type #602 merged. The diff now holds only the change of this PR.NumberOfFramesrule above, so that the SEG derivation also completes on the reported input.[[]]per-frame item forNumberOfFrames: 1.log.errortolog.warn, with a message that is true.