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

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.
@@ -1,4 +1,4 @@
1
- import { log, ValueRepresentation as ValueRepresentation$1, reservePrivateBlock, findPrivateBlock, writePart10, TagHex, resolveCharsetDecoder, normalizeSyntax, isEncapsulatedSyntax, EXPLICIT_LITTLE_ENDIAN, IMPLICIT_LITTLE_ENDIAN, VALID_VRS, ReadBufferStream, DEFLATED_EXPLICIT_LITTLE_ENDIAN, DeflatedReadBufferStream, writeTagObject, writeDataSet, getTagWriteValues, Tag, UNDEFINED_LENGTH, singleVRs, DicomMetaDictionary, VM_DELIMITER, UNDEFINED_LENGTH_FIX, EXPLICIT_BIG_ENDIAN, DicomMetadataListener, isVideoTransferSyntax, addAccessors, createInformationFilter, toInt, toFloat, dicomJson, BULKDATA_VRS, DEFAULT_INFORMATION_TAGS, ITEM_DELIMITATION_LENGTH, PADDING_NULL, PADDING_SPACE, PN_COMPONENT_DELIMITER, SEQUENCE_DELIMITATION_VALUE, SEQUENCE_DELIMITER_TAG, SEQUENCE_ITEM_TAG, TAG_NAME_MAP, encodingMapping, unencapsulatedTransferSyntaxes, videoTransferSyntaxUIDs, registerPrivatesModule, lookupPrivateTag, privateBlockKey, frameDataset, definePrivateAliases, setPersonName, setAttribute, setVr, WriteBufferStream } from '@dcmjs-org/core';
1
+ import { log, ValueRepresentation as ValueRepresentation$1, reservePrivateBlock, findPrivateBlock, writePart10, TagHex, resolveCharsetDecoder, normalizeSyntax, isEncapsulatedSyntax, EXPLICIT_LITTLE_ENDIAN, IMPLICIT_LITTLE_ENDIAN, VALID_VRS, ReadBufferStream, DEFLATED_EXPLICIT_LITTLE_ENDIAN, DeflatedReadBufferStream, writeTagObject, writeDataSet, getTagWriteValues, Tag, UNDEFINED_LENGTH, isUnSequenceValue, singleVRs, DicomMetaDictionary, VM_DELIMITER, UNDEFINED_LENGTH_FIX, EXPLICIT_BIG_ENDIAN, DicomMetadataListener, isVideoTransferSyntax, addAccessors, createInformationFilter, toInt, toFloat, dicomJson, BULKDATA_VRS, DEFAULT_INFORMATION_TAGS, ITEM_DELIMITATION_LENGTH, PADDING_NULL, PADDING_SPACE, PN_COMPONENT_DELIMITER, SEQUENCE_DELIMITATION_VALUE, SEQUENCE_DELIMITER_TAG, SEQUENCE_ITEM_TAG, TAG_NAME_MAP, encodingMapping, unencapsulatedTransferSyntaxes, videoTransferSyntaxUIDs, registerPrivatesModule, lookupPrivateTag, privateBlockKey, frameDataset, definePrivateAliases, setPersonName, setAttribute, setVr, WriteBufferStream } from '@dcmjs-org/core';
2
2
 
3
3
  /* eslint no-bitwise: 0 */
