@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.
@@ -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) {
@@ -2064,12 +2072,14 @@ var AsyncDicomReader = /*#__PURE__*/function () {
2064
2072
  key: "readSequence",
2065
2073
  value: (function () {
2066
2074
  var _readSequence = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(listener, sqTagInfo, options) {
2067
- var length, stream, syntax, endOffset, tagInfo, tag, itemLength, itemUntilOffset, _t;
2075
+ var _ref, _sqTagInfo$sequenceRe;
2076
+ var length, stream, readSyntax, endOffset, tagInfo, tag, itemLength, itemUntilOffset, decoder, _t;
2068
2077
  return _regeneratorRuntime().wrap(function (_context6) {
2069
2078
  while (1) switch (_context6.prev = _context6.next) {
2070
2079
  case 0:
2071
2080
  length = sqTagInfo.length;
2072
- stream = this.stream, syntax = this.syntax;
2081
+ stream = this.stream;
2082
+ 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
2083
  endOffset = length === UNDEFINED_LENGTH_FIX ? Number.MAX_SAFE_INTEGER : stream.offset + length;
2074
2084
  case 1:
2075
2085
  _t = stream.offset < endOffset;
@@ -2087,7 +2097,9 @@ var AsyncDicomReader = /*#__PURE__*/function () {
2087
2097
  break;
2088
2098
  }
2089
2099
  readLog.debug("readSequence loop", stream.offset, endOffset);
2090
- tagInfo = this.readTagHeader(syntax, options);
2100
+ tagInfo = this.readTagHeader(_objectSpread2(_objectSpread2({}, options), {}, {
2101
+ readSyntax: readSyntax
2102
+ }));
2091
2103
  tag = tagInfo.tag;
2092
2104
  if (!(tag === TagHex.Item)) {
2093
2105
  _context6.next = 5;
@@ -2096,12 +2108,17 @@ var AsyncDicomReader = /*#__PURE__*/function () {
2096
2108
  listener.startObject();
2097
2109
  // defined-length item: stop at its own end (see doc comment)
2098
2110
  itemLength = tagInfo.length;
2099
- itemUntilOffset = itemLength === UNDEFINED_LENGTH_FIX ? endOffset : Math.min(stream.offset + itemLength, endOffset);
2111
+ itemUntilOffset = itemLength === UNDEFINED_LENGTH_FIX ? endOffset : Math.min(stream.offset + itemLength, endOffset); // A SpecificCharacterSet in the item applies only to that
2112
+ // item (PS3.5 7.5.3), but the item is read on this stream:
2113
+ // put back the decoder the item started with.
2114
+ decoder = stream.decoder;
2100
2115
  _context6.next = 4;
2101
2116
  return this.read(listener, _objectSpread2(_objectSpread2({}, options), {}, {
2102
- untilOffset: itemUntilOffset
2117
+ untilOffset: itemUntilOffset,
2118
+ readSyntax: readSyntax
2103
2119
  }));
2104
2120
  case 4:
2121
+ stream.setDecoder(decoder);
2105
2122
  _context6.next = 7;
2106
2123
  break;
2107
2124
  case 5:
@@ -2527,14 +2544,15 @@ var AsyncDicomReader = /*#__PURE__*/function () {
2527
2544
  }, {
2528
2545
  key: "readTagHeader",
2529
2546
  value: function readTagHeader() {
2547
+ var _options$readSyntax;
2530
2548
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
2531
2549
  untilTag: null,
2532
2550
  includeUntilTagValue: false
2533
2551
  };
2534
- var stream = this.stream,
2535
- syntax = this.syntax;
2552
+ var stream = this.stream;
2536
2553
  var untilTag = options.untilTag,
2537
2554
  includeUntilTagValue = options.includeUntilTagValue;
2555
+ var syntax = (_options$readSyntax = options.readSyntax) !== null && _options$readSyntax !== void 0 ? _options$readSyntax : this.syntax;
2538
2556
  var implicit = syntax == IMPLICIT_LITTLE_ENDIAN;
2539
2557
  var isLittleEndian = syntax !== EXPLICIT_BIG_ENDIAN;
2540
2558
  stream.setEndian(isLittleEndian);
@@ -2554,6 +2572,7 @@ var AsyncDicomReader = /*#__PURE__*/function () {
2554
2572
  var length = null;
2555
2573
  var vr = null;
2556
2574
  var vrType;
2575
+ var wireVrType = null;
2557
2576
  var isCommand = tagObj.group() === 0;
2558
2577
  if (tagObj.isInstruction()) {
2559
2578
  length = stream.readUint32();
@@ -2588,6 +2607,7 @@ var AsyncDicomReader = /*#__PURE__*/function () {
2588
2607
  } else {
2589
2608
  var _DicomMessage$lookupT;
2590
2609
  vrType = stream.readVR();
2610
+ wireVrType = vrType;
2591
2611
  if (vrType === "UN" && (_DicomMessage$lookupT = DicomMessage.lookupTag(tagObj)) !== null && _DicomMessage$lookupT !== void 0 && _DicomMessage$lookupT.vr) {
2592
2612
  vrType = DicomMessage.lookupTag(tagObj).vr;
2593
2613
  if (vrType === "xs") {
@@ -2607,11 +2627,16 @@ var AsyncDicomReader = /*#__PURE__*/function () {
2607
2627
  length = stream.readUint16();
2608
2628
  }
2609
2629
  }
2630
+ var sequenceReadSyntax;
2631
+ if (!implicit && wireVrType === "UN" && isUnSequenceValue(stream.view, stream.offset, length, vr.type)) {
2632
+ vr = ValueRepresentation$1.createByTypeString("SQ");
2633
+ sequenceReadSyntax = IMPLICIT_LITTLE_ENDIAN;
2634
+ }
2610
2635
  var punctuatedTag = DicomMetaDictionary.punctuateTag(tag);
2611
2636
  var entry = DicomMetaDictionary.dictionary[punctuatedTag];
2612
2637
 
2613
2638
  // Include both the string and object values for vr and tag
2614
- var header = {
2639
+ var header = _objectSpread2({
2615
2640
  vrObj: vr,
2616
2641
  vr: vr.type,
2617
2642
  tag: tag,
@@ -2619,7 +2644,9 @@ var AsyncDicomReader = /*#__PURE__*/function () {
2619
2644
  vm: entry === null || entry === void 0 ? void 0 : entry.vm,
2620
2645
  name: entry === null || entry === void 0 ? void 0 : entry.name,
2621
2646
  length: length === UNDEFINED_LENGTH ? -1 : length
2622
- };
2647
+ }, sequenceReadSyntax && {
2648
+ sequenceReadSyntax: sequenceReadSyntax
2649
+ });
2623
2650
  return header;
2624
2651
  }
2625
2652
 
@@ -2633,12 +2660,14 @@ var AsyncDicomReader = /*#__PURE__*/function () {
2633
2660
  key: "readSingle",
2634
2661
  value: (function () {
2635
2662
  var _readSingle = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(tagInfo, listener, options) {
2663
+ var _options$readSyntax2;
2636
2664
  var length, stream, syntax, vr, values, times, i, _vr$read, value, _vr$read2, _value, delimiterChar, decoder, valuesForListener;
2637
2665
  return _regeneratorRuntime().wrap(function (_context11) {
2638
2666
  while (1) switch (_context11.prev = _context11.next) {
2639
2667
  case 0:
2640
2668
  length = tagInfo.length;
2641
- stream = this.stream, syntax = this.syntax;
2669
+ stream = this.stream;
2670
+ syntax = (_options$readSyntax2 = options === null || options === void 0 ? void 0 : options.readSyntax) !== null && _options$readSyntax2 !== void 0 ? _options$readSyntax2 : this.syntax;
2642
2671
  _context11.next = 1;
2643
2672
  return this.stream.ensureAvailable(length);
2644
2673
  case 1:
@@ -12756,6 +12785,11 @@ var DICOMMicroscopyViewer = {
12756
12785
  MeasurementReport: MeasurementReport$1
12757
12786
  };
12758
12787
 
12788
+ /**
12789
+ * @deprecated The adapters moved to `@cornerstonejs/adapters`. Import them
12790
+ * from that package. `@dcmjs-org/dcmjs` keeps this export only for
12791
+ * compatibility with 0.x, and a later major release removes it.
12792
+ */
12759
12793
  var adapters = {
12760
12794
  Cornerstone: Cornerstone,
12761
12795
  Cornerstone3D: Cornerstone3D,
@@ -15937,4 +15971,4 @@ ValueRepresentation.setTagClass(Tag);
15937
15971
  // entries (src/eventStream.js, ...): the default entry is the 0.52 surface.
15938
15972
 
15939
15973
  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
15974
+ //# sourceMappingURL=dcmjs.shared-DnjtTwFB.js.map