@dcmjs-org/dcmjs 1.0.0-beta.19 → 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.
package/build/dcmjs.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var dcmjs = require('./dcmjs.shared-L4OH_Ab_.cjs');
5
+ var dcmjs = require('./dcmjs.shared-Cmkm67T1.cjs');
6
6
  var core = require('@dcmjs-org/core');
7
7
 
8
8
 
package/build/dcmjs.es.js CHANGED
@@ -1,3 +1,3 @@
1
- export { D as DICOMWEB, j as adapters, k as anonymizer, l as async, m as constants, n as data, o as default, p as derivations, q as normalizers, s as sr, u as utilities } from './dcmjs.shared-DnjtTwFB.js';
1
+ export { D as DICOMWEB, j as adapters, k as anonymizer, l as async, m as constants, n as data, o as default, p as derivations, q as normalizers, s as sr, u as utilities } from './dcmjs.shared-RH-AbhO5.js';
2
2
  export { log } from '@dcmjs-org/core';
3
3
  //# sourceMappingURL=dcmjs.es.js.map
package/build/dcmjs.js CHANGED
@@ -16826,6 +16826,8 @@
16826
16826
  _classCallCheck(this, AsyncDicomReader);
16827
16827
  _defineProperty(this, "syntax", EXPLICIT_LITTLE_ENDIAN);
16828
16828
  this.isLittleEndian = options === null || options === void 0 ? void 0 : options.isLittleEndian;
16829
+ // Number of sequence items being read, 0 at the top level
16830
+ this.sequenceDepth = 0;
16829
16831
  // Default maxFragmentSize is 128 MB (128 * 1024 * 1024 bytes)
16830
16832
  this.maxFragmentSize = (_options$maxFragmentS = options === null || options === void 0 ? void 0 : options.maxFragmentSize) !== null && _options$maxFragmentS !== void 0 ? _options$maxFragmentS : 128 * 1024 * 1024;
