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

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.
@@ -3568,6 +3568,22 @@ var ImageNormalizer = /*#__PURE__*/function (_Normalizer) {
3568
3568
  DimensionDescriptionLabel: "ImagePositionPatient"
3569
3569
  }];
3570
3570
  }
3571
+
3572
+ /**
3573
+ * Fills in the functional groups of a multiframe dataset.
3574
+ *
3575
+ * A missing or empty SharedFunctionalGroupsSequence is built from the
3576
+ * top-level image plane attributes; a one-item array is used as its item.
3577
+ * The shared item gets the list accessors (addAccessors), so both
3578
+ * `SharedFunctionalGroupsSequence.X` and `SharedFunctionalGroupsSequence[0].X`
3579
+ * work.
3580
+ * The PerFrameFunctionalGroupsSequence is filled up to the declared
3581
+ * NumberOfFrames with items at the top-level position, existing items keep
3582
+ * their content, and each item without a FrameContentSequence gets one.
3583
+ * Added items share the position but get increasing InStackPositionNumber.
3584
+ * Items beyond NumberOfFrames are kept unchanged; a null item there is
3585
+ * skipped and does not throw.
3586
+ */
3571
3587
  }, {
3572
3588
  key: "normalizeMultiframe",
3573
3589
  value: function normalizeMultiframe() {
@@ -3591,6 +3607,10 @@ var ImageNormalizer = /*#__PURE__*/function (_Normalizer) {
3591
3607
  if (!ds.PresentationLUTShape) {
3592
3608
  ds.PresentationLUTShape = "IDENTITY";
3593
3609
  }
3610
+ if (Array.isArray(ds.SharedFunctionalGroupsSequence)) {
3611
+ // The shared group has one item; an empty array counts as missing
3612
+ ds.SharedFunctionalGroupsSequence = ds.SharedFunctionalGroupsSequence[0];
3613
+ }
3594
3614
  if (!ds.SharedFunctionalGroupsSequence) {
3595
3615
  log.warn("Missing SharedFunctionalGroupsSequence; using the top-level image plane attributes");
3596
3616
  ds.SharedFunctionalGroupsSequence = ImageNormalizer.sharedImagePlaneGroups(ds, {
@@ -3598,6 +3618,7 @@ var ImageNormalizer = /*#__PURE__*/function (_Normalizer) {
3598
3618
  SpacingBetweenSlices: ds.SpacingBetweenSlices
3599
3619
  });
3600
3620
  }
3621
+ ds.SharedFunctionalGroupsSequence = addAccessors(ds.SharedFunctionalGroupsSequence);
3601
3622
 
3602
3623
  // TODO: special case!
3603
3624
  if (ds.BodyPartExamined === "PROSTATE") {
@@ -3617,23 +3638,20 @@ var ImageNormalizer = /*#__PURE__*/function (_Normalizer) {
3617
3638
  RescaleSlope: rescaleSlope,
3618
3639
  RescaleType: "US"
3619
3640
  };
3620
- var frameCount = this.datasets.length;
3621
- if (!ds.PerFrameFunctionalGroupsSequence) {
3622
- // One item per declared frame, all at the top-level position
3623
- frameCount = Math.max(frameCount, Number(ds.NumberOfFrames) || 0);
3624
- ds.PerFrameFunctionalGroupsSequence = Array.from({
3625
- length: frameCount
3626
- }, function () {
3627
- return ImageNormalizer.planePositionGroup(ds);
3628
- });
3629
- } else if (!Array.isArray(ds.PerFrameFunctionalGroupsSequence)) {
3630
- ds.PerFrameFunctionalGroupsSequence = [ds.PerFrameFunctionalGroupsSequence];
3641
+ var frameCount = Math.max(this.datasets.length, Number(ds.NumberOfFrames) || 0);
3642
+ var perFrame = ds.PerFrameFunctionalGroupsSequence || [];
3643
+ ds.PerFrameFunctionalGroupsSequence = Array.isArray(perFrame) ? perFrame : [perFrame];
3644
+ while (ds.PerFrameFunctionalGroupsSequence.length < frameCount) {
3645
+ ds.PerFrameFunctionalGroupsSequence.push(ImageNormalizer.planePositionGroup(ds));
3631
3646
  }
3632
3647
  for (var frameNumber = 1; frameNumber <= frameCount; frameNumber++) {
3633
3648
  var _ds$PerFrameFunctiona, _ref;
3649
+ var item = (_ds$PerFrameFunctiona = ds.PerFrameFunctionalGroupsSequence)[_ref = frameNumber - 1] || (_ds$PerFrameFunctiona[_ref] = {});
3650
+ if (item.FrameContentSequence) {
3651
+ continue;
3652
+ }
3634
3653
  var dataset = this.datasets[frameNumber - 1] || {};
3635
- (_ds$PerFrameFunctiona = ds.PerFrameFunctionalGroupsSequence)[_ref = frameNumber - 1] || (_ds$PerFrameFunctiona[_ref] = {});
3636
- ds.PerFrameFunctionalGroupsSequence[frameNumber - 1].FrameContentSequence = {
3654
+ item.FrameContentSequence = {
3637
3655
  FrameAcquisitionDuration: 0,
3638
3656
  StackID: 1,
3639
3657
  InStackPositionNumber: frameNumber,
@@ -3641,9 +3659,8 @@ var ImageNormalizer = /*#__PURE__*/function (_Normalizer) {
3641
3659
  };
3642
3660
  var frameTime = dataset.AcquisitionDate + dataset.AcquisitionTime;
3643
3661
  if (!isNaN(frameTime)) {
3644
- var frameContentSequence = ds.PerFrameFunctionalGroupsSequence[frameNumber - 1].FrameContentSequence;
3645
- frameContentSequence.FrameAcquisitionDateTime = frameTime;
3646
- frameContentSequence.FrameReferenceDateTime = frameTime;
3662
+ item.FrameContentSequence.FrameAcquisitionDateTime = frameTime;
3663
+ item.FrameContentSequence.FrameReferenceDateTime = frameTime;
3647
3664
  }
3648
3665
  }
3649
3666
 
@@ -3671,7 +3688,7 @@ var ImageNormalizer = /*#__PURE__*/function (_Normalizer) {
3671
3688
  count: 0
3672
3689
  };
3673
3690
  ds.PerFrameFunctionalGroupsSequence.forEach(function (functionalGroup) {
3674
- if (functionalGroup.FrameVOILUT) {
3691
+ if (functionalGroup !== null && functionalGroup !== void 0 && functionalGroup.FrameVOILUT) {
3675
3692
  var wc = functionalGroup.FrameVOILUTSequence.WindowCenter;
3676
3693
  var ww = functionalGroup.FrameVOILUTSequence.WindowWidth;
3677
3694
  if (functionalGroup.FrameVOILUTSequence && wc && ww) {
@@ -3745,9 +3762,11 @@ var ImageNormalizer = /*#__PURE__*/function (_Normalizer) {
3745
3762
  }, {
3746
3763
  key: "planePositionGroup",
3747
3764
  value: function planePositionGroup(dataset) {
3765
+ var position = dataset.ImagePositionPatient;
3748
3766
  return {
3749
3767
  PlanePositionSequence: {
3750
- ImagePositionPatient: dataset.ImagePositionPatient
3768
+ // A copy, so that no two frames share one array
3769
+ ImagePositionPatient: Array.isArray(position) ? position.slice() : position
3751
3770
  }
3752
3771
  };
3753
3772
  }
@@ -16045,4 +16064,4 @@ ValueRepresentation.setTagClass(Tag);
16045
16064
  // entries (src/eventStream.js, ...): the default entry is the 0.52 surface.
16046
16065
 
16047
16066
  export { DICOMWEB as D, _inherits as _, _createClass as a, _objectSpread2 as b, _classCallCheck as c, _callSuper as d, _createForOfIteratorHelper as e, datasetToDict as f, _typeof as g, _asyncToGenerator as h, _regeneratorRuntime as i, adapters as j, anonymizer as k, async as l, constants as m, data as n, dcmjs as o, derivations as p, normalizers as q, sr as s, utilities as u };
16048
- //# sourceMappingURL=dcmjs.shared-CMo1hh3U.js.map
16067
+ //# sourceMappingURL=dcmjs.shared-DVqSe8G1.js.map