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

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.
@@ -1077,7 +1077,8 @@ var DicomMessage = /*#__PURE__*/function () {
1077
1077
  }
1078
1078
  var length = null,
1079
1079
  vr = null,
1080
- vrType;
1080
+ vrType,
1081
+ wireVrType = null;
1081
1082
  if (implicit) {
1082
1083
  length = stream.readUint32();
1083
1084
  var elementData = DicomMessage.lookupTag(tag);
@@ -1105,6 +1106,7 @@ var DicomMessage = /*#__PURE__*/function () {
1105
1106
  vr = core.ValueRepresentation.createByTypeString(vrType);
1106
1107
  } else {
1107
1108
  vrType = stream.readVR();
1109
+ wireVrType = vrType;
1108
1110
  if (vrType === "UN" && DicomMessage.lookupTag(tag) && DicomMessage.lookupTag(tag).vr) {
1109
1111
  vrType = DicomMessage.lookupTag(tag).vr;
1110
1112
  if (vrType === "xs") {
@@ -1123,13 +1125,19 @@ var DicomMessage = /*#__PURE__*/function () {
1123
1125
  length = stream.readUint16();
1124
1126
  }
1125
1127
  }
1128
+ var readSyntax = syntax;
1129
+ if (!implicit && wireVrType === "UN" && core.isUnSequenceValue(stream.view, stream.offset, length, vr.type)) {
1130
+ vr = core.ValueRepresentation.createByTypeString("SQ");
1131
+ readSyntax = core.IMPLICIT_LITTLE_ENDIAN;
1132
+ stream.setEndian(true); // the items are LE in a BE body too
1133
+ }
1126
1134
  var values = [];
1127
1135
  var rawValues = [];
1128
1136
  if (vr.isBinary() && length > vr.maxLength && !vr.noMultiple) {
1129
1137
  var times = length / vr.maxLength,
1130
1138
  i = 0;
1131
1139
  while (i++ < times) {
1132
- var _vr$read = vr.read(stream, vr.maxLength, syntax, options),
1140
+ var _vr$read = vr.read(stream, vr.maxLength, readSyntax, options),
1133
1141
  rawValue = _vr$read.rawValue,
1134
1142
  value = _vr$read.value;
1135
1143
  rawValues.push(rawValue);
@@ -1140,7 +1148,7 @@ var DicomMessage = /*#__PURE__*/function () {
1140
1148
  var readOptions = vr.type === "SQ" ? _objectSpread2(_objectSpread2({}, options), {}, {
1141
1149
  readItem: readItem
1142
1150
  }) : options;
1143
- var _ref = vr.read(stream, length, syntax, readOptions) || {},
1151
+ var _ref = vr.read(stream, length, readSyntax, readOptions) || {},
1144
1152
  _rawValue = _ref.rawValue,
1145
1153
  _value = _ref.value;
1146
1154
  if (!vr.isBinary() && core.singleVRs.indexOf(vr.type) == -1) {
@@ -2066,12 +2074,14 @@ var AsyncDicomReader = /*#__PURE__*/function () {
2066
2074
  key: "readSequence",
2067
2075
  value: (function () {
2068
2076
  var _readSequence = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(listener, sqTagInfo, options) {
2069
- var length, stream, syntax, endOffset, tagInfo, tag, itemLength, itemUntilOffset, _t;
2077
+ var _ref, _sqTagInfo$sequenceRe;
2078
+ var length, stream, readSyntax, endOffset, tagInfo, tag, itemLength, itemUntilOffset, decoder, _t;
2070
2079
  return _regeneratorRuntime().wrap(function (_context6) {
2071
2080
  while (1) switch (_context6.prev = _context6.next) {
2072
2081
  case 0:
2073
2082
  length = sqTagInfo.length;
2074
- stream = this.stream, syntax = this.syntax;
2083
+ stream = this.stream;
2084
+ readSyntax = (_ref = (_sqTagInfo$sequenceRe = sqTagInfo.sequenceReadSyntax) !== null && _sqTagInfo$sequenceRe !== void 0 ? _sqTagInfo$sequenceRe : options === null || options === void 0 ? void 0 : options.readSyntax) !== null && _ref !== void 0 ? _ref : this.syntax;
2075
2085
  endOffset = length === core.UNDEFINED_LENGTH_FIX ? Number.MAX_SAFE_INTEGER : stream.offset + length;
2076
2086
  case 1:
2077
2087
  _t = stream.offset < endOffset;
@@ -2089,7 +2099,9 @@ var AsyncDicomReader = /*#__PURE__*/function () {
2089
2099
  break;
2090
2100
  }
2091
2101
  readLog.debug("readSequence loop", stream.offset, endOffset);
2092
- tagInfo = this.readTagHeader(syntax, options);
2102
+ tagInfo = this.readTagHeader(_objectSpread2(_objectSpread2({}, options), {}, {
2103
+ readSyntax: readSyntax
2104
+ }));
2093
2105
  tag = tagInfo.tag;
2094
2106
  if (!(tag === core.TagHex.Item)) {
2095
2107
  _context6.next = 5;
@@ -2098,12 +2110,17 @@ var AsyncDicomReader = /*#__PURE__*/function () {
2098
2110
  listener.startObject();
2099
2111
  // defined-length item: stop at its own end (see doc comment)
2100
2112
  itemLength = tagInfo.length;
2101
- itemUntilOffset = itemLength === core.UNDEFINED_LENGTH_FIX ? endOffset : Math.min(stream.offset + itemLength, endOffset);
2113
+ itemUntilOffset = itemLength === core.UNDEFINED_LENGTH_FIX ? endOffset : Math.min(stream.offset + itemLength, endOffset); // A SpecificCharacterSet in the item applies only to that
2114
+ // item (PS3.5 7.5.3), but the item is read on this stream:
2115
+ // put back the decoder the item started with.
2116
+ decoder = stream.decoder;
2102
2117
  _context6.next = 4;
2103
2118
  return this.read(listener, _objectSpread2(_objectSpread2({}, options), {}, {
2104
- untilOffset: itemUntilOffset
2119
+ untilOffset: itemUntilOffset,
2120
+ readSyntax: readSyntax
2105
2121
  }));
2106
2122
  case 4:
2123
+ stream.setDecoder(decoder);
2107
2124
  _context6.next = 7;
2108
2125
  break;
2109
2126
  case 5:
@@ -2529,14 +2546,15 @@ var AsyncDicomReader = /*#__PURE__*/function () {
2529
2546
  }, {
2530
2547
  key: "readTagHeader",
2531
2548
  value: function readTagHeader() {
2549
+ var _options$readSyntax;
2532
2550
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
2533
2551
  untilTag: null,
2534
2552
  includeUntilTagValue: false
2535
2553
  };
2536
- var stream = this.stream,
2537
- syntax = this.syntax;
2554
+ var stream = this.stream;
2538
2555
  var untilTag = options.untilTag,
2539
2556
  includeUntilTagValue = options.includeUntilTagValue;
2557
+ var syntax = (_options$readSyntax = options.readSyntax) !== null && _options$readSyntax !== void 0 ? _options$readSyntax : this.syntax;
2540
2558
  var implicit = syntax == core.IMPLICIT_LITTLE_ENDIAN;
2541
2559
  var isLittleEndian = syntax !== core.EXPLICIT_BIG_ENDIAN;
2542
2560
  stream.setEndian(isLittleEndian);
@@ -2556,6 +2574,7 @@ var AsyncDicomReader = /*#__PURE__*/function () {
2556
2574
  var length = null;
2557
2575
  var vr = null;
2558
2576
  var vrType;
2577
+ var wireVrType = null;
2559
2578
  var isCommand = tagObj.group() === 0;
2560
2579
  if (tagObj.isInstruction()) {
2561
2580
  length = stream.readUint32();
@@ -2590,6 +2609,7 @@ var AsyncDicomReader = /*#__PURE__*/function () {
2590
2609
  } else {
2591
2610
  var _DicomMessage$lookupT;
2592
2611
  vrType = stream.readVR();
2612
+ wireVrType = vrType;
2593
2613
  if (vrType === "UN" && (_DicomMessage$lookupT = DicomMessage.lookupTag(tagObj)) !== null && _DicomMessage$lookupT !== void 0 && _DicomMessage$lookupT.vr) {
2594
2614
  vrType = DicomMessage.lookupTag(tagObj).vr;
2595
2615
  if (vrType === "xs") {
@@ -2609,11 +2629,16 @@ var AsyncDicomReader = /*#__PURE__*/function () {
2609
2629
  length = stream.readUint16();
2610
2630
  }
2611
2631
  }
2632
+ var sequenceReadSyntax;
2633
+ if (!implicit && wireVrType === "UN" && core.isUnSequenceValue(stream.view, stream.offset, length, vr.type)) {
2634
+ vr = core.ValueRepresentation.createByTypeString("SQ");
2635
+ sequenceReadSyntax = core.IMPLICIT_LITTLE_ENDIAN;
2636
+ }
2612
2637
  var punctuatedTag = core.DicomMetaDictionary.punctuateTag(tag);
2613
2638
  var entry = core.DicomMetaDictionary.dictionary[punctuatedTag];
2614
2639
 
2615
2640
  // Include both the string and object values for vr and tag
2616
- var header = {
2641
+ var header = _objectSpread2({
2617
2642
  vrObj: vr,
2618
2643
  vr: vr.type,
2619
2644
  tag: tag,
@@ -2621,7 +2646,9 @@ var AsyncDicomReader = /*#__PURE__*/function () {
2621
2646
  vm: entry === null || entry === void 0 ? void 0 : entry.vm,
2622
2647
  name: entry === null || entry === void 0 ? void 0 : entry.name,
2623
2648
  length: length === core.UNDEFINED_LENGTH ? -1 : length
2624
- };
2649
+ }, sequenceReadSyntax && {
2650
+ sequenceReadSyntax: sequenceReadSyntax
2651
+ });
2625
2652
  return header;
2626
2653
  }
2627
2654
 
@@ -2635,12 +2662,14 @@ var AsyncDicomReader = /*#__PURE__*/function () {
2635
2662
  key: "readSingle",
2636
2663
  value: (function () {
2637
2664
  var _readSingle = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(tagInfo, listener, options) {
2665
+ var _options$readSyntax2;
2638
2666
  var length, stream, syntax, vr, values, times, i, _vr$read, value, _vr$read2, _value, delimiterChar, decoder, valuesForListener;
2639
2667
  return _regeneratorRuntime().wrap(function (_context11) {
2640
2668
  while (1) switch (_context11.prev = _context11.next) {
2641
2669
  case 0:
2642
2670
  length = tagInfo.length;
2643
- stream = this.stream, syntax = this.syntax;
2671
+ stream = this.stream;
2672
+ syntax = (_options$readSyntax2 = options === null || options === void 0 ? void 0 : options.readSyntax) !== null && _options$readSyntax2 !== void 0 ? _options$readSyntax2 : this.syntax;
2644
2673
  _context11.next = 1;
2645
2674
  return this.stream.ensureAvailable(length);
2646
2675
  case 1:
@@ -12758,6 +12787,11 @@ var DICOMMicroscopyViewer = {
12758
12787
  MeasurementReport: MeasurementReport$1
12759
12788
  };
12760
12789
 
12790
+ /**
12791
+ * @deprecated The adapters moved to `@cornerstonejs/adapters`. Import them
12792
+ * from that package. `@dcmjs-org/dcmjs` keeps this export only for
12793
+ * compatibility with 0.x, and a later major release removes it.
12794
+ */
12761
12795
  var adapters = {
12762
12796
  Cornerstone: Cornerstone,
12763
12797
  Cornerstone3D: Cornerstone3D,
@@ -15959,4 +15993,4 @@ exports.derivations = derivations;
15959
15993
  exports.normalizers = normalizers;
15960
15994
  exports.sr = sr;
15961
15995
  exports.utilities = utilities;
15962
- //# sourceMappingURL=dcmjs.shared-CKG7Js9d.cjs.map
15996
+ //# sourceMappingURL=dcmjs.shared-L4OH_Ab_.cjs.map