16831
16833
  this.stream = new ReadBufferStream(null, _objectSpread2(_objectSpread2({
@@ -17287,16 +17289,24 @@
17287
17289
  * item boundary and returns control here for the next item. Without that
17288
17290
  * offset, read() skips the later Item tags as instructions, and all items
17289
17291
  * of a defined-length sequence merge into the first item.
17292
+ *
17293
+ * untilTag and includeUntilTagValue apply to the top-level data set only,
17294
+ * so the items are read without them: an Icon Image Sequence item has its
17295
+ * own Pixel Data, which must not stop a read with untilTag 7FE00010.
17290
17296
  */
17291
17297
  }, {
17292
17298
  key: "readSequence",
17293
17299
  value: (function () {
17294
17300
  var _readSequence = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(listener, sqTagInfo, options) {
17295
17301
  var _ref, _sqTagInfo$sequenceRe;
17296
- var length, stream, readSyntax, endOffset, tagInfo, tag, itemLength, itemUntilOffset, decoder, _t;
17302
+ var itemOptions, length, stream, readSyntax, endOffset, tagInfo, tag, itemLength, itemUntilOffset, decoder, _t;
17297
17303
  return _regeneratorRuntime().wrap(function (_context6) {
17298
17304
  while (1) switch (_context6.prev = _context6.next) {
17299
17305
  case 0:
17306
+ itemOptions = _objectSpread2(_objectSpread2({}, options), {}, {
17307
+ untilTag: null,
17308
+ includeUntilTagValue: false
17309
+ });
17300
17310
  length = sqTagInfo.length;
17301
17311
  stream = this.stream;
17302
17312
  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;
@@ -17313,16 +17323,16 @@
17313
17323
  _t = _context6.sent;
17314
17324
  case 3:
17315
17325
  if (!_t) {
17316
- _context6.next = 8;
17326
+ _context6.next = 10;
17317
17327
  break;
17318
17328
  }
17319
17329
  readLog.debug("readSequence loop", stream.offset, endOffset);
17320
- tagInfo = this.readTagHeader(_objectSpread2(_objectSpread2({}, options), {}, {
17330
+ tagInfo = this.readTagHeader(_objectSpread2(_objectSpread2({}, itemOptions), {}, {
17321
17331
  readSyntax: readSyntax
17322
17332
  }));
17323
17333
  tag = tagInfo.tag;
17324
17334
  if (!(tag === TagHex.Item)) {
17325
- _context6.next = 5;
17335
+ _context6.next = 7;
17326
17336
  break;
17327
17337
  }
17328
17338
  listener.startObject();
@@ -17332,38 +17342,59 @@
17332
17342
  // item (PS3.5 7.5.3), but the item is read on this stream:
17333
17343
  // put back the decoder the item started with.
17334
17344
  decoder = stream.decoder;
17335
- _context6.next = 4;
17336
- return this.read(listener, _objectSpread2(_objectSpread2({}, options), {}, {
17345
+ this.sequenceDepth++;
17346
+ _context6.prev = 4;
17347
+ _context6.next = 5;
17348
+ return this.read(listener, _objectSpread2(_objectSpread2({}, itemOptions), {}, {
17337
17349
  untilOffset: itemUntilOffset,
17338
17350
  readSyntax: readSyntax
17339
17351
  }));
17340
- case 4:
17352
+ case 5:
17353
+ _context6.prev = 5;
17354
+ this.sequenceDepth--;
17355
+ return _context6.finish(5);
17356
+ case 6:
17341
17357
  stream.setDecoder(decoder);
17342
- _context6.next = 7;
17358
+ _context6.next = 9;
17343
17359
  break;
17344
- case 5:
17360
+ case 7:
17345
17361
  if (!(tag === TagHex.SequenceDelimitationEnd)) {
17346
- _context6.next = 6;
17362
+ _context6.next = 8;
17347
17363
  break;
17348
17364
  }
17349
17365
  return _context6.abrupt("return");
17350
- case 6:
17366
+ case 8:
17351
17367
  console.warn("Unknown tag info", length, tagInfo);
17352
- throw new Error();
17353
- case 7:
17368
+ throw new Error("Expected an item or a sequence delimitation item in a sequence, found tag ".concat(tag));
17369
+ case 9:
17354
17370
  _context6.next = 1;
17355
17371
  break;
17356
- case 8:
17372
+ case 10:
17357
17373
  case "end":
17358
17374
  return _context6.stop();
17359
17375
  }
17360
- }, _callee6, this);
17376
+ }, _callee6, this, [[4,, 5, 6]]);
17361
17377
  }));
17362
17378
  function readSequence(_x3, _x4, _x5) {
17363
17379
  return _readSequence.apply(this, arguments);
17364
17380
  }
17365
17381
  return readSequence;
17366
- }())
17382
+ }()
17383
+ /**
17384
+ * The number of frames of the Pixel Data being read. NumberOfFrames is
17385
+ * tracked for the top-level data set only, so Pixel Data inside a sequence
17386
+ * item (an Icon Image Sequence item, for example) is a single frame.
17387
+ */
17388
+ )
17389
+ }, {
17390
+ key: "getNumberOfFrames",
17391
+ value: function getNumberOfFrames() {
17392
+ var _this$listener;
17393
+ if (this.sequenceDepth > 0) {
17394
+ return 1;
17395
+ }
17396
+ 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);
17397
+ }
17367
17398
  }, {
17368
17399
  key: "readPixelData",
17369
17400
  value: function readPixelData(tagInfo) {
@@ -17433,8 +17464,7 @@
17433
17464
  key: "readCompressed",
17434
17465
  value: (function () {
17435
17466
  var _readCompressed = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(_tagInfo) {
17436
- var _listener$information;
17437
- var stream, listener, transferSyntaxUid, isVideo, numberOfFrames, isSingleFrame, offsets, singleArray, startOffset, frameNumber, lastFrame, frameTag, length;
17467
+ var stream, listener, transferSyntaxUid, isVideo, isSingleFrame, offsets, singleArray, startOffset, frameNumber, lastFrame, frameTag, length;
17438
17468
  return _regeneratorRuntime().wrap(function (_context8) {
17439
17469
  while (1) switch (_context8.prev = _context8.next) {
17440
17470
  case 0:
@@ -17445,8 +17475,7 @@
17445
17475
  case 1:
17446
17476
  // Check if this is a video transfer syntax
17447
17477
  isVideo = isVideoTransferSyntax(transferSyntaxUid); // Check number of frames - only use video logic for single frame (or undefined)
17448
- numberOfFrames = (_listener$information = listener.information) === null || _listener$information === void 0 ? void 0 : _listener$information.numberOfFrames;
17449
- isSingleFrame = !numberOfFrames || parseInt(numberOfFrames) <= 1;
17478
+ isSingleFrame = this.getNumberOfFrames() <= 1;
17450
17479
  _context8.next = 2;
17451
17480
  return this.readOffsets();
17452
17481
  case 2:
@@ -17560,23 +17589,22 @@
17560
17589
  key: "readUncompressed",
17561
17590
  value: (function () {
17562
17591
  var _readUncompressed = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee0(tagInfo) {
17563
- var _listener$information2;
17564
- var length, listener, numberOfFrames, frameLength, _listener$information3, _listener$information4, _listener$information5, _listener$information6, rows, cols, samplesPerPixel, bitsAllocated, bitsPerFrame, frameNumber;
17592
+ var length, listener, numberOfFrames, frameLength, _listener$information, _listener$information2, _listener$information3, _listener$information4, rows, cols, samplesPerPixel, bitsAllocated, bitsPerFrame, frameNumber;
17565
17593
  return _regeneratorRuntime().wrap(function (_context0) {
17566
17594
  while (1) switch (_context0.prev = _context0.next) {
17567
17595
  case 0:
17568
17596
  length = tagInfo.length;
17569
17597
  listener = this.listener;
17570
- numberOfFrames = parseInt(((_listener$information2 = listener.information) === null || _listener$information2 === void 0 ? void 0 : _listener$information2.numberOfFrames) || 1);
17598
+ numberOfFrames = this.getNumberOfFrames();
17571
17599
  frameLength = Math.floor(length / numberOfFrames);
17572
17600
  if (!(numberOfFrames > 1)) {
17573
17601
  _context0.next = 4;
17574
17602
  break;
17575
17603
  }
17576
- rows = (_listener$information3 = listener.information) === null || _listener$information3 === void 0 ? void 0 : _listener$information3.rows;
17577
- cols = (_listener$information4 = listener.information) === null || _listener$information4 === void 0 ? void 0 : _listener$information4.columns;
17578
- samplesPerPixel = (_listener$information5 = listener.information) === null || _listener$information5 === void 0 ? void 0 : _listener$information5.samplesPerPixel;
17579
- bitsAllocated = (_listener$information6 = listener.information) === null || _listener$information6 === void 0 ? void 0 : _listener$information6.bitsAllocated;
17604
+ rows = (_listener$information = listener.information) === null || _listener$information === void 0 ? void 0 : _listener$information.rows;
17605
+ cols = (_listener$information2 = listener.information) === null || _listener$information2 === void 0 ? void 0 : _listener$information2.columns;
17606
+ samplesPerPixel = (_listener$information3 = listener.information) === null || _listener$information3 === void 0 ? void 0 : _listener$information3.samplesPerPixel;
17607
+ bitsAllocated = (_listener$information4 = listener.information) === null || _listener$information4 === void 0 ? void 0 : _listener$information4.bitsAllocated;
17580
17608
  bitsPerFrame = rows * cols * samplesPerPixel * bitsAllocated;
17581
17609
  if (!(bitsPerFrame % 8 !== 0)) {
17582
17610
  _context0.next = 3;
@@ -17645,18 +17673,18 @@
17645
17673
  key: "readUncompressedBitFrame",
17646
17674
  value: (function () {
17647
17675
  var _readUncompressedBitFrame = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee1(tagInfo) {
17648
- var _listener$information7, _listener$information8, _listener$information9, _listener$information0, _listener$information1;
17676
+ var _listener$information5, _listener$information6, _listener$information7, _listener$information8;
17649
17677
  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;
17650
17678
  return _regeneratorRuntime().wrap(function (_context1) {
17651
17679
  while (1) switch (_context1.prev = _context1.next) {
17652
17680
  case 0:
17653
17681
  length = tagInfo.length;
17654
17682
  listener = this.listener, stream = this.stream;
17655
- numberOfFrames = parseInt(((_listener$information7 = listener.information) === null || _listener$information7 === void 0 ? void 0 : _listener$information7.numberOfFrames) || 1);
17656
- rows = (_listener$information8 = listener.information) === null || _listener$information8 === void 0 ? void 0 : _listener$information8.rows;
17657
- cols = (_listener$information9 = listener.information) === null || _listener$information9 === void 0 ? void 0 : _listener$information9.columns;
17658
- samplesPerPixel = ((_listener$information0 = listener.information) === null || _listener$information0 === void 0 ? void 0 : _listener$information0.samplesPerPixel) || 1;
17659
- bitsAllocated = (_listener$information1 = listener.information) === null || _listener$information1 === void 0 ? void 0 : _listener$information1.bitsAllocated;
17683
+ numberOfFrames = this.getNumberOfFrames();
17684
+ rows = (_listener$information5 = listener.information) === null || _listener$information5 === void 0 ? void 0 : _listener$information5.rows;
17685
+ cols = (_listener$information6 = listener.information) === null || _listener$information6 === void 0 ? void 0 : _listener$information6.columns;
17686
+ samplesPerPixel = ((_listener$information7 = listener.information) === null || _listener$information7 === void 0 ? void 0 : _listener$information7.samplesPerPixel) || 1;
17687
+ bitsAllocated = (_listener$information8 = listener.information) === null || _listener$information8 === void 0 ? void 0 : _listener$information8.bitsAllocated;
17660
17688
  if (!(!rows || !cols || !bitsAllocated)) {
17661
17689
  _context1.next = 1;
17662
17690
  break;
@@ -17803,13 +17831,13 @@
17803
17831
  if (elementData) {
17804
17832
  vrType = elementData.vr;
17805
17833
  if (vrType === "xs") {
17806
- var _this$listener;
17834
+ var _this$listener2;
17807
17835
  // The dictionary meta-VR "xs" ("US or SS") resolves via
17808
17836
  // PixelRepresentation (PS3.5), exactly like the sync
17809
17837
  // reader (DicomMessage._readTag). The listener's
17810
17838
  // information filter tracks (0028,0103), which precedes
17811
17839
  // every xs tag in tag order.
17812
- 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);
17840
+ 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);
17813
17841
  }
17814
17842
  } else {
17815
17843
  //unknown tag
@@ -17831,10 +17859,10 @@
17831
17859
  if (vrType === "UN" && (_DicomMessage$lookupT = DicomMessage.lookupTag(tagObj)) !== null && _DicomMessage$lookupT !== void 0 && _DicomMessage$lookupT.vr) {
17832
17860
  vrType = DicomMessage.lookupTag(tagObj).vr;
17833
17861
  if (vrType === "xs") {
17834
- var _this$listener2;
17862
+ var _this$listener3;
17835
17863
  // Same PixelRepresentation-driven US/SS resolution for
17836
17864
  // explicit-VR UN elements whose dictionary VR is "xs".
17837
- 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);
17865
+ 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);
17838
17866
  }
17839
17867
  vr = ValueRepresentation$1.parseUnknownVr(vrType);
17840
17868
  } else {