@dcmjs-org/dcmjs 1.0.0-beta.21 → 1.0.0-beta.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3570,6 +3570,22 @@ var ImageNormalizer = /*#__PURE__*/function (_Normalizer) {
3570
3570
  DimensionDescriptionLabel: "ImagePositionPatient"
3571
3571
  }];
3572
3572
  }
3573
+
3574
+ /**
3575
+ * Fills in the functional groups of a multiframe dataset.
3576
+ *
3577
+ * A missing or empty SharedFunctionalGroupsSequence is built from the
3578
+ * top-level image plane attributes; a one-item array is used as its item.
3579
+ * The shared item gets the list accessors (addAccessors), so both
3580
+ * `SharedFunctionalGroupsSequence.X` and `SharedFunctionalGroupsSequence[0].X`
3581
+ * work.
3582
+ * The PerFrameFunctionalGroupsSequence is filled up to the declared
3583
+ * NumberOfFrames with items at the top-level position, existing items keep
3584
+ * their content, and each item without a FrameContentSequence gets one.
3585
+ * Added items share the position but get increasing InStackPositionNumber.
3586
+ * Items beyond NumberOfFrames are kept unchanged; a null item there is
3587
+ * skipped and does not throw.
3588
+ */
3573
3589
  }, {
3574
3590
  key: "normalizeMultiframe",
3575
3591
  value: function normalizeMultiframe() {
@@ -3593,6 +3609,10 @@ var ImageNormalizer = /*#__PURE__*/function (_Normalizer) {
3593
3609
  if (!ds.PresentationLUTShape) {
3594
3610
  ds.PresentationLUTShape = "IDENTITY";
3595
3611
  }
3612
+ if (Array.isArray(ds.SharedFunctionalGroupsSequence)) {
3613
+ // The shared group has one item; an empty array counts as missing
3614
+ ds.SharedFunctionalGroupsSequence = ds.SharedFunctionalGroupsSequence[0];
3615
+ }
3596
3616
  if (!ds.SharedFunctionalGroupsSequence) {
3597
3617
  core.log.warn("Missing SharedFunctionalGroupsSequence; using the top-level image plane attributes");
3598
3618
  ds.SharedFunctionalGroupsSequence = ImageNormalizer.sharedImagePlaneGroups(ds, {
@@ -3600,6 +3620,7 @@ var ImageNormalizer = /*#__PURE__*/function (_Normalizer) {
3600
3620
  SpacingBetweenSlices: ds.SpacingBetweenSlices
3601
3621
  });
3602
3622
  }
3623
+ ds.SharedFunctionalGroupsSequence = core.addAccessors(ds.SharedFunctionalGroupsSequence);
3603
3624
 
3604
3625
  // TODO: special case!
3605
3626
  if (ds.BodyPartExamined === "PROSTATE") {
@@ -3619,23 +3640,20 @@ var ImageNormalizer = /*#__PURE__*/function (_Normalizer) {
3619
3640
  RescaleSlope: rescaleSlope,
3620
3641
  RescaleType: "US"
3621
3642
  };
3622
- var frameCount = this.datasets.length;
3623
- if (!ds.PerFrameFunctionalGroupsSequence) {
3624
- // One item per declared frame, all at the top-level position
3625
- frameCount = Math.max(frameCount, Number(ds.NumberOfFrames) || 0);
3626
- ds.PerFrameFunctionalGroupsSequence = Array.from({
3627
- length: frameCount
3628
- }, function () {
3629
- return ImageNormalizer.planePositionGroup(ds);
3630
- });
3631
- } else if (!Array.isArray(ds.PerFrameFunctionalGroupsSequence)) {
3632
- ds.PerFrameFunctionalGroupsSequence = [ds.PerFrameFunctionalGroupsSequence];
3643
+ var frameCount = Math.max(this.datasets.length, Number(ds.NumberOfFrames) || 0);
3644
+ var perFrame = ds.PerFrameFunctionalGroupsSequence || [];
3645
+ ds.PerFrameFunctionalGroupsSequence = Array.isArray(perFrame) ? perFrame : [perFrame];
3646
+ while (ds.PerFrameFunctionalGroupsSequence.length < frameCount) {
3647
+ ds.PerFrameFunctionalGroupsSequence.push(ImageNormalizer.planePositionGroup(ds));
3633
3648
  }
3634
3649
  for (var frameNumber = 1; frameNumber <= frameCount; frameNumber++) {
3635
3650
  var _ds$PerFrameFunctiona, _ref;
3651
+ var item = (_ds$PerFrameFunctiona = ds.PerFrameFunctionalGroupsSequence)[_ref = frameNumber - 1] || (_ds$PerFrameFunctiona[_ref] = {});
3652
+ if (item.FrameContentSequence) {
3653
+ continue;
3654
+ }
3636
3655
  var dataset = this.datasets[frameNumber - 1] || {};
3637
- (_ds$PerFrameFunctiona = ds.PerFrameFunctionalGroupsSequence)[_ref = frameNumber - 1] || (_ds$PerFrameFunctiona[_ref] = {});
3638
- ds.PerFrameFunctionalGroupsSequence[frameNumber - 1].FrameContentSequence = {
3656
+ item.FrameContentSequence = {
3639
3657
  FrameAcquisitionDuration: 0,
3640
3658
  StackID: 1,
3641
3659
  InStackPositionNumber: frameNumber,
@@ -3643,9 +3661,8 @@ var ImageNormalizer = /*#__PURE__*/function (_Normalizer) {
3643
3661
  };
3644
3662
  var frameTime = dataset.AcquisitionDate + dataset.AcquisitionTime;
3645
3663
  if (!isNaN(frameTime)) {
3646
- var frameContentSequence = ds.PerFrameFunctionalGroupsSequence[frameNumber - 1].FrameContentSequence;
3647
- frameContentSequence.FrameAcquisitionDateTime = frameTime;
3648
- frameContentSequence.FrameReferenceDateTime = frameTime;
3664
+ item.FrameContentSequence.FrameAcquisitionDateTime = frameTime;
3665
+ item.FrameContentSequence.FrameReferenceDateTime = frameTime;
3649
3666
  }
3650
3667
  }
3651
3668
 
@@ -3673,7 +3690,7 @@ var ImageNormalizer = /*#__PURE__*/function (_Normalizer) {
3673
3690
  count: 0
3674
3691
  };
3675
3692
  ds.PerFrameFunctionalGroupsSequence.forEach(function (functionalGroup) {
3676
- if (functionalGroup.FrameVOILUT) {
3693
+ if (functionalGroup !== null && functionalGroup !== void 0 && functionalGroup.FrameVOILUT) {
3677
3694
  var wc = functionalGroup.FrameVOILUTSequence.WindowCenter;
3678
3695
  var ww = functionalGroup.FrameVOILUTSequence.WindowWidth;
3679
3696
  if (functionalGroup.FrameVOILUTSequence && wc && ww) {
@@ -3747,9 +3764,11 @@ var ImageNormalizer = /*#__PURE__*/function (_Normalizer) {
3747
3764
  }, {
3748
3765
  key: "planePositionGroup",
3749
3766
  value: function planePositionGroup(dataset) {
3767
+ var position = dataset.ImagePositionPatient;
3750
3768
  return {
3751
3769
  PlanePositionSequence: {
3752
- ImagePositionPatient: dataset.ImagePositionPatient
3770
+ // A copy, so that no two frames share one array
3771
+ ImagePositionPatient: Array.isArray(position) ? position.slice() : position
3753
3772
  }
3754
3773
  };
3755
3774
  }
@@ -16067,4 +16086,4 @@ exports.derivations = derivations;
16067
16086
  exports.normalizers = normalizers;
16068
16087
  exports.sr = sr;
16069
16088
  exports.utilities = utilities;
16070
- //# sourceMappingURL=dcmjs.shared-C_SwQ4fu.cjs.map
16089
+ //# sourceMappingURL=dcmjs.shared-Dkebpbbj.cjs.map