@dcmjs-org/dcmjs 1.0.0-beta.17 → 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.
package/build/dcmjs.js CHANGED
@@ -7914,61 +7914,69 @@
7914
7914
  return view.getBigUint64(offset - viewOffset, isLittleEndian);
7915
7915
  }
7916
7916
  }, {
7917
- key: "getFloat32",
7918
- value: function getFloat32(offset, isLittleEndian) {
7919
- var _this$findView5 = this.findView(offset, 4),
7917
+ key: "getBigInt64",
7918
+ value: function getBigInt64(offset, isLittleEndian) {
7919
+ var _this$findView5 = this.findView(offset, 8),
7920
7920
  view = _this$findView5.view,
7921
7921
  viewOffset = _this$findView5.viewOffset;
7922
+ return view.getBigInt64(offset - viewOffset, isLittleEndian);
7923
+ }
7924
+ }, {
7925
+ key: "getFloat32",
7926
+ value: function getFloat32(offset, isLittleEndian) {
7927
+ var _this$findView6 = this.findView(offset, 4),
7928
+ view = _this$findView6.view,
7929
+ viewOffset = _this$findView6.viewOffset;
7922
7930
  return view.getFloat32(offset - viewOffset, isLittleEndian);
7923
7931
  }
7924
7932
  }, {
7925
7933
  key: "getFloat64",
7926
7934
  value: function getFloat64(offset, isLittleEndian) {
7927
- var _this$findView6 = this.findView(offset, 8),
7928
- view = _this$findView6.view,
7929
- viewOffset = _this$findView6.viewOffset;
7935
+ var _this$findView7 = this.findView(offset, 8),
7936
+ view = _this$findView7.view,
7937
+ viewOffset = _this$findView7.viewOffset;
7930
7938
  return view.getFloat64(offset - viewOffset, isLittleEndian);
7931
7939
  }
7932
7940
  }, {
7933
7941
  key: "getInt8",
7934
7942
  value: function getInt8(offset) {
7935
- var _this$findView7 = this.findView(offset, 1),
7936
- view = _this$findView7.view,
7937
- viewOffset = _this$findView7.viewOffset;
7943
+ var _this$findView8 = this.findView(offset, 1),
7944
+ view = _this$findView8.view,
7945
+ viewOffset = _this$findView8.viewOffset;
7938
7946
  return view.getInt8(offset - viewOffset);
7939
7947
  }
7940
7948
  }, {
7941
7949
  key: "getInt16",
7942
7950
  value: function getInt16(offset, isLittleEndian) {
7943
- var _this$findView8 = this.findView(offset, 2),
7944
- view = _this$findView8.view,
7945
- viewOffset = _this$findView8.viewOffset;
7951
+ var _this$findView9 = this.findView(offset, 2),
7952
+ view = _this$findView9.view,
7953
+ viewOffset = _this$findView9.viewOffset;
7946
7954
  return view.getInt16(offset - viewOffset, isLittleEndian);
7947
7955
  }
7948
7956
  }, {
7949
7957
  key: "getInt32",
7950
7958
  value: function getInt32(offset, isLittleEndian) {
7951
- var _this$findView9 = this.findView(offset, 4),
7952
- view = _this$findView9.view,
7953
- viewOffset = _this$findView9.viewOffset;
7959
+ var _this$findView0 = this.findView(offset, 4),
7960
+ view = _this$findView0.view,
7961
+ viewOffset = _this$findView0.viewOffset;
7954
7962
  return view.getInt32(offset - viewOffset, isLittleEndian);
7955
7963
  }
7956
7964
  }, {
7957
7965
  key: "setUint8",
7958
7966
  value: function setUint8(offset, value) {
7959
- var _this$findView0 = this.findView(offset, 1),
7960
- view = _this$findView0.view,
7961
- viewOffset = _this$findView0.viewOffset;
7967
+ var _this$findView1 = this.findView(offset, 1),
7968
+ view = _this$findView1.view,
7969
+ viewOffset = _this$findView1.viewOffset;
7962
7970
  view.setUint8(offset - viewOffset, value);
7963
7971
  // Commit is unneeded since 1 byte will always be available
7964
7972
  }
7965
7973
  }, {
7966
7974
  key: "setUint16",
7967
7975
  value: function setUint16(offset, value, isLittleEndian) {
7968
- var _this$findView1 = this.findView(offset, 2),
7969
- view = _this$findView1.view,
7970
- viewOffset = _this$findView1.viewOffset,
7971
- writeCommit = _this$findView1.writeCommit;
7976
+ var _this$findView10 = this.findView(offset, 2),
7977
+ view = _this$findView10.view,
7978
+ viewOffset = _this$findView10.viewOffset,
7979
+ writeCommit = _this$findView10.writeCommit;
7972
7980
  view.setUint16(offset - viewOffset, value, isLittleEndian);
7973
7981
  if (writeCommit) {
7974
7982
  this.writeCommit(view, offset);
@@ -7977,10 +7985,10 @@
7977
7985
  }, {
7978
7986
  key: "setUint32",
7979
7987
  value: function setUint32(offset, value, isLittleEndian) {
7980
- var _this$findView10 = this.findView(offset, 4),
7981
- view = _this$findView10.view,
7982
- viewOffset = _this$findView10.viewOffset,
7983
- writeCommit = _this$findView10.writeCommit;
7988
+ var _this$findView11 = this.findView(offset, 4),
7989
+ view = _this$findView11.view,
7990
+ viewOffset = _this$findView11.viewOffset,
7991
+ writeCommit = _this$findView11.writeCommit;
7984
7992
  view.setUint32(offset - viewOffset, value, isLittleEndian);
7985
7993
  if (writeCommit) {
7986
7994
  this.writeCommit(view, offset);
@@ -7989,22 +7997,34 @@
7989
7997
  }, {
7990
7998
  key: "setBigUint64",
7991
7999
  value: function setBigUint64(offset, value, isLittleEndian) {
7992
- var _this$findView11 = this.findView(offset, 8),
7993
- view = _this$findView11.view,
7994
- viewOffset = _this$findView11.viewOffset,
7995
- writeCommit = _this$findView11.writeCommit;
8000
+ var _this$findView12 = this.findView(offset, 8),
8001
+ view = _this$findView12.view,
8002
+ viewOffset = _this$findView12.viewOffset,
8003
+ writeCommit = _this$findView12.writeCommit;
7996
8004
  view.setBigUint64(offset - viewOffset, value, isLittleEndian);
7997
8005
  if (writeCommit) {
7998
8006
  this.writeCommit(view, offset);
7999
8007
  }
8000
8008
  }
8009
+ }, {
8010
+ key: "setBigInt64",
8011
+ value: function setBigInt64(offset, value, isLittleEndian) {
8012
+ var _this$findView13 = this.findView(offset, 8),
8013
+ view = _this$findView13.view,
8014
+ viewOffset = _this$findView13.viewOffset,
8015
+ writeCommit = _this$findView13.writeCommit;
8016
+ view.setBigInt64(offset - viewOffset, value, isLittleEndian);
8017
+ if (writeCommit) {
8018
+ this.writeCommit(view, offset);
8019
+ }
8020
+ }
8001
8021
  }, {
8002
8022
  key: "setFloat32",
8003
8023
  value: function setFloat32(offset, value, isLittleEndian) {
8004
- var _this$findView12 = this.findView(offset, 4),
8005
- view = _this$findView12.view,
8006
- viewOffset = _this$findView12.viewOffset,
8007
- writeCommit = _this$findView12.writeCommit;
8024
+ var _this$findView14 = this.findView(offset, 4),
8025
+ view = _this$findView14.view,
8026
+ viewOffset = _this$findView14.viewOffset,
8027
+ writeCommit = _this$findView14.writeCommit;
8008
8028
  view.setFloat32(offset - viewOffset, value, isLittleEndian);
8009
8029
  if (writeCommit) {
8010
8030
  this.writeCommit(view, offset);
@@ -8013,10 +8033,10 @@
8013
8033
  }, {
8014
8034
  key: "setFloat64",
8015
8035
  value: function setFloat64(offset, value, isLittleEndian) {
8016
- var _this$findView13 = this.findView(offset, 8),
8017
- view = _this$findView13.view,
8018
- viewOffset = _this$findView13.viewOffset,
8019
- writeCommit = _this$findView13.writeCommit;
8036
+ var _this$findView15 = this.findView(offset, 8),
8037
+ view = _this$findView15.view,
8038
+ viewOffset = _this$findView15.viewOffset,
8039
+ writeCommit = _this$findView15.writeCommit;
8020
8040
  view.setFloat64(offset - viewOffset, value, isLittleEndian);
8021
8041
  if (writeCommit) {
8022
8042
  this.writeCommit(view, offset);
@@ -8025,19 +8045,19 @@
8025
8045
  }, {
8026
8046
  key: "setInt8",
8027
8047
  value: function setInt8(offset, value) {
8028
- var _this$findView14 = this.findView(offset, 1),
8029
- view = _this$findView14.view,
8030
- viewOffset = _this$findView14.viewOffset;
8048
+ var _this$findView16 = this.findView(offset, 1),
8049
+ view = _this$findView16.view,
8050
+ viewOffset = _this$findView16.viewOffset;
8031
8051
  view.setInt8(offset - viewOffset, value);
8032
8052
  // Commit is unneeded since 1 byte will always be available
8033
8053
  }
8034
8054
  }, {
8035
8055
  key: "setInt16",
8036
8056
  value: function setInt16(offset, value, isLittleEndian) {
8037
- var _this$findView15 = this.findView(offset, 2),
8038
- view = _this$findView15.view,
8039
- viewOffset = _this$findView15.viewOffset,
8040
- writeCommit = _this$findView15.writeCommit;
8057
+ var _this$findView17 = this.findView(offset, 2),
8058
+ view = _this$findView17.view,
8059
+ viewOffset = _this$findView17.viewOffset,
8060
+ writeCommit = _this$findView17.writeCommit;
8041
8061
  view.setInt16(offset - viewOffset, value, isLittleEndian);
8042
8062
  if (writeCommit) {
8043
8063
  this.writeCommit(view, offset);
@@ -8046,10 +8066,10 @@
8046
8066
  }, {
8047
8067
  key: "setInt32",
8048
8068
  value: function setInt32(offset, value, isLittleEndian) {
8049
- var _this$findView16 = this.findView(offset, 4),
8050
- view = _this$findView16.view,
8051
- viewOffset = _this$findView16.viewOffset,
8052
- writeCommit = _this$findView16.writeCommit;
8069
+ var _this$findView18 = this.findView(offset, 4),
8070
+ view = _this$findView18.view,
8071
+ viewOffset = _this$findView18.viewOffset,
8072
+ writeCommit = _this$findView18.writeCommit;
8053
8073
  view.setInt32(offset - viewOffset, value, isLittleEndian);
8054
8074
  if (writeCommit) {
8055
8075
  this.writeCommit(view, offset);
@@ -8547,7 +8567,7 @@
8547
8567
  }
8548
8568
  var validationLog = log.getLogger("validation.dcmjs");
8549
8569
 
8550
- var _excluded = ["littleEndian", "start", "stop", "noCopy", "clearBuffers"];
8570
+ var _excluded = ["littleEndian", "start", "stop", "noCopy", "clearBuffers", "decoder"];
8551
8571
  var legacyWarned = new Set();
8552
8572
 
8553
8573
  /** Warns once per class that a positional (0.x) constructor form was used. */
@@ -8768,6 +8788,13 @@
8768
8788
  this.view.setBigUint64(this.offset, value, this.isLittleEndian);
8769
8789
  return this.increment(8);
8770
8790
  }
8791
+ }, {
8792
+ key: "writeBigInt64",
8793
+ value: function writeBigInt64(value) {
8794
+ this.checkSize(8);
8795
+ this.view.setBigInt64(this.offset, value, this.isLittleEndian);
8796
+ return this.increment(8);
8797
+ }
8771
8798
  }, {
8772
8799
  key: "writeFloat",
8773
8800
  value: function writeFloat(value) {
@@ -8828,6 +8855,13 @@
8828
8855
  this.increment(8);
8829
8856
  return val;
8830
8857
  }
8858
+ }, {
8859
+ key: "readBigInt64",
8860
+ value: function readBigInt64() {
8861
+ var val = this.view.getBigInt64(this.offset, this.isLittleEndian);
8862
+ this.increment(8);
8863
+ return val;
8864
+ }
8831
8865
  }, {
8832
8866
  key: "readUint32",
8833
8867
  value: function readUint32() {
@@ -9132,6 +9166,12 @@
9132
9166
  var end = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : start + 1;
9133
9167
  return this.view.hasData(start, end);
9134
9168
  }
9169
+
9170
+ /**
9171
+ * Returns a read stream over the next `length` bytes and moves past them.
9172
+ * The new stream decodes text with this stream's decoder, so sequence items
9173
+ * use the dataset's SpecificCharacterSet (PS3.5 7.5.3).
9174
+ */
9135
9175
  }, {
9136
9176
  key: "more",
9137
9177
  value: function more(length) {
@@ -9145,7 +9185,9 @@
9145
9185
  // start: this.offset,
9146
9186
  // stop: this.offset + length
9147
9187
  // });
9148
- var newBuf = new ReadBufferStream(this.slice(this.offset, this.offset + length));
9188
+ var newBuf = new ReadBufferStream(this.slice(this.offset, this.offset + length), {
9189
+ decoder: this.decoder
9190
+ });
9149
9191
  this.increment(length);
9150
9192
  newBuf.setComplete();
9151
9193
  return newBuf;
@@ -9200,7 +9242,8 @@
9200
9242
  var ReadBufferStream = /*#__PURE__*/function (_BufferStream2) {
9201
9243
  /**
9202
9244
  * @param {ArrayBuffer|ArrayBufferView|BufferStream|null} buffer
9203
- * @param {{littleEndian?: boolean, start?: number, stop?: number, noCopy?: boolean, clearBuffers?: boolean}} [options]
9245
+ * @param {{littleEndian?: boolean, start?: number, stop?: number, noCopy?: boolean, clearBuffers?: boolean, decoder?: TextDecoder}} [options]
9246
+ * `decoder` decodes text; the default is latin1.
9204
9247
  */
9205
9248
  function ReadBufferStream(buffer, options, legacyOptions) {
9206
9249
  var _this3;
@@ -9222,13 +9265,15 @@
9222
9265
  noCopy = _options$noCopy === void 0 ? false : _options$noCopy,
9223
9266
  _options$clearBuffers = _options.clearBuffers,
9224
9267
  clearBuffers = _options$clearBuffers === void 0 ? false : _options$clearBuffers,
9268
+ decoder = _options.decoder,
9225
9269
  rest = _objectWithoutProperties(_options, _excluded);
9226
9270
  _this3 = _callSuper(this, ReadBufferStream, [_objectSpread2(_objectSpread2({}, rest), {}, {
9227
9271
  littleEndian: littleEndian,
9228
9272
  clearBuffers: clearBuffers
9229
9273
  })]);
9230
9274
  _this3.noCopy = noCopy;
9231
- _this3.decoder = new TextDecoder("latin1");
9275
+ // a stream over part of a dataset gets the dataset's decoder
9276
+ _this3.decoder = decoder !== null && decoder !== void 0 ? decoder : new TextDecoder("latin1");
9232
9277
  if (buffer instanceof BufferStream) {
9233
9278
  _this3.view.from(buffer.view, options);
9234
9279
  _this3.isComplete = true;
@@ -9389,7 +9434,6 @@
9389
9434
  /**
9390
9435
  * The classification of each VR, stored once. ValueRepresentation copies
9391
9436
  * the flags to each instance; singleVRs and BINARY_VRS are computed here.
9392
- * OL/OV have flags but no VR class in 1.0.
9393
9437
  * @typedef {Object} VrFlags
9394
9438
  * @property {boolean} [binary] binary number or tag: isBinary()
9395
9439
  * @property {boolean} [length32] 32-bit explicit VR length: isLength32()
@@ -9405,12 +9449,13 @@
9405
9449
  OB: "length32 single readSingle byteStream",
9406
9450
  OD: "length32 byteStream",
9407
9451
  OF: "length32 single readSingle byteStream",
9408
- OL: "byteStream",
9409
- OV: "byteStream",
9452
+ OL: "length32 single byteStream",
9453
+ OV: "length32 single byteStream",
9410
9454
  OW: "length32 single readSingle byteStream",
9411
9455
  SL: "binary",
9412
9456
  SQ: "length32 single readSingle",
9413
9457
  SS: "binary",
9458
+ SV: "binary length32",
9414
9459
  UC: "length32",
9415
9460
  UL: "binary",
9416
9461
  UN: "length32 single readSingle byteStream",
@@ -10234,7 +10279,7 @@
10234
10279
  vr = Vrs.US;
10235
10280
  } else {
10236
10281
  // Warn at most once per unknown type (issue #457): files can
10237
- // carry many elements of the same unregistered VR (OL/OV/SV),
10282
+ // carry many elements of the same unregistered VR,
10238
10283
  // and a per-element warning is pure log spam.
10239
10284
  if (!unknownVrTypesWarned.has(type)) {
10240
10285
  unknownVrTypesWarned.add(type);
@@ -11149,6 +11194,8 @@
11149
11194
  throw new Error("SequenceOfItems.read needs readOptions.readItem to parse the items");
11150
11195
  }
11151
11196
  elements.push(readOptions.readItem(itemStream, syntax));
11197
+ } else {
11198
+ elements.push({});
11152
11199
  }
11153
11200
  if (!undefLength && read == sqlength) {
11154
11201
  break;
@@ -11360,11 +11407,19 @@
11360
11407
  }
11361
11408
  }]);
11362
11409
  }(ValueRepresentation$1);
11410
+ /**
11411
+ * UV, Unsigned 64-bit Very Long, and the base of SV (PS3.5 Section 6.2,
11412
+ * Table 6.2-1,
11413
+ * https://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_6.2.html).
11414
+ */
11363
11415
  var Unsigned64BitVeryLong = /*#__PURE__*/function (_ValueRepresentation10) {
11364
11416
  function Unsigned64BitVeryLong() {
11365
11417
  var _this26;
11418
+ var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "UV";
11419
+ var accessor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "BigUint64";
11366
11420
  _classCallCheck(this, Unsigned64BitVeryLong);
11367
- _this26 = _callSuper(this, Unsigned64BitVeryLong, ["UV"]);
11421
+ _this26 = _callSuper(this, Unsigned64BitVeryLong, [type]);
11422
+ _this26.accessor = accessor;
11368
11423
  _this26.maxLength = 8;
11369
11424
  _this26.padByte = PADDING_NULL;
11370
11425
  _this26.fixed = true;
@@ -11375,13 +11430,13 @@
11375
11430
  return _createClass(Unsigned64BitVeryLong, [{
11376
11431
  key: "readBytes",
11377
11432
  value: function readBytes(stream) {
11378
- return stream.readBigUint64();
11433
+ return stream["read".concat(this.accessor)]();
11379
11434
  }
11380
11435
 
11381
11436
  /**
11382
- * DataView.setBigUint64 only accepts BigInt values, so this method
11383
- * coerces Numbers and numeric strings, as the other numeric VRs do with
11384
- * toInt/toFloat. A null or undefined entry becomes 0, as US/UL write null
11437
+ * DataView.setBigUint64 and setBigInt64 only accept BigInt values, so
11438
+ * this method coerces Numbers and numeric strings, as the other numeric
11439
+ * VRs do with toInt/toFloat. A null or undefined entry becomes 0, as US/UL write null
11385
11440
  * entries. A null, undefined or empty scalar stays as it is, so the base
11386
11441
  * write() writes a zero-length element (PS3.5 7.4, Type 2).
11387
11442
  */
@@ -11399,10 +11454,23 @@
11399
11454
  } else if (value !== null && value !== undefined && value !== "") {
11400
11455
  coercedValue = coerce(value);
11401
11456
  }
11402
- return _get(_getPrototypeOf(Unsigned64BitVeryLong.prototype), "writeBytes", this).call(this, stream, coercedValue, _get(_getPrototypeOf(Unsigned64BitVeryLong.prototype), "write", this).call(this, stream, "BigUint64", coercedValue), writeOptions);
11457
+ return _get(_getPrototypeOf(Unsigned64BitVeryLong.prototype), "writeBytes", this).call(this, stream, coercedValue, _get(_getPrototypeOf(Unsigned64BitVeryLong.prototype), "write", this).call(this, stream, this.accessor, coercedValue), writeOptions);
11403
11458
  }
11404
11459
  }]);
11405
11460
  }(ValueRepresentation$1);
11461
+ /**
11462
+ * SV, Signed 64-bit Very Long (PS3.5 Section 6.2, Table 6.2-1,
11463
+ * https://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_6.2.html).
11464
+ * Reads give BigInt values; writes take a BigInt, a Number or a numeric string.
11465
+ */
11466
+ var Signed64BitVeryLong = /*#__PURE__*/function (_Unsigned64BitVeryLon) {
11467
+ function Signed64BitVeryLong() {
11468
+ _classCallCheck(this, Signed64BitVeryLong);
11469
+ return _callSuper(this, Signed64BitVeryLong, ["SV", "BigInt64"]);
11470
+ }
11471
+ _inherits(Signed64BitVeryLong, _Unsigned64BitVeryLon);
11472
+ return _createClass(Signed64BitVeryLong);
11473
+ }(Unsigned64BitVeryLong);
11406
11474
  var UniqueIdentifier = /*#__PURE__*/function (_AsciiStringRepresent8) {
11407
11475
  function UniqueIdentifier() {
11408
11476
  var _this27;
@@ -11495,7 +11563,9 @@
11495
11563
  key: "read",
11496
11564
  value: function read(stream, length, syntax, readOptions) {
11497
11565
  var arrayBuffer = this.readBytes(stream, length, syntax)[0];
11498
- var streamFromBuffer = new ReadBufferStream(arrayBuffer);
11566
+ var streamFromBuffer = new ReadBufferStream(arrayBuffer, {
11567
+ decoder: stream.decoder
11568
+ });
11499
11569
  var vr = ValueRepresentation$1.createByTypeString(this.type);
11500
11570
  if (vr.isBinary() && length > vr.maxLength && !vr.noMultiple) {
11501
11571
  var values = [];
@@ -11570,6 +11640,38 @@
11570
11640
  }
11571
11641
  _inherits(OtherFloatString, _BinaryRepresentation6);
11572
11642
  return _createClass(OtherFloatString);
11643
+ }(BinaryRepresentation); // A stream of 32 bit words, for example Long Triangle Point Index List
11644
+ // (0066,0041), where the 16 bit OW form caps a surface at 65535 points.
11645
+ var OtherLongString = /*#__PURE__*/function (_BinaryRepresentation7) {
11646
+ function OtherLongString() {
11647
+ var _this35;
11648
+ _classCallCheck(this, OtherLongString);
11649
+ _this35 = _callSuper(this, OtherLongString, ["OL"]);
11650
+ _this35.maxLength = null;
11651
+ _this35.padByte = PADDING_NULL;
11652
+ _this35.noMultiple = true;
11653
+ return _this35;
11654
+ }
11655
+ _inherits(OtherLongString, _BinaryRepresentation7);
11656
+ return _createClass(OtherLongString);
11657
+ }(BinaryRepresentation);
11658
+ /**
11659
+ * OV, Other 64-bit Very Long: a stream of 64 bit words, read and written as
11660
+ * raw bytes (PS3.5 Section 6.2, Table 6.2-1,
11661
+ * https://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_6.2.html).
11662
+ */
11663
+ var OtherVeryLongString = /*#__PURE__*/function (_BinaryRepresentation8) {
11664
+ function OtherVeryLongString() {
11665
+ var _this36;
11666
+ _classCallCheck(this, OtherVeryLongString);
11667
+ _this36 = _callSuper(this, OtherVeryLongString, ["OV"]);
11668
+ _this36.maxLength = null;
11669
+ _this36.padByte = PADDING_NULL;
11670
+ _this36.noMultiple = true;
11671
+ return _this36;
11672
+ }
11673
+ _inherits(OtherVeryLongString, _BinaryRepresentation8);
11674
+ return _createClass(OtherVeryLongString);
11573
11675
  }(BinaryRepresentation);
11574
11676
  /**
11575
11677
  * The shared VR instances by code (`Vrs.DS`); `registerVr` extends it.
@@ -11592,12 +11694,15 @@
11592
11694
  OB: new OtherByteString(),
11593
11695
  OD: new OtherDoubleString(),
11594
11696
  OF: new OtherFloatString(),
11697
+ OL: new OtherLongString(),
11698
+ OV: new OtherVeryLongString(),
11595
11699
  OW: new OtherWordString(),
11596
11700
  PN: new PersonName(),
11597
11701
  SH: new ShortString(),
11598
11702
  SL: new SignedLong(),
11599
11703
  SQ: new SequenceOfItems(),
11600
11704
  SS: new SignedShort(),
11705
+ SV: new Signed64BitVeryLong(),
11601
11706
  ST: new ShortText(),
11602
11707
  TM: new TimeValue(),
11603
11708
  UC: new UnlimitedCharacters(),
@@ -11683,6 +11788,107 @@
11683
11788
  return EXPLICIT_LITTLE_ENDIAN;
11684
11789
  }
11685
11790
 
11791
+ var BINARY_AS = new Set(["ArrayBuffer", "Uint8Array"]);
11792
+ var isSharedBuffer = function isSharedBuffer(v) {
11793
+ return typeof SharedArrayBuffer !== "undefined" && v instanceof SharedArrayBuffer;
11794
+ };
11795
+
11796
+ /**
11797
+ * True when a binary value holds no bytes: no fragment, or only fragments of
11798
+ * zero length (a Part 10 reader gives one empty fragment for an empty
11799
+ * element). Such a value naturalizes to null (NAT-U-BIN-1).
11800
+ */
11801
+ function isEmptyBinary(fragments) {
11802
+ return fragments.every(function (f) {
11803
+ return isBinaryData(f) && f.byteLength === 0;
11804
+ });
11805
+ }
11806
+
11807
+ /** True for bytes: an ArrayBuffer, a SharedArrayBuffer, or a view. */
11808
+ function isBinaryData(v) {
11809
+ return v instanceof ArrayBuffer || ArrayBuffer.isView(v) || isSharedBuffer(v);
11810
+ }
11811
+
11812
+ /**
11813
+ * Checks the `binaryAs` naturalize option and gives its value.
11814
+ *
11815
+ * @param {string} [binaryAs="ArrayBuffer"]
11816
+ * @returns {"ArrayBuffer"|"Uint8Array"}
11817
+ */
11818
+ function checkBinaryAs() {
11819
+ var binaryAs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "ArrayBuffer";
11820
+ if (!BINARY_AS.has(binaryAs)) {
11821
+ throw new TypeError("binaryAs must be \"ArrayBuffer\" or \"Uint8Array\", not \"".concat(binaryAs, "\""));
11822
+ }
11823
+ return binaryAs;
11824
+ }
11825
+
11826
+ /**
11827
+ * One fragment or frame of a binary value in the naturalized form
11828
+ * (NAT-U-BIN in docs/specs/naturalized-dataset.md).
11829
+ *
11830
+ * - "ArrayBuffer" (the default): an ArrayBuffer. A view that covers its whole
11831
+ * buffer gives that buffer; any other view is copied to its own buffer.
11832
+ * - "Uint8Array": a Uint8Array over the same bytes, never a copy.
11833
+ *
11834
+ * Anything that is not an ArrayBuffer or a view, for example a
11835
+ * `{ BulkDataURI }` reference, is returned unchanged.
11836
+ */
11837
+ function naturalBinaryFragment(fragment) {
11838
+ var binaryAs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "ArrayBuffer";
11839
+ if (fragment instanceof ArrayBuffer) {
11840
+ return binaryAs === "Uint8Array" ? new Uint8Array(fragment) : fragment;
11841
+ }
11842
+ if (isSharedBuffer(fragment)) {
11843
+ // a shared buffer is not an ArrayBuffer: the default mode copies it
11844
+ var view = new Uint8Array(fragment);
11845
+ return binaryAs === "Uint8Array" ? view : view.slice().buffer;
11846
+ }
11847
+ if (!ArrayBuffer.isView(fragment)) {
11848
+ return fragment;
11849
+ }
11850
+ var buffer = fragment.buffer,
11851
+ byteOffset = fragment.byteOffset,
11852
+ byteLength = fragment.byteLength;
11853
+ if (binaryAs === "Uint8Array") {
11854
+ return new Uint8Array(buffer, byteOffset, byteLength);
11855
+ }
11856
+ if (!(buffer instanceof ArrayBuffer)) {
11857
+ // a view over a shared buffer
11858
+ return new Uint8Array(buffer, byteOffset, byteLength).slice().buffer;
11859
+ }
11860
+ return byteOffset === 0 && byteLength === buffer.byteLength ? buffer : buffer.slice(byteOffset, byteOffset + byteLength);
11861
+ }
11862
+
11863
+ /**
11864
+ * PS3.5 §6.2.2: true when an explicit-VR UN value holds a sequence, encoded
11865
+ * as Implicit VR Little Endian. The rule applies only when the dictionary VR
11866
+ * `vr` is SQ, or is UN because the tag has no dictionary entry. The value
11867
+ * must start with the item tag (FFFE,E000), and the first item length must
11868
+ * be undefined or fit in the value. Any other value stays UN bytes.
11869
+ *
11870
+ * @param {DataView|SplitDataView} view - the bytes, with absolute offsets
11871
+ * @param {number} offset - the start of the value
11872
+ * @param {number} length - the value length
11873
+ * @param {string} vr - the VR after the dictionary lookup
11874
+ */
11875
+ function isUnSequenceValue(view, offset, length, vr) {
11876
+ if (vr !== "UN" && vr !== "SQ") return false;
11877
+ if (length === UNDEFINED_LENGTH || length < 8) return false;
11878
+ if (offset + 8 > view.byteLength) return false;
11879
+ var tag = (view.getUint16(offset, true) << 16 | view.getUint16(offset + 2, true)) >>> 0;
11880
+ if (tag !== SEQUENCE_ITEM_TAG) return false;
11881
+ var itemLength = view.getUint32(offset + 4, true);
11882
+ return itemLength === UNDEFINED_LENGTH || itemLength <= length - 8;
11883
+ }
11884
+
11885
+ /** True for an item dataset: an object whose keys are all tags ("00100010"). */
11886
+ function isItemDictLike(v) {
11887
+ return v && _typeof(v) === "object" && !isBinaryData(v) && Object.keys(v).every(function (k) {
11888
+ return /^[0-9A-Fx]{8,9}$/i.test(k);
11889
+ });
11890
+ }
11891
+
11686
11892
  function paddingLeft(paddingValue, string) {
11687
11893
  return String(paddingValue + string).slice(-paddingValue.length);
11688
11894
  }
@@ -11761,6 +11967,10 @@
11761
11967
  }, {
11762
11968
  key: "write",
11763
11969
  value: function write(stream, vrType, values, syntax, writeOptions) {
11970
+ // A UN whose values are item datasets is a sequence (PS3.5 §6.2.2).
11971
+ if (vrType === "UN" && Array.isArray(values) && values.length > 0 && values.every(isItemDictLike)) {
11972
+ vrType = "SQ";
11973
+ }
11764
11974
  var vr = ValueRepresentation$1.createByTypeString(vrType);
11765
11975
  var useSyntax = normalizeSyntax(syntax);
11766
11976
  // No value (NAT-U-RT-7): absent, null, "" or only undefined entries is
@@ -12688,78 +12898,6 @@
12688
12898
  return entry !== null && entry !== void 0 && entry.vm && !isMultiVM(entry.vm) ? 1 : undefined;
12689
12899
  }
12690
12900
 
12691
- var BINARY_AS = new Set(["ArrayBuffer", "Uint8Array"]);
12692
- var isSharedBuffer = function isSharedBuffer(v) {
12693
- return typeof SharedArrayBuffer !== "undefined" && v instanceof SharedArrayBuffer;
12694
- };
12695
-
12696
- /**
12697
- * True when a binary value holds no bytes: no fragment, or only fragments of
12698
- * zero length (a Part 10 reader gives one empty fragment for an empty
12699
- * element). Such a value naturalizes to null (NAT-U-BIN-1).
12700
- */
12701
- function isEmptyBinary(fragments) {
12702
- return fragments.every(function (f) {
12703
- return isBinaryData(f) && f.byteLength === 0;
12704
- });
12705
- }
12706
-
12707
- /** True for bytes: an ArrayBuffer, a SharedArrayBuffer, or a view. */
12708
- function isBinaryData(v) {
12709
- return v instanceof ArrayBuffer || ArrayBuffer.isView(v) || isSharedBuffer(v);
12710
- }
12711
-
12712
- /**
12713
- * Checks the `binaryAs` naturalize option and gives its value.
12714
- *
12715
- * @param {string} [binaryAs="ArrayBuffer"]
12716
- * @returns {"ArrayBuffer"|"Uint8Array"}
12717
- */
12718
- function checkBinaryAs() {
12719
- var binaryAs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "ArrayBuffer";
12720
- if (!BINARY_AS.has(binaryAs)) {
12721
- throw new TypeError("binaryAs must be \"ArrayBuffer\" or \"Uint8Array\", not \"".concat(binaryAs, "\""));
12722
- }
12723
- return binaryAs;
12724
- }
12725
-
12726
- /**
12727
- * One fragment or frame of a binary value in the naturalized form
12728
- * (NAT-U-BIN in docs/specs/naturalized-dataset.md).
12729
- *
12730
- * - "ArrayBuffer" (the default): an ArrayBuffer. A view that covers its whole
12731
- * buffer gives that buffer; any other view is copied to its own buffer.
12732
- * - "Uint8Array": a Uint8Array over the same bytes, never a copy.
12733
- *
12734
- * Anything that is not an ArrayBuffer or a view, for example a
12735
- * `{ BulkDataURI }` reference, is returned unchanged.
12736
- */
12737
- function naturalBinaryFragment(fragment) {
12738
- var binaryAs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "ArrayBuffer";
12739
- if (fragment instanceof ArrayBuffer) {
12740
- return binaryAs === "Uint8Array" ? new Uint8Array(fragment) : fragment;
12741
- }
12742
- if (isSharedBuffer(fragment)) {
12743
- // a shared buffer is not an ArrayBuffer: the default mode copies it
12744
- var view = new Uint8Array(fragment);
12745
- return binaryAs === "Uint8Array" ? view : view.slice().buffer;
12746
- }
12747
- if (!ArrayBuffer.isView(fragment)) {
12748
- return fragment;
12749
- }
12750
- var buffer = fragment.buffer,
12751
- byteOffset = fragment.byteOffset,
12752
- byteLength = fragment.byteLength;
12753
- if (binaryAs === "Uint8Array") {
12754
- return new Uint8Array(buffer, byteOffset, byteLength);
12755
- }
12756
- if (!(buffer instanceof ArrayBuffer)) {
12757
- // a view over a shared buffer
12758
- return new Uint8Array(buffer, byteOffset, byteLength).slice().buffer;
12759
- }
12760
- return byteOffset === 0 && byteLength === buffer.byteLength ? buffer : buffer.slice(byteOffset, byteOffset + byteLength);
12761
- }
12762
-
12763
12901
  /**
12764
12902
  * Exposes a single-item sequence as its item object, which also behaves like
12765
12903
  * a one-element list. This is the 1.0 naturalized shape (no Proxy):
@@ -14068,7 +14206,12 @@
14068
14206
  return value;
14069
14207
  }
14070
14208
 
14071
- // keep the static function to support previous calls to the class
14209
+ /**
14210
+ * Converts a naturalized dataset to a DICOM JSON style dict. A DS
14211
+ * number is formatted to 16 characters or less (PS3.5 Table 6.2-1,
14212
+ * https://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_6.2.html).
14213
+ * Kept static to support previous calls to the class.
14214
+ */
14072
14215
  }, {
14073
14216
  key: "denaturalizeDataset",
14074
14217
  value: function denaturalizeDataset(dataset) {
@@ -14121,6 +14264,13 @@
14121
14264
  }
14122
14265
  }
14123
14266
  var _vr = ValueRepresentation$1.createByTypeString(dataItem.vr);
14267
+ if (dataItem.vr === "DS") {
14268
+ // Fit numbers to 16 characters; String(number) is cut below
14269
+ var formatDs = function formatDs(value) {
14270
+ return typeof value === "number" || value instanceof Number ? _vr.convertToString(Number(value)) : value;
14271
+ };
14272
+ dataItem.Value = Array.isArray(dataItem.Value) ? dataItem.Value.map(formatDs) : formatDs(dataItem.Value);
14273
+ }
14124
14274
  dataItem.Value = DicomMetaDictionary.denaturalizeValue(dataItem.Value);
14125
14275
  if (entry.vr == "SQ") {
14126
14276
  var unnaturalValues = [];
@@ -16145,7 +16295,8 @@
16145
16295
  }
16146
16296
  var length = null,
16147
16297
  vr = null,
16148
- vrType;
16298
+ vrType,
16299
+ wireVrType = null;
16149
16300
  if (implicit) {
16150
16301
  length = stream.readUint32();
16151
16302
  var elementData = DicomMessage.lookupTag(tag);
@@ -16173,6 +16324,7 @@
16173
16324
  vr = ValueRepresentation$1.createByTypeString(vrType);
16174
16325
  } else {
16175
16326
  vrType = stream.readVR();
16327
+ wireVrType = vrType;
16176
16328
  if (vrType === "UN" && DicomMessage.lookupTag(tag) && DicomMessage.lookupTag(tag).vr) {
16177
16329
  vrType = DicomMessage.lookupTag(tag).vr;
16178
16330
  if (vrType === "xs") {
@@ -16191,13 +16343,19 @@
16191
16343
  length = stream.readUint16();
16192
16344
  }
16193
16345
  }
16346
+ var readSyntax = syntax;
16347
+ if (!implicit && wireVrType === "UN" && isUnSequenceValue(stream.view, stream.offset, length, vr.type)) {
16348
+ vr = ValueRepresentation$1.createByTypeString("SQ");
16349
+ readSyntax = IMPLICIT_LITTLE_ENDIAN;
16350
+ stream.setEndian(true); // the items are LE in a BE body too
16351
+ }
16194
16352
  var values = [];
16195
16353
  var rawValues = [];
16196
16354
  if (vr.isBinary() && length > vr.maxLength && !vr.noMultiple) {
16197
16355
  var times = length / vr.maxLength,
16198
16356
  i = 0;
16199
16357
  while (i++ < times) {
16200
- var _vr$read = vr.read(stream, vr.maxLength, syntax, options),
16358
+ var _vr$read = vr.read(stream, vr.maxLength, readSyntax, options),
16201
16359
  rawValue = _vr$read.rawValue,
16202
16360
  value = _vr$read.value;
16203
16361
  rawValues.push(rawValue);
@@ -16208,7 +16366,7 @@
16208
16366
  var readOptions = vr.type === "SQ" ? _objectSpread2(_objectSpread2({}, options), {}, {
16209
16367
  readItem: readItem
16210
16368
  }) : options;
16211
- var _ref = vr.read(stream, length, syntax, readOptions) || {},
16369
+ var _ref = vr.read(stream, length, readSyntax, readOptions) || {},
16212
16370
  _rawValue = _ref.rawValue,
16213
16371
  _value = _ref.value;
16214
16372
  if (!vr.isBinary() && singleVRs.indexOf(vr.type) == -1) {
@@ -17134,12 +17292,14 @@
17134
17292
  key: "readSequence",
17135
17293
  value: (function () {
17136
17294
  var _readSequence = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(listener, sqTagInfo, options) {
17137
- var length, stream, syntax, endOffset, tagInfo, tag, itemLength, itemUntilOffset, _t;
17295
+ var _ref, _sqTagInfo$sequenceRe;
17296
+ var length, stream, readSyntax, endOffset, tagInfo, tag, itemLength, itemUntilOffset, decoder, _t;
17138
17297
  return _regeneratorRuntime().wrap(function (_context6) {
17139
17298
  while (1) switch (_context6.prev = _context6.next) {
17140
17299
  case 0:
17141
17300
  length = sqTagInfo.length;
17142
- stream = this.stream, syntax = this.syntax;
17301
+ stream = this.stream;
17302
+ 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;
17143
17303
  endOffset = length === UNDEFINED_LENGTH_FIX ? Number.MAX_SAFE_INTEGER : stream.offset + length;
17144
17304
  case 1:
17145
17305
  _t = stream.offset < endOffset;
@@ -17157,7 +17317,9 @@
17157
17317
  break;
17158
17318
  }
17159
17319
  readLog.debug("readSequence loop", stream.offset, endOffset);
17160
- tagInfo = this.readTagHeader(syntax, options);
17320
+ tagInfo = this.readTagHeader(_objectSpread2(_objectSpread2({}, options), {}, {
17321
+ readSyntax: readSyntax
17322
+ }));
17161
17323
  tag = tagInfo.tag;
17162
17324
  if (!(tag === TagHex.Item)) {
17163
17325
  _context6.next = 5;
@@ -17166,12 +17328,17 @@
17166
17328
  listener.startObject();
17167
17329
  // defined-length item: stop at its own end (see doc comment)
17168
17330
  itemLength = tagInfo.length;
17169
- itemUntilOffset = itemLength === UNDEFINED_LENGTH_FIX ? endOffset : Math.min(stream.offset + itemLength, endOffset);
17331
+ itemUntilOffset = itemLength === UNDEFINED_LENGTH_FIX ? endOffset : Math.min(stream.offset + itemLength, endOffset); // A SpecificCharacterSet in the item applies only to that
17332
+ // item (PS3.5 7.5.3), but the item is read on this stream:
17333
+ // put back the decoder the item started with.
17334
+ decoder = stream.decoder;
17170
17335
  _context6.next = 4;
17171
17336
  return this.read(listener, _objectSpread2(_objectSpread2({}, options), {}, {
17172
- untilOffset: itemUntilOffset
17337
+ untilOffset: itemUntilOffset,
17338
+ readSyntax: readSyntax
17173
17339
  }));
17174
17340
  case 4:
17341
+ stream.setDecoder(decoder);
17175
17342
  _context6.next = 7;
17176
17343
  break;
17177
17344
  case 5:
@@ -17597,14 +17764,15 @@
17597
17764
  }, {
17598
17765
  key: "readTagHeader",
17599
17766
  value: function readTagHeader() {
17767
+ var _options$readSyntax;
17600
17768
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
17601
17769
  untilTag: null,
17602
17770
  includeUntilTagValue: false
17603
17771
  };
17604
- var stream = this.stream,
17605
- syntax = this.syntax;
17772
+ var stream = this.stream;
17606
17773
  var untilTag = options.untilTag,
17607
17774
  includeUntilTagValue = options.includeUntilTagValue;
17775
+ var syntax = (_options$readSyntax = options.readSyntax) !== null && _options$readSyntax !== void 0 ? _options$readSyntax : this.syntax;
17608
17776
  var implicit = syntax == IMPLICIT_LITTLE_ENDIAN;
17609
17777
  var isLittleEndian = syntax !== EXPLICIT_BIG_ENDIAN;
17610
17778
  stream.setEndian(isLittleEndian);
@@ -17624,6 +17792,7 @@
17624
17792
  var length = null;
17625
17793
  var vr = null;
17626
17794
  var vrType;
17795
+ var wireVrType = null;
17627
17796
  var isCommand = tagObj.group() === 0;
17628
17797
  if (tagObj.isInstruction()) {
17629
17798
  length = stream.readUint32();
@@ -17658,6 +17827,7 @@
17658
17827
  } else {
17659
17828
  var _DicomMessage$lookupT;
17660
17829
  vrType = stream.readVR();
17830
+ wireVrType = vrType;
17661
17831
  if (vrType === "UN" && (_DicomMessage$lookupT = DicomMessage.lookupTag(tagObj)) !== null && _DicomMessage$lookupT !== void 0 && _DicomMessage$lookupT.vr) {
17662
17832
  vrType = DicomMessage.lookupTag(tagObj).vr;
17663
17833
  if (vrType === "xs") {
@@ -17677,11 +17847,16 @@
17677
17847
  length = stream.readUint16();
17678
17848
  }
17679
17849
  }
17850
+ var sequenceReadSyntax;
17851
+ if (!implicit && wireVrType === "UN" && isUnSequenceValue(stream.view, stream.offset, length, vr.type)) {
17852
+ vr = ValueRepresentation$1.createByTypeString("SQ");
17853
+ sequenceReadSyntax = IMPLICIT_LITTLE_ENDIAN;
17854
+ }
17680
17855
  var punctuatedTag = DicomMetaDictionary.punctuateTag(tag);
17681
17856
  var entry = DicomMetaDictionary.dictionary[punctuatedTag];
17682
17857
 
17683
17858
  // Include both the string and object values for vr and tag
17684
- var header = {
17859
+ var header = _objectSpread2({
17685
17860
  vrObj: vr,
17686
17861
  vr: vr.type,
17687
17862
  tag: tag,
@@ -17689,7 +17864,9 @@
17689
17864
  vm: entry === null || entry === void 0 ? void 0 : entry.vm,
17690
17865
  name: entry === null || entry === void 0 ? void 0 : entry.name,
17691
17866
  length: length === UNDEFINED_LENGTH ? -1 : length
17692
- };
17867
+ }, sequenceReadSyntax && {
17868
+ sequenceReadSyntax: sequenceReadSyntax
17869
+ });
17693
17870
  return header;
17694
17871
  }
17695
17872
 
@@ -17703,12 +17880,14 @@
17703
17880
  key: "readSingle",
17704
17881
  value: (function () {
17705
17882
  var _readSingle = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(tagInfo, listener, options) {
17883
+ var _options$readSyntax2;
17706
17884
  var length, stream, syntax, vr, values, times, i, _vr$read, value, _vr$read2, _value, delimiterChar, decoder, valuesForListener;
17707
17885
  return _regeneratorRuntime().wrap(function (_context11) {
17708
17886
  while (1) switch (_context11.prev = _context11.next) {
17709
17887
  case 0:
17710
17888
  length = tagInfo.length;
17711
- stream = this.stream, syntax = this.syntax;
17889
+ stream = this.stream;
17890
+ syntax = (_options$readSyntax2 = options === null || options === void 0 ? void 0 : options.readSyntax) !== null && _options$readSyntax2 !== void 0 ? _options$readSyntax2 : this.syntax;
17712
17891
  _context11.next = 1;
17713
17892
  return this.stream.ensureAvailable(length);
17714
17893
  case 1:
@@ -18496,16 +18675,10 @@
18496
18675
  //
18497
18676
  // shared
18498
18677
  var SpacingBetweenSlices = Math.abs(distance1 - distance0);
18499
- ds.SharedFunctionalGroupsSequence = {
18500
- PlaneOrientationSequence: {
18501
- ImageOrientationPatient: dataset0.ImageOrientationPatient
18502
- },
18503
- PixelMeasuresSequence: {
18504
- PixelSpacing: dataset0.PixelSpacing,
18505
- SpacingBetweenSlices: SpacingBetweenSlices,
18506
- SliceThickness: SpacingBetweenSlices
18507
- }
18508
- };
18678
+ ds.SharedFunctionalGroupsSequence = ImageNormalizer.sharedImagePlaneGroups(dataset0, {
18679
+ SpacingBetweenSlices: SpacingBetweenSlices,
18680
+ SliceThickness: SpacingBetweenSlices
18681
+ });
18509
18682
  ds.ReferencedSeriesSequence = {
18510
18683
  SeriesInstanceUID: dataset0.SeriesInstanceUID,
18511
18684
  ReferencedInstanceSequence: []
@@ -18518,15 +18691,12 @@
18518
18691
  // and set the referenced series uid
18519
18692
  distanceDatasetPairs.forEach(function (pair) {
18520
18693
  var dataset = pair[1];
18521
- ds.PerFrameFunctionalGroupsSequence.push({
18522
- PlanePositionSequence: {
18523
- ImagePositionPatient: dataset.ImagePositionPatient
18524
- },
18694
+ ds.PerFrameFunctionalGroupsSequence.push(_objectSpread2(_objectSpread2({}, ImageNormalizer.planePositionGroup(dataset)), {}, {
18525
18695
  FrameVOILUTSequence: {
18526
18696
  WindowCenter: dataset.WindowCenter,
18527
18697
  WindowWidth: dataset.WindowWidth
18528
18698
  }
18529
- });
18699
+ }));
18530
18700
  ds.ReferencedSeriesSequence.ReferencedInstanceSequence.push({
18531
18701
  ReferencedSOPClassUID: dataset.SOPClassUID,
18532
18702
  ReferencedSOPInstanceUID: dataset.SOPInstanceUID
@@ -18568,7 +18738,11 @@
18568
18738
  ds.PresentationLUTShape = "IDENTITY";
18569
18739
  }
18570
18740
  if (!ds.SharedFunctionalGroupsSequence) {
18571
- log.error("Can only process multiframe data with SharedFunctionalGroupsSequence");
18741
+ log.warn("Missing SharedFunctionalGroupsSequence; using the top-level image plane attributes");
18742
+ ds.SharedFunctionalGroupsSequence = ImageNormalizer.sharedImagePlaneGroups(ds, {
18743
+ SliceThickness: ds.SliceThickness,
18744
+ SpacingBetweenSlices: ds.SpacingBetweenSlices
18745
+ });
18572
18746
  }
18573
18747
 
18574
18748
  // TODO: special case!
@@ -18589,9 +18763,22 @@
18589
18763
  RescaleSlope: rescaleSlope,
18590
18764
  RescaleType: "US"
18591
18765
  };
18592
- var frameNumber = 1;
18593
- this.datasets.forEach(function (dataset) {
18594
- if (ds.NumberOfFrames === 1) ds.PerFrameFunctionalGroupsSequence = [ds.PerFrameFunctionalGroupsSequence];
18766
+ var frameCount = this.datasets.length;
18767
+ if (!ds.PerFrameFunctionalGroupsSequence) {
18768
+ // One item per declared frame, all at the top-level position
18769
+ frameCount = Math.max(frameCount, Number(ds.NumberOfFrames) || 0);
18770
+ ds.PerFrameFunctionalGroupsSequence = Array.from({
18771
+ length: frameCount
18772
+ }, function () {
18773
+ return ImageNormalizer.planePositionGroup(ds);
18774
+ });
18775
+ } else if (!Array.isArray(ds.PerFrameFunctionalGroupsSequence)) {
18776
+ ds.PerFrameFunctionalGroupsSequence = [ds.PerFrameFunctionalGroupsSequence];
18777
+ }
18778
+ for (var frameNumber = 1; frameNumber <= frameCount; frameNumber++) {
18779
+ var _ds$PerFrameFunctiona, _ref;
18780
+ var dataset = this.datasets[frameNumber - 1] || {};
18781
+ (_ds$PerFrameFunctiona = ds.PerFrameFunctionalGroupsSequence)[_ref = frameNumber - 1] || (_ds$PerFrameFunctiona[_ref] = {});
18595
18782
  ds.PerFrameFunctionalGroupsSequence[frameNumber - 1].FrameContentSequence = {
18596
18783
  FrameAcquisitionDuration: 0,
18597
18784
  StackID: 1,
@@ -18604,8 +18791,7 @@
18604
18791
  frameContentSequence.FrameAcquisitionDateTime = frameTime;
18605
18792
  frameContentSequence.FrameReferenceDateTime = frameTime;
18606
18793
  }
18607
- frameNumber++;
18608
- });
18794
+ }
18609
18795
 
18610
18796
  //
18611
18797
  // TODO: convert this to shared functional group not top level element
@@ -18690,6 +18876,27 @@
18690
18876
  value: function vec3Dot(a, b) {
18691
18877
  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
18692
18878
  }
18879
+ }, {
18880
+ key: "sharedImagePlaneGroups",
18881
+ value: function sharedImagePlaneGroups(dataset, pixelMeasures) {
18882
+ return {
18883
+ PlaneOrientationSequence: {
18884
+ ImageOrientationPatient: dataset.ImageOrientationPatient
18885
+ },
18886
+ PixelMeasuresSequence: _objectSpread2({
18887
+ PixelSpacing: dataset.PixelSpacing
18888
+ }, pixelMeasures)
18889
+ };
18890
+ }
18891
+ }, {
18892
+ key: "planePositionGroup",
18893
+ value: function planePositionGroup(dataset) {
18894
+ return {
18895
+ PlanePositionSequence: {
18896
+ ImagePositionPatient: dataset.ImagePositionPatient
18897
+ }
18898
+ };
18899
+ }
18693
18900
  }]);
18694
18901
  }(Normalizer);
18695
18902
  var MRImageNormalizer = /*#__PURE__*/function (_ImageNormalizer) {
@@ -21472,7 +21679,7 @@
21472
21679
  var _matrix$shape = _slicedToArray(matrix.shape, 2),
21473
21680
  rows = _matrix$shape[0],
21474
21681
  cols = _matrix$shape[1];
21475
- var result = ndarray(new Uint8Array(rows * cols), [rows, cols]);
21682
+ var result = ndarray(new matrix.data.constructor(rows * cols), [rows, cols]);
21476
21683
  for (var i = 0; i < rows; i++) {
21477
21684
  for (var j = 0; j < cols; j++) {
21478
21685
  result.set(i, j, matrix.get(i, cols - 1 - j));
@@ -21491,7 +21698,7 @@
21491
21698
  var _matrix$shape2 = _slicedToArray(matrix.shape, 2),
21492
21699
  rows = _matrix$shape2[0],
21493
21700
  cols = _matrix$shape2[1];
21494
- var result = ndarray(new Uint8Array(rows * cols), [rows, cols]);
21701
+ var result = ndarray(new matrix.data.constructor(rows * cols), [rows, cols]);
21495
21702
  for (var j = 0; j < cols; j++) {
21496
21703
  for (var i = 0; i < rows; i++) {
21497
21704
  result.set(i, j, matrix.get(rows - 1 - i, j));
@@ -21510,7 +21717,7 @@
21510
21717
  var _matrix$shape = _slicedToArray(matrix.shape, 2),
21511
21718
  rows = _matrix$shape[0],
21512
21719
  cols = _matrix$shape[1];
21513
- var result = ndarray(new Uint8Array(rows * cols), [cols, rows]);
21720
+ var result = ndarray(new matrix.data.constructor(rows * cols), [cols, rows]);
21514
21721
  var resultColsMinus1 = result.shape[1] - 1;
21515
21722
  for (var i = 0; i < rows; i++) {
21516
21723
  for (var j = 0; j < cols; j++) {
@@ -27792,6 +27999,11 @@
27792
27999
  MeasurementReport: MeasurementReport$1
27793
28000
  };
27794
28001
 
28002
+ /**
28003
+ * @deprecated The adapters moved to `@cornerstonejs/adapters`. Import them
28004
+ * from that package. `@dcmjs-org/dcmjs` keeps this export only for
28005
+ * compatibility with 0.x, and a later major release removes it.
28006
+ */
27795
28007
  var adapters = {
27796
28008
  Cornerstone: Cornerstone,
27797
28009
  Cornerstone3D: Cornerstone3D,