@dcmjs-org/dcmjs 1.0.0-beta.17 → 1.0.0-beta.18

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.
@@ -3428,16 +3428,10 @@ var ImageNormalizer = /*#__PURE__*/function (_Normalizer) {
3428
3428
  //
3429
3429
  // shared
3430
3430
  var SpacingBetweenSlices = Math.abs(distance1 - distance0);
3431
- ds.SharedFunctionalGroupsSequence = {
3432
- PlaneOrientationSequence: {
3433
- ImageOrientationPatient: dataset0.ImageOrientationPatient
3434
- },
3435
- PixelMeasuresSequence: {
3436
- PixelSpacing: dataset0.PixelSpacing,
3437
- SpacingBetweenSlices: SpacingBetweenSlices,
3438
- SliceThickness: SpacingBetweenSlices
3439
- }
3440
- };
3431
+ ds.SharedFunctionalGroupsSequence = ImageNormalizer.sharedImagePlaneGroups(dataset0, {
3432
+ SpacingBetweenSlices: SpacingBetweenSlices,
3433
+ SliceThickness: SpacingBetweenSlices
3434
+ });
3441
3435
  ds.ReferencedSeriesSequence = {
3442
3436
  SeriesInstanceUID: dataset0.SeriesInstanceUID,
3443
3437
  ReferencedInstanceSequence: []
@@ -3450,15 +3444,12 @@ var ImageNormalizer = /*#__PURE__*/function (_Normalizer) {
3450
3444
  // and set the referenced series uid
3451
3445
  distanceDatasetPairs.forEach(function (pair) {
3452
3446
  var dataset = pair[1];
3453
- ds.PerFrameFunctionalGroupsSequence.push({
3454
- PlanePositionSequence: {
3455
- ImagePositionPatient: dataset.ImagePositionPatient
3456
- },
3447
+ ds.PerFrameFunctionalGroupsSequence.push(_objectSpread2(_objectSpread2({}, ImageNormalizer.planePositionGroup(dataset)), {}, {
3457
3448
  FrameVOILUTSequence: {
3458
3449
  WindowCenter: dataset.WindowCenter,
3459
3450
  WindowWidth: dataset.WindowWidth
3460
3451
  }
3461
- });
3452
+ }));
3462
3453
  ds.ReferencedSeriesSequence.ReferencedInstanceSequence.push({
3463
3454
  ReferencedSOPClassUID: dataset.SOPClassUID,
3464
3455
  ReferencedSOPInstanceUID: dataset.SOPInstanceUID
@@ -3500,7 +3491,11 @@ var ImageNormalizer = /*#__PURE__*/function (_Normalizer) {
3500
3491
  ds.PresentationLUTShape = "IDENTITY";
3501
3492
  }
3502
3493
  if (!ds.SharedFunctionalGroupsSequence) {
3503
- core.log.error("Can only process multiframe data with SharedFunctionalGroupsSequence");
3494
+ core.log.warn("Missing SharedFunctionalGroupsSequence; using the top-level image plane attributes");
3495
+ ds.SharedFunctionalGroupsSequence = ImageNormalizer.sharedImagePlaneGroups(ds, {
3496
+ SliceThickness: ds.SliceThickness,
3497
+ SpacingBetweenSlices: ds.SpacingBetweenSlices
3498
+ });
3504
3499
  }
3505
3500
 
3506
3501
  // TODO: special case!
@@ -3521,9 +3516,22 @@ var ImageNormalizer = /*#__PURE__*/function (_Normalizer) {
3521
3516
  RescaleSlope: rescaleSlope,
3522
3517
  RescaleType: "US"
3523
3518
  };
3524
- var frameNumber = 1;
3525
- this.datasets.forEach(function (dataset) {
3526
- if (ds.NumberOfFrames === 1) ds.PerFrameFunctionalGroupsSequence = [ds.PerFrameFunctionalGroupsSequence];
3519
+ var frameCount = this.datasets.length;
3520
+ if (!ds.PerFrameFunctionalGroupsSequence) {
3521
+ // One item per declared frame, all at the top-level position
3522
+ frameCount = Math.max(frameCount, Number(ds.NumberOfFrames) || 0);
3523
+ ds.PerFrameFunctionalGroupsSequence = Array.from({
3524
+ length: frameCount
3525
+ }, function () {
3526
+ return ImageNormalizer.planePositionGroup(ds);
3527
+ });
3528
+ } else if (!Array.isArray(ds.PerFrameFunctionalGroupsSequence)) {
3529
+ ds.PerFrameFunctionalGroupsSequence = [ds.PerFrameFunctionalGroupsSequence];
3530
+ }
3531
+ for (var frameNumber = 1; frameNumber <= frameCount; frameNumber++) {
3532
+ var _ds$PerFrameFunctiona, _ref;
3533
+ var dataset = this.datasets[frameNumber - 1] || {};
3534
+ (_ds$PerFrameFunctiona = ds.PerFrameFunctionalGroupsSequence)[_ref = frameNumber - 1] || (_ds$PerFrameFunctiona[_ref] = {});
3527
3535
  ds.PerFrameFunctionalGroupsSequence[frameNumber - 1].FrameContentSequence = {
3528
3536
  FrameAcquisitionDuration: 0,
3529
3537
  StackID: 1,
@@ -3536,8 +3544,7 @@ var ImageNormalizer = /*#__PURE__*/function (_Normalizer) {
3536
3544
  frameContentSequence.FrameAcquisitionDateTime = frameTime;
3537
3545
  frameContentSequence.FrameReferenceDateTime = frameTime;
3538
3546
  }
3539
- frameNumber++;
3540
- });
3547
+ }
3541
3548
 
3542
3549
  //
3543
3550
  // TODO: convert this to shared functional group not top level element
@@ -3622,6 +3629,27 @@ var ImageNormalizer = /*#__PURE__*/function (_Normalizer) {
3622
3629
  value: function vec3Dot(a, b) {
3623
3630
  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
3624
3631
  }
3632
+ }, {
3633
+ key: "sharedImagePlaneGroups",
3634
+ value: function sharedImagePlaneGroups(dataset, pixelMeasures) {
3635
+ return {
3636
+ PlaneOrientationSequence: {
3637
+ ImageOrientationPatient: dataset.ImageOrientationPatient
3638
+ },
3639
+ PixelMeasuresSequence: _objectSpread2({
3640
+ PixelSpacing: dataset.PixelSpacing
3641
+ }, pixelMeasures)
3642
+ };
3643
+ }
3644
+ }, {
3645
+ key: "planePositionGroup",
3646
+ value: function planePositionGroup(dataset) {
3647
+ return {
3648
+ PlanePositionSequence: {
3649
+ ImagePositionPatient: dataset.ImagePositionPatient
3650
+ }
3651
+ };
3652
+ }
3625
3653
  }]);
3626
3654
  }(Normalizer);
3627
3655
  var MRImageNormalizer = /*#__PURE__*/function (_ImageNormalizer) {
@@ -6410,7 +6438,7 @@ function h(matrix) {
6410
6438
  var _matrix$shape = _slicedToArray(matrix.shape, 2),
6411
6439
  rows = _matrix$shape[0],
6412
6440
  cols = _matrix$shape[1];
6413
- var result = ndarray(new Uint8Array(rows * cols), [rows, cols]);
6441
+ var result = ndarray(new matrix.data.constructor(rows * cols), [rows, cols]);
6414
6442
  for (var i = 0; i < rows; i++) {
6415
6443
  for (var j = 0; j < cols; j++) {
6416
6444
  result.set(i, j, matrix.get(i, cols - 1 - j));
@@ -6429,7 +6457,7 @@ function v(matrix) {
6429
6457
  var _matrix$shape2 = _slicedToArray(matrix.shape, 2),
6430
6458
  rows = _matrix$shape2[0],
6431
6459
  cols = _matrix$shape2[1];
6432
- var result = ndarray(new Uint8Array(rows * cols), [rows, cols]);
6460
+ var result = ndarray(new matrix.data.constructor(rows * cols), [rows, cols]);
6433
6461
  for (var j = 0; j < cols; j++) {
6434
6462
  for (var i = 0; i < rows; i++) {
6435
6463
  result.set(i, j, matrix.get(rows - 1 - i, j));
@@ -6448,7 +6476,7 @@ function rotateMatrix902D (matrix) {
6448
6476
  var _matrix$shape = _slicedToArray(matrix.shape, 2),
6449
6477
  rows = _matrix$shape[0],
6450
6478
  cols = _matrix$shape[1];
6451
- var result = ndarray(new Uint8Array(rows * cols), [cols, rows]);
6479
+ var result = ndarray(new matrix.data.constructor(rows * cols), [cols, rows]);
6452
6480
  var resultColsMinus1 = result.shape[1] - 1;
6453
6481
  for (var i = 0; i < rows; i++) {
6454
6482
  for (var j = 0; j < cols; j++) {
@@ -15931,4 +15959,4 @@ exports.derivations = derivations;
15931
15959
  exports.normalizers = normalizers;
15932
15960
  exports.sr = sr;
15933
15961
  exports.utilities = utilities;
15934
- //# sourceMappingURL=dcmjs.shared---E7clvy.cjs.map
15962
+ //# sourceMappingURL=dcmjs.shared-CKG7Js9d.cjs.map