dcmjs 0.24.1 → 0.24.2
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.es.js +94 -47
- package/build/dcmjs.es.js.map +1 -1
- package/build/dcmjs.js +94 -47
- package/build/dcmjs.js.map +1 -1
- package/package.json +1 -1
- package/test/data-options.test.js +237 -0
- package/test/data.test.js +22 -50
- package/test/untilTag.test.js +0 -44
package/build/dcmjs.es.js
CHANGED
|
@@ -1176,7 +1176,8 @@ var ReadBufferStream = /*#__PURE__*/function (_BufferStream) {
|
|
|
1176
1176
|
|
|
1177
1177
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
1178
1178
|
start: null,
|
|
1179
|
-
stop: null
|
|
1179
|
+
stop: null,
|
|
1180
|
+
noCopy: false
|
|
1180
1181
|
};
|
|
1181
1182
|
|
|
1182
1183
|
_classCallCheck(this, ReadBufferStream);
|
|
@@ -1184,12 +1185,27 @@ var ReadBufferStream = /*#__PURE__*/function (_BufferStream) {
|
|
|
1184
1185
|
_this = _super.call(this, buffer, littleEndian);
|
|
1185
1186
|
_this.offset = options.start || 0;
|
|
1186
1187
|
_this.size = options.stop || _this.buffer.byteLength;
|
|
1188
|
+
_this.noCopy = options.noCopy;
|
|
1187
1189
|
_this.startOffset = _this.offset;
|
|
1188
1190
|
_this.endOffset = _this.size;
|
|
1189
1191
|
return _this;
|
|
1190
1192
|
}
|
|
1191
1193
|
|
|
1192
1194
|
_createClass(ReadBufferStream, [{
|
|
1195
|
+
key: "getBuffer",
|
|
1196
|
+
value: function getBuffer(start, end) {
|
|
1197
|
+
if (this.noCopy) {
|
|
1198
|
+
return new Uint8Array(this.buffer, start, end - start);
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
if (!start && !end) {
|
|
1202
|
+
start = 0;
|
|
1203
|
+
end = this.size;
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
return this.buffer.slice(start, end);
|
|
1207
|
+
}
|
|
1208
|
+
}, {
|
|
1193
1209
|
key: "readString",
|
|
1194
1210
|
value: function readString(length) {
|
|
1195
1211
|
var chars = [];
|
|
@@ -1311,25 +1327,10 @@ var WriteBufferStream = /*#__PURE__*/function (_BufferStream2) {
|
|
|
1311
1327
|
return _createClass(WriteBufferStream);
|
|
1312
1328
|
}(BufferStream);
|
|
1313
1329
|
|
|
1314
|
-
function paddingLeft(paddingValue, string) {
|
|
1315
|
-
return String(paddingValue + string).slice(-paddingValue.length);
|
|
1316
|
-
}
|
|
1317
|
-
|
|
1318
1330
|
function rtrim(str) {
|
|
1319
1331
|
return str.replace(/\s*$/g, "");
|
|
1320
1332
|
}
|
|
1321
1333
|
|
|
1322
|
-
function tagFromNumbers(group, element) {
|
|
1323
|
-
return new Tag((group << 16 | element) >>> 0);
|
|
1324
|
-
}
|
|
1325
|
-
|
|
1326
|
-
function readTag(stream) {
|
|
1327
|
-
var group = stream.readUint16(),
|
|
1328
|
-
element = stream.readUint16();
|
|
1329
|
-
var tag = tagFromNumbers(group, element);
|
|
1330
|
-
return tag;
|
|
1331
|
-
}
|
|
1332
|
-
|
|
1333
1334
|
function toWindows(inputArray, size) {
|
|
1334
1335
|
return Array.from({
|
|
1335
1336
|
length: inputArray.length - (size - 1)
|
|
@@ -1716,7 +1717,8 @@ var BinaryRepresentation = /*#__PURE__*/function (_ValueRepresentation2) {
|
|
|
1716
1717
|
|
|
1717
1718
|
var rangeStream = new ReadBufferStream(stream.buffer, stream.isLittleEndian, {
|
|
1718
1719
|
start: start,
|
|
1719
|
-
stop: stop
|
|
1720
|
+
stop: stop,
|
|
1721
|
+
noCopy: stream.noCopy
|
|
1720
1722
|
});
|
|
1721
1723
|
var frameSize = 0;
|
|
1722
1724
|
|
|
@@ -1736,16 +1738,21 @@ var BinaryRepresentation = /*#__PURE__*/function (_ValueRepresentation2) {
|
|
|
1736
1738
|
|
|
1737
1739
|
if (fragments.length === 1) {
|
|
1738
1740
|
return fragments[0];
|
|
1739
|
-
}
|
|
1740
|
-
|
|
1741
|
+
}
|
|
1741
1742
|
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1743
|
+
if (rangeStream.noCopy) {
|
|
1744
|
+
// return the fragments for downstream application to process
|
|
1745
|
+
return fragments;
|
|
1746
|
+
} else {
|
|
1747
|
+
// Allocate a final ArrayBuffer and concat all buffers into it
|
|
1748
|
+
var mergedFrame = new ArrayBuffer(frameSize);
|
|
1749
|
+
var u8Data = new Uint8Array(mergedFrame);
|
|
1750
|
+
fragments.reduce(function (offset, buffer) {
|
|
1751
|
+
u8Data.set(new Uint8Array(buffer), offset);
|
|
1752
|
+
return offset + buffer.byteLength;
|
|
1753
|
+
}, 0);
|
|
1754
|
+
return mergedFrame;
|
|
1755
|
+
}
|
|
1749
1756
|
});
|
|
1750
1757
|
} // If no offset table, loop through remainder of stream looking for termination tag
|
|
1751
1758
|
else {
|
|
@@ -1878,9 +1885,7 @@ var AttributeTag = /*#__PURE__*/function (_ValueRepresentation3) {
|
|
|
1878
1885
|
_createClass(AttributeTag, [{
|
|
1879
1886
|
key: "readBytes",
|
|
1880
1887
|
value: function readBytes(stream) {
|
|
1881
|
-
|
|
1882
|
-
element = stream.readUint16();
|
|
1883
|
-
return tagFromNumbers(group, element).value;
|
|
1888
|
+
return Tag.readTag(stream).value;
|
|
1884
1889
|
}
|
|
1885
1890
|
}, {
|
|
1886
1891
|
key: "writeBytes",
|
|
@@ -2317,7 +2322,7 @@ var SequenceOfItems = /*#__PURE__*/function (_ValueRepresentation7) {
|
|
|
2317
2322
|
/* eslint-disable-next-line no-constant-condition */
|
|
2318
2323
|
|
|
2319
2324
|
while (true) {
|
|
2320
|
-
var tag = readTag(stream),
|
|
2325
|
+
var tag = Tag.readTag(stream),
|
|
2321
2326
|
length = null;
|
|
2322
2327
|
read += 4;
|
|
2323
2328
|
|
|
@@ -2388,7 +2393,9 @@ var SequenceOfItems = /*#__PURE__*/function (_ValueRepresentation7) {
|
|
|
2388
2393
|
|
|
2389
2394
|
read += toRead;
|
|
2390
2395
|
if (undef) stream.increment(8);
|
|
2391
|
-
|
|
2396
|
+
|
|
2397
|
+
var items = DicomMessage._read(itemStream, syntax);
|
|
2398
|
+
|
|
2392
2399
|
elements.push(items);
|
|
2393
2400
|
}
|
|
2394
2401
|
|
|
@@ -2820,6 +2827,10 @@ var OtherFloatString = /*#__PURE__*/function (_BinaryRepresentation5) {
|
|
|
2820
2827
|
var IMPLICIT_LITTLE_ENDIAN = "1.2.840.10008.1.2";
|
|
2821
2828
|
var EXPLICIT_LITTLE_ENDIAN = "1.2.840.10008.1.2.1";
|
|
2822
2829
|
|
|
2830
|
+
function paddingLeft(paddingValue, string) {
|
|
2831
|
+
return String(paddingValue + string).slice(-paddingValue.length);
|
|
2832
|
+
}
|
|
2833
|
+
|
|
2823
2834
|
var Tag = /*#__PURE__*/function () {
|
|
2824
2835
|
function Tag(value) {
|
|
2825
2836
|
_classCallCheck(this, Tag);
|
|
@@ -3389,11 +3400,40 @@ var DicomMessage = /*#__PURE__*/function () {
|
|
|
3389
3400
|
value: function read(bufferStream, syntax, ignoreErrors) {
|
|
3390
3401
|
var untilTag = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
3391
3402
|
var includeUntilTagValue = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
3403
|
+
console.warn("DicomMessage.read to be deprecated after dcmjs 0.24.x");
|
|
3404
|
+
return this._read(bufferStream, syntax, {
|
|
3405
|
+
ignoreErrors: ignoreErrors,
|
|
3406
|
+
untilTag: untilTag,
|
|
3407
|
+
includeUntilTagValue: includeUntilTagValue
|
|
3408
|
+
});
|
|
3409
|
+
}
|
|
3410
|
+
}, {
|
|
3411
|
+
key: "readTag",
|
|
3412
|
+
value: function readTag(bufferStream, syntax) {
|
|
3413
|
+
var untilTag = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
3414
|
+
var includeUntilTagValue = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
3415
|
+
console.warn("DicomMessage.readTag to be deprecated after dcmjs 0.24.x");
|
|
3416
|
+
return this._readTag(bufferStream, syntax, {
|
|
3417
|
+
untilTag: untilTag,
|
|
3418
|
+
includeUntilTagValue: includeUntilTagValue
|
|
3419
|
+
});
|
|
3420
|
+
}
|
|
3421
|
+
}, {
|
|
3422
|
+
key: "_read",
|
|
3423
|
+
value: function _read(bufferStream, syntax) {
|
|
3424
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
3425
|
+
ignoreErrors: false,
|
|
3426
|
+
untilTag: null,
|
|
3427
|
+
includeUntilTagValue: false
|
|
3428
|
+
};
|
|
3429
|
+
var ignoreErrors = options.ignoreErrors,
|
|
3430
|
+
untilTag = options.untilTag;
|
|
3392
3431
|
var dict = {};
|
|
3393
3432
|
|
|
3394
3433
|
try {
|
|
3395
3434
|
while (!bufferStream.end()) {
|
|
3396
|
-
var readInfo = DicomMessage.
|
|
3435
|
+
var readInfo = DicomMessage._readTag(bufferStream, syntax, options);
|
|
3436
|
+
|
|
3397
3437
|
var cleanTagString = readInfo.tag.toCleanString();
|
|
3398
3438
|
dict[cleanTagString] = {
|
|
3399
3439
|
vr: readInfo.vr.type,
|
|
@@ -3435,12 +3475,12 @@ var DicomMessage = /*#__PURE__*/function () {
|
|
|
3435
3475
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
3436
3476
|
ignoreErrors: false,
|
|
3437
3477
|
untilTag: null,
|
|
3438
|
-
includeUntilTagValue: false
|
|
3478
|
+
includeUntilTagValue: false,
|
|
3479
|
+
noCopy: false
|
|
3439
3480
|
};
|
|
3440
|
-
var
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
var stream = new ReadBufferStream(buffer),
|
|
3481
|
+
var stream = new ReadBufferStream(buffer, null, {
|
|
3482
|
+
noCopy: options.noCopy
|
|
3483
|
+
}),
|
|
3444
3484
|
useSyntax = EXPLICIT_LITTLE_ENDIAN$1;
|
|
3445
3485
|
stream.reset();
|
|
3446
3486
|
stream.increment(128);
|
|
@@ -3449,15 +3489,20 @@ var DicomMessage = /*#__PURE__*/function () {
|
|
|
3449
3489
|
throw new Error("Invalid a dicom file");
|
|
3450
3490
|
}
|
|
3451
3491
|
|
|
3452
|
-
var el = DicomMessage.
|
|
3492
|
+
var el = DicomMessage._readTag(stream, useSyntax),
|
|
3453
3493
|
metaLength = el.values[0]; //read header buffer
|
|
3454
3494
|
|
|
3495
|
+
|
|
3455
3496
|
var metaStream = stream.more(metaLength);
|
|
3456
|
-
|
|
3497
|
+
|
|
3498
|
+
var metaHeader = DicomMessage._read(metaStream, useSyntax, options); //get the syntax
|
|
3499
|
+
|
|
3457
3500
|
|
|
3458
3501
|
var mainSyntax = metaHeader["00020010"].Value[0];
|
|
3459
3502
|
mainSyntax = DicomMessage._normalizeSyntax(mainSyntax);
|
|
3460
|
-
|
|
3503
|
+
|
|
3504
|
+
var objects = DicomMessage._read(stream, mainSyntax, options);
|
|
3505
|
+
|
|
3461
3506
|
var dicomDict = new DicomDict(metaHeader);
|
|
3462
3507
|
dicomDict.dict = objects;
|
|
3463
3508
|
return dicomDict;
|
|
@@ -3483,17 +3528,19 @@ var DicomMessage = /*#__PURE__*/function () {
|
|
|
3483
3528
|
return written;
|
|
3484
3529
|
}
|
|
3485
3530
|
}, {
|
|
3486
|
-
key: "
|
|
3487
|
-
value: function
|
|
3488
|
-
var
|
|
3489
|
-
|
|
3531
|
+
key: "_readTag",
|
|
3532
|
+
value: function _readTag(stream, syntax) {
|
|
3533
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
3534
|
+
untilTag: null,
|
|
3535
|
+
includeUntilTagValue: false
|
|
3536
|
+
};
|
|
3537
|
+
var untilTag = options.untilTag,
|
|
3538
|
+
includeUntilTagValue = options.includeUntilTagValue;
|
|
3490
3539
|
var implicit = syntax == IMPLICIT_LITTLE_ENDIAN$1 ? true : false,
|
|
3491
3540
|
isLittleEndian = syntax == IMPLICIT_LITTLE_ENDIAN$1 || syntax == EXPLICIT_LITTLE_ENDIAN$1 ? true : false;
|
|
3492
3541
|
var oldEndian = stream.isLittleEndian;
|
|
3493
3542
|
stream.setEndian(isLittleEndian);
|
|
3494
|
-
var
|
|
3495
|
-
element = stream.readUint16(),
|
|
3496
|
-
tag = tagFromNumbers(group, element);
|
|
3543
|
+
var tag = Tag.readTag(stream);
|
|
3497
3544
|
|
|
3498
3545
|
if (untilTag === tag.toCleanString() && untilTag !== null) {
|
|
3499
3546
|
if (!includeUntilTagValue) {
|