@dcmjs-org/dcmjs 1.0.0-beta.19 → 1.0.0-beta.21
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 +200 -62
- 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-DnjtTwFB.js → dcmjs.shared-CMo1hh3U.js} +127 -53
- package/build/dcmjs.shared-CMo1hh3U.js.map +1 -0
- package/build/{dcmjs.shared-L4OH_Ab_.cjs → dcmjs.shared-C_SwQ4fu.cjs} +126 -52
- package/build/dcmjs.shared-C_SwQ4fu.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-DnjtTwFB.js.map +0 -1
- package/build/dcmjs.shared-L4OH_Ab_.cjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { log, ValueRepresentation as ValueRepresentation$1, reservePrivateBlock, findPrivateBlock, writePart10, TagHex, resolveCharsetDecoder, normalizeSyntax, isEncapsulatedSyntax, EXPLICIT_LITTLE_ENDIAN, IMPLICIT_LITTLE_ENDIAN, VALID_VRS, ReadBufferStream, DEFLATED_EXPLICIT_LITTLE_ENDIAN, DeflatedReadBufferStream, writeTagObject, writeDataSet, getTagWriteValues, Tag, UNDEFINED_LENGTH, isUnSequenceValue, singleVRs, DicomMetaDictionary, VM_DELIMITER, UNDEFINED_LENGTH_FIX, EXPLICIT_BIG_ENDIAN, DicomMetadataListener, isVideoTransferSyntax, addAccessors, createInformationFilter, toInt, toFloat, dicomJson, BULKDATA_VRS, DEFAULT_INFORMATION_TAGS, ITEM_DELIMITATION_LENGTH, PADDING_NULL, PADDING_SPACE, PN_COMPONENT_DELIMITER, SEQUENCE_DELIMITATION_VALUE, SEQUENCE_DELIMITER_TAG, SEQUENCE_ITEM_TAG, TAG_NAME_MAP, encodingMapping, unencapsulatedTransferSyntaxes, videoTransferSyntaxUIDs, registerPrivatesModule, lookupPrivateTag, privateBlockKey, frameDataset, definePrivateAliases, setPersonName, setAttribute, setVr, WriteBufferStream } from '@dcmjs-org/core';
|
|
1
|
+
import { log, ValueRepresentation as ValueRepresentation$1, reservePrivateBlock, findPrivateBlock, writePart10, TagHex, resolveCharsetDecoder, normalizeSyntax, isEncapsulatedSyntax, EXPLICIT_LITTLE_ENDIAN, IMPLICIT_LITTLE_ENDIAN, VALID_VRS, ReadBufferStream, DEFLATED_EXPLICIT_LITTLE_ENDIAN, DeflatedReadBufferStream, writeTagObject, writeDataSet, getTagWriteValues, Tag, UNDEFINED_LENGTH, isUnSequenceValue, singleVRs, DicomMetaDictionary, VM_DELIMITER, UNDEFINED_LENGTH_FIX, EXPLICIT_BIG_ENDIAN, DicomMetadataListener, swapBytes, isVideoTransferSyntax, addAccessors, createInformationFilter, toInt, toFloat, dicomJson, BULKDATA_VRS, DEFAULT_INFORMATION_TAGS, ITEM_DELIMITATION_LENGTH, PADDING_NULL, PADDING_SPACE, PN_COMPONENT_DELIMITER, SEQUENCE_DELIMITATION_VALUE, SEQUENCE_DELIMITER_TAG, SEQUENCE_ITEM_TAG, TAG_NAME_MAP, encodingMapping, unencapsulatedTransferSyntaxes, videoTransferSyntaxUIDs, registerPrivatesModule, lookupPrivateTag, privateBlockKey, frameDataset, definePrivateAliases, setPersonName, setAttribute, setVr, WriteBufferStream } from '@dcmjs-org/core';
|
|
2
2
|
|
|
3
3
|
/* eslint no-bitwise: 0 */
|
|
4
4
|
var BitArray = {
|
|
@@ -1606,7 +1606,9 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
1606
1606
|
_classCallCheck(this, AsyncDicomReader);
|
|
1607
1607
|
_defineProperty(this, "syntax", EXPLICIT_LITTLE_ENDIAN);
|
|
1608
1608
|
this.isLittleEndian = options === null || options === void 0 ? void 0 : options.isLittleEndian;
|
|
1609
|
-
//
|
|
1609
|
+
// Number of sequence items being read, 0 at the top level
|
|
1610
|
+
this.sequenceDepth = 0;
|
|
1611
|
+
// Default maxFragmentSize is 128 MB; a Big Endian fragment is at least one word, so it can be larger
|
|
1610
1612
|
this.maxFragmentSize = (_options$maxFragmentS = options === null || options === void 0 ? void 0 : options.maxFragmentSize) !== null && _options$maxFragmentS !== void 0 ? _options$maxFragmentS : 128 * 1024 * 1024;
|
|
1611
1613
|
this.stream = new ReadBufferStream(null, _objectSpread2(_objectSpread2({
|
|
1612
1614
|
clearBuffers: true
|
|
@@ -2067,16 +2069,24 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2067
2069
|
* item boundary and returns control here for the next item. Without that
|
|
2068
2070
|
* offset, read() skips the later Item tags as instructions, and all items
|
|
2069
2071
|
* of a defined-length sequence merge into the first item.
|
|
2072
|
+
*
|
|
2073
|
+
* untilTag and includeUntilTagValue apply to the top-level data set only,
|
|
2074
|
+
* so the items are read without them: an Icon Image Sequence item has its
|
|
2075
|
+
* own Pixel Data, which must not stop a read with untilTag 7FE00010.
|
|
2070
2076
|
*/
|
|
2071
2077
|
}, {
|
|
2072
2078
|
key: "readSequence",
|
|
2073
2079
|
value: (function () {
|
|
2074
2080
|
var _readSequence = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(listener, sqTagInfo, options) {
|
|
2075
2081
|
var _ref, _sqTagInfo$sequenceRe;
|
|
2076
|
-
var length, stream, readSyntax, endOffset, tagInfo, tag, itemLength, itemUntilOffset, decoder, _t;
|
|
2082
|
+
var itemOptions, length, stream, readSyntax, endOffset, tagInfo, tag, itemLength, itemUntilOffset, decoder, _t;
|
|
2077
2083
|
return _regeneratorRuntime().wrap(function (_context6) {
|
|
2078
2084
|
while (1) switch (_context6.prev = _context6.next) {
|
|
2079
2085
|
case 0:
|
|
2086
|
+
itemOptions = _objectSpread2(_objectSpread2({}, options), {}, {
|
|
2087
|
+
untilTag: null,
|
|
2088
|
+
includeUntilTagValue: false
|
|
2089
|
+
});
|
|
2080
2090
|
length = sqTagInfo.length;
|
|
2081
2091
|
stream = this.stream;
|
|
2082
2092
|
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;
|
|
@@ -2093,16 +2103,16 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2093
2103
|
_t = _context6.sent;
|
|
2094
2104
|
case 3:
|
|
2095
2105
|
if (!_t) {
|
|
2096
|
-
_context6.next =
|
|
2106
|
+
_context6.next = 10;
|
|
2097
2107
|
break;
|
|
2098
2108
|
}
|
|
2099
2109
|
readLog.debug("readSequence loop", stream.offset, endOffset);
|
|
2100
|
-
tagInfo = this.readTagHeader(_objectSpread2(_objectSpread2({},
|
|
2110
|
+
tagInfo = this.readTagHeader(_objectSpread2(_objectSpread2({}, itemOptions), {}, {
|
|
2101
2111
|
readSyntax: readSyntax
|
|
2102
2112
|
}));
|
|
2103
2113
|
tag = tagInfo.tag;
|
|
2104
2114
|
if (!(tag === TagHex.Item)) {
|
|
2105
|
-
_context6.next =
|
|
2115
|
+
_context6.next = 7;
|
|
2106
2116
|
break;
|
|
2107
2117
|
}
|
|
2108
2118
|
listener.startObject();
|
|
@@ -2112,38 +2122,59 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2112
2122
|
// item (PS3.5 7.5.3), but the item is read on this stream:
|
|
2113
2123
|
// put back the decoder the item started with.
|
|
2114
2124
|
decoder = stream.decoder;
|
|
2115
|
-
|
|
2116
|
-
|
|
2125
|
+
this.sequenceDepth++;
|
|
2126
|
+
_context6.prev = 4;
|
|
2127
|
+
_context6.next = 5;
|
|
2128
|
+
return this.read(listener, _objectSpread2(_objectSpread2({}, itemOptions), {}, {
|
|
2117
2129
|
untilOffset: itemUntilOffset,
|
|
2118
2130
|
readSyntax: readSyntax
|
|
2119
2131
|
}));
|
|
2120
|
-
case
|
|
2132
|
+
case 5:
|
|
2133
|
+
_context6.prev = 5;
|
|
2134
|
+
this.sequenceDepth--;
|
|
2135
|
+
return _context6.finish(5);
|
|
2136
|
+
case 6:
|
|
2121
2137
|
stream.setDecoder(decoder);
|
|
2122
|
-
_context6.next =
|
|
2138
|
+
_context6.next = 9;
|
|
2123
2139
|
break;
|
|
2124
|
-
case
|
|
2140
|
+
case 7:
|
|
2125
2141
|
if (!(tag === TagHex.SequenceDelimitationEnd)) {
|
|
2126
|
-
_context6.next =
|
|
2142
|
+
_context6.next = 8;
|
|
2127
2143
|
break;
|
|
2128
2144
|
}
|
|
2129
2145
|
return _context6.abrupt("return");
|
|
2130
|
-
case
|
|
2146
|
+
case 8:
|
|
2131
2147
|
console.warn("Unknown tag info", length, tagInfo);
|
|
2132
|
-
throw new Error();
|
|
2133
|
-
case
|
|
2148
|
+
throw new Error("Expected an item or a sequence delimitation item in a sequence, found tag ".concat(tag));
|
|
2149
|
+
case 9:
|
|
2134
2150
|
_context6.next = 1;
|
|
2135
2151
|
break;
|
|
2136
|
-
case
|
|
2152
|
+
case 10:
|
|
2137
2153
|
case "end":
|
|
2138
2154
|
return _context6.stop();
|
|
2139
2155
|
}
|
|
2140
|
-
}, _callee6, this);
|
|
2156
|
+
}, _callee6, this, [[4,, 5, 6]]);
|
|
2141
2157
|
}));
|
|
2142
2158
|
function readSequence(_x3, _x4, _x5) {
|
|
2143
2159
|
return _readSequence.apply(this, arguments);
|
|
2144
2160
|
}
|
|
2145
2161
|
return readSequence;
|
|
2146
|
-
}()
|
|
2162
|
+
}()
|
|
2163
|
+
/**
|
|
2164
|
+
* The number of frames of the Pixel Data being read. NumberOfFrames is
|
|
2165
|
+
* tracked for the top-level data set only, so Pixel Data inside a sequence
|
|
2166
|
+
* item (an Icon Image Sequence item, for example) is a single frame.
|
|
2167
|
+
*/
|
|
2168
|
+
)
|
|
2169
|
+
}, {
|
|
2170
|
+
key: "getNumberOfFrames",
|
|
2171
|
+
value: function getNumberOfFrames() {
|
|
2172
|
+
var _this$listener;
|
|
2173
|
+
if (this.sequenceDepth > 0) {
|
|
2174
|
+
return 1;
|
|
2175
|
+
}
|
|
2176
|
+
return parseInt(((_this$listener = this.listener) === null || _this$listener === void 0 || (_this$listener = _this$listener.information) === null || _this$listener === void 0 ? void 0 : _this$listener.numberOfFrames) || 1);
|
|
2177
|
+
}
|
|
2147
2178
|
}, {
|
|
2148
2179
|
key: "readPixelData",
|
|
2149
2180
|
value: function readPixelData(tagInfo) {
|
|
@@ -2156,16 +2187,28 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2156
2187
|
/**
|
|
2157
2188
|
* Emits one or more listener.value() calls for a fragment, splitting if needed.
|
|
2158
2189
|
* This does NOT start/pop any array contexts; callers control the surrounding structure.
|
|
2190
|
+
* In Explicit VR Big Endian, each fragment holds whole words of wordWidth
|
|
2191
|
+
* bytes, swapped to little endian.
|
|
2159
2192
|
*/
|
|
2160
2193
|
}, {
|
|
2161
2194
|
key: "_emitSplitValues",
|
|
2162
2195
|
value: (function () {
|
|
2163
2196
|
var _emitSplitValues2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(length) {
|
|
2164
2197
|
var _listener$awaitDrain;
|
|
2165
|
-
var
|
|
2198
|
+
var wordWidth,
|
|
2199
|
+
stream,
|
|
2200
|
+
listener,
|
|
2201
|
+
maxFragmentSize,
|
|
2202
|
+
swap,
|
|
2203
|
+
fragmentSize,
|
|
2204
|
+
offset,
|
|
2205
|
+
chunkSize,
|
|
2206
|
+
buffer,
|
|
2207
|
+
_args7 = arguments;
|
|
2166
2208
|
return _regeneratorRuntime().wrap(function (_context7) {
|
|
2167
2209
|
while (1) switch (_context7.prev = _context7.next) {
|
|
2168
2210
|
case 0:
|
|
2211
|
+
wordWidth = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : 1;
|
|
2169
2212
|
stream = this.stream, listener = this.listener;
|
|
2170
2213
|
_context7.next = 1;
|
|
2171
2214
|
return (_listener$awaitDrain = listener.awaitDrain) === null || _listener$awaitDrain === void 0 ? void 0 : _listener$awaitDrain.call(listener);
|
|
@@ -2177,6 +2220,8 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2177
2220
|
}
|
|
2178
2221
|
throw new Error("maxFragmentSize must be a positive number, got ".concat(maxFragmentSize));
|
|
2179
2222
|
case 2:
|
|
2223
|
+
swap = this.syntax === EXPLICIT_BIG_ENDIAN && wordWidth > 1;
|
|
2224
|
+
fragmentSize = swap ? Math.max(wordWidth, maxFragmentSize - maxFragmentSize % wordWidth) : maxFragmentSize;
|
|
2180
2225
|
offset = 0;
|
|
2181
2226
|
case 3:
|
|
2182
2227
|
if (!(offset < length)) {
|
|
@@ -2184,11 +2229,14 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2184
2229
|
break;
|
|
2185
2230
|
}
|
|
2186
2231
|
readLog.trace("_emitSplitValues loop", offset, length);
|
|
2187
|
-
chunkSize = Math.min(
|
|
2232
|
+
chunkSize = Math.min(fragmentSize, length - offset);
|
|
2188
2233
|
_context7.next = 4;
|
|
2189
2234
|
return stream.ensureAvailable(chunkSize);
|
|
2190
2235
|
case 4:
|
|
2191
2236
|
buffer = stream.readArrayBuffer(chunkSize);
|
|
2237
|
+
if (swap) {
|
|
2238
|
+
swapBytes(buffer, wordWidth);
|
|
2239
|
+
}
|
|
2192
2240
|
listener.value(buffer);
|
|
2193
2241
|
offset += chunkSize;
|
|
2194
2242
|
stream.consume();
|
|
@@ -2213,8 +2261,7 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2213
2261
|
key: "readCompressed",
|
|
2214
2262
|
value: (function () {
|
|
2215
2263
|
var _readCompressed = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(_tagInfo) {
|
|
2216
|
-
var
|
|
2217
|
-
var stream, listener, transferSyntaxUid, isVideo, numberOfFrames, isSingleFrame, offsets, singleArray, startOffset, frameNumber, lastFrame, frameTag, length;
|
|
2264
|
+
var stream, listener, transferSyntaxUid, isVideo, isSingleFrame, offsets, singleArray, startOffset, frameNumber, lastFrame, frameTag, length;
|
|
2218
2265
|
return _regeneratorRuntime().wrap(function (_context8) {
|
|
2219
2266
|
while (1) switch (_context8.prev = _context8.next) {
|
|
2220
2267
|
case 0:
|
|
@@ -2225,8 +2272,7 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2225
2272
|
case 1:
|
|
2226
2273
|
// Check if this is a video transfer syntax
|
|
2227
2274
|
isVideo = isVideoTransferSyntax(transferSyntaxUid); // Check number of frames - only use video logic for single frame (or undefined)
|
|
2228
|
-
|
|
2229
|
-
isSingleFrame = !numberOfFrames || parseInt(numberOfFrames) <= 1;
|
|
2275
|
+
isSingleFrame = this.getNumberOfFrames() <= 1;
|
|
2230
2276
|
_context8.next = 2;
|
|
2231
2277
|
return this.readOffsets();
|
|
2232
2278
|
case 2:
|
|
@@ -2340,23 +2386,23 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2340
2386
|
key: "readUncompressed",
|
|
2341
2387
|
value: (function () {
|
|
2342
2388
|
var _readUncompressed = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee0(tagInfo) {
|
|
2343
|
-
var _listener$information2;
|
|
2344
|
-
var length, listener, numberOfFrames, frameLength, _listener$information3, _listener$information4, _listener$information5, _listener$information6, rows, cols, samplesPerPixel, bitsAllocated, bitsPerFrame, frameNumber;
|
|
2389
|
+
var length, listener, wordWidth, numberOfFrames, frameLength, _listener$information, _listener$information2, _listener$information3, _listener$information4, rows, cols, samplesPerPixel, bitsAllocated, bitsPerFrame, allPixelData, offset, frameNumber;
|
|
2345
2390
|
return _regeneratorRuntime().wrap(function (_context0) {
|
|
2346
2391
|
while (1) switch (_context0.prev = _context0.next) {
|
|
2347
2392
|
case 0:
|
|
2348
2393
|
length = tagInfo.length;
|
|
2349
2394
|
listener = this.listener;
|
|
2350
|
-
|
|
2395
|
+
wordWidth = this.wordWidth(tagInfo);
|
|
2396
|
+
numberOfFrames = this.getNumberOfFrames();
|
|
2351
2397
|
frameLength = Math.floor(length / numberOfFrames);
|
|
2352
2398
|
if (!(numberOfFrames > 1)) {
|
|
2353
2399
|
_context0.next = 4;
|
|
2354
2400
|
break;
|
|
2355
2401
|
}
|
|
2356
|
-
rows = (_listener$
|
|
2357
|
-
cols = (_listener$
|
|
2358
|
-
samplesPerPixel = (_listener$
|
|
2359
|
-
bitsAllocated = (_listener$
|
|
2402
|
+
rows = (_listener$information = listener.information) === null || _listener$information === void 0 ? void 0 : _listener$information.rows;
|
|
2403
|
+
cols = (_listener$information2 = listener.information) === null || _listener$information2 === void 0 ? void 0 : _listener$information2.columns;
|
|
2404
|
+
samplesPerPixel = (_listener$information3 = listener.information) === null || _listener$information3 === void 0 ? void 0 : _listener$information3.samplesPerPixel;
|
|
2405
|
+
bitsAllocated = (_listener$information4 = listener.information) === null || _listener$information4 === void 0 ? void 0 : _listener$information4.bitsAllocated;
|
|
2360
2406
|
bitsPerFrame = rows * cols * samplesPerPixel * bitsAllocated;
|
|
2361
2407
|
if (!(bitsPerFrame % 8 !== 0)) {
|
|
2362
2408
|
_context0.next = 3;
|
|
@@ -2379,24 +2425,41 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2379
2425
|
}
|
|
2380
2426
|
throw new Error("Invalid frame length: ".concat(length, " for ").concat(numberOfFrames, " frames"));
|
|
2381
2427
|
case 4:
|
|
2382
|
-
|
|
2428
|
+
if (!(this.syntax === EXPLICIT_BIG_ENDIAN && frameLength % wordWidth !== 0)) {
|
|
2429
|
+
_context0.next = 6;
|
|
2430
|
+
break;
|
|
2431
|
+
}
|
|
2432
|
+
_context0.next = 5;
|
|
2433
|
+
return this.stream.ensureAvailable(length);
|
|
2383
2434
|
case 5:
|
|
2435
|
+
allPixelData = this.stream.readArrayBuffer(length);
|
|
2436
|
+
this.stream.consume();
|
|
2437
|
+
swapBytes(allPixelData, wordWidth);
|
|
2438
|
+
for (offset = 0; offset < length; offset += frameLength) {
|
|
2439
|
+
listener.startObject([]);
|
|
2440
|
+
listener.value(allPixelData.slice(offset, offset + frameLength));
|
|
2441
|
+
listener.pop();
|
|
2442
|
+
}
|
|
2443
|
+
return _context0.abrupt("return");
|
|
2444
|
+
case 6:
|
|
2445
|
+
frameNumber = 0;
|
|
2446
|
+
case 7:
|
|
2384
2447
|
if (!(frameNumber < numberOfFrames)) {
|
|
2385
|
-
_context0.next =
|
|
2448
|
+
_context0.next = 10;
|
|
2386
2449
|
break;
|
|
2387
2450
|
}
|
|
2388
2451
|
readLog.trace("readUncompressed loop", frameNumber, numberOfFrames);
|
|
2389
2452
|
listener.startObject([]);
|
|
2390
|
-
_context0.next =
|
|
2391
|
-
return this._emitSplitValues(frameLength);
|
|
2392
|
-
case
|
|
2453
|
+
_context0.next = 8;
|
|
2454
|
+
return this._emitSplitValues(frameLength, wordWidth);
|
|
2455
|
+
case 8:
|
|
2393
2456
|
listener.pop();
|
|
2394
2457
|
// console.log(stream.getBufferMemoryInfo());
|
|
2395
|
-
case
|
|
2458
|
+
case 9:
|
|
2396
2459
|
frameNumber++;
|
|
2397
|
-
_context0.next =
|
|
2460
|
+
_context0.next = 7;
|
|
2398
2461
|
break;
|
|
2399
|
-
case
|
|
2462
|
+
case 10:
|
|
2400
2463
|
case "end":
|
|
2401
2464
|
return _context0.stop();
|
|
2402
2465
|
}
|
|
@@ -2425,18 +2488,18 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2425
2488
|
key: "readUncompressedBitFrame",
|
|
2426
2489
|
value: (function () {
|
|
2427
2490
|
var _readUncompressedBitFrame = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee1(tagInfo) {
|
|
2428
|
-
var _listener$
|
|
2491
|
+
var _listener$information5, _listener$information6, _listener$information7, _listener$information8;
|
|
2429
2492
|
var length, listener, stream, numberOfFrames, rows, cols, samplesPerPixel, bitsAllocated, bitsPerFrame, bytesPerFrame, totalBits, totalBytes, allPixelData, frameNumber, bitOffset, frameBuffer, frameView, sourceView, bitIndex, globalBitIndex, sourceByteIndex, sourceBitIndex, targetByteIndex, targetBitIndex, sourceByte, bitValue;
|
|
2430
2493
|
return _regeneratorRuntime().wrap(function (_context1) {
|
|
2431
2494
|
while (1) switch (_context1.prev = _context1.next) {
|
|
2432
2495
|
case 0:
|
|
2433
2496
|
length = tagInfo.length;
|
|
2434
2497
|
listener = this.listener, stream = this.stream;
|
|
2435
|
-
numberOfFrames =
|
|
2436
|
-
rows = (_listener$
|
|
2437
|
-
cols = (_listener$
|
|
2438
|
-
samplesPerPixel = ((_listener$
|
|
2439
|
-
bitsAllocated = (_listener$
|
|
2498
|
+
numberOfFrames = this.getNumberOfFrames();
|
|
2499
|
+
rows = (_listener$information5 = listener.information) === null || _listener$information5 === void 0 ? void 0 : _listener$information5.rows;
|
|
2500
|
+
cols = (_listener$information6 = listener.information) === null || _listener$information6 === void 0 ? void 0 : _listener$information6.columns;
|
|
2501
|
+
samplesPerPixel = ((_listener$information7 = listener.information) === null || _listener$information7 === void 0 ? void 0 : _listener$information7.samplesPerPixel) || 1;
|
|
2502
|
+
bitsAllocated = (_listener$information8 = listener.information) === null || _listener$information8 === void 0 ? void 0 : _listener$information8.bitsAllocated;
|
|
2440
2503
|
if (!(!rows || !cols || !bitsAllocated)) {
|
|
2441
2504
|
_context1.next = 1;
|
|
2442
2505
|
break;
|
|
@@ -2464,6 +2527,10 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2464
2527
|
case 4:
|
|
2465
2528
|
allPixelData = stream.readArrayBuffer(totalBytes);
|
|
2466
2529
|
stream.consume();
|
|
2530
|
+
if (this.syntax === EXPLICIT_BIG_ENDIAN) {
|
|
2531
|
+
// the bits of OW data are packed in big endian words
|
|
2532
|
+
swapBytes(allPixelData, this.wordWidth(tagInfo));
|
|
2533
|
+
}
|
|
2467
2534
|
|
|
2468
2535
|
// Extract each frame, unpacking bits so each frame starts at byte 0
|
|
2469
2536
|
for (frameNumber = 0; frameNumber < numberOfFrames; frameNumber++) {
|
|
@@ -2505,7 +2572,8 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2505
2572
|
}()
|
|
2506
2573
|
/**
|
|
2507
2574
|
* Reads raw binary data in chunks and delivers it to the listener.
|
|
2508
|
-
*
|
|
2575
|
+
* Reads the value in fragments of `maxFragmentSize` bytes.
|
|
2576
|
+
* OW/OF/OL/OD/OV words come as little endian, as on the other read paths.
|
|
2509
2577
|
*/
|
|
2510
2578
|
)
|
|
2511
2579
|
}, {
|
|
@@ -2518,7 +2586,7 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2518
2586
|
case 0:
|
|
2519
2587
|
length = tagInfo.length;
|
|
2520
2588
|
_context10.next = 1;
|
|
2521
|
-
return this._emitSplitValues(length);
|
|
2589
|
+
return this._emitSplitValues(length, this.wordWidth(tagInfo));
|
|
2522
2590
|
case 1:
|
|
2523
2591
|
case "end":
|
|
2524
2592
|
return _context10.stop();
|
|
@@ -2529,7 +2597,13 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2529
2597
|
return _readRawBinary.apply(this, arguments);
|
|
2530
2598
|
}
|
|
2531
2599
|
return readRawBinary;
|
|
2532
|
-
}())
|
|
2600
|
+
}() /** Bytes per word of the value field; "ox" (a UN pixel data) is OW. */)
|
|
2601
|
+
}, {
|
|
2602
|
+
key: "wordWidth",
|
|
2603
|
+
value: function wordWidth(tagInfo) {
|
|
2604
|
+
var _ValueRepresentation$;
|
|
2605
|
+
return (_ValueRepresentation$ = ValueRepresentation$1.createByTypeString(tagInfo.vr).wordWidth) !== null && _ValueRepresentation$ !== void 0 ? _ValueRepresentation$ : 1;
|
|
2606
|
+
}
|
|
2533
2607
|
}, {
|
|
2534
2608
|
key: "isSequence",
|
|
2535
2609
|
value: function isSequence(tagInfo) {
|
|
@@ -2583,13 +2657,13 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2583
2657
|
if (elementData) {
|
|
2584
2658
|
vrType = elementData.vr;
|
|
2585
2659
|
if (vrType === "xs") {
|
|
2586
|
-
var _this$
|
|
2660
|
+
var _this$listener2;
|
|
2587
2661
|
// The dictionary meta-VR "xs" ("US or SS") resolves via
|
|
2588
2662
|
// PixelRepresentation (PS3.5), exactly like the sync
|
|
2589
2663
|
// reader (DicomMessage._readTag). The listener's
|
|
2590
2664
|
// information filter tracks (0028,0103), which precedes
|
|
2591
2665
|
// every xs tag in tag order.
|
|
2592
|
-
vrType = DicomMessage.resolveXsVrType((_this$
|
|
2666
|
+
vrType = DicomMessage.resolveXsVrType((_this$listener2 = this.listener) === null || _this$listener2 === void 0 || (_this$listener2 = _this$listener2.information) === null || _this$listener2 === void 0 ? void 0 : _this$listener2.pixelRepresentation);
|
|
2593
2667
|
}
|
|
2594
2668
|
} else {
|
|
2595
2669
|
//unknown tag
|
|
@@ -2611,10 +2685,10 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2611
2685
|
if (vrType === "UN" && (_DicomMessage$lookupT = DicomMessage.lookupTag(tagObj)) !== null && _DicomMessage$lookupT !== void 0 && _DicomMessage$lookupT.vr) {
|
|
2612
2686
|
vrType = DicomMessage.lookupTag(tagObj).vr;
|
|
2613
2687
|
if (vrType === "xs") {
|
|
2614
|
-
var _this$
|
|
2688
|
+
var _this$listener3;
|
|
2615
2689
|
// Same PixelRepresentation-driven US/SS resolution for
|
|
2616
2690
|
// explicit-VR UN elements whose dictionary VR is "xs".
|
|
2617
|
-
vrType = DicomMessage.resolveXsVrType((_this$
|
|
2691
|
+
vrType = DicomMessage.resolveXsVrType((_this$listener3 = this.listener) === null || _this$listener3 === void 0 || (_this$listener3 = _this$listener3.information) === null || _this$listener3 === void 0 ? void 0 : _this$listener3.pixelRepresentation);
|
|
2618
2692
|
}
|
|
2619
2693
|
vr = ValueRepresentation$1.parseUnknownVr(vrType);
|
|
2620
2694
|
} else {
|
|
@@ -15971,4 +16045,4 @@ ValueRepresentation.setTagClass(Tag);
|
|
|
15971
16045
|
// entries (src/eventStream.js, ...): the default entry is the 0.52 surface.
|
|
15972
16046
|
|
|
15973
16047
|
export { DICOMWEB as D, _inherits as _, _createClass as a, _objectSpread2 as b, _classCallCheck as c, _callSuper as d, _createForOfIteratorHelper as e, datasetToDict as f, _typeof as g, _asyncToGenerator as h, _regeneratorRuntime as i, adapters as j, anonymizer as k, async as l, constants as m, data as n, dcmjs as o, derivations as p, normalizers as q, sr as s, utilities as u };
|
|
15974
|
-
//# sourceMappingURL=dcmjs.shared-
|
|
16048
|
+
//# sourceMappingURL=dcmjs.shared-CMo1hh3U.js.map
|