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