dcmjs 0.30.0 → 0.30.2

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.
package/build/dcmjs.es.js CHANGED
@@ -8468,6 +8468,11 @@ var ValueRepresentation = /*#__PURE__*/function () {
8468
8468
  }
8469
8469
  return vr;
8470
8470
  }
8471
+ }, {
8472
+ key: "parseUnknownVr",
8473
+ value: function parseUnknownVr(type) {
8474
+ return new ParsedUnknownValue(type);
8475
+ }
8471
8476
  }]);
8472
8477
  return ValueRepresentation;
8473
8478
  }();
@@ -9534,60 +9539,108 @@ var UnknownValue = /*#__PURE__*/function (_BinaryRepresentation) {
9534
9539
  }
9535
9540
  return _createClass(UnknownValue);
9536
9541
  }(BinaryRepresentation);
9537
- var OtherWordString = /*#__PURE__*/function (_BinaryRepresentation2) {
9538
- _inherits(OtherWordString, _BinaryRepresentation2);
9539
- var _super30 = _createSuper(OtherWordString);
9540
- function OtherWordString() {
9542
+ var ParsedUnknownValue = /*#__PURE__*/function (_BinaryRepresentation2) {
9543
+ _inherits(ParsedUnknownValue, _BinaryRepresentation2);
9544
+ var _super30 = _createSuper(ParsedUnknownValue);
9545
+ function ParsedUnknownValue(vr) {
9541
9546
  var _this29;
9542
- _classCallCheck(this, OtherWordString);
9543
- _this29 = _super30.call(this, "OW");
9547
+ _classCallCheck(this, ParsedUnknownValue);
9548
+ _this29 = _super30.call(this, vr);
9544
9549
  _this29.maxLength = null;
9545
- _this29.padByte = PADDING_NULL;
9550
+ _this29.padByte = 0;
9546
9551
  _this29.noMultiple = true;
9552
+ _this29._isBinary = true;
9553
+ _this29._allowMultiple = false;
9554
+ _this29._isExplicit = true;
9547
9555
  return _this29;
9548
9556
  }
9549
- return _createClass(OtherWordString);
9557
+ _createClass(ParsedUnknownValue, [{
9558
+ key: "read",
9559
+ value: function read(stream, length, syntax) {
9560
+ var arrayBuffer = this.readBytes(stream, length, syntax)[0];
9561
+ var streamFromBuffer = new ReadBufferStream(arrayBuffer, true);
9562
+ var vr = ValueRepresentation.createByTypeString(this.type);
9563
+ var values = [];
9564
+ if (vr.isBinary() && length > vr.maxLength && !vr.noMultiple) {
9565
+ var times = length / vr.maxLength,
9566
+ i = 0;
9567
+ while (i++ < times) {
9568
+ values.push(vr.read(streamFromBuffer, vr.maxLength, syntax));
9569
+ }
9570
+ } else {
9571
+ var val = vr.read(streamFromBuffer, length, syntax);
9572
+ if (!vr.isBinary() && singleVRs$1.indexOf(vr.type) == -1) {
9573
+ values = val;
9574
+ if (typeof val === "string") {
9575
+ values = val.split(String.fromCharCode(VM_DELIMITER));
9576
+ }
9577
+ } else if (vr.type == "SQ") {
9578
+ values = val;
9579
+ } else if (vr.type == "OW" || vr.type == "OB") {
9580
+ values = val;
9581
+ } else {
9582
+ Array.isArray(val) ? values = val : values.push(val);
9583
+ }
9584
+ }
9585
+ return values;
9586
+ }
9587
+ }]);
9588
+ return ParsedUnknownValue;
9550
9589
  }(BinaryRepresentation);
9551
- var OtherByteString = /*#__PURE__*/function (_BinaryRepresentation3) {
9552
- _inherits(OtherByteString, _BinaryRepresentation3);
9553
- var _super31 = _createSuper(OtherByteString);
9554
- function OtherByteString() {
9590
+ var OtherWordString = /*#__PURE__*/function (_BinaryRepresentation3) {
9591
+ _inherits(OtherWordString, _BinaryRepresentation3);
9592
+ var _super31 = _createSuper(OtherWordString);
9593
+ function OtherWordString() {
9555
9594
  var _this30;
9556
- _classCallCheck(this, OtherByteString);
9557
- _this30 = _super31.call(this, "OB");
9595
+ _classCallCheck(this, OtherWordString);
9596
+ _this30 = _super31.call(this, "OW");
9558
9597
  _this30.maxLength = null;
9559
9598
  _this30.padByte = PADDING_NULL;
9560
9599
  _this30.noMultiple = true;
9561
9600
  return _this30;
9562
9601
  }
9563
- return _createClass(OtherByteString);
9602
+ return _createClass(OtherWordString);
9564
9603
  }(BinaryRepresentation);
9565
- var OtherDoubleString = /*#__PURE__*/function (_BinaryRepresentation4) {
9566
- _inherits(OtherDoubleString, _BinaryRepresentation4);
9567
- var _super32 = _createSuper(OtherDoubleString);
9568
- function OtherDoubleString() {
9604
+ var OtherByteString = /*#__PURE__*/function (_BinaryRepresentation4) {
9605
+ _inherits(OtherByteString, _BinaryRepresentation4);
9606
+ var _super32 = _createSuper(OtherByteString);
9607
+ function OtherByteString() {
9569
9608
  var _this31;
9570
- _classCallCheck(this, OtherDoubleString);
9571
- _this31 = _super32.call(this, "OD");
9609
+ _classCallCheck(this, OtherByteString);
9610
+ _this31 = _super32.call(this, "OB");
9572
9611
  _this31.maxLength = null;
9573
9612
  _this31.padByte = PADDING_NULL;
9574
9613
  _this31.noMultiple = true;
9575
9614
  return _this31;
9576
9615
  }
9577
- return _createClass(OtherDoubleString);
9616
+ return _createClass(OtherByteString);
9578
9617
  }(BinaryRepresentation);
9579
- var OtherFloatString = /*#__PURE__*/function (_BinaryRepresentation5) {
9580
- _inherits(OtherFloatString, _BinaryRepresentation5);
9581
- var _super33 = _createSuper(OtherFloatString);
9582
- function OtherFloatString() {
9618
+ var OtherDoubleString = /*#__PURE__*/function (_BinaryRepresentation5) {
9619
+ _inherits(OtherDoubleString, _BinaryRepresentation5);
9620
+ var _super33 = _createSuper(OtherDoubleString);
9621
+ function OtherDoubleString() {
9583
9622
  var _this32;
9584
- _classCallCheck(this, OtherFloatString);
9585
- _this32 = _super33.call(this, "OF");
9623
+ _classCallCheck(this, OtherDoubleString);
9624
+ _this32 = _super33.call(this, "OD");
9586
9625
  _this32.maxLength = null;
9587
9626
  _this32.padByte = PADDING_NULL;
9588
9627
  _this32.noMultiple = true;
9589
9628
  return _this32;
9590
9629
  }
9630
+ return _createClass(OtherDoubleString);
9631
+ }(BinaryRepresentation);
9632
+ var OtherFloatString = /*#__PURE__*/function (_BinaryRepresentation6) {
9633
+ _inherits(OtherFloatString, _BinaryRepresentation6);
9634
+ var _super34 = _createSuper(OtherFloatString);
9635
+ function OtherFloatString() {
9636
+ var _this33;
9637
+ _classCallCheck(this, OtherFloatString);
9638
+ _this33 = _super34.call(this, "OF");
9639
+ _this33.maxLength = null;
9640
+ _this33.padByte = PADDING_NULL;
9641
+ _this33.noMultiple = true;
9642
+ return _this33;
9643
+ }
9591
9644
  return _createClass(OtherFloatString);
9592
9645
  }(BinaryRepresentation); // these VR instances are precreate and are reused for each requested vr/tag
9593
9646
  var VRinstances = {
@@ -10213,7 +10266,12 @@ var DicomMessage = /*#__PURE__*/function () {
10213
10266
  vr = ValueRepresentation.createByTypeString(vrType);
10214
10267
  } else {
10215
10268
  vrType = stream.readVR();
10216
- vr = ValueRepresentation.createByTypeString(vrType);
10269
+ if (vrType === "UN" && DicomMessage.lookupTag(tag) && DicomMessage.lookupTag(tag).vr) {
10270
+ vrType = DicomMessage.lookupTag(tag).vr;
10271
+ vr = ValueRepresentation.parseUnknownVr(vrType);
10272
+ } else {
10273
+ vr = ValueRepresentation.createByTypeString(vrType);
10274
+ }
10217
10275
  if (vr.isExplicit()) {
10218
10276
  stream.increment(2);
10219
10277
  length = stream.readUint32();
@@ -17410,13 +17468,18 @@ function generateToolState$1(imageIds, arrayBuffer, metadataProvider) {
17410
17468
  var imagePlaneModule = metadataProvider.get("imagePlaneModule", imageIds[0]);
17411
17469
  var generalSeriesModule = metadataProvider.get("generalSeriesModule", imageIds[0]);
17412
17470
  var SeriesInstanceUID = generalSeriesModule.seriesInstanceUID;
17413
- if (!imagePlaneModule) {
17414
- console.warn("Insufficient metadata, imagePlaneModule missing.");
17415
- }
17416
- var ImageOrientationPatient = Array.isArray(imagePlaneModule.rowCosines) ? [].concat(_toConsumableArray(imagePlaneModule.rowCosines), _toConsumableArray(imagePlaneModule.columnCosines)) : [imagePlaneModule.rowCosines.x, imagePlaneModule.rowCosines.y, imagePlaneModule.rowCosines.z, imagePlaneModule.columnCosines.x, imagePlaneModule.columnCosines.y, imagePlaneModule.columnCosines.z];
17471
+ var ImageOrientationPatient;
17472
+ var validOrientations;
17473
+ var hasCoordinateSystem = ("FrameOfReferenceUID" in multiframe);
17474
+ if (hasCoordinateSystem) {
17475
+ if (!imagePlaneModule) {
17476
+ console.warn("Insufficient metadata, imagePlaneModule missing.");
17477
+ }
17478
+ ImageOrientationPatient = Array.isArray(imagePlaneModule.rowCosines) ? [].concat(_toConsumableArray(imagePlaneModule.rowCosines), _toConsumableArray(imagePlaneModule.columnCosines)) : [imagePlaneModule.rowCosines.x, imagePlaneModule.rowCosines.y, imagePlaneModule.rowCosines.z, imagePlaneModule.columnCosines.x, imagePlaneModule.columnCosines.y, imagePlaneModule.columnCosines.z];
17417
17479
 
17418
- // Get IOP from ref series, compute supported orientations:
17419
- var validOrientations = getValidOrientations(ImageOrientationPatient);
17480
+ // Get IOP from ref series, compute supported orientations:
17481
+ validOrientations = getValidOrientations(ImageOrientationPatient);
17482
+ }
17420
17483
  var sliceLength = multiframe.Columns * multiframe.Rows;
17421
17484
  var segMetadata = getSegmentMetadata(multiframe, SeriesInstanceUID);
17422
17485
  var TransferSyntaxUID = multiframe._meta.TransferSyntaxUID.Value[0];
@@ -17434,7 +17497,12 @@ function generateToolState$1(imageIds, arrayBuffer, metadataProvider) {
17434
17497
  throw new Error("Fractional segmentations are not yet supported");
17435
17498
  }
17436
17499
  }
17437
- var orientation = checkOrientation(multiframe, validOrientations, [imagePlaneModule.rows, imagePlaneModule.columns, imageIds.length], tolerance);
17500
+ var orientation;
17501
+ if (hasCoordinateSystem) {
17502
+ orientation = checkOrientation(multiframe, validOrientations, [imagePlaneModule.rows, imagePlaneModule.columns, imageIds.length], tolerance);
17503
+ } else {
17504
+ orientation = "Planar";
17505
+ }
17438
17506
  var overlapping = false;
17439
17507
  if (!skipOverlapping) {
17440
17508
  overlapping = checkSEGsOverlapping(pixelData, multiframe, imageIds, validOrientations, metadataProvider, tolerance);
@@ -17505,9 +17573,7 @@ function findReferenceSourceImageId(multiframe, frameSegment, imageIds, metadata
17505
17573
  return imageId;
17506
17574
  }
17507
17575
  var frameSourceImageSequence = undefined;
17508
- if (SourceImageSequence && SourceImageSequence.length !== 0) {
17509
- frameSourceImageSequence = SourceImageSequence[frameSegment];
17510
- } else if (PerFrameFunctionalGroup.DerivationImageSequence) {
17576
+ if (PerFrameFunctionalGroup.DerivationImageSequence) {
17511
17577
  var DerivationImageSequence = PerFrameFunctionalGroup.DerivationImageSequence;
17512
17578
  if (Array.isArray(DerivationImageSequence)) {
17513
17579
  if (DerivationImageSequence.length !== 0) {
@@ -17526,6 +17592,8 @@ function findReferenceSourceImageId(multiframe, frameSegment, imageIds, metadata
17526
17592
  }
17527
17593
  }
17528
17594
  }
17595
+ } else if (SourceImageSequence && SourceImageSequence.length !== 0) {
17596
+ frameSourceImageSequence = SourceImageSequence[frameSegment];
17529
17597
  }
17530
17598
  if (frameSourceImageSequence) {
17531
17599
  imageId = getImageIdOfSourceImagebySourceImageSequence(frameSourceImageSequence, imageIds, metadataProvider);
@@ -17603,9 +17671,15 @@ function checkSEGsOverlapping(pixelData, multiframe, imageIds, validOrientations
17603
17671
  for (var i = 0; i < role.length; ++i) {
17604
17672
  var _frameSegment = role[i];
17605
17673
  var PerFrameFunctionalGroups = PerFrameFunctionalGroupsSequence[_frameSegment];
17606
- var ImageOrientationPatientI = sharedImageOrientationPatient || PerFrameFunctionalGroups.PlaneOrientationSequence.ImageOrientationPatient;
17607
17674
  var pixelDataI2D = ndarray$1(new Uint8Array(pixelData.buffer, _frameSegment * sliceLength, sliceLength), [Rows, Columns]);
17608
- var alignedPixelDataI = alignPixelDataWithSourceData(pixelDataI2D, ImageOrientationPatientI, validOrientations, tolerance);
17675
+ var alignedPixelDataI = void 0;
17676
+ var hasCoordinateSystem = ("FrameOfReferenceUID" in multiframe);
17677
+ if (hasCoordinateSystem) {
17678
+ var ImageOrientationPatientI = sharedImageOrientationPatient || PerFrameFunctionalGroups.PlaneOrientationSequence.ImageOrientationPatient;
17679
+ alignedPixelDataI = alignPixelDataWithSourceData(pixelDataI2D, ImageOrientationPatientI, validOrientations, tolerance);
17680
+ } else {
17681
+ alignedPixelDataI = pixelDataI2D;
17682
+ }
17609
17683
  if (!alignedPixelDataI) {
17610
17684
  console.warn("Individual SEG frames are out of plane with respect to the first SEG frame, this is not yet supported, skipping this frame.");
17611
17685
  continue;
@@ -17668,9 +17742,15 @@ function insertOverlappingPixelDataPlanar(segmentsOnFrame, segmentsOnFrameArray,
17668
17742
  i = _i2;
17669
17743
  return "continue";
17670
17744
  }
17671
- var ImageOrientationPatientI = sharedImageOrientationPatient || PerFrameFunctionalGroups.PlaneOrientationSequence.ImageOrientationPatient;
17672
17745
  var pixelDataI2D = ndarray$1(new Uint8Array(pixelData.buffer, _i2 * sliceLength, sliceLength), [Rows, Columns]);
17673
- var alignedPixelDataI = alignPixelDataWithSourceData(pixelDataI2D, ImageOrientationPatientI, validOrientations, tolerance);
17746
+ var alignedPixelDataI = void 0;
17747
+ var hasCoordinateSystem = ("FrameOfReferenceUID" in multiframe);
17748
+ if (hasCoordinateSystem) {
17749
+ var ImageOrientationPatientI = sharedImageOrientationPatient || PerFrameFunctionalGroups.PlaneOrientationSequence.ImageOrientationPatient;
17750
+ alignedPixelDataI = alignPixelDataWithSourceData(pixelDataI2D, ImageOrientationPatientI, validOrientations, tolerance);
17751
+ } else {
17752
+ alignedPixelDataI = pixelDataI2D;
17753
+ }
17674
17754
  if (!alignedPixelDataI) {
17675
17755
  throw new Error("Individual SEG frames are out of plane with respect to the first SEG frame. " + "This is not yet supported. Aborting segmentation loading.");
17676
17756
  }
@@ -17680,8 +17760,8 @@ function insertOverlappingPixelDataPlanar(segmentsOnFrame, segmentsOnFrameArray,
17680
17760
  i = _i2;
17681
17761
  return "continue";
17682
17762
  }
17683
- var sourceImageMetadata = metadataProvider.get("instance", imageId);
17684
- if (Rows !== sourceImageMetadata.Rows || Columns !== sourceImageMetadata.Columns) {
17763
+ var sourceImageMetadata = metadataProvider.get("imagePixelModule", imageId);
17764
+ if (Rows !== sourceImageMetadata.rows || Columns !== sourceImageMetadata.columns) {
17685
17765
  throw new Error("Individual SEG frames have different geometry dimensions (Rows and Columns) " + "respect to the source image reference frame. This is not yet supported. " + "Aborting segmentation loading. ");
17686
17766
  }
17687
17767
  var imageIdIndex = imageIds.findIndex(function (element) {
@@ -17751,9 +17831,15 @@ function insertPixelDataPlanar(segmentsOnFrame, segmentsOnFrameArray, labelmapBu
17751
17831
  var sliceLength = Columns * Rows;
17752
17832
  var _loop5 = function _loop5(groupsLen, _i3) {
17753
17833
  var PerFrameFunctionalGroups = PerFrameFunctionalGroupsSequence[_i3];
17754
- var ImageOrientationPatientI = sharedImageOrientationPatient || PerFrameFunctionalGroups.PlaneOrientationSequence.ImageOrientationPatient;
17755
17834
  var pixelDataI2D = ndarray$1(new Uint8Array(pixelData.buffer, _i3 * sliceLength, sliceLength), [Rows, Columns]);
17756
- var alignedPixelDataI = alignPixelDataWithSourceData(pixelDataI2D, ImageOrientationPatientI, validOrientations, tolerance);
17835
+ var alignedPixelDataI = void 0;
17836
+ var hasCoordinateSystem = ("FrameOfReferenceUID" in multiframe);
17837
+ if (hasCoordinateSystem) {
17838
+ var ImageOrientationPatientI = sharedImageOrientationPatient || PerFrameFunctionalGroups.PlaneOrientationSequence.ImageOrientationPatient;
17839
+ alignedPixelDataI = alignPixelDataWithSourceData(pixelDataI2D, ImageOrientationPatientI, validOrientations, tolerance);
17840
+ } else {
17841
+ alignedPixelDataI = pixelDataI2D;
17842
+ }
17757
17843
  if (!alignedPixelDataI) {
17758
17844
  throw new Error("Individual SEG frames are out of plane with respect to the first SEG frame. " + "This is not yet supported. Aborting segmentation loading.");
17759
17845
  }
@@ -17766,8 +17852,8 @@ function insertPixelDataPlanar(segmentsOnFrame, segmentsOnFrameArray, labelmapBu
17766
17852
  console.warn("Image not present in stack, can't import frame : " + _i3 + ".");
17767
17853
  return "continue";
17768
17854
  }
17769
- var sourceImageMetadata = metadataProvider.get("instance", imageId);
17770
- if (Rows !== sourceImageMetadata.Rows || Columns !== sourceImageMetadata.Columns) {
17855
+ var sourceImageMetadata = metadataProvider.get("imagePixelModule", imageId);
17856
+ if (Rows !== sourceImageMetadata.rows || Columns !== sourceImageMetadata.columns) {
17771
17857
  throw new Error("Individual SEG frames have different geometry dimensions (Rows and Columns) " + "respect to the source image reference frame. This is not yet supported. " + "Aborting segmentation loading. ");
17772
17858
  }
17773
17859
  var imageIdIndex = imageIds.findIndex(function (element) {