@dcmjs-org/dcmjs 1.0.0-beta.20 → 1.0.0-beta.22
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 +1 -1
- package/build/dcmjs.es.js +1 -1
- package/build/dcmjs.js +173 -44
- package/build/dcmjs.js.map +1 -1
- package/build/dcmjs.min.js +1 -1
- package/build/dcmjs.min.js.map +1 -1
- package/build/{dcmjs.shared-RH-AbhO5.js → dcmjs.shared-DVqSe8G1.js} +100 -35
- package/build/dcmjs.shared-DVqSe8G1.js.map +1 -0
- package/build/{dcmjs.shared-Cmkm67T1.cjs → dcmjs.shared-Dkebpbbj.cjs} +99 -34
- package/build/dcmjs.shared-Dkebpbbj.cjs.map +1 -0
- package/build/eventStream.cjs +1 -1
- package/build/eventStream.es.js +1 -1
- package/package.json +7 -7
- package/build/dcmjs.shared-Cmkm67T1.cjs.map +0 -1
- package/build/dcmjs.shared-RH-AbhO5.js.map +0 -1
package/build/dcmjs.cjs
CHANGED
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-
|
|
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-DVqSe8G1.js';
|
|
2
2
|
export { log } from '@dcmjs-org/core';
|
|
3
3
|
//# sourceMappingURL=dcmjs.es.js.map
|
package/build/dcmjs.js
CHANGED
|
@@ -8906,10 +8906,9 @@
|
|
|
8906
8906
|
}, {
|
|
8907
8907
|
key: "readUint16Array",
|
|
8908
8908
|
value: function readUint16Array(length) {
|
|
8909
|
-
var
|
|
8910
|
-
arr = new Uint16Array(
|
|
8911
|
-
|
|
8912
|
-
while (i++ < sixlen) {
|
|
8909
|
+
var words = Math.floor(length / 2),
|
|
8910
|
+
arr = new Uint16Array(words);
|
|
8911
|
+
for (var i = 0; i < words; i++) {
|
|
8913
8912
|
arr[i] = this.view.getUint16(this.offset, this.isLittleEndian);
|
|
8914
8913
|
this.offset += 2;
|
|
8915
8914
|
}
|
|
@@ -9915,6 +9914,50 @@
|
|
|
9915
9914
|
pnAddValueAccessors: pnAddValueAccessors
|
|
9916
9915
|
};
|
|
9917
9916
|
|
|
9917
|
+
/** A Uint8Array over the bytes of data, or undefined when data has no bytes. */
|
|
9918
|
+
function asBytes(data) {
|
|
9919
|
+
if (ArrayBuffer.isView(data)) {
|
|
9920
|
+
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
9921
|
+
}
|
|
9922
|
+
// not instanceof: a buffer from another realm (worker, jsdom) fails it
|
|
9923
|
+
if (data && typeof data.byteLength === "number") {
|
|
9924
|
+
return new Uint8Array(data);
|
|
9925
|
+
}
|
|
9926
|
+
return undefined;
|
|
9927
|
+
}
|
|
9928
|
+
|
|
9929
|
+
/**
|
|
9930
|
+
* Reverses the bytes of each word of data, in place: Explicit VR Big Endian
|
|
9931
|
+
* to the little endian in-memory form (PS3.5 Section 7.3), or back.
|
|
9932
|
+
* @param {ArrayBuffer|ArrayBufferView} data
|
|
9933
|
+
* @param {number} wordWidth bytes per word; 1 changes nothing
|
|
9934
|
+
* @returns data
|
|
9935
|
+
*/
|
|
9936
|
+
function swapBytes(data, wordWidth) {
|
|
9937
|
+
var bytes = wordWidth > 1 ? asBytes(data) : undefined;
|
|
9938
|
+
if (!bytes) {
|
|
9939
|
+
return data;
|
|
9940
|
+
}
|
|
9941
|
+
var end = bytes.length - bytes.length % wordWidth;
|
|
9942
|
+
for (var start = 0; start < end; start += wordWidth) {
|
|
9943
|
+
for (var i = start, j = start + wordWidth - 1; i < j; i++, j--) {
|
|
9944
|
+
var b = bytes[i];
|
|
9945
|
+
bytes[i] = bytes[j];
|
|
9946
|
+
bytes[j] = b;
|
|
9947
|
+
}
|
|
9948
|
+
}
|
|
9949
|
+
return data;
|
|
9950
|
+
}
|
|
9951
|
+
|
|
9952
|
+
/**
|
|
9953
|
+
* {@link swapBytes} on a copy. Gives data itself when there is nothing to
|
|
9954
|
+
* swap, so the caller must not modify the result.
|
|
9955
|
+
*/
|
|
9956
|
+
function swappedCopy(data, wordWidth) {
|
|
9957
|
+
var bytes = wordWidth > 1 ? asBytes(data) : undefined;
|
|
9958
|
+
return bytes ? swapBytes(bytes.slice(), wordWidth).buffer : data;
|
|
9959
|
+
}
|
|
9960
|
+
|
|
9918
9961
|
function rtrim(str) {
|
|
9919
9962
|
return str.replace(/\s*$/g, "");
|
|
9920
9963
|
}
|
|
@@ -9951,6 +9994,15 @@
|
|
|
9951
9994
|
vr._isLength32 = !!flags.length32;
|
|
9952
9995
|
}
|
|
9953
9996
|
|
|
9997
|
+
// Bytes per word of a binary value field, for Explicit VR Big Endian (OB, UN: 1)
|
|
9998
|
+
var WORD_WIDTHS = {
|
|
9999
|
+
OD: 8,
|
|
10000
|
+
OF: 4,
|
|
10001
|
+
OL: 4,
|
|
10002
|
+
OV: 8,
|
|
10003
|
+
OW: 2
|
|
10004
|
+
};
|
|
10005
|
+
|
|
9954
10006
|
// Unknown VR types already warned about by createByTypeString — the UN
|
|
9955
10007
|
// fallback warns at most once per type (issue #457).
|
|
9956
10008
|
var unknownVrTypesWarned = new Set();
|
|
@@ -10353,8 +10405,16 @@
|
|
|
10353
10405
|
_this2._storeRaw = false;
|
|
10354
10406
|
return _this2;
|
|
10355
10407
|
}
|
|
10408
|
+
|
|
10409
|
+
/** Bytes per word of the value field; 1 for a byte stream. */
|
|
10356
10410
|
_inherits(BinaryRepresentation, _ValueRepresentation3);
|
|
10357
10411
|
return _createClass(BinaryRepresentation, [{
|
|
10412
|
+
key: "wordWidth",
|
|
10413
|
+
get: function get() {
|
|
10414
|
+
var _WORD_WIDTHS$this$typ;
|
|
10415
|
+
return (_WORD_WIDTHS$this$typ = WORD_WIDTHS[this.type]) !== null && _WORD_WIDTHS$this$typ !== void 0 ? _WORD_WIDTHS$this$typ : 1;
|
|
10416
|
+
}
|
|
10417
|
+
}, {
|
|
10358
10418
|
key: "writeBytes",
|
|
10359
10419
|
value: function writeBytes(stream, value, _syntax, isEncapsulated) {
|
|
10360
10420
|
var writeOptions = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
@@ -10427,6 +10487,9 @@
|
|
|
10427
10487
|
return 0xffffffff;
|
|
10428
10488
|
} else {
|
|
10429
10489
|
var binaryData = value[0];
|
|
10490
|
+
if (!stream.isLittleEndian) {
|
|
10491
|
+
binaryData = swappedCopy(binaryData, this.wordWidth);
|
|
10492
|
+
}
|
|
10430
10493
|
binaryStream = new ReadBufferStream(binaryData);
|
|
10431
10494
|
stream.concat(binaryStream);
|
|
10432
10495
|
return _get(_getPrototypeOf(BinaryRepresentation.prototype), "writeBytes", this).call(this, stream, binaryData, [binaryStream.size], writeOptions);
|
|
@@ -10539,12 +10602,6 @@
|
|
|
10539
10602
|
}
|
|
10540
10603
|
return frames;
|
|
10541
10604
|
} else {
|
|
10542
|
-
var bytes;
|
|
10543
|
-
/*if (this.type == 'OW') {
|
|
10544
|
-
bytes = stream.readUint16Array(length);
|
|
10545
|
-
} else if (this.type == 'OB') {
|
|
10546
|
-
bytes = stream.readUint8Array(length);
|
|
10547
|
-
}*/
|
|
10548
10605
|
// A declared length longer than the data present means a
|
|
10549
10606
|
// truncated or malformed file: read the bytes that are present.
|
|
10550
10607
|
// https://github.com/dcmjs-org/dcmjs/security/advisories/GHSA-xwvm-687g-rm36
|
|
@@ -10553,8 +10610,12 @@
|
|
|
10553
10610
|
validationLog.warn("".concat(this.type, " value declares ").concat(length, " bytes but only ").concat(available, " are available - reading the available bytes"));
|
|
10554
10611
|
length = available;
|
|
10555
10612
|
}
|
|
10556
|
-
bytes = stream.getBuffer(stream.offset, stream.offset + length);
|
|
10613
|
+
var bytes = stream.getBuffer(stream.offset, stream.offset + length);
|
|
10557
10614
|
stream.increment(length);
|
|
10615
|
+
if (!stream.isLittleEndian) {
|
|
10616
|
+
// getBuffer gives a copy
|
|
10617
|
+
swapBytes(bytes, this.wordWidth);
|
|
10618
|
+
}
|
|
10558
10619
|
return [bytes];
|
|
10559
10620
|
}
|
|
10560
10621
|
}
|
|
@@ -11558,12 +11619,15 @@
|
|
|
11558
11619
|
_this30._storeRaw = true;
|
|
11559
11620
|
return _this30;
|
|
11560
11621
|
}
|
|
11622
|
+
|
|
11623
|
+
/** The second read swaps only what readBytes did not (scalar VRs, "ox"). */
|
|
11561
11624
|
_inherits(ParsedUnknownValue, _BinaryRepresentation2);
|
|
11562
11625
|
return _createClass(ParsedUnknownValue, [{
|
|
11563
11626
|
key: "read",
|
|
11564
11627
|
value: function read(stream, length, syntax, readOptions) {
|
|
11565
11628
|
var arrayBuffer = this.readBytes(stream, length, syntax)[0];
|
|
11566
11629
|
var streamFromBuffer = new ReadBufferStream(arrayBuffer, {
|
|
11630
|
+
littleEndian: stream.isLittleEndian || this.wordWidth > 1,
|
|
11567
11631
|
decoder: stream.decoder
|
|
11568
11632
|
});
|
|
11569
11633
|
var vr = ValueRepresentation$1.createByTypeString(this.type);
|
|
@@ -16828,7 +16892,7 @@
|
|
|
16828
16892
|
this.isLittleEndian = options === null || options === void 0 ? void 0 : options.isLittleEndian;
|
|
16829
16893
|
// Number of sequence items being read, 0 at the top level
|
|
16830
16894
|
this.sequenceDepth = 0;
|
|
16831
|
-
// Default maxFragmentSize is 128 MB
|
|
16895
|
+
// Default maxFragmentSize is 128 MB; a Big Endian fragment is at least one word, so it can be larger
|
|
16832
16896
|
this.maxFragmentSize = (_options$maxFragmentS = options === null || options === void 0 ? void 0 : options.maxFragmentSize) !== null && _options$maxFragmentS !== void 0 ? _options$maxFragmentS : 128 * 1024 * 1024;
|
|
16833
16897
|
this.stream = new ReadBufferStream(null, _objectSpread2(_objectSpread2({
|
|
16834
16898
|
clearBuffers: true
|
|
@@ -17407,16 +17471,28 @@
|
|
|
17407
17471
|
/**
|
|
17408
17472
|
* Emits one or more listener.value() calls for a fragment, splitting if needed.
|
|
17409
17473
|
* This does NOT start/pop any array contexts; callers control the surrounding structure.
|
|
17474
|
+
* In Explicit VR Big Endian, each fragment holds whole words of wordWidth
|
|
17475
|
+
* bytes, swapped to little endian.
|
|
17410
17476
|
*/
|
|
17411
17477
|
}, {
|
|
17412
17478
|
key: "_emitSplitValues",
|
|
17413
17479
|
value: (function () {
|
|
17414
17480
|
var _emitSplitValues2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(length) {
|
|
17415
17481
|
var _listener$awaitDrain;
|
|
17416
|
-
var
|
|
17482
|
+
var wordWidth,
|
|
17483
|
+
stream,
|
|
17484
|
+
listener,
|
|
17485
|
+
maxFragmentSize,
|
|
17486
|
+
swap,
|
|
17487
|
+
fragmentSize,
|
|
17488
|
+
offset,
|
|
17489
|
+
chunkSize,
|
|
17490
|
+
buffer,
|
|
17491
|
+
_args7 = arguments;
|
|
17417
17492
|
return _regeneratorRuntime().wrap(function (_context7) {
|
|
17418
17493
|
while (1) switch (_context7.prev = _context7.next) {
|
|
17419
17494
|
case 0:
|
|
17495
|
+
wordWidth = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : 1;
|
|
17420
17496
|
stream = this.stream, listener = this.listener;
|
|
17421
17497
|
_context7.next = 1;
|
|
17422
17498
|
return (_listener$awaitDrain = listener.awaitDrain) === null || _listener$awaitDrain === void 0 ? void 0 : _listener$awaitDrain.call(listener);
|
|
@@ -17428,6 +17504,8 @@
|
|
|
17428
17504
|
}
|
|
17429
17505
|
throw new Error("maxFragmentSize must be a positive number, got ".concat(maxFragmentSize));
|
|
17430
17506
|
case 2:
|
|
17507
|
+
swap = this.syntax === EXPLICIT_BIG_ENDIAN && wordWidth > 1;
|
|
17508
|
+
fragmentSize = swap ? Math.max(wordWidth, maxFragmentSize - maxFragmentSize % wordWidth) : maxFragmentSize;
|
|
17431
17509
|
offset = 0;
|
|
17432
17510
|
case 3:
|
|
17433
17511
|
if (!(offset < length)) {
|
|
@@ -17435,11 +17513,14 @@
|
|
|
17435
17513
|
break;
|
|
17436
17514
|
}
|
|
17437
17515
|
readLog.trace("_emitSplitValues loop", offset, length);
|
|
17438
|
-
chunkSize = Math.min(
|
|
17516
|
+
chunkSize = Math.min(fragmentSize, length - offset);
|
|
17439
17517
|
_context7.next = 4;
|
|
17440
17518
|
return stream.ensureAvailable(chunkSize);
|
|
17441
17519
|
case 4:
|
|
17442
17520
|
buffer = stream.readArrayBuffer(chunkSize);
|
|
17521
|
+
if (swap) {
|
|
17522
|
+
swapBytes(buffer, wordWidth);
|
|
17523
|
+
}
|
|
17443
17524
|
listener.value(buffer);
|
|
17444
17525
|
offset += chunkSize;
|
|
17445
17526
|
stream.consume();
|
|
@@ -17589,12 +17670,13 @@
|
|
|
17589
17670
|
key: "readUncompressed",
|
|
17590
17671
|
value: (function () {
|
|
17591
17672
|
var _readUncompressed = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee0(tagInfo) {
|
|
17592
|
-
var length, listener, numberOfFrames, frameLength, _listener$information, _listener$information2, _listener$information3, _listener$information4, rows, cols, samplesPerPixel, bitsAllocated, bitsPerFrame, frameNumber;
|
|
17673
|
+
var length, listener, wordWidth, numberOfFrames, frameLength, _listener$information, _listener$information2, _listener$information3, _listener$information4, rows, cols, samplesPerPixel, bitsAllocated, bitsPerFrame, allPixelData, offset, frameNumber;
|
|
17593
17674
|
return _regeneratorRuntime().wrap(function (_context0) {
|
|
17594
17675
|
while (1) switch (_context0.prev = _context0.next) {
|
|
17595
17676
|
case 0:
|
|
17596
17677
|
length = tagInfo.length;
|
|
17597
17678
|
listener = this.listener;
|
|
17679
|
+
wordWidth = this.wordWidth(tagInfo);
|
|
17598
17680
|
numberOfFrames = this.getNumberOfFrames();
|
|
17599
17681
|
frameLength = Math.floor(length / numberOfFrames);
|
|
17600
17682
|
if (!(numberOfFrames > 1)) {
|
|
@@ -17627,24 +17709,41 @@
|
|
|
17627
17709
|
}
|
|
17628
17710
|
throw new Error("Invalid frame length: ".concat(length, " for ").concat(numberOfFrames, " frames"));
|
|
17629
17711
|
case 4:
|
|
17630
|
-
|
|
17712
|
+
if (!(this.syntax === EXPLICIT_BIG_ENDIAN && frameLength % wordWidth !== 0)) {
|
|
17713
|
+
_context0.next = 6;
|
|
17714
|
+
break;
|
|
17715
|
+
}
|
|
17716
|
+
_context0.next = 5;
|
|
17717
|
+
return this.stream.ensureAvailable(length);
|
|
17631
17718
|
case 5:
|
|
17719
|
+
allPixelData = this.stream.readArrayBuffer(length);
|
|
17720
|
+
this.stream.consume();
|
|
17721
|
+
swapBytes(allPixelData, wordWidth);
|
|
17722
|
+
for (offset = 0; offset < length; offset += frameLength) {
|
|
17723
|
+
listener.startObject([]);
|
|
17724
|
+
listener.value(allPixelData.slice(offset, offset + frameLength));
|
|
17725
|
+
listener.pop();
|
|
17726
|
+
}
|
|
17727
|
+
return _context0.abrupt("return");
|
|
17728
|
+
case 6:
|
|
17729
|
+
frameNumber = 0;
|
|
17730
|
+
case 7:
|
|
17632
17731
|
if (!(frameNumber < numberOfFrames)) {
|
|
17633
|
-
_context0.next =
|
|
17732
|
+
_context0.next = 10;
|
|
17634
17733
|
break;
|
|
17635
17734
|
}
|
|
17636
17735
|
readLog.trace("readUncompressed loop", frameNumber, numberOfFrames);
|
|
17637
17736
|
listener.startObject([]);
|
|
17638
|
-
_context0.next =
|
|
17639
|
-
return this._emitSplitValues(frameLength);
|
|
17640
|
-
case
|
|
17737
|
+
_context0.next = 8;
|
|
17738
|
+
return this._emitSplitValues(frameLength, wordWidth);
|
|
17739
|
+
case 8:
|
|
17641
17740
|
listener.pop();
|
|
17642
17741
|
// console.log(stream.getBufferMemoryInfo());
|
|
17643
|
-
case
|
|
17742
|
+
case 9:
|
|
17644
17743
|
frameNumber++;
|
|
17645
|
-
_context0.next =
|
|
17744
|
+
_context0.next = 7;
|
|
17646
17745
|
break;
|
|
17647
|
-
case
|
|
17746
|
+
case 10:
|
|
17648
17747
|
case "end":
|
|
17649
17748
|
return _context0.stop();
|
|
17650
17749
|
}
|
|
@@ -17712,6 +17811,10 @@
|
|
|
17712
17811
|
case 4:
|
|
17713
17812
|
allPixelData = stream.readArrayBuffer(totalBytes);
|
|
17714
17813
|
stream.consume();
|
|
17814
|
+
if (this.syntax === EXPLICIT_BIG_ENDIAN) {
|
|
17815
|
+
// the bits of OW data are packed in big endian words
|
|
17816
|
+
swapBytes(allPixelData, this.wordWidth(tagInfo));
|
|
17817
|
+
}
|
|
17715
17818
|
|
|
17716
17819
|
// Extract each frame, unpacking bits so each frame starts at byte 0
|
|
17717
17820
|
for (frameNumber = 0; frameNumber < numberOfFrames; frameNumber++) {
|
|
@@ -17753,7 +17856,8 @@
|
|
|
17753
17856
|
}()
|
|
17754
17857
|
/**
|
|
17755
17858
|
* Reads raw binary data in chunks and delivers it to the listener.
|
|
17756
|
-
*
|
|
17859
|
+
* Reads the value in fragments of `maxFragmentSize` bytes.
|
|
17860
|
+
* OW/OF/OL/OD/OV words come as little endian, as on the other read paths.
|
|
17757
17861
|
*/
|
|
17758
17862
|
)
|
|
17759
17863
|
}, {
|
|
@@ -17766,7 +17870,7 @@
|
|
|
17766
17870
|
case 0:
|
|
17767
17871
|
length = tagInfo.length;
|
|
17768
17872
|
_context10.next = 1;
|
|
17769
|
-
return this._emitSplitValues(length);
|
|
17873
|
+
return this._emitSplitValues(length, this.wordWidth(tagInfo));
|
|
17770
17874
|
case 1:
|
|
17771
17875
|
case "end":
|
|
17772
17876
|
return _context10.stop();
|
|
@@ -17777,7 +17881,13 @@
|
|
|
17777
17881
|
return _readRawBinary.apply(this, arguments);
|
|
17778
17882
|
}
|
|
17779
17883
|
return readRawBinary;
|
|
17780
|
-
}())
|
|
17884
|
+
}() /** Bytes per word of the value field; "ox" (a UN pixel data) is OW. */)
|
|
17885
|
+
}, {
|
|
17886
|
+
key: "wordWidth",
|
|
17887
|
+
value: function wordWidth(tagInfo) {
|
|
17888
|
+
var _ValueRepresentation$;
|
|
17889
|
+
return (_ValueRepresentation$ = ValueRepresentation$1.createByTypeString(tagInfo.vr).wordWidth) !== null && _ValueRepresentation$ !== void 0 ? _ValueRepresentation$ : 1;
|
|
17890
|
+
}
|
|
17781
17891
|
}, {
|
|
17782
17892
|
key: "isSequence",
|
|
17783
17893
|
value: function isSequence(tagInfo) {
|
|
@@ -18742,6 +18852,22 @@
|
|
|
18742
18852
|
DimensionDescriptionLabel: "ImagePositionPatient"
|
|
18743
18853
|
}];
|
|
18744
18854
|
}
|
|
18855
|
+
|
|
18856
|
+
/**
|
|
18857
|
+
* Fills in the functional groups of a multiframe dataset.
|
|
18858
|
+
*
|
|
18859
|
+
* A missing or empty SharedFunctionalGroupsSequence is built from the
|
|
18860
|
+
* top-level image plane attributes; a one-item array is used as its item.
|
|
18861
|
+
* The shared item gets the list accessors (addAccessors), so both
|
|
18862
|
+
* `SharedFunctionalGroupsSequence.X` and `SharedFunctionalGroupsSequence[0].X`
|
|
18863
|
+
* work.
|
|
18864
|
+
* The PerFrameFunctionalGroupsSequence is filled up to the declared
|
|
18865
|
+
* NumberOfFrames with items at the top-level position, existing items keep
|
|
18866
|
+
* their content, and each item without a FrameContentSequence gets one.
|
|
18867
|
+
* Added items share the position but get increasing InStackPositionNumber.
|
|
18868
|
+
* Items beyond NumberOfFrames are kept unchanged; a null item there is
|
|
18869
|
+
* skipped and does not throw.
|
|
18870
|
+
*/
|
|
18745
18871
|
}, {
|
|
18746
18872
|
key: "normalizeMultiframe",
|
|
18747
18873
|
value: function normalizeMultiframe() {
|
|
@@ -18765,6 +18891,10 @@
|
|
|
18765
18891
|
if (!ds.PresentationLUTShape) {
|
|
18766
18892
|
ds.PresentationLUTShape = "IDENTITY";
|
|
18767
18893
|
}
|
|
18894
|
+
if (Array.isArray(ds.SharedFunctionalGroupsSequence)) {
|
|
18895
|
+
// The shared group has one item; an empty array counts as missing
|
|
18896
|
+
ds.SharedFunctionalGroupsSequence = ds.SharedFunctionalGroupsSequence[0];
|
|
18897
|
+
}
|
|
18768
18898
|
if (!ds.SharedFunctionalGroupsSequence) {
|
|
18769
18899
|
log.warn("Missing SharedFunctionalGroupsSequence; using the top-level image plane attributes");
|
|
18770
18900
|
ds.SharedFunctionalGroupsSequence = ImageNormalizer.sharedImagePlaneGroups(ds, {
|
|
@@ -18772,6 +18902,7 @@
|
|
|
18772
18902
|
SpacingBetweenSlices: ds.SpacingBetweenSlices
|
|
18773
18903
|
});
|
|
18774
18904
|
}
|
|
18905
|
+
ds.SharedFunctionalGroupsSequence = addAccessors(ds.SharedFunctionalGroupsSequence);
|
|
18775
18906
|
|
|
18776
18907
|
// TODO: special case!
|
|
18777
18908
|
if (ds.BodyPartExamined === "PROSTATE") {
|
|
@@ -18791,23 +18922,20 @@
|
|
|
18791
18922
|
RescaleSlope: rescaleSlope,
|
|
18792
18923
|
RescaleType: "US"
|
|
18793
18924
|
};
|
|
18794
|
-
var frameCount = this.datasets.length;
|
|
18795
|
-
|
|
18796
|
-
|
|
18797
|
-
|
|
18798
|
-
ds.PerFrameFunctionalGroupsSequence
|
|
18799
|
-
length: frameCount
|
|
18800
|
-
}, function () {
|
|
18801
|
-
return ImageNormalizer.planePositionGroup(ds);
|
|
18802
|
-
});
|
|
18803
|
-
} else if (!Array.isArray(ds.PerFrameFunctionalGroupsSequence)) {
|
|
18804
|
-
ds.PerFrameFunctionalGroupsSequence = [ds.PerFrameFunctionalGroupsSequence];
|
|
18925
|
+
var frameCount = Math.max(this.datasets.length, Number(ds.NumberOfFrames) || 0);
|
|
18926
|
+
var perFrame = ds.PerFrameFunctionalGroupsSequence || [];
|
|
18927
|
+
ds.PerFrameFunctionalGroupsSequence = Array.isArray(perFrame) ? perFrame : [perFrame];
|
|
18928
|
+
while (ds.PerFrameFunctionalGroupsSequence.length < frameCount) {
|
|
18929
|
+
ds.PerFrameFunctionalGroupsSequence.push(ImageNormalizer.planePositionGroup(ds));
|
|
18805
18930
|
}
|
|
18806
18931
|
for (var frameNumber = 1; frameNumber <= frameCount; frameNumber++) {
|
|
18807
18932
|
var _ds$PerFrameFunctiona, _ref;
|
|
18933
|
+
var item = (_ds$PerFrameFunctiona = ds.PerFrameFunctionalGroupsSequence)[_ref = frameNumber - 1] || (_ds$PerFrameFunctiona[_ref] = {});
|
|
18934
|
+
if (item.FrameContentSequence) {
|
|
18935
|
+
continue;
|
|
18936
|
+
}
|
|
18808
18937
|
var dataset = this.datasets[frameNumber - 1] || {};
|
|
18809
|
-
|
|
18810
|
-
ds.PerFrameFunctionalGroupsSequence[frameNumber - 1].FrameContentSequence = {
|
|
18938
|
+
item.FrameContentSequence = {
|
|
18811
18939
|
FrameAcquisitionDuration: 0,
|
|
18812
18940
|
StackID: 1,
|
|
18813
18941
|
InStackPositionNumber: frameNumber,
|
|
@@ -18815,9 +18943,8 @@
|
|
|
18815
18943
|
};
|
|
18816
18944
|
var frameTime = dataset.AcquisitionDate + dataset.AcquisitionTime;
|
|
18817
18945
|
if (!isNaN(frameTime)) {
|
|
18818
|
-
|
|
18819
|
-
|
|
18820
|
-
frameContentSequence.FrameReferenceDateTime = frameTime;
|
|
18946
|
+
item.FrameContentSequence.FrameAcquisitionDateTime = frameTime;
|
|
18947
|
+
item.FrameContentSequence.FrameReferenceDateTime = frameTime;
|
|
18821
18948
|
}
|
|
18822
18949
|
}
|
|
18823
18950
|
|
|
@@ -18845,7 +18972,7 @@
|
|
|
18845
18972
|
count: 0
|
|
18846
18973
|
};
|
|
18847
18974
|
ds.PerFrameFunctionalGroupsSequence.forEach(function (functionalGroup) {
|
|
18848
|
-
if (functionalGroup.FrameVOILUT) {
|
|
18975
|
+
if (functionalGroup !== null && functionalGroup !== void 0 && functionalGroup.FrameVOILUT) {
|
|
18849
18976
|
var wc = functionalGroup.FrameVOILUTSequence.WindowCenter;
|
|
18850
18977
|
var ww = functionalGroup.FrameVOILUTSequence.WindowWidth;
|
|
18851
18978
|
if (functionalGroup.FrameVOILUTSequence && wc && ww) {
|
|
@@ -18919,9 +19046,11 @@
|
|
|
18919
19046
|
}, {
|
|
18920
19047
|
key: "planePositionGroup",
|
|
18921
19048
|
value: function planePositionGroup(dataset) {
|
|
19049
|
+
var position = dataset.ImagePositionPatient;
|
|
18922
19050
|
return {
|
|
18923
19051
|
PlanePositionSequence: {
|
|
18924
|
-
|
|
19052
|
+
// A copy, so that no two frames share one array
|
|
19053
|
+
ImagePositionPatient: Array.isArray(position) ? position.slice() : position
|
|
18925
19054
|
}
|
|
18926
19055
|
};
|
|
18927
19056
|
}
|