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.js CHANGED
@@ -8474,6 +8474,11 @@
8474
8474
  }
8475
8475
  return vr;
8476
8476
  }
8477
+ }, {
8478
+ key: "parseUnknownVr",
8479
+ value: function parseUnknownVr(type) {
8480
+ return new ParsedUnknownValue(type);
8481
+ }
8477
8482
  }]);
8478
8483
  return ValueRepresentation;
8479
8484
  }();
@@ -9540,60 +9545,108 @@
9540
9545
  }
9541
9546
  return _createClass(UnknownValue);
9542
9547
  }(BinaryRepresentation);
9543
- var OtherWordString = /*#__PURE__*/function (_BinaryRepresentation2) {
9544
- _inherits(OtherWordString, _BinaryRepresentation2);
9545
- var _super30 = _createSuper(OtherWordString);
9546
- function OtherWordString() {
9548
+ var ParsedUnknownValue = /*#__PURE__*/function (_BinaryRepresentation2) {
9549
+ _inherits(ParsedUnknownValue, _BinaryRepresentation2);
9550
+ var _super30 = _createSuper(ParsedUnknownValue);
9551
+ function ParsedUnknownValue(vr) {
9547
9552
  var _this29;
9548
- _classCallCheck(this, OtherWordString);
9549
- _this29 = _super30.call(this, "OW");
9553
+ _classCallCheck(this, ParsedUnknownValue);
9554
+ _this29 = _super30.call(this, vr);
9550
9555
  _this29.maxLength = null;
9551
- _this29.padByte = PADDING_NULL;
9556
+ _this29.padByte = 0;
9552
9557
  _this29.noMultiple = true;
9558
+ _this29._isBinary = true;
9559
+ _this29._allowMultiple = false;
9560
+ _this29._isExplicit = true;
9553
9561
  return _this29;
9554
9562
  }
9555
- return _createClass(OtherWordString);
9563
+ _createClass(ParsedUnknownValue, [{
9564
+ key: "read",
9565
+ value: function read(stream, length, syntax) {
9566
+ var arrayBuffer = this.readBytes(stream, length, syntax)[0];
9567
+ var streamFromBuffer = new ReadBufferStream(arrayBuffer, true);
9568
+ var vr = ValueRepresentation.createByTypeString(this.type);
9569
+ var values = [];
9570
+ if (vr.isBinary() && length > vr.maxLength && !vr.noMultiple) {
9571
+ var times = length / vr.maxLength,
9572
+ i = 0;
9573
+ while (i++ < times) {
9574
+ values.push(vr.read(streamFromBuffer, vr.maxLength, syntax));
9575
+ }
9576
+ } else {
9577
+ var val = vr.read(streamFromBuffer, length, syntax);
9578
+ if (!vr.isBinary() && singleVRs$1.indexOf(vr.type) == -1) {
9579
+ values = val;
9580
+ if (typeof val === "string") {
9581
+ values = val.split(String.fromCharCode(VM_DELIMITER));
9582
+ }
9583
+ } else if (vr.type == "SQ") {
9584
+ values = val;
9585
+ } else if (vr.type == "OW" || vr.type == "OB") {
9586
+ values = val;
9587
+ } else {
9588
+ Array.isArray(val) ? values = val : values.push(val);
9589
+ }
9590
+ }
9591
+ return values;
9592
+ }
9593
+ }]);
9594
+ return ParsedUnknownValue;
9556
9595
  }(BinaryRepresentation);
9557
- var OtherByteString = /*#__PURE__*/function (_BinaryRepresentation3) {
9558
- _inherits(OtherByteString, _BinaryRepresentation3);
9559
- var _super31 = _createSuper(OtherByteString);
9560
- function OtherByteString() {
9596
+ var OtherWordString = /*#__PURE__*/function (_BinaryRepresentation3) {
9597
+ _inherits(OtherWordString, _BinaryRepresentation3);
9598
+ var _super31 = _createSuper(OtherWordString);
9599
+ function OtherWordString() {
9561
9600
  var _this30;
9562
- _classCallCheck(this, OtherByteString);
9563
- _this30 = _super31.call(this, "OB");
9601
+ _classCallCheck(this, OtherWordString);
9602
+ _this30 = _super31.call(this, "OW");
9564
9603
  _this30.maxLength = null;
9565
9604
  _this30.padByte = PADDING_NULL;
9566
9605
  _this30.noMultiple = true;
9567
9606
  return _this30;
9568
9607
  }
9569
- return _createClass(OtherByteString);
9608
+ return _createClass(OtherWordString);
9570
9609
  }(BinaryRepresentation);
9571
- var OtherDoubleString = /*#__PURE__*/function (_BinaryRepresentation4) {
9572
- _inherits(OtherDoubleString, _BinaryRepresentation4);
9573
- var _super32 = _createSuper(OtherDoubleString);
9574
- function OtherDoubleString() {
9610
+ var OtherByteString = /*#__PURE__*/function (_BinaryRepresentation4) {
9611
+ _inherits(OtherByteString, _BinaryRepresentation4);
9612
+ var _super32 = _createSuper(OtherByteString);
9613
+ function OtherByteString() {
9575
9614
  var _this31;
9576
- _classCallCheck(this, OtherDoubleString);
9577
- _this31 = _super32.call(this, "OD");
9615
+ _classCallCheck(this, OtherByteString);
9616
+ _this31 = _super32.call(this, "OB");
9578
9617
  _this31.maxLength = null;
9579
9618
  _this31.padByte = PADDING_NULL;
9580
9619
  _this31.noMultiple = true;
9581
9620
  return _this31;
9582
9621
  }
9583
- return _createClass(OtherDoubleString);
9622
+ return _createClass(OtherByteString);
9584
9623
  }(BinaryRepresentation);
9585
- var OtherFloatString = /*#__PURE__*/function (_BinaryRepresentation5) {
9586
- _inherits(OtherFloatString, _BinaryRepresentation5);
9587
- var _super33 = _createSuper(OtherFloatString);
9588
- function OtherFloatString() {
9624
+ var OtherDoubleString = /*#__PURE__*/function (_BinaryRepresentation5) {
9625
+ _inherits(OtherDoubleString, _BinaryRepresentation5);
9626
+ var _super33 = _createSuper(OtherDoubleString);
9627
+ function OtherDoubleString() {
9589
9628
  var _this32;
9590
- _classCallCheck(this, OtherFloatString);
9591
- _this32 = _super33.call(this, "OF");
9629
+ _classCallCheck(this, OtherDoubleString);
9630
+ _this32 = _super33.call(this, "OD");
9592
9631
  _this32.maxLength = null;
9593
9632
  _this32.padByte = PADDING_NULL;
9594
9633
  _this32.noMultiple = true;
9595
9634
  return _this32;
9596
9635
  }
9636
+ return _createClass(OtherDoubleString);
9637
+ }(BinaryRepresentation);
9638
+ var OtherFloatString = /*#__PURE__*/function (_BinaryRepresentation6) {
9639
+ _inherits(OtherFloatString, _BinaryRepresentation6);
9640
+ var _super34 = _createSuper(OtherFloatString);
9641
+ function OtherFloatString() {
9642
+ var _this33;
9643
+ _classCallCheck(this, OtherFloatString);
9644
+ _this33 = _super34.call(this, "OF");
9645
+ _this33.maxLength = null;
9646
+ _this33.padByte = PADDING_NULL;
9647
+ _this33.noMultiple = true;
9648
+ return _this33;
9649
+ }
9597
9650
  return _createClass(OtherFloatString);
9598
9651
  }(BinaryRepresentation); // these VR instances are precreate and are reused for each requested vr/tag
9599
9652
  var VRinstances = {
@@ -10219,7 +10272,12 @@
10219
10272
  vr = ValueRepresentation.createByTypeString(vrType);
10220
10273
  } else {
10221
10274
  vrType = stream.readVR();
10222
- vr = ValueRepresentation.createByTypeString(vrType);
10275
+ if (vrType === "UN" && DicomMessage.lookupTag(tag) && DicomMessage.lookupTag(tag).vr) {
10276
+ vrType = DicomMessage.lookupTag(tag).vr;
10277
+ vr = ValueRepresentation.parseUnknownVr(vrType);
10278
+ } else {
10279
+ vr = ValueRepresentation.createByTypeString(vrType);
10280
+ }
10223
10281
  if (vr.isExplicit()) {
10224
10282
  stream.increment(2);
10225
10283
  length = stream.readUint32();
@@ -17416,13 +17474,18 @@ b"+i+"*=d\
17416
17474
  var imagePlaneModule = metadataProvider.get("imagePlaneModule", imageIds[0]);
17417
17475
  var generalSeriesModule = metadataProvider.get("generalSeriesModule", imageIds[0]);
17418
17476
  var SeriesInstanceUID = generalSeriesModule.seriesInstanceUID;
17419
- if (!imagePlaneModule) {
17420
- console.warn("Insufficient metadata, imagePlaneModule missing.");
17421
- }
17422
- 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];
17477
+ var ImageOrientationPatient;
17478
+ var validOrientations;
17479
+ var hasCoordinateSystem = ("FrameOfReferenceUID" in multiframe);
17480
+ if (hasCoordinateSystem) {
17481
+ if (!imagePlaneModule) {
17482
+ console.warn("Insufficient metadata, imagePlaneModule missing.");
17483
+ }
17484
+ 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];
17423
17485
 
17424
- // Get IOP from ref series, compute supported orientations:
17425
- var validOrientations = getValidOrientations(ImageOrientationPatient);
17486
+ // Get IOP from ref series, compute supported orientations:
17487
+ validOrientations = getValidOrientations(ImageOrientationPatient);
17488
+ }
17426
17489
  var sliceLength = multiframe.Columns * multiframe.Rows;
17427
17490
  var segMetadata = getSegmentMetadata(multiframe, SeriesInstanceUID);
17428
17491
  var TransferSyntaxUID = multiframe._meta.TransferSyntaxUID.Value[0];
@@ -17440,7 +17503,12 @@ b"+i+"*=d\
17440
17503
  throw new Error("Fractional segmentations are not yet supported");
17441
17504
  }
17442
17505
  }
17443
- var orientation = checkOrientation(multiframe, validOrientations, [imagePlaneModule.rows, imagePlaneModule.columns, imageIds.length], tolerance);
17506
+ var orientation;
17507
+ if (hasCoordinateSystem) {
17508
+ orientation = checkOrientation(multiframe, validOrientations, [imagePlaneModule.rows, imagePlaneModule.columns, imageIds.length], tolerance);
17509
+ } else {
17510
+ orientation = "Planar";
17511
+ }
17444
17512
  var overlapping = false;
17445
17513
  if (!skipOverlapping) {
17446
17514
  overlapping = checkSEGsOverlapping(pixelData, multiframe, imageIds, validOrientations, metadataProvider, tolerance);
@@ -17511,9 +17579,7 @@ b"+i+"*=d\
17511
17579
  return imageId;
17512
17580
  }
17513
17581
  var frameSourceImageSequence = undefined;
17514
- if (SourceImageSequence && SourceImageSequence.length !== 0) {
17515
- frameSourceImageSequence = SourceImageSequence[frameSegment];
17516
- } else if (PerFrameFunctionalGroup.DerivationImageSequence) {
17582
+ if (PerFrameFunctionalGroup.DerivationImageSequence) {
17517
17583
  var DerivationImageSequence = PerFrameFunctionalGroup.DerivationImageSequence;
17518
17584
  if (Array.isArray(DerivationImageSequence)) {
17519
17585
  if (DerivationImageSequence.length !== 0) {
@@ -17532,6 +17598,8 @@ b"+i+"*=d\
17532
17598
  }
17533
17599
  }
17534
17600
  }
17601
+ } else if (SourceImageSequence && SourceImageSequence.length !== 0) {
17602
+ frameSourceImageSequence = SourceImageSequence[frameSegment];
17535
17603
  }
17536
17604
  if (frameSourceImageSequence) {
17537
17605
  imageId = getImageIdOfSourceImagebySourceImageSequence(frameSourceImageSequence, imageIds, metadataProvider);
@@ -17609,9 +17677,15 @@ b"+i+"*=d\
17609
17677
  for (var i = 0; i < role.length; ++i) {
17610
17678
  var _frameSegment = role[i];
17611
17679
  var PerFrameFunctionalGroups = PerFrameFunctionalGroupsSequence[_frameSegment];
17612
- var ImageOrientationPatientI = sharedImageOrientationPatient || PerFrameFunctionalGroups.PlaneOrientationSequence.ImageOrientationPatient;
17613
17680
  var pixelDataI2D = ndarray$1(new Uint8Array(pixelData.buffer, _frameSegment * sliceLength, sliceLength), [Rows, Columns]);
17614
- var alignedPixelDataI = alignPixelDataWithSourceData(pixelDataI2D, ImageOrientationPatientI, validOrientations, tolerance);
17681
+ var alignedPixelDataI = void 0;
17682
+ var hasCoordinateSystem = ("FrameOfReferenceUID" in multiframe);
17683
+ if (hasCoordinateSystem) {
17684
+ var ImageOrientationPatientI = sharedImageOrientationPatient || PerFrameFunctionalGroups.PlaneOrientationSequence.ImageOrientationPatient;
17685
+ alignedPixelDataI = alignPixelDataWithSourceData(pixelDataI2D, ImageOrientationPatientI, validOrientations, tolerance);
17686
+ } else {
17687
+ alignedPixelDataI = pixelDataI2D;
17688
+ }
17615
17689
  if (!alignedPixelDataI) {
17616
17690
  console.warn("Individual SEG frames are out of plane with respect to the first SEG frame, this is not yet supported, skipping this frame.");
17617
17691
  continue;
@@ -17674,9 +17748,15 @@ b"+i+"*=d\
17674
17748
  i = _i2;
17675
17749
  return "continue";
17676
17750
  }
17677
- var ImageOrientationPatientI = sharedImageOrientationPatient || PerFrameFunctionalGroups.PlaneOrientationSequence.ImageOrientationPatient;
17678
17751
  var pixelDataI2D = ndarray$1(new Uint8Array(pixelData.buffer, _i2 * sliceLength, sliceLength), [Rows, Columns]);
17679
- var alignedPixelDataI = alignPixelDataWithSourceData(pixelDataI2D, ImageOrientationPatientI, validOrientations, tolerance);
17752
+ var alignedPixelDataI = void 0;
17753
+ var hasCoordinateSystem = ("FrameOfReferenceUID" in multiframe);
17754
+ if (hasCoordinateSystem) {
17755
+ var ImageOrientationPatientI = sharedImageOrientationPatient || PerFrameFunctionalGroups.PlaneOrientationSequence.ImageOrientationPatient;
17756
+ alignedPixelDataI = alignPixelDataWithSourceData(pixelDataI2D, ImageOrientationPatientI, validOrientations, tolerance);
17757
+ } else {
17758
+ alignedPixelDataI = pixelDataI2D;
17759
+ }
17680
17760
  if (!alignedPixelDataI) {
17681
17761
  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.");
17682
17762
  }
@@ -17686,8 +17766,8 @@ b"+i+"*=d\
17686
17766
  i = _i2;
17687
17767
  return "continue";
17688
17768
  }
17689
- var sourceImageMetadata = metadataProvider.get("instance", imageId);
17690
- if (Rows !== sourceImageMetadata.Rows || Columns !== sourceImageMetadata.Columns) {
17769
+ var sourceImageMetadata = metadataProvider.get("imagePixelModule", imageId);
17770
+ if (Rows !== sourceImageMetadata.rows || Columns !== sourceImageMetadata.columns) {
17691
17771
  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. ");
17692
17772
  }
17693
17773
  var imageIdIndex = imageIds.findIndex(function (element) {
@@ -17757,9 +17837,15 @@ b"+i+"*=d\
17757
17837
  var sliceLength = Columns * Rows;
17758
17838
  var _loop5 = function _loop5(groupsLen, _i3) {
17759
17839
  var PerFrameFunctionalGroups = PerFrameFunctionalGroupsSequence[_i3];
17760
- var ImageOrientationPatientI = sharedImageOrientationPatient || PerFrameFunctionalGroups.PlaneOrientationSequence.ImageOrientationPatient;
17761
17840
  var pixelDataI2D = ndarray$1(new Uint8Array(pixelData.buffer, _i3 * sliceLength, sliceLength), [Rows, Columns]);
17762
- var alignedPixelDataI = alignPixelDataWithSourceData(pixelDataI2D, ImageOrientationPatientI, validOrientations, tolerance);
17841
+ var alignedPixelDataI = void 0;
17842
+ var hasCoordinateSystem = ("FrameOfReferenceUID" in multiframe);
17843
+ if (hasCoordinateSystem) {
17844
+ var ImageOrientationPatientI = sharedImageOrientationPatient || PerFrameFunctionalGroups.PlaneOrientationSequence.ImageOrientationPatient;
17845
+ alignedPixelDataI = alignPixelDataWithSourceData(pixelDataI2D, ImageOrientationPatientI, validOrientations, tolerance);
17846
+ } else {
17847
+ alignedPixelDataI = pixelDataI2D;
17848
+ }
17763
17849
  if (!alignedPixelDataI) {
17764
17850
  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.");
17765
17851
  }
@@ -17772,8 +17858,8 @@ b"+i+"*=d\
17772
17858
  console.warn("Image not present in stack, can't import frame : " + _i3 + ".");
17773
17859
  return "continue";
17774
17860
  }
17775
- var sourceImageMetadata = metadataProvider.get("instance", imageId);
17776
- if (Rows !== sourceImageMetadata.Rows || Columns !== sourceImageMetadata.Columns) {
17861
+ var sourceImageMetadata = metadataProvider.get("imagePixelModule", imageId);
17862
+ if (Rows !== sourceImageMetadata.rows || Columns !== sourceImageMetadata.columns) {
17777
17863
  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. ");
17778
17864
  }
17779
17865
  var imageIdIndex = imageIds.findIndex(function (element) {