4
4
  var BitArray = {
@@ -1075,7 +1075,8 @@ var DicomMessage = /*#__PURE__*/function () {
1075
1075
  }
1076
1076
  var length = null,
1077
1077
  vr = null,
1078
- vrType;
1078
+ vrType,
1079
+ wireVrType = null;
1079
1080
  if (implicit) {
1080
1081
  length = stream.readUint32();
1081
1082
  var elementData = DicomMessage.lookupTag(tag);
@@ -1103,6 +1104,7 @@ var DicomMessage = /*#__PURE__*/function () {
1103
1104
  vr = ValueRepresentation$1.createByTypeString(vrType);
1104
1105
  } else {
1105
1106
  vrType = stream.readVR();
1107
+ wireVrType = vrType;
1106
1108
  if (vrType === "UN" && DicomMessage.lookupTag(tag) && DicomMessage.lookupTag(tag).vr) {
1107
1109
  vrType = DicomMessage.lookupTag(tag).vr;
1108
1110
  if (vrType === "xs") {
@@ -1121,13 +1123,19 @@ var DicomMessage = /*#__PURE__*/function () {
1121
1123
  length = stream.readUint16();
1122
1124
  }
1123
1125
  }
1126
+ var readSyntax = syntax;
1127
+ if (!implicit && wireVrType === "UN" && isUnSequenceValue(stream.view, stream.offset, length, vr.type)) {
1128
+ vr = ValueRepresentation$1.createByTypeString("SQ");
1129
+ readSyntax = IMPLICIT_LITTLE_ENDIAN;
1130
+ stream.setEndian(true); // the items are LE in a BE body too
1131
+ }
1124
1132
  var values = [];
1125
1133
  var rawValues = [];
1126
1134
  if (vr.isBinary() && length > vr.maxLength && !vr.noMultiple) {
1127
1135
  var times = length / vr.maxLength,
1128
1136
  i = 0;
1129
1137
  while (i++ < times) {
1130
- var _vr$read = vr.read(stream, vr.maxLength, syntax, options),
1138
+ var _vr$read = vr.read(stream, vr.maxLength, readSyntax, options),
1131
1139
  rawValue = _vr$read.rawValue,
1132
1140
  value = _vr$read.value;
1133
1141
  rawValues.push(rawValue);
@@ -1138,7 +1146,7 @@ var DicomMessage = /*#__PURE__*/function () {
1138
1146
  var readOptions = vr.type === "SQ" ? _objectSpread2(_objectSpread2({}, options), {}, {
1139
1147
  readItem: readItem
1140
1148
  }) : options;
1141
- var _ref = vr.read(stream, length, syntax, readOptions) || {},
1149
+ var _ref = vr.read(stream, length, readSyntax, readOptions) || {},
1142
1150
  _rawValue = _ref.rawValue,
1143
1151
  _value = _ref.value;
1144
1152
  if (!vr.isBinary() && singleVRs.indexOf(vr.type) == -1) {
@@ -1598,6 +1606,8 @@ var AsyncDicomReader = /*#__PURE__*/function () {
1598
1606
  _classCallCheck(this, AsyncDicomReader);
1599
1607
  _defineProperty(this, "syntax", EXPLICIT_LITTLE_ENDIAN);
1600
1608
  this.isLittleEndian = options === null || options === void 0 ? void 0 : options.isLittleEndian;
1609
+ // Number of sequence items being read, 0 at the top level
1610
+ this.sequenceDepth = 0;
1601
1611
  // Default maxFragmentSize is 128 MB (128 * 1024 * 1024 bytes)
1602
1612
  this.maxFragmentSize = (_options$maxFragmentS = options === null || options === void 0 ? void 0 : options.maxFragmentSize) !== null && _options$maxFragmentS !== void 0 ? _options$maxFragmentS : 128 * 1024 * 1024;
1603
1613
  this.stream = new ReadBufferStream(null, _objectSpread2(_objectSpread2({
@@ -2059,17 +2069,27 @@ var AsyncDicomReader = /*#__PURE__*/function () {
2059
2069
  * item boundary and returns control here for the next item. Without that
2060
2070
  * offset, read() skips the later Item tags as instructions, and all items
2061
2071
  * of a defined-length sequence merge into the first item.
2072
+ *
2073
+ * untilTag and includeUntilTagValue apply to the top-level data set only,
2074
+ * so the items are read without them: an Icon Image Sequence item has its
2075
+ * own Pixel Data, which must not stop a read with untilTag 7FE00010.
2062
2076
  */
2063
2077
  }, {
2064
2078
  key: "readSequence",
2065
2079
  value: (function () {
2066
2080
  var _readSequence = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(listener, sqTagInfo, options) {
2067
- var length, stream, syntax, endOffset, tagInfo, tag, itemLength, itemUntilOffset, _t;
2081
+ var _ref, _sqTagInfo$sequenceRe;
2082
+ var itemOptions, length, stream, readSyntax, endOffset, tagInfo, tag, itemLength, itemUntilOffset, decoder, _t;
2068
2083
  return _regeneratorRuntime().wrap(function (_context6) {
2069
2084
  while (1) switch (_context6.prev = _context6.next) {
2070
2085
  case 0:
2086
+ itemOptions = _objectSpread2(_objectSpread2({}, options), {}, {
2087
+ untilTag: null,
2088
+ includeUntilTagValue: false
2089
+ });
2071
2090
  length = sqTagInfo.length;
2072
- stream = this.stream, syntax = this.syntax;
2091
+ stream = this.stream;
2092
+ 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;
2073
2093
  endOffset = length === UNDEFINED_LENGTH_FIX ? Number.MAX_SAFE_INTEGER : stream.offset + length;
2074
2094
  case 1:
2075
2095
  _t = stream.offset < endOffset;
@@ -2083,50 +2103,78 @@ var AsyncDicomReader = /*#__PURE__*/function () {
2083
2103
  _t = _context6.sent;
2084
2104
  case 3:
2085
2105
  if (!_t) {
2086
- _context6.next = 8;
2106
+ _context6.next = 10;
2087
2107
  break;
2088
2108
  }
2089
2109
  readLog.debug("readSequence loop", stream.offset, endOffset);
2090
- tagInfo = this.readTagHeader(syntax, options);
2110
+ tagInfo = this.readTagHeader(_objectSpread2(_objectSpread2({}, itemOptions), {}, {
2111
+ readSyntax: readSyntax
2112
+ }));
2091
2113
  tag = tagInfo.tag;
2092
2114
  if (!(tag === TagHex.Item)) {
2093
- _context6.next = 5;
2115
+ _context6.next = 7;
2094
2116
  break;
2095
2117
  }
2096
2118
  listener.startObject();
2097
2119
  // defined-length item: stop at its own end (see doc comment)
2098
2120
  itemLength = tagInfo.length;
2099
- itemUntilOffset = itemLength === UNDEFINED_LENGTH_FIX ? endOffset : Math.min(stream.offset + itemLength, endOffset);
2100
- _context6.next = 4;
2101
- return this.read(listener, _objectSpread2(_objectSpread2({}, options), {}, {
2102
- untilOffset: itemUntilOffset
2121
+ itemUntilOffset = itemLength === UNDEFINED_LENGTH_FIX ? endOffset : Math.min(stream.offset + itemLength, endOffset); // A SpecificCharacterSet in the item applies only to that
2122
+ // item (PS3.5 7.5.3), but the item is read on this stream:
2123
+ // put back the decoder the item started with.
2124
+ decoder = stream.decoder;
2125
+ this.sequenceDepth++;
2126
+ _context6.prev = 4;
2127
+ _context6.next = 5;
2128
+ return this.read(listener, _objectSpread2(_objectSpread2({}, itemOptions), {}, {
2129
+ untilOffset: itemUntilOffset,
2130
+ readSyntax: readSyntax
2103
2131
  }));
2104
- case 4:
2105
- _context6.next = 7;
2106
- break;
2107
2132
  case 5:
2133
+ _context6.prev = 5;
2134
+ this.sequenceDepth--;
2135
+ return _context6.finish(5);
2136
+ case 6:
2137
+ stream.setDecoder(decoder);
2138
+ _context6.next = 9;
2139
+ break;
2140
+ case 7:
2108
2141
  if (!(tag === TagHex.SequenceDelimitationEnd)) {
2109
- _context6.next = 6;
2142
+ _context6.next = 8;
2110
2143
  break;
2111
2144
  }
2112
2145
  return _context6.abrupt("return");
2113
- case 6:
2146
+ case 8:
2114
2147
  console.warn("Unknown tag info", length, tagInfo);
2115
- throw new Error();
2116
- case 7:
2148
+ throw new Error("Expected an item or a sequence delimitation item in a sequence, found tag ".concat(tag));
2149
+ case 9:
2117
2150
  _context6.next = 1;
2118
2151
  break;
2119
- case 8:
2152
+ case 10:
2120
2153
  case "end":
2121
2154
  return _context6.stop();
2122
2155
  }
2123
- }, _callee6, this);
2156
+ }, _callee6, this, [[4,, 5, 6]]);
2124
2157
  }));
2125
2158
  function readSequence(_x3, _x4, _x5) {
2126
2159
  return _readSequence.apply(this, arguments);
2127
2160
  }
2128
2161
  return readSequence;
2129
- }())
2162
+ }()
2163
+ /**
2164
+ * The number of frames of the Pixel Data being read. NumberOfFrames is
2165
+ * tracked for the top-level data set only, so Pixel Data inside a sequence
2166
+ * item (an Icon Image Sequence item, for example) is a single frame.
2167
+ */
2168
+ )
2169
+ }, {
2170
+ key: "getNumberOfFrames",
2171
+ value: function getNumberOfFrames() {
2172
+ var _this$listener;
2173
+ if (this.sequenceDepth > 0) {
2174
+ return 1;
2175
+ }
2176
+ return parseInt(((_this$listener = this.listener) === null || _this$listener === void 0 || (_this$listener = _this$listener.information) === null || _this$listener === void 0 ? void 0 : _this$listener.numberOfFrames) || 1);
2177
+ }
2130
2178
  }, {
2131
2179
  key: "readPixelData",
2132
2180
  value: function readPixelData(tagInfo) {
@@ -2196,8 +2244,7 @@ var AsyncDicomReader = /*#__PURE__*/function () {
2196
2244
  key: "readCompressed",
2197
2245
  value: (function () {
2198
2246
  var _readCompressed = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(_tagInfo) {
2199
- var _listener$information;
2200
- var stream, listener, transferSyntaxUid, isVideo, numberOfFrames, isSingleFrame, offsets, singleArray, startOffset, frameNumber, lastFrame, frameTag, length;
2247
+ var stream, listener, transferSyntaxUid, isVideo, isSingleFrame, offsets, singleArray, startOffset, frameNumber, lastFrame, frameTag, length;
2201
2248
  return _regeneratorRuntime().wrap(function (_context8) {
2202
2249
  while (1) switch (_context8.prev = _context8.next) {
2203
2250
  case 0:
@@ -2208,8 +2255,7 @@ var AsyncDicomReader = /*#__PURE__*/function () {
2208
2255
  case 1:
2209
2256
  // Check if this is a video transfer syntax
2210
2257
  isVideo = isVideoTransferSyntax(transferSyntaxUid); // Check number of frames - only use video logic for single frame (or undefined)
2211
- numberOfFrames = (_listener$information = listener.information) === null || _listener$information === void 0 ? void 0 : _listener$information.numberOfFrames;
2212
- isSingleFrame = !numberOfFrames || parseInt(numberOfFrames) <= 1;
2258
+ isSingleFrame = this.getNumberOfFrames() <= 1;
2213
2259
  _context8.next = 2;
2214
2260
  return this.readOffsets();
2215
2261
  case 2:
@@ -2323,23 +2369,22 @@ var AsyncDicomReader = /*#__PURE__*/function () {
2323
2369
  key: "readUncompressed",
2324
2370
  value: (function () {
2325
2371
  var _readUncompressed = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee0(tagInfo) {
2326
- var _listener$information2;
2327
- var length, listener, numberOfFrames, frameLength, _listener$information3, _listener$information4, _listener$information5, _listener$information6, rows, cols, samplesPerPixel, bitsAllocated, bitsPerFrame, frameNumber;
2372
+ var length, listener, numberOfFrames, frameLength, _listener$information, _listener$information2, _listener$information3, _listener$information4, rows, cols, samplesPerPixel, bitsAllocated, bitsPerFrame, frameNumber;
2328
2373
  return _regeneratorRuntime().wrap(function (_context0) {
2329
2374
  while (1) switch (_context0.prev = _context0.next) {
2330
2375
  case 0:
2331
2376
  length = tagInfo.length;
2332
2377
  listener = this.listener;
2333
- numberOfFrames = parseInt(((_listener$information2 = listener.information) === null || _listener$information2 === void 0 ? void 0 : _listener$information2.numberOfFrames) || 1);
2378
+ numberOfFrames = this.getNumberOfFrames();
2334
2379
  frameLength = Math.floor(length / numberOfFrames);
2335
2380
  if (!(numberOfFrames > 1)) {
2336
2381
  _context0.next = 4;
2337
2382
  break;
2338
2383
  }
2339
- rows = (_listener$information3 = listener.information) === null || _listener$information3 === void 0 ? void 0 : _listener$information3.rows;
2340
- cols = (_listener$information4 = listener.information) === null || _listener$information4 === void 0 ? void 0 : _listener$information4.columns;
2341
- samplesPerPixel = (_listener$information5 = listener.information) === null || _listener$information5 === void 0 ? void 0 : _listener$information5.samplesPerPixel;
2342
- bitsAllocated = (_listener$information6 = listener.information) === null || _listener$information6 === void 0 ? void 0 : _listener$information6.bitsAllocated;
2384
+ rows = (_listener$information = listener.information) === null || _listener$information === void 0 ? void 0 : _listener$information.rows;
2385
+ cols = (_listener$information2 = listener.information) === null || _listener$information2 === void 0 ? void 0 : _listener$information2.columns;
2386
+ samplesPerPixel = (_listener$information3 = listener.information) === null || _listener$information3 === void 0 ? void 0 : _listener$information3.samplesPerPixel;
2387
+ bitsAllocated = (_listener$information4 = listener.information) === null || _listener$information4 === void 0 ? void 0 : _listener$information4.bitsAllocated;
2343
2388
  bitsPerFrame = rows * cols * samplesPerPixel * bitsAllocated;
2344
2389
  if (!(bitsPerFrame % 8 !== 0)) {
2345
2390
  _context0.next = 3;
@@ -2408,18 +2453,18 @@ var AsyncDicomReader = /*#__PURE__*/function () {
2408
2453
  key: "readUncompressedBitFrame",
2409
2454
  value: (function () {
2410
2455
  var _readUncompressedBitFrame = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee1(tagInfo) {
2411
- var _listener$information7, _listener$information8, _listener$information9, _listener$information0, _listener$information1;
2456
+ var _listener$information5, _listener$information6, _listener$information7, _listener$information8;
2412
2457
  var length, listener, stream, numberOfFrames, rows, cols, samplesPerPixel, bitsAllocated, bitsPerFrame, bytesPerFrame, totalBits, totalBytes, allPixelData, frameNumber, bitOffset, frameBuffer, frameView, sourceView, bitIndex, globalBitIndex, sourceByteIndex, sourceBitIndex, targetByteIndex, targetBitIndex, sourceByte, bitValue;
2413
2458
  return _regeneratorRuntime().wrap(function (_context1) {
2414
2459
  while (1) switch (_context1.prev = _context1.next) {
2415
2460
  case 0:
2416
2461
  length = tagInfo.length;
2417
2462
  listener = this.listener, stream = this.stream;
2418
- numberOfFrames = parseInt(((_listener$information7 = listener.information) === null || _listener$information7 === void 0 ? void 0 : _listener$information7.numberOfFrames) || 1);
2419
- rows = (_listener$information8 = listener.information) === null || _listener$information8 === void 0 ? void 0 : _listener$information8.rows;
2420
- cols = (_listener$information9 = listener.information) === null || _listener$information9 === void 0 ? void 0 : _listener$information9.columns;
2421
- samplesPerPixel = ((_listener$information0 = listener.information) === null || _listener$information0 === void 0 ? void 0 : _listener$information0.samplesPerPixel) || 1;
2422
- bitsAllocated = (_listener$information1 = listener.information) === null || _listener$information1 === void 0 ? void 0 : _listener$information1.bitsAllocated;
2463
+ numberOfFrames = this.getNumberOfFrames();
2464
+ rows = (_listener$information5 = listener.information) === null || _listener$information5 === void 0 ? void 0 : _listener$information5.rows;
2465
+ cols = (_listener$information6 = listener.information) === null || _listener$information6 === void 0 ? void 0 : _listener$information6.columns;
2466
+ samplesPerPixel = ((_listener$information7 = listener.information) === null || _listener$information7 === void 0 ? void 0 : _listener$information7.samplesPerPixel) || 1;
2467
+ bitsAllocated = (_listener$information8 = listener.information) === null || _listener$information8 === void 0 ? void 0 : _listener$information8.bitsAllocated;
2423
2468
  if (!(!rows || !cols || !bitsAllocated)) {
2424
2469
  _context1.next = 1;
2425
2470
  break;
@@ -2527,14 +2572,15 @@ var AsyncDicomReader = /*#__PURE__*/function () {
2527
2572
  }, {
2528
2573
  key: "readTagHeader",
2529
2574
  value: function readTagHeader() {
2575
+ var _options$readSyntax;
2530
2576
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
2531
2577
  untilTag: null,
2532
2578
  includeUntilTagValue: false
2533
2579
  };
2534
- var stream = this.stream,
2535
- syntax = this.syntax;
2580
+ var stream = this.stream;
2536
2581
  var untilTag = options.untilTag,
2537
2582
  includeUntilTagValue = options.includeUntilTagValue;
2583
+ var syntax = (_options$readSyntax = options.readSyntax) !== null && _options$readSyntax !== void 0 ? _options$readSyntax : this.syntax;
2538
2584
  var implicit = syntax == IMPLICIT_LITTLE_ENDIAN;
2539
2585
  var isLittleEndian = syntax !== EXPLICIT_BIG_ENDIAN;
2540
2586
  stream.setEndian(isLittleEndian);
@@ -2554,6 +2600,7 @@ var AsyncDicomReader = /*#__PURE__*/function () {
2554
2600
  var length = null;
2555
2601
  var vr = null;
2556
2602
  var vrType;
2603
+ var wireVrType = null;
2557
2604
  var isCommand = tagObj.group() === 0;
2558
2605
  if (tagObj.isInstruction()) {
2559
2606
  length = stream.readUint32();
@@ -2564,13 +2611,13 @@ var AsyncDicomReader = /*#__PURE__*/function () {
2564
2611
  if (elementData) {
2565
2612
  vrType = elementData.vr;
2566
2613
  if (vrType === "xs") {
2567
- var _this$listener;
2614
+ var _this$listener2;
2568
2615
  // The dictionary meta-VR "xs" ("US or SS") resolves via
2569
2616
  // PixelRepresentation (PS3.5), exactly like the sync
2570
2617
  // reader (DicomMessage._readTag). The listener's
2571
2618
  // information filter tracks (0028,0103), which precedes
2572
2619
  // every xs tag in tag order.
2573
- vrType = DicomMessage.resolveXsVrType((_this$listener = this.listener) === null || _this$listener === void 0 || (_this$listener = _this$listener.information) === null || _this$listener === void 0 ? void 0 : _this$listener.pixelRepresentation);
2620
+ vrType = DicomMessage.resolveXsVrType((_this$listener2 = this.listener) === null || _this$listener2 === void 0 || (_this$listener2 = _this$listener2.information) === null || _this$listener2 === void 0 ? void 0 : _this$listener2.pixelRepresentation);
2574
2621
  }
2575
2622
  } else {
2576
2623
  //unknown tag
@@ -2588,13 +2635,14 @@ var AsyncDicomReader = /*#__PURE__*/function () {
2588
2635
  } else {
2589
2636
  var _DicomMessage$lookupT;
2590
2637
  vrType = stream.readVR();
2638
+ wireVrType = vrType;
2591
2639
  if (vrType === "UN" && (_DicomMessage$lookupT = DicomMessage.lookupTag(tagObj)) !== null && _DicomMessage$lookupT !== void 0 && _DicomMessage$lookupT.vr) {
2592
2640
  vrType = DicomMessage.lookupTag(tagObj).vr;
2593
2641
  if (vrType === "xs") {
2594
- var _this$listener2;
2642
+ var _this$listener3;
2595
2643
  // Same PixelRepresentation-driven US/SS resolution for
2596
2644
  // explicit-VR UN elements whose dictionary VR is "xs".
2597
- vrType = DicomMessage.resolveXsVrType((_this$listener2 = this.listener) === null || _this$listener2 === void 0 || (_this$listener2 = _this$listener2.information) === null || _this$listener2 === void 0 ? void 0 : _this$listener2.pixelRepresentation);
2645
+ vrType = DicomMessage.resolveXsVrType((_this$listener3 = this.listener) === null || _this$listener3 === void 0 || (_this$listener3 = _this$listener3.information) === null || _this$listener3 === void 0 ? void 0 : _this$listener3.pixelRepresentation);
2598
2646
  }
2599
2647
  vr = ValueRepresentation$1.parseUnknownVr(vrType);
2600
2648
  } else {
@@ -2607,11 +2655,16 @@ var AsyncDicomReader = /*#__PURE__*/function () {
2607
2655
  length = stream.readUint16();
2608
2656
  }
2609
2657
  }
2658
+ var sequenceReadSyntax;
2659
+ if (!implicit && wireVrType === "UN" && isUnSequenceValue(stream.view, stream.offset, length, vr.type)) {
2660
+ vr = ValueRepresentation$1.createByTypeString("SQ");
2661
+ sequenceReadSyntax = IMPLICIT_LITTLE_ENDIAN;
2662
+ }
2610
2663
  var punctuatedTag = DicomMetaDictionary.punctuateTag(tag);
2611
2664
  var entry = DicomMetaDictionary.dictionary[punctuatedTag];
2612
2665
 
2613
2666
  // Include both the string and object values for vr and tag
2614
- var header = {
2667
+ var header = _objectSpread2({
2615
2668
  vrObj: vr,
2616
2669
  vr: vr.type,
2617
2670
  tag: tag,
@@ -2619,7 +2672,9 @@ var AsyncDicomReader = /*#__PURE__*/function () {
2619
2672
  vm: entry === null || entry === void 0 ? void 0 : entry.vm,
2620
2673
  name: entry === null || entry === void 0 ? void 0 : entry.name,
2621
2674
  length: length === UNDEFINED_LENGTH ? -1 : length
2622
- };
2675
+ }, sequenceReadSyntax && {
2676
+ sequenceReadSyntax: sequenceReadSyntax
2677
+ });
2623
2678
  return header;
2624
2679
  }
2625
2680
 
@@ -2633,12 +2688,14 @@ var AsyncDicomReader = /*#__PURE__*/function () {
2633
2688
  key: "readSingle",
2634
2689
  value: (function () {
2635
2690
  var _readSingle = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(tagInfo, listener, options) {
2691
+ var _options$readSyntax2;
2636
2692
  var length, stream, syntax, vr, values, times, i, _vr$read, value, _vr$read2, _value, delimiterChar, decoder, valuesForListener;
2637
2693
  return _regeneratorRuntime().wrap(function (_context11) {
2638
2694
  while (1) switch (_context11.prev = _context11.next) {
2639
2695
  case 0:
2640
2696
  length = tagInfo.length;
2641
- stream = this.stream, syntax = this.syntax;
2697
+ stream = this.stream;
2698
+ syntax = (_options$readSyntax2 = options === null || options === void 0 ? void 0 : options.readSyntax) !== null && _options$readSyntax2 !== void 0 ? _options$readSyntax2 : this.syntax;
2642
2699
  _context11.next = 1;
2643
2700
  return this.stream.ensureAvailable(length);
2644
2701
  case 1:
@@ -12756,6 +12813,11 @@ var DICOMMicroscopyViewer = {
12756
12813
  MeasurementReport: MeasurementReport$1
12757
12814
  };
12758
12815
 
12816
+ /**
12817
+ * @deprecated The adapters moved to `@cornerstonejs/adapters`. Import them
12818
+ * from that package. `@dcmjs-org/dcmjs` keeps this export only for
12819
+ * compatibility with 0.x, and a later major release removes it.
12820
+ */
12759
12821
  var adapters = {
12760
12822
  Cornerstone: Cornerstone,
12761
12823
  Cornerstone3D: Cornerstone3D,
@@ -15937,4 +15999,4 @@ ValueRepresentation.setTagClass(Tag);
15937
15999
  // entries (src/eventStream.js, ...): the default entry is the 0.52 surface.
15938
16000
 
15939
16001
  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 };
15940
- //# sourceMappingURL=dcmjs.shared-BLrcKS2A.js.map
16002
+ //# sourceMappingURL=dcmjs.shared-RH-AbhO5.js.map