dcmjs 0.53.1 → 0.53.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 +230 -548
- package/build/dcmjs.es.js.map +1 -1
- package/build/dcmjs.js +69 -20
- package/build/dcmjs.js.map +1 -1
- package/build/dcmjs.min.js +1 -1
- package/build/dcmjs.min.js.map +1 -1
- package/package.json +1 -1
package/build/dcmjs.js
CHANGED
|
@@ -10890,6 +10890,8 @@
|
|
|
10890
10890
|
if (undef) stream.increment(8);
|
|
10891
10891
|
var items = DicomMessage$3._read(itemStream, syntax);
|
|
10892
10892
|
elements.push(items);
|
|
10893
|
+
} else {
|
|
10894
|
+
elements.push({});
|
|
10893
10895
|
}
|
|
10894
10896
|
if (!undefLength && read == sqlength) {
|
|
10895
10897
|
break;
|
|
@@ -12863,6 +12865,13 @@
|
|
|
12863
12865
|
return String(paddingValue + string).slice(-paddingValue.length);
|
|
12864
12866
|
}
|
|
12865
12867
|
var DicomMessage$1;
|
|
12868
|
+
|
|
12869
|
+
/** True when every value is an item dataset object, not binary data. */
|
|
12870
|
+
function isItemList(values) {
|
|
12871
|
+
return Array.isArray(values) && values.length > 0 && values.every(function (v) {
|
|
12872
|
+
return v !== null && _typeof(v) === "object" && !(v instanceof ArrayBuffer) && !ArrayBuffer.isView(v);
|
|
12873
|
+
});
|
|
12874
|
+
}
|
|
12866
12875
|
var Tag = /*#__PURE__*/function () {
|
|
12867
12876
|
function Tag(value) {
|
|
12868
12877
|
_classCallCheck(this, Tag);
|
|
@@ -12937,6 +12946,10 @@
|
|
|
12937
12946
|
}, {
|
|
12938
12947
|
key: "write",
|
|
12939
12948
|
value: function write(stream, vrType, values, syntax, writeOptions) {
|
|
12949
|
+
// A UN whose values are item datasets is a sequence: write it as SQ (PS3.5 §6.2.2).
|
|
12950
|
+
if (vrType === "UN" && isItemList(values)) {
|
|
12951
|
+
vrType = "SQ";
|
|
12952
|
+
}
|
|
12940
12953
|
var vr = ValueRepresentation.createByTypeString(vrType);
|
|
12941
12954
|
var useSyntax = DicomMessage$1._normalizeSyntax(syntax);
|
|
12942
12955
|
var implicit = useSyntax === IMPLICIT_LITTLE_ENDIAN;
|
|
@@ -13077,6 +13090,15 @@
|
|
|
13077
13090
|
}
|
|
13078
13091
|
|
|
13079
13092
|
var singleVRs = ["SQ", "OF", "OW", "OB", "UN", "LT"];
|
|
13093
|
+
|
|
13094
|
+
/**
|
|
13095
|
+
* PS3.5 §6.2.2: a UN value that holds a sequence is Implicit VR LE.
|
|
13096
|
+
* dcmjs finds that case by the item tag (FFFE,E000), FE FF 00 E0, at the
|
|
13097
|
+
* start of a defined-length value.
|
|
13098
|
+
*/
|
|
13099
|
+
function isUnSequenceValue(stream, length) {
|
|
13100
|
+
return length >= 8 && length !== UNDEFINED_LENGTH && stream.peekUint8(0) === 0xfe && stream.peekUint8(1) === 0xff && stream.peekUint8(2) === 0x00 && stream.peekUint8(3) === 0xe0;
|
|
13101
|
+
}
|
|
13080
13102
|
var DicomMessage = /*#__PURE__*/function () {
|
|
13081
13103
|
function DicomMessage() {
|
|
13082
13104
|
_classCallCheck(this, DicomMessage);
|
|
@@ -13316,7 +13338,9 @@
|
|
|
13316
13338
|
}
|
|
13317
13339
|
var length = null,
|
|
13318
13340
|
vr = null,
|
|
13319
|
-
vrType
|
|
13341
|
+
vrType,
|
|
13342
|
+
wireVrType = null; // VR as literally encoded in the stream (explicit mode)
|
|
13343
|
+
|
|
13320
13344
|
if (implicit) {
|
|
13321
13345
|
length = stream.readUint32();
|
|
13322
13346
|
var elementData = DicomMessage.lookupTag(tag);
|
|
@@ -13339,6 +13363,8 @@
|
|
|
13339
13363
|
vr = ValueRepresentation.createByTypeString(vrType);
|
|
13340
13364
|
} else {
|
|
13341
13365
|
vrType = stream.readVR();
|
|
13366
|
+
wireVrType = vrType; // remember literal stream VR before any override
|
|
13367
|
+
|
|
13342
13368
|
if (vrType === "UN" && DicomMessage.lookupTag(tag) && DicomMessage.lookupTag(tag).vr) {
|
|
13343
13369
|
vrType = DicomMessage.lookupTag(tag).vr;
|
|
13344
13370
|
vr = ValueRepresentation.parseUnknownVr(vrType);
|
|
@@ -13352,20 +13378,26 @@
|
|
|
13352
13378
|
length = stream.readUint16();
|
|
13353
13379
|
}
|
|
13354
13380
|
}
|
|
13381
|
+
var readSyntax = syntax;
|
|
13382
|
+
if (!implicit && wireVrType === "UN" && isUnSequenceValue(stream, length)) {
|
|
13383
|
+
vrType = "SQ";
|
|
13384
|
+
vr = ValueRepresentation.createByTypeString("SQ");
|
|
13385
|
+
readSyntax = IMPLICIT_LITTLE_ENDIAN;
|
|
13386
|
+
}
|
|
13355
13387
|
var values = [];
|
|
13356
13388
|
var rawValues = [];
|
|
13357
13389
|
if (vr.isBinary() && length > vr.maxLength && !vr.noMultiple) {
|
|
13358
13390
|
var times = length / vr.maxLength,
|
|
13359
13391
|
i = 0;
|
|
13360
13392
|
while (i++ < times) {
|
|
13361
|
-
var _vr$read = vr.read(stream, vr.maxLength,
|
|
13393
|
+
var _vr$read = vr.read(stream, vr.maxLength, readSyntax, options),
|
|
13362
13394
|
rawValue = _vr$read.rawValue,
|
|
13363
13395
|
value = _vr$read.value;
|
|
13364
13396
|
rawValues.push(rawValue);
|
|
13365
13397
|
values.push(value);
|
|
13366
13398
|
}
|
|
13367
13399
|
} else {
|
|
13368
|
-
var _ref = vr.read(stream, length,
|
|
13400
|
+
var _ref = vr.read(stream, length, readSyntax, options) || {},
|
|
13369
13401
|
_rawValue = _ref.rawValue,
|
|
13370
13402
|
_value = _ref.value;
|
|
13371
13403
|
if (!vr.isBinary() && singleVRs.indexOf(vr.type) == -1) {
|
|
@@ -14673,12 +14705,14 @@
|
|
|
14673
14705
|
key: "readSequence",
|
|
14674
14706
|
value: function () {
|
|
14675
14707
|
var _readSequence = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(listener, sqTagInfo, options) {
|
|
14676
|
-
var
|
|
14708
|
+
var _ref, _sqTagInfo$sequenceRe;
|
|
14709
|
+
var length, stream, sequenceReadSyntax, endOffset, tagInfo, tag, itemLength, itemUntilOffset, decoder, _t;
|
|
14677
14710
|
return _regeneratorRuntime().wrap(function (_context6) {
|
|
14678
14711
|
while (1) switch (_context6.prev = _context6.next) {
|
|
14679
14712
|
case 0:
|
|
14680
14713
|
length = sqTagInfo.length;
|
|
14681
|
-
stream = this.stream
|
|
14714
|
+
stream = this.stream;
|
|
14715
|
+
sequenceReadSyntax = (_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;
|
|
14682
14716
|
endOffset = length === UNDEFINED_LENGTH_FIX ? Number.MAX_SAFE_INTEGER : stream.offset + length;
|
|
14683
14717
|
case 1:
|
|
14684
14718
|
_t = stream.offset < endOffset;
|
|
@@ -14696,7 +14730,9 @@
|
|
|
14696
14730
|
break;
|
|
14697
14731
|
}
|
|
14698
14732
|
readLog.debug("readSequence loop", stream.offset, endOffset);
|
|
14699
|
-
tagInfo = this.readTagHeader(
|
|
14733
|
+
tagInfo = this.readTagHeader(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
14734
|
+
readSyntax: sequenceReadSyntax
|
|
14735
|
+
}));
|
|
14700
14736
|
tag = tagInfo.tag;
|
|
14701
14737
|
if (!(tag === TagHex.Item)) {
|
|
14702
14738
|
_context6.next = 5;
|
|
@@ -14716,7 +14752,8 @@
|
|
|
14716
14752
|
decoder = stream.decoder;
|
|
14717
14753
|
_context6.next = 4;
|
|
14718
14754
|
return this.read(listener, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
14719
|
-
untilOffset: itemUntilOffset
|
|
14755
|
+
untilOffset: itemUntilOffset,
|
|
14756
|
+
readSyntax: sequenceReadSyntax
|
|
14720
14757
|
}));
|
|
14721
14758
|
case 4:
|
|
14722
14759
|
stream.setDecoder(decoder);
|
|
@@ -15145,16 +15182,17 @@
|
|
|
15145
15182
|
}, {
|
|
15146
15183
|
key: "readTagHeader",
|
|
15147
15184
|
value: function readTagHeader() {
|
|
15185
|
+
var _options$readSyntax;
|
|
15148
15186
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
15149
15187
|
untilTag: null,
|
|
15150
15188
|
includeUntilTagValue: false
|
|
15151
15189
|
};
|
|
15152
|
-
var stream = this.stream
|
|
15153
|
-
syntax = this.syntax;
|
|
15190
|
+
var stream = this.stream;
|
|
15154
15191
|
var untilTag = options.untilTag,
|
|
15155
15192
|
includeUntilTagValue = options.includeUntilTagValue;
|
|
15156
|
-
var
|
|
15157
|
-
var
|
|
15193
|
+
var effectiveSyntax = (_options$readSyntax = options === null || options === void 0 ? void 0 : options.readSyntax) !== null && _options$readSyntax !== void 0 ? _options$readSyntax : this.syntax;
|
|
15194
|
+
var implicit = effectiveSyntax == IMPLICIT_LITTLE_ENDIAN;
|
|
15195
|
+
var isLittleEndian = effectiveSyntax !== EXPLICIT_BIG_ENDIAN;
|
|
15158
15196
|
stream.setEndian(isLittleEndian);
|
|
15159
15197
|
var tagObj = Tag.readTag(stream);
|
|
15160
15198
|
var tag = tagObj.cleanString;
|
|
@@ -15172,6 +15210,7 @@
|
|
|
15172
15210
|
var length = null;
|
|
15173
15211
|
var vr = null;
|
|
15174
15212
|
var vrType;
|
|
15213
|
+
var wireVrType = null;
|
|
15175
15214
|
var isCommand = tagObj.group() === 0;
|
|
15176
15215
|
if (tagObj.isInstruction()) {
|
|
15177
15216
|
length = stream.readUint32();
|
|
@@ -15203,6 +15242,7 @@
|
|
|
15203
15242
|
} else {
|
|
15204
15243
|
var _DicomMessage$lookupT;
|
|
15205
15244
|
vrType = stream.readVR();
|
|
15245
|
+
wireVrType = vrType;
|
|
15206
15246
|
if (vrType === "UN" && (_DicomMessage$lookupT = DicomMessage.lookupTag(tagObj)) !== null && _DicomMessage$lookupT !== void 0 && _DicomMessage$lookupT.vr) {
|
|
15207
15247
|
vrType = DicomMessage.lookupTag(tagObj).vr;
|
|
15208
15248
|
vr = ValueRepresentation.parseUnknownVr(vrType);
|
|
@@ -15216,11 +15256,16 @@
|
|
|
15216
15256
|
length = stream.readUint16();
|
|
15217
15257
|
}
|
|
15218
15258
|
}
|
|
15259
|
+
var sequenceReadSyntax;
|
|
15260
|
+
if (!implicit && wireVrType === "UN" && isUnSequenceValue(stream, length)) {
|
|
15261
|
+
vr = ValueRepresentation.createByTypeString("SQ");
|
|
15262
|
+
sequenceReadSyntax = IMPLICIT_LITTLE_ENDIAN;
|
|
15263
|
+
}
|
|
15219
15264
|
var punctuatedTag = DicomMetaDictionary.punctuateTag(tag);
|
|
15220
15265
|
var entry = DicomMetaDictionary.dictionary[punctuatedTag];
|
|
15221
15266
|
|
|
15222
15267
|
// Include both the string and object values for vr and tag
|
|
15223
|
-
var header = {
|
|
15268
|
+
var header = _objectSpread2({
|
|
15224
15269
|
vrObj: vr,
|
|
15225
15270
|
vr: vr.type,
|
|
15226
15271
|
tag: tag,
|
|
@@ -15228,7 +15273,9 @@
|
|
|
15228
15273
|
vm: entry === null || entry === void 0 ? void 0 : entry.vm,
|
|
15229
15274
|
name: entry === null || entry === void 0 ? void 0 : entry.name,
|
|
15230
15275
|
length: length === UNDEFINED_LENGTH ? -1 : length
|
|
15231
|
-
}
|
|
15276
|
+
}, sequenceReadSyntax !== undefined && {
|
|
15277
|
+
sequenceReadSyntax: sequenceReadSyntax
|
|
15278
|
+
});
|
|
15232
15279
|
return header;
|
|
15233
15280
|
}
|
|
15234
15281
|
|
|
@@ -15242,12 +15289,14 @@
|
|
|
15242
15289
|
key: "readSingle",
|
|
15243
15290
|
value: (function () {
|
|
15244
15291
|
var _readSingle = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(tagInfo, listener, options) {
|
|
15245
|
-
var
|
|
15292
|
+
var _options$readSyntax2;
|
|
15293
|
+
var length, stream, readSyntax, vr, values, times, i, _vr$read, value, _vr$read2, _value, delimiterChar, _values, _values2, coding, valuesForListener;
|
|
15246
15294
|
return _regeneratorRuntime().wrap(function (_context11) {
|
|
15247
15295
|
while (1) switch (_context11.prev = _context11.next) {
|
|
15248
15296
|
case 0:
|
|
15249
15297
|
length = tagInfo.length;
|
|
15250
|
-
stream = this.stream
|
|
15298
|
+
stream = this.stream;
|
|
15299
|
+
readSyntax = (_options$readSyntax2 = options === null || options === void 0 ? void 0 : options.readSyntax) !== null && _options$readSyntax2 !== void 0 ? _options$readSyntax2 : this.syntax;
|
|
15251
15300
|
_context11.next = 1;
|
|
15252
15301
|
return this.stream.ensureAvailable(length);
|
|
15253
15302
|
case 1:
|
|
@@ -15258,11 +15307,11 @@
|
|
|
15258
15307
|
i = 0;
|
|
15259
15308
|
while (i++ < times) {
|
|
15260
15309
|
readLog.trace("readSingle multi-value loop", i, times);
|
|
15261
|
-
_vr$read = vr.read(stream, vr.maxLength,
|
|
15310
|
+
_vr$read = vr.read(stream, vr.maxLength, readSyntax), value = _vr$read.value;
|
|
15262
15311
|
values.push(value);
|
|
15263
15312
|
}
|
|
15264
15313
|
} else {
|
|
15265
|
-
_value = (_vr$read2 = vr.read(stream, length,
|
|
15314
|
+
_value = (_vr$read2 = vr.read(stream, length, readSyntax)) === null || _vr$read2 === void 0 ? void 0 : _vr$read2.value;
|
|
15266
15315
|
if (!vr.isBinary() && singleVRs.indexOf(vr.type) == -1) {
|
|
15267
15316
|
values = _value;
|
|
15268
15317
|
if (typeof _value === "string") {
|
|
@@ -19037,7 +19086,7 @@
|
|
|
19037
19086
|
var _matrix$shape = _slicedToArray(matrix.shape, 2),
|
|
19038
19087
|
rows = _matrix$shape[0],
|
|
19039
19088
|
cols = _matrix$shape[1];
|
|
19040
|
-
var result = ndarray(new
|
|
19089
|
+
var result = ndarray(new matrix.data.constructor(rows * cols), [rows, cols]);
|
|
19041
19090
|
for (var i = 0; i < rows; i++) {
|
|
19042
19091
|
for (var j = 0; j < cols; j++) {
|
|
19043
19092
|
result.set(i, j, matrix.get(i, cols - 1 - j));
|
|
@@ -19056,7 +19105,7 @@
|
|
|
19056
19105
|
var _matrix$shape2 = _slicedToArray(matrix.shape, 2),
|
|
19057
19106
|
rows = _matrix$shape2[0],
|
|
19058
19107
|
cols = _matrix$shape2[1];
|
|
19059
|
-
var result = ndarray(new
|
|
19108
|
+
var result = ndarray(new matrix.data.constructor(rows * cols), [rows, cols]);
|
|
19060
19109
|
for (var j = 0; j < cols; j++) {
|
|
19061
19110
|
for (var i = 0; i < rows; i++) {
|
|
19062
19111
|
result.set(i, j, matrix.get(rows - 1 - i, j));
|
|
@@ -19075,7 +19124,7 @@
|
|
|
19075
19124
|
var _matrix$shape = _slicedToArray(matrix.shape, 2),
|
|
19076
19125
|
rows = _matrix$shape[0],
|
|
19077
19126
|
cols = _matrix$shape[1];
|
|
19078
|
-
var result = ndarray(new
|
|
19127
|
+
var result = ndarray(new matrix.data.constructor(rows * cols), [cols, rows]);
|
|
19079
19128
|
var resultColsMinus1 = result.shape[1] - 1;
|
|
19080
19129
|
for (var i = 0; i < rows; i++) {
|
|
19081
19130
|
for (var j = 0; j < cols; j++) {
|