@dcmjs-org/dcmjs 1.0.0-beta.9 → 1.0.0
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/README.md +5 -6
- package/build/dcmjs.cjs +1 -1
- package/build/dcmjs.es.js +1 -1
- package/build/dcmjs.js +3166 -1704
- package/build/dcmjs.js.map +1 -1
- package/build/dcmjs.min.js +2 -2
- package/build/dcmjs.min.js.map +1 -1
- package/build/{dcmjs.shared-CvR7StGL.cjs → dcmjs.shared-Gy1xZ3Jj.cjs} +408 -139
- package/build/dcmjs.shared-Gy1xZ3Jj.cjs.map +1 -0
- package/build/{dcmjs.shared-DzVDSFp8.js → dcmjs.shared-oZ6PMYsB.js} +409 -140
- package/build/dcmjs.shared-oZ6PMYsB.js.map +1 -0
- package/build/eventStream.cjs +45 -12
- package/build/eventStream.cjs.map +1 -1
- package/build/eventStream.es.js +46 -13
- package/build/eventStream.es.js.map +1 -1
- package/package.json +8 -8
- package/build/dcmjs.shared-CvR7StGL.cjs.map +0 -1
- package/build/dcmjs.shared-DzVDSFp8.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { log, ValueRepresentation as ValueRepresentation$1, 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, 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, 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, registerTag, dictionary, WriteBufferStream } from '@dcmjs-org/core';
|
|
2
2
|
|
|
3
3
|
/* eslint no-bitwise: 0 */
|
|
4
4
|
var BitArray = {
|
|
@@ -718,6 +718,34 @@ var DicomDict = /*#__PURE__*/function () {
|
|
|
718
718
|
this.dict[tag].Value = ValueRepresentation$1.addValueAccessorsFor(this.dict[tag].vr, values);
|
|
719
719
|
}
|
|
720
720
|
|
|
721
|
+
/**
|
|
722
|
+
* Reserves a private block for a creator, and writes its creator element
|
|
723
|
+
* when the creator has no block yet; pass `{ create: false }` to only look
|
|
724
|
+
* it up. The block is found by creator, never assumed (NAT-U-PRIV-11).
|
|
725
|
+
*
|
|
726
|
+
* dicomDict.privateBlock("4D43:ACME 1.0").set("x01", "CS", ["HYBRID"]);
|
|
727
|
+
*
|
|
728
|
+
* @param {number|string} groupOrKey odd group number, or block key "gggg:creator"
|
|
729
|
+
* @param {string} [creator] creator string, with a group number
|
|
730
|
+
* @param {{create?: boolean}} [options] create defaults to true; false
|
|
731
|
+
* returns null when the creator is absent
|
|
732
|
+
* @returns {Object|null} accessor with key, group, creator, reservedBlock,
|
|
733
|
+
* tag, has, get and set
|
|
734
|
+
*/
|
|
735
|
+
}, {
|
|
736
|
+
key: "privateBlock",
|
|
737
|
+
value: function privateBlock(groupOrKey, creator) {
|
|
738
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
739
|
+
if (typeof groupOrKey === "string" && _typeof(creator) === "object") {
|
|
740
|
+
options = creator;
|
|
741
|
+
creator = undefined;
|
|
742
|
+
}
|
|
743
|
+
var _ref = options || {},
|
|
744
|
+
_ref$create = _ref.create,
|
|
745
|
+
create = _ref$create === void 0 ? true : _ref$create;
|
|
746
|
+
return create ? reservePrivateBlock(this.dict, groupOrKey, creator) : findPrivateBlock(this.dict, groupOrKey, creator);
|
|
747
|
+
}
|
|
748
|
+
|
|
721
749
|
// The Part 10 envelope (preamble/DICM, computed meta group length,
|
|
722
750
|
// deflate branch, default transfer syntax) moved verbatim to
|
|
723
751
|
// @dcmjs-org/core as writePart10 (core/writeCore.js); this delegation
|
|
@@ -906,7 +934,7 @@ var DicomMessage = /*#__PURE__*/function () {
|
|
|
906
934
|
// issue #93 opt-in: accept preamble-less / meta-less inputs
|
|
907
935
|
allowMissingHeader: false
|
|
908
936
|
};
|
|
909
|
-
var stream = new ReadBufferStream(buffer,
|
|
937
|
+
var stream = new ReadBufferStream(buffer, {
|
|
910
938
|
noCopy: options.noCopy
|
|
911
939
|
}),
|
|
912
940
|
useSyntax = EXPLICIT_LITTLE_ENDIAN;
|
|
@@ -1047,7 +1075,8 @@ var DicomMessage = /*#__PURE__*/function () {
|
|
|
1047
1075
|
}
|
|
1048
1076
|
var length = null,
|
|
1049
1077
|
vr = null,
|
|
1050
|
-
vrType
|
|
1078
|
+
vrType,
|
|
1079
|
+
wireVrType = null;
|
|
1051
1080
|
if (implicit) {
|
|
1052
1081
|
length = stream.readUint32();
|
|
1053
1082
|
var elementData = DicomMessage.lookupTag(tag);
|
|
@@ -1075,6 +1104,7 @@ var DicomMessage = /*#__PURE__*/function () {
|
|
|
1075
1104
|
vr = ValueRepresentation$1.createByTypeString(vrType);
|
|
1076
1105
|
} else {
|
|
1077
1106
|
vrType = stream.readVR();
|
|
1107
|
+
wireVrType = vrType;
|
|
1078
1108
|
if (vrType === "UN" && DicomMessage.lookupTag(tag) && DicomMessage.lookupTag(tag).vr) {
|
|
1079
1109
|
vrType = DicomMessage.lookupTag(tag).vr;
|
|
1080
1110
|
if (vrType === "xs") {
|
|
@@ -1093,13 +1123,19 @@ var DicomMessage = /*#__PURE__*/function () {
|
|
|
1093
1123
|
length = stream.readUint16();
|
|
1094
1124
|
}
|
|
1095
1125
|
}
|
|
1126
|
+
var readSyntax = syntax;
|
|
1127
|
+
if (!implicit && wireVrType === "UN" && isUnSequenceValue(stream.view, stream.offset, length, vr.type)) {
|
|
1128
|
+
vr = ValueRepresentation$1.createByTypeString("SQ");
|
|
1129
|
+
readSyntax = IMPLICIT_LITTLE_ENDIAN;
|
|
1130
|
+
stream.setEndian(true); // the items are LE in a BE body too
|
|
1131
|
+
}
|
|
1096
1132
|
var values = [];
|
|
1097
1133
|
var rawValues = [];
|
|
1098
1134
|
if (vr.isBinary() && length > vr.maxLength && !vr.noMultiple) {
|
|
1099
1135
|
var times = length / vr.maxLength,
|
|
1100
1136
|
i = 0;
|
|
1101
1137
|
while (i++ < times) {
|
|
1102
|
-
var _vr$read = vr.read(stream, vr.maxLength,
|
|
1138
|
+
var _vr$read = vr.read(stream, vr.maxLength, readSyntax, options),
|
|
1103
1139
|
rawValue = _vr$read.rawValue,
|
|
1104
1140
|
value = _vr$read.value;
|
|
1105
1141
|
rawValues.push(rawValue);
|
|
@@ -1110,7 +1146,7 @@ var DicomMessage = /*#__PURE__*/function () {
|
|
|
1110
1146
|
var readOptions = vr.type === "SQ" ? _objectSpread2(_objectSpread2({}, options), {}, {
|
|
1111
1147
|
readItem: readItem
|
|
1112
1148
|
}) : options;
|
|
1113
|
-
var _ref = vr.read(stream, length,
|
|
1149
|
+
var _ref = vr.read(stream, length, readSyntax, readOptions) || {},
|
|
1114
1150
|
_rawValue = _ref.rawValue,
|
|
1115
1151
|
_value = _ref.value;
|
|
1116
1152
|
if (!vr.isBinary() && singleVRs.indexOf(vr.type) == -1) {
|
|
@@ -1325,25 +1361,65 @@ var ValueRepresentation = /*#__PURE__*/function (_CoreValueRepresentat) {
|
|
|
1325
1361
|
//
|
|
1326
1362
|
// Handle DICOM and CIELAB colors
|
|
1327
1363
|
// based on:
|
|
1328
|
-
// https://github.com/
|
|
1364
|
+
// https://github.com/DCMTK/dcmtk/blob/88105877c3b610e23fc9422ba6a84af85552f5dd/dcmiod/libsrc/cielabutil.cc
|
|
1329
1365
|
//
|
|
1330
1366
|
// RGB here refers to sRGB 0-1 per component.
|
|
1331
1367
|
// dicomlab is CIELAB values as defined in the dicom standard
|
|
1332
|
-
// XYZ is CIEXYZ convention
|
|
1333
|
-
//
|
|
1334
|
-
// TODO: needs a test suite
|
|
1335
|
-
// TODO: only dicomlab2RGB tested on real data
|
|
1368
|
+
// XYZ is CIEXYZ convention, relative to the D50 white point (ICC PCS)
|
|
1336
1369
|
//
|
|
1370
|
+
// DICOM encodes CIELab values in the same way as the ICC Profile Connection
|
|
1371
|
+
// Space (PCS, see PS3.3 C.10.7.1.1), i.e. relative to the D50 illuminant,
|
|
1372
|
+
// whereas the native white point of sRGB is D65. The conversions below
|
|
1373
|
+
// therefore chromatically adapt between the two using the linear Bradford
|
|
1374
|
+
// transform. Matrices and constants are those of the CSS Color Module Level 4
|
|
1375
|
+
// sample code (https://www.w3.org/TR/css-color-4/#color-conversion-code).
|
|
1337
1376
|
//
|
|
1377
|
+
|
|
1378
|
+
// White points, defined by their 4-figure CIE x,y chromaticities.
|
|
1379
|
+
// D50 is intentionally [0.96430, 1, 0.82510] and not the ICC.1 PCS illuminant
|
|
1380
|
+
// [0.9642, 1, 0.8249]: this matches DCMTK, highdicom and CSS Color 4, and
|
|
1381
|
+
// encodes sRGB white as exactly 0x8080 in a* and b*.
|
|
1382
|
+
var D50_WHITEPOINT_XYZ = [0.3457 / 0.3585, 1.0, (1.0 - 0.3457 - 0.3585) / 0.3585];
|
|
1383
|
+
var D65_WHITEPOINT_XYZ = [0.3127 / 0.329, 1.0, (1.0 - 0.3127 - 0.329) / 0.329];
|
|
1384
|
+
function clamp01(n) {
|
|
1385
|
+
return Math.min(1.0, Math.max(0.0, n));
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
// Rounds to the nearest integer in [0, max]; NaN (invalid input) gives 0
|
|
1389
|
+
function roundClamp(n, max) {
|
|
1390
|
+
if (!(n >= 0.0)) {
|
|
1391
|
+
return 0;
|
|
1392
|
+
}
|
|
1393
|
+
if (n > max) {
|
|
1394
|
+
return max;
|
|
1395
|
+
}
|
|
1396
|
+
return Math.floor(n + 0.5);
|
|
1397
|
+
}
|
|
1338
1398
|
var Colors = /*#__PURE__*/function () {
|
|
1339
1399
|
function Colors() {
|
|
1340
1400
|
_classCallCheck(this, Colors);
|
|
1341
1401
|
}
|
|
1342
1402
|
return _createClass(Colors, null, [{
|
|
1403
|
+
key: "d50WhitePointXYZ",
|
|
1404
|
+
value:
|
|
1405
|
+
/**
|
|
1406
|
+
* White point of the D50 illuminant (ICC PCS), the reference white of
|
|
1407
|
+
* DICOM CIELab. Use this white with the XYZ values of rgb2XYZ, xyz2RGB,
|
|
1408
|
+
* lab2XYZ and xyz2LAB.
|
|
1409
|
+
*/
|
|
1410
|
+
function d50WhitePointXYZ() {
|
|
1411
|
+
return [].concat(D50_WHITEPOINT_XYZ);
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
/**
|
|
1415
|
+
* White point of the D65 illuminant, the native white of sRGB. No
|
|
1416
|
+
* conversion in this class uses it. Do not combine it with the XYZ
|
|
1417
|
+
* values of this class, which are relative to D50.
|
|
1418
|
+
*/
|
|
1419
|
+
}, {
|
|
1343
1420
|
key: "d65WhitePointXYZ",
|
|
1344
1421
|
value: function d65WhitePointXYZ() {
|
|
1345
|
-
|
|
1346
|
-
return [0.950456, 1.0, 1.088754];
|
|
1422
|
+
return [].concat(D65_WHITEPOINT_XYZ);
|
|
1347
1423
|
}
|
|
1348
1424
|
}, {
|
|
1349
1425
|
key: "dicomlab2RGB",
|
|
@@ -1355,6 +1431,26 @@ var Colors = /*#__PURE__*/function () {
|
|
|
1355
1431
|
value: function rgb2DICOMLAB(rgb) {
|
|
1356
1432
|
return Colors.lab2DICOMLAB(Colors.rgb2LAB(rgb));
|
|
1357
1433
|
}
|
|
1434
|
+
|
|
1435
|
+
// 16 bit DICOM CIELab -> 8 bit sRGB, rounded and clamped
|
|
1436
|
+
}, {
|
|
1437
|
+
key: "dicomlab2RGB8",
|
|
1438
|
+
value: function dicomlab2RGB8(dicomlab) {
|
|
1439
|
+
return Colors.dicomlab2RGB(dicomlab).map(function (n) {
|
|
1440
|
+
return roundClamp(n * 255.0, 255);
|
|
1441
|
+
});
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
// 8 bit sRGB (array or typed array) -> 16 bit DICOM CIELab, rounded and clamped
|
|
1445
|
+
}, {
|
|
1446
|
+
key: "rgb82DICOMLAB",
|
|
1447
|
+
value: function rgb82DICOMLAB(rgb) {
|
|
1448
|
+
return Colors.rgb2DICOMLAB(Array.from(rgb, function (n) {
|
|
1449
|
+
return n / 255.0;
|
|
1450
|
+
})).map(function (n) {
|
|
1451
|
+
return roundClamp(n, 65535);
|
|
1452
|
+
});
|
|
1453
|
+
}
|
|
1358
1454
|
}, {
|
|
1359
1455
|
key: "dicomlab2LAB",
|
|
1360
1456
|
value: function dicomlab2LAB(dicomlab) {
|
|
@@ -1383,7 +1479,8 @@ var Colors = /*#__PURE__*/function () {
|
|
|
1383
1479
|
}, {
|
|
1384
1480
|
key: "gammaCorrection",
|
|
1385
1481
|
value: function gammaCorrection(n) {
|
|
1386
|
-
|
|
1482
|
+
// sRGB transfer function (IEC 61966-2-1), linear to gamma-encoded
|
|
1483
|
+
if (n <= 0.0031308) {
|
|
1387
1484
|
return 12.92 * n;
|
|
1388
1485
|
} else {
|
|
1389
1486
|
return 1.055 * Math.pow(n, 1 / 2.4) - 0.055;
|
|
@@ -1392,27 +1489,39 @@ var Colors = /*#__PURE__*/function () {
|
|
|
1392
1489
|
}, {
|
|
1393
1490
|
key: "invGammaCorrection",
|
|
1394
1491
|
value: function invGammaCorrection(n) {
|
|
1395
|
-
|
|
1492
|
+
// sRGB transfer function (IEC 61966-2-1), gamma-encoded to linear
|
|
1493
|
+
if (n <= 0.04045) {
|
|
1396
1494
|
return n / 12.92;
|
|
1397
1495
|
} else {
|
|
1398
1496
|
return Math.pow((n + 0.055) / 1.055, 2.4);
|
|
1399
1497
|
}
|
|
1400
1498
|
}
|
|
1499
|
+
|
|
1500
|
+
// sRGB -> CIE XYZ relative to D50, as DICOM CIELab requires (not D65)
|
|
1401
1501
|
}, {
|
|
1402
1502
|
key: "rgb2XYZ",
|
|
1403
1503
|
value: function rgb2XYZ(rgb) {
|
|
1504
|
+
// sRGB to linear RGB
|
|
1404
1505
|
var R = Colors.invGammaCorrection(rgb[0]);
|
|
1405
1506
|
var G = Colors.invGammaCorrection(rgb[1]);
|
|
1406
1507
|
var B = Colors.invGammaCorrection(rgb[2]);
|
|
1407
|
-
|
|
1508
|
+
|
|
1509
|
+
// linear RGB to CIE XYZ (D65)
|
|
1510
|
+
var X65 = 506752.0 / 1228815.0 * R + 87881.0 / 245763.0 * G + 12673.0 / 70218.0 * B;
|
|
1511
|
+
var Y65 = 87098.0 / 409605.0 * R + 175762.0 / 245763.0 * G + 12673.0 / 175545.0 * B;
|
|
1512
|
+
var Z65 = 7918.0 / 409605.0 * R + 87881.0 / 737289.0 * G + 1001167.0 / 1053270.0 * B;
|
|
1513
|
+
|
|
1514
|
+
// chromatic adaptation D65 to D50 (linear Bradford)
|
|
1515
|
+
return [1.0479297925449969 * X65 + 0.022946870601609652 * Y65 - 0.05019226628920524 * Z65, 0.02962780877005599 * X65 + 0.9904344267538799 * Y65 - 0.017073799063418826 * Z65, -0.009243040646204504 * X65 + 0.015055191490298152 * Y65 + 0.7518742814281371 * Z65];
|
|
1408
1516
|
}
|
|
1517
|
+
|
|
1518
|
+
// CIE XYZ relative to D50 -> CIELab
|
|
1409
1519
|
}, {
|
|
1410
1520
|
key: "xyz2LAB",
|
|
1411
1521
|
value: function xyz2LAB(xyz) {
|
|
1412
|
-
var
|
|
1413
|
-
var
|
|
1414
|
-
var
|
|
1415
|
-
var Z = xyz[2] / whitePoint[2];
|
|
1522
|
+
var X = xyz[0] / D50_WHITEPOINT_XYZ[0];
|
|
1523
|
+
var Y = xyz[1] / D50_WHITEPOINT_XYZ[1];
|
|
1524
|
+
var Z = xyz[2] / D50_WHITEPOINT_XYZ[2];
|
|
1416
1525
|
X = Colors.labf(X);
|
|
1417
1526
|
Y = Colors.labf(Y);
|
|
1418
1527
|
Z = Colors.labf(Z);
|
|
@@ -1423,50 +1532,58 @@ var Colors = /*#__PURE__*/function () {
|
|
|
1423
1532
|
value: function lab2RGB(lab) {
|
|
1424
1533
|
return Colors.xyz2RGB(Colors.lab2XYZ(lab));
|
|
1425
1534
|
}
|
|
1535
|
+
|
|
1536
|
+
// CIELab -> CIE XYZ relative to D50
|
|
1426
1537
|
}, {
|
|
1427
1538
|
key: "lab2XYZ",
|
|
1428
1539
|
value: function lab2XYZ(lab) {
|
|
1429
1540
|
var L = (lab[0] + 16) / 116;
|
|
1430
1541
|
var a = L + lab[1] / 500;
|
|
1431
1542
|
var b = L - lab[2] / 200;
|
|
1432
|
-
|
|
1433
|
-
return [whitePoint[0] * Colors.labfInv(a), whitePoint[1] * Colors.labfInv(L), whitePoint[2] * Colors.labfInv(b)];
|
|
1543
|
+
return [D50_WHITEPOINT_XYZ[0] * Colors.labfInv(a), D50_WHITEPOINT_XYZ[1] * Colors.labfInv(L), D50_WHITEPOINT_XYZ[2] * Colors.labfInv(b)];
|
|
1434
1544
|
}
|
|
1545
|
+
|
|
1546
|
+
// CIE XYZ relative to D50 -> sRGB, clipped per channel to [0, 1]
|
|
1435
1547
|
}, {
|
|
1436
1548
|
key: "xyz2RGB",
|
|
1437
1549
|
value: function xyz2RGB(xyz) {
|
|
1438
|
-
var
|
|
1439
|
-
|
|
1440
|
-
|
|
1550
|
+
var _xyz = _slicedToArray(xyz, 3),
|
|
1551
|
+
X = _xyz[0],
|
|
1552
|
+
Y = _xyz[1],
|
|
1553
|
+
Z = _xyz[2];
|
|
1441
1554
|
|
|
1442
|
-
|
|
1443
|
-
var
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1555
|
+
// chromatic adaptation D50 to D65 (linear Bradford)
|
|
1556
|
+
var X65 = 0.955473421488075 * X - 0.02309845494876471 * Y + 0.06325924320057072 * Z;
|
|
1557
|
+
var Y65 = -0.0283697093338637 * X + 1.0099953980813041 * Y + 0.021041441191917323 * Z;
|
|
1558
|
+
var Z65 = 0.012314014864481998 * X - 0.020507649298898964 * Y + 1.330365926242124 * Z;
|
|
1559
|
+
|
|
1560
|
+
// CIE XYZ (D65) to linear RGB
|
|
1561
|
+
var R1 = 12831.0 / 3959.0 * X65 - 329.0 / 214.0 * Y65 - 1974.0 / 3959.0 * Z65;
|
|
1562
|
+
var G1 = -851781 / 878810.0 * X65 + 1648619.0 / 878810.0 * Y65 + 36519.0 / 878810.0 * Z65;
|
|
1563
|
+
var B1 = 705.0 / 12673.0 * X65 - 2585.0 / 12673.0 * Y65 + 705.0 / 667.0 * Z65;
|
|
1450
1564
|
|
|
1451
|
-
|
|
1452
|
-
|
|
1565
|
+
// Clip to the sRGB gamut (also makes sure that gamma encoding is
|
|
1566
|
+
// well-defined), then transform from linear RGB to sRGB
|
|
1567
|
+
return [Colors.gammaCorrection(clamp01(R1)), Colors.gammaCorrection(clamp01(G1)), Colors.gammaCorrection(clamp01(B1))];
|
|
1453
1568
|
}
|
|
1454
1569
|
}, {
|
|
1455
1570
|
key: "labf",
|
|
1456
1571
|
value: function labf(n) {
|
|
1457
|
-
|
|
1458
|
-
|
|
1572
|
+
// epsilon = (6/29)^3 = 216/24389, kappa = (29/3)^3 = 24389/27
|
|
1573
|
+
if (n > 216.0 / 24389.0) {
|
|
1574
|
+
return Math.cbrt(n);
|
|
1459
1575
|
} else {
|
|
1460
|
-
return
|
|
1576
|
+
return (24389.0 / 27.0 * n + 16.0) / 116.0;
|
|
1461
1577
|
}
|
|
1462
1578
|
}
|
|
1463
1579
|
}, {
|
|
1464
1580
|
key: "labfInv",
|
|
1465
1581
|
value: function labfInv(n) {
|
|
1466
|
-
|
|
1582
|
+
// n > 6/29 <=> n^3 > epsilon
|
|
1583
|
+
if (n > 6.0 / 29.0) {
|
|
1467
1584
|
return n * n * n;
|
|
1468
1585
|
} else {
|
|
1469
|
-
return
|
|
1586
|
+
return (116.0 * n - 16.0) / (24389.0 / 27.0);
|
|
1470
1587
|
}
|
|
1471
1588
|
}
|
|
1472
1589
|
}]);
|
|
@@ -1489,11 +1606,15 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
1489
1606
|
_classCallCheck(this, AsyncDicomReader);
|
|
1490
1607
|
_defineProperty(this, "syntax", EXPLICIT_LITTLE_ENDIAN);
|
|
1491
1608
|
this.isLittleEndian = options === null || options === void 0 ? void 0 : options.isLittleEndian;
|
|
1492
|
-
//
|
|
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
|
|
1493
1612
|
this.maxFragmentSize = (_options$maxFragmentS = options === null || options === void 0 ? void 0 : options.maxFragmentSize) !== null && _options$maxFragmentS !== void 0 ? _options$maxFragmentS : 128 * 1024 * 1024;
|
|
1494
|
-
this.stream = new ReadBufferStream(null,
|
|
1613
|
+
this.stream = new ReadBufferStream(null, _objectSpread2(_objectSpread2({
|
|
1495
1614
|
clearBuffers: true
|
|
1496
|
-
}, options)
|
|
1615
|
+
}, options), {}, {
|
|
1616
|
+
littleEndian: this.isLittleEndian
|
|
1617
|
+
}));
|
|
1497
1618
|
}
|
|
1498
1619
|
|
|
1499
1620
|
/** Sentinel returned when stream is Part 10 but has no preamble (starts with meta). */
|
|
@@ -1879,7 +2000,7 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
1879
2000
|
break;
|
|
1880
2001
|
}
|
|
1881
2002
|
// Group length
|
|
1882
|
-
stream.increment(
|
|
2003
|
+
stream.increment(length);
|
|
1883
2004
|
return _context5.abrupt("continue", 1);
|
|
1884
2005
|
case 5:
|
|
1885
2006
|
addTagResult = listener.addTag(tag, tagInfo);
|
|
@@ -1948,17 +2069,27 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
1948
2069
|
* item boundary and returns control here for the next item. Without that
|
|
1949
2070
|
* offset, read() skips the later Item tags as instructions, and all items
|
|
1950
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.
|
|
1951
2076
|
*/
|
|
1952
2077
|
}, {
|
|
1953
2078
|
key: "readSequence",
|
|
1954
2079
|
value: (function () {
|
|
1955
2080
|
var _readSequence = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(listener, sqTagInfo, options) {
|
|
1956
|
-
var
|
|
2081
|
+
var _ref, _sqTagInfo$sequenceRe;
|
|
2082
|
+
var itemOptions, length, stream, readSyntax, endOffset, tagInfo, tag, itemLength, itemUntilOffset, decoder, _t;
|
|
1957
2083
|
return _regeneratorRuntime().wrap(function (_context6) {
|
|
1958
2084
|
while (1) switch (_context6.prev = _context6.next) {
|
|
1959
2085
|
case 0:
|
|
2086
|
+
itemOptions = _objectSpread2(_objectSpread2({}, options), {}, {
|
|
2087
|
+
untilTag: null,
|
|
2088
|
+
includeUntilTagValue: false
|
|
2089
|
+
});
|
|
1960
2090
|
length = sqTagInfo.length;
|
|
1961
|
-
stream = this.stream
|
|
2091
|
+
stream = this.stream;
|
|
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;
|
|
1962
2093
|
endOffset = length === UNDEFINED_LENGTH_FIX ? Number.MAX_SAFE_INTEGER : stream.offset + length;
|
|
1963
2094
|
case 1:
|
|
1964
2095
|
_t = stream.offset < endOffset;
|
|
@@ -1972,50 +2103,78 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
1972
2103
|
_t = _context6.sent;
|
|
1973
2104
|
case 3:
|
|
1974
2105
|
if (!_t) {
|
|
1975
|
-
_context6.next =
|
|
2106
|
+
_context6.next = 10;
|
|
1976
2107
|
break;
|
|
1977
2108
|
}
|
|
1978
2109
|
readLog.debug("readSequence loop", stream.offset, endOffset);
|
|
1979
|
-
tagInfo = this.readTagHeader(
|
|
2110
|
+
tagInfo = this.readTagHeader(_objectSpread2(_objectSpread2({}, itemOptions), {}, {
|
|
2111
|
+
readSyntax: readSyntax
|
|
2112
|
+
}));
|
|
1980
2113
|
tag = tagInfo.tag;
|
|
1981
2114
|
if (!(tag === TagHex.Item)) {
|
|
1982
|
-
_context6.next =
|
|
2115
|
+
_context6.next = 7;
|
|
1983
2116
|
break;
|
|
1984
2117
|
}
|
|
1985
2118
|
listener.startObject();
|
|
1986
2119
|
// defined-length item: stop at its own end (see doc comment)
|
|
1987
2120
|
itemLength = tagInfo.length;
|
|
1988
|
-
itemUntilOffset = itemLength === UNDEFINED_LENGTH_FIX ? endOffset : Math.min(stream.offset + itemLength, endOffset);
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
2121
|
+
itemUntilOffset = itemLength === UNDEFINED_LENGTH_FIX ? endOffset : Math.min(stream.offset + itemLength, endOffset); // A SpecificCharacterSet in the item applies only to that
|
|
2122
|
+
// item (PS3.5 7.5.3), but the item is read on this stream:
|
|
2123
|
+
// put back the decoder the item started with.
|
|
2124
|
+
decoder = stream.decoder;
|
|
2125
|
+
this.sequenceDepth++;
|
|
2126
|
+
_context6.prev = 4;
|
|
2127
|
+
_context6.next = 5;
|
|
2128
|
+
return this.read(listener, _objectSpread2(_objectSpread2({}, itemOptions), {}, {
|
|
2129
|
+
untilOffset: itemUntilOffset,
|
|
2130
|
+
readSyntax: readSyntax
|
|
1992
2131
|
}));
|
|
1993
|
-
case 4:
|
|
1994
|
-
_context6.next = 7;
|
|
1995
|
-
break;
|
|
1996
2132
|
case 5:
|
|
2133
|
+
_context6.prev = 5;
|
|
2134
|
+
this.sequenceDepth--;
|
|
2135
|
+
return _context6.finish(5);
|
|
2136
|
+
case 6:
|
|
2137
|
+
stream.setDecoder(decoder);
|
|
2138
|
+
_context6.next = 9;
|
|
2139
|
+
break;
|
|
2140
|
+
case 7:
|
|
1997
2141
|
if (!(tag === TagHex.SequenceDelimitationEnd)) {
|
|
1998
|
-
_context6.next =
|
|
2142
|
+
_context6.next = 8;
|
|
1999
2143
|
break;
|
|
2000
2144
|
}
|
|
2001
2145
|
return _context6.abrupt("return");
|
|
2002
|
-
case
|
|
2146
|
+
case 8:
|
|
2003
2147
|
console.warn("Unknown tag info", length, tagInfo);
|
|
2004
|
-
throw new Error();
|
|
2005
|
-
case
|
|
2148
|
+
throw new Error("Expected an item or a sequence delimitation item in a sequence, found tag ".concat(tag));
|
|
2149
|
+
case 9:
|
|
2006
2150
|
_context6.next = 1;
|
|
2007
2151
|
break;
|
|
2008
|
-
case
|
|
2152
|
+
case 10:
|
|
2009
2153
|
case "end":
|
|
2010
2154
|
return _context6.stop();
|
|
2011
2155
|
}
|
|
2012
|
-
}, _callee6, this);
|
|
2156
|
+
}, _callee6, this, [[4,, 5, 6]]);
|
|
2013
2157
|
}));
|
|
2014
2158
|
function readSequence(_x3, _x4, _x5) {
|
|
2015
2159
|
return _readSequence.apply(this, arguments);
|
|
2016
2160
|
}
|
|
2017
2161
|
return readSequence;
|
|
2018
|
-
}()
|
|
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
|
+
}
|
|
2019
2178
|
}, {
|
|
2020
2179
|
key: "readPixelData",
|
|
2021
2180
|
value: function readPixelData(tagInfo) {
|
|
@@ -2028,16 +2187,28 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2028
2187
|
/**
|
|
2029
2188
|
* Emits one or more listener.value() calls for a fragment, splitting if needed.
|
|
2030
2189
|
* This does NOT start/pop any array contexts; callers control the surrounding structure.
|
|
2190
|
+
* In a big endian stream, each fragment holds whole words of wordWidth
|
|
2191
|
+
* bytes, swapped to little endian.
|
|
2031
2192
|
*/
|
|
2032
2193
|
}, {
|
|
2033
2194
|
key: "_emitSplitValues",
|
|
2034
2195
|
value: (function () {
|
|
2035
2196
|
var _emitSplitValues2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(length) {
|
|
2036
2197
|
var _listener$awaitDrain;
|
|
2037
|
-
var
|
|
2198
|
+
var wordWidth,
|
|
2199
|
+
stream,
|
|
2200
|
+
listener,
|
|
2201
|
+
maxFragmentSize,
|
|
2202
|
+
swap,
|
|
2203
|
+
fragmentSize,
|
|
2204
|
+
offset,
|
|
2205
|
+
chunkSize,
|
|
2206
|
+
buffer,
|
|
2207
|
+
_args7 = arguments;
|
|
2038
2208
|
return _regeneratorRuntime().wrap(function (_context7) {
|
|
2039
2209
|
while (1) switch (_context7.prev = _context7.next) {
|
|
2040
2210
|
case 0:
|
|
2211
|
+
wordWidth = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : 1;
|
|
2041
2212
|
stream = this.stream, listener = this.listener;
|
|
2042
2213
|
_context7.next = 1;
|
|
2043
2214
|
return (_listener$awaitDrain = listener.awaitDrain) === null || _listener$awaitDrain === void 0 ? void 0 : _listener$awaitDrain.call(listener);
|
|
@@ -2049,6 +2220,8 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2049
2220
|
}
|
|
2050
2221
|
throw new Error("maxFragmentSize must be a positive number, got ".concat(maxFragmentSize));
|
|
2051
2222
|
case 2:
|
|
2223
|
+
swap = !stream.isLittleEndian && wordWidth > 1;
|
|
2224
|
+
fragmentSize = swap ? Math.max(wordWidth, maxFragmentSize - maxFragmentSize % wordWidth) : maxFragmentSize;
|
|
2052
2225
|
offset = 0;
|
|
2053
2226
|
case 3:
|
|
2054
2227
|
if (!(offset < length)) {
|
|
@@ -2056,11 +2229,14 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2056
2229
|
break;
|
|
2057
2230
|
}
|
|
2058
2231
|
readLog.trace("_emitSplitValues loop", offset, length);
|
|
2059
|
-
chunkSize = Math.min(
|
|
2232
|
+
chunkSize = Math.min(fragmentSize, length - offset);
|
|
2060
2233
|
_context7.next = 4;
|
|
2061
2234
|
return stream.ensureAvailable(chunkSize);
|
|
2062
2235
|
case 4:
|
|
2063
2236
|
buffer = stream.readArrayBuffer(chunkSize);
|
|
2237
|
+
if (swap) {
|
|
2238
|
+
swapBytes(buffer, wordWidth);
|
|
2239
|
+
}
|
|
2064
2240
|
listener.value(buffer);
|
|
2065
2241
|
offset += chunkSize;
|
|
2066
2242
|
stream.consume();
|
|
@@ -2085,8 +2261,7 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2085
2261
|
key: "readCompressed",
|
|
2086
2262
|
value: (function () {
|
|
2087
2263
|
var _readCompressed = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(_tagInfo) {
|
|
2088
|
-
var
|
|
2089
|
-
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;
|
|
2090
2265
|
return _regeneratorRuntime().wrap(function (_context8) {
|
|
2091
2266
|
while (1) switch (_context8.prev = _context8.next) {
|
|
2092
2267
|
case 0:
|
|
@@ -2097,8 +2272,7 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2097
2272
|
case 1:
|
|
2098
2273
|
// Check if this is a video transfer syntax
|
|
2099
2274
|
isVideo = isVideoTransferSyntax(transferSyntaxUid); // Check number of frames - only use video logic for single frame (or undefined)
|
|
2100
|
-
|
|
2101
|
-
isSingleFrame = !numberOfFrames || parseInt(numberOfFrames) <= 1;
|
|
2275
|
+
isSingleFrame = this.getNumberOfFrames() <= 1;
|
|
2102
2276
|
_context8.next = 2;
|
|
2103
2277
|
return this.readOffsets();
|
|
2104
2278
|
case 2:
|
|
@@ -2212,23 +2386,23 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2212
2386
|
key: "readUncompressed",
|
|
2213
2387
|
value: (function () {
|
|
2214
2388
|
var _readUncompressed = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee0(tagInfo) {
|
|
2215
|
-
var _listener$information2;
|
|
2216
|
-
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;
|
|
2217
2390
|
return _regeneratorRuntime().wrap(function (_context0) {
|
|
2218
2391
|
while (1) switch (_context0.prev = _context0.next) {
|
|
2219
2392
|
case 0:
|
|
2220
2393
|
length = tagInfo.length;
|
|
2221
2394
|
listener = this.listener;
|
|
2222
|
-
|
|
2395
|
+
wordWidth = this.wordWidth(tagInfo);
|
|
2396
|
+
numberOfFrames = this.getNumberOfFrames();
|
|
2223
2397
|
frameLength = Math.floor(length / numberOfFrames);
|
|
2224
2398
|
if (!(numberOfFrames > 1)) {
|
|
2225
2399
|
_context0.next = 4;
|
|
2226
2400
|
break;
|
|
2227
2401
|
}
|
|
2228
|
-
rows = (_listener$
|
|
2229
|
-
cols = (_listener$
|
|
2230
|
-
samplesPerPixel = (_listener$
|
|
2231
|
-
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;
|
|
2232
2406
|
bitsPerFrame = rows * cols * samplesPerPixel * bitsAllocated;
|
|
2233
2407
|
if (!(bitsPerFrame % 8 !== 0)) {
|
|
2234
2408
|
_context0.next = 3;
|
|
@@ -2251,24 +2425,41 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2251
2425
|
}
|
|
2252
2426
|
throw new Error("Invalid frame length: ".concat(length, " for ").concat(numberOfFrames, " frames"));
|
|
2253
2427
|
case 4:
|
|
2254
|
-
|
|
2428
|
+
if (!(!this.stream.isLittleEndian && frameLength % wordWidth !== 0)) {
|
|
2429
|
+
_context0.next = 6;
|
|
2430
|
+
break;
|
|
2431
|
+
}
|
|
2432
|
+
_context0.next = 5;
|
|
2433
|
+
return this.stream.ensureAvailable(length);
|
|
2255
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:
|
|
2256
2447
|
if (!(frameNumber < numberOfFrames)) {
|
|
2257
|
-
_context0.next =
|
|
2448
|
+
_context0.next = 10;
|
|
2258
2449
|
break;
|
|
2259
2450
|
}
|
|
2260
2451
|
readLog.trace("readUncompressed loop", frameNumber, numberOfFrames);
|
|
2261
2452
|
listener.startObject([]);
|
|
2262
|
-
_context0.next =
|
|
2263
|
-
return this._emitSplitValues(frameLength);
|
|
2264
|
-
case
|
|
2453
|
+
_context0.next = 8;
|
|
2454
|
+
return this._emitSplitValues(frameLength, wordWidth);
|
|
2455
|
+
case 8:
|
|
2265
2456
|
listener.pop();
|
|
2266
2457
|
// console.log(stream.getBufferMemoryInfo());
|
|
2267
|
-
case
|
|
2458
|
+
case 9:
|
|
2268
2459
|
frameNumber++;
|
|
2269
|
-
_context0.next =
|
|
2460
|
+
_context0.next = 7;
|
|
2270
2461
|
break;
|
|
2271
|
-
case
|
|
2462
|
+
case 10:
|
|
2272
2463
|
case "end":
|
|
2273
2464
|
return _context0.stop();
|
|
2274
2465
|
}
|
|
@@ -2297,18 +2488,18 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2297
2488
|
key: "readUncompressedBitFrame",
|
|
2298
2489
|
value: (function () {
|
|
2299
2490
|
var _readUncompressedBitFrame = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee1(tagInfo) {
|
|
2300
|
-
var _listener$
|
|
2491
|
+
var _listener$information5, _listener$information6, _listener$information7, _listener$information8;
|
|
2301
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;
|
|
2302
2493
|
return _regeneratorRuntime().wrap(function (_context1) {
|
|
2303
2494
|
while (1) switch (_context1.prev = _context1.next) {
|
|
2304
2495
|
case 0:
|
|
2305
2496
|
length = tagInfo.length;
|
|
2306
2497
|
listener = this.listener, stream = this.stream;
|
|
2307
|
-
numberOfFrames =
|
|
2308
|
-
rows = (_listener$
|
|
2309
|
-
cols = (_listener$
|
|
2310
|
-
samplesPerPixel = ((_listener$
|
|
2311
|
-
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;
|
|
2312
2503
|
if (!(!rows || !cols || !bitsAllocated)) {
|
|
2313
2504
|
_context1.next = 1;
|
|
2314
2505
|
break;
|
|
@@ -2336,6 +2527,10 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2336
2527
|
case 4:
|
|
2337
2528
|
allPixelData = stream.readArrayBuffer(totalBytes);
|
|
2338
2529
|
stream.consume();
|
|
2530
|
+
if (!stream.isLittleEndian) {
|
|
2531
|
+
// the bits of OW data are packed in big endian words
|
|
2532
|
+
swapBytes(allPixelData, this.wordWidth(tagInfo));
|
|
2533
|
+
}
|
|
2339
2534
|
|
|
2340
2535
|
// Extract each frame, unpacking bits so each frame starts at byte 0
|
|
2341
2536
|
for (frameNumber = 0; frameNumber < numberOfFrames; frameNumber++) {
|
|
@@ -2377,7 +2572,8 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2377
2572
|
}()
|
|
2378
2573
|
/**
|
|
2379
2574
|
* Reads raw binary data in chunks and delivers it to the listener.
|
|
2380
|
-
*
|
|
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.
|
|
2381
2577
|
*/
|
|
2382
2578
|
)
|
|
2383
2579
|
}, {
|
|
@@ -2390,7 +2586,7 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2390
2586
|
case 0:
|
|
2391
2587
|
length = tagInfo.length;
|
|
2392
2588
|
_context10.next = 1;
|
|
2393
|
-
return this._emitSplitValues(length);
|
|
2589
|
+
return this._emitSplitValues(length, this.wordWidth(tagInfo));
|
|
2394
2590
|
case 1:
|
|
2395
2591
|
case "end":
|
|
2396
2592
|
return _context10.stop();
|
|
@@ -2401,7 +2597,13 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2401
2597
|
return _readRawBinary.apply(this, arguments);
|
|
2402
2598
|
}
|
|
2403
2599
|
return readRawBinary;
|
|
2404
|
-
}())
|
|
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
|
+
}
|
|
2405
2607
|
}, {
|
|
2406
2608
|
key: "isSequence",
|
|
2407
2609
|
value: function isSequence(tagInfo) {
|
|
@@ -2416,14 +2618,15 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2416
2618
|
}, {
|
|
2417
2619
|
key: "readTagHeader",
|
|
2418
2620
|
value: function readTagHeader() {
|
|
2621
|
+
var _options$readSyntax;
|
|
2419
2622
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
2420
2623
|
untilTag: null,
|
|
2421
2624
|
includeUntilTagValue: false
|
|
2422
2625
|
};
|
|
2423
|
-
var stream = this.stream
|
|
2424
|
-
syntax = this.syntax;
|
|
2626
|
+
var stream = this.stream;
|
|
2425
2627
|
var untilTag = options.untilTag,
|
|
2426
2628
|
includeUntilTagValue = options.includeUntilTagValue;
|
|
2629
|
+
var syntax = (_options$readSyntax = options.readSyntax) !== null && _options$readSyntax !== void 0 ? _options$readSyntax : this.syntax;
|
|
2427
2630
|
var implicit = syntax == IMPLICIT_LITTLE_ENDIAN;
|
|
2428
2631
|
var isLittleEndian = syntax !== EXPLICIT_BIG_ENDIAN;
|
|
2429
2632
|
stream.setEndian(isLittleEndian);
|
|
@@ -2443,6 +2646,7 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2443
2646
|
var length = null;
|
|
2444
2647
|
var vr = null;
|
|
2445
2648
|
var vrType;
|
|
2649
|
+
var wireVrType = null;
|
|
2446
2650
|
var isCommand = tagObj.group() === 0;
|
|
2447
2651
|
if (tagObj.isInstruction()) {
|
|
2448
2652
|
length = stream.readUint32();
|
|
@@ -2453,13 +2657,13 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2453
2657
|
if (elementData) {
|
|
2454
2658
|
vrType = elementData.vr;
|
|
2455
2659
|
if (vrType === "xs") {
|
|
2456
|
-
var _this$
|
|
2660
|
+
var _this$listener2;
|
|
2457
2661
|
// The dictionary meta-VR "xs" ("US or SS") resolves via
|
|
2458
2662
|
// PixelRepresentation (PS3.5), exactly like the sync
|
|
2459
2663
|
// reader (DicomMessage._readTag). The listener's
|
|
2460
2664
|
// information filter tracks (0028,0103), which precedes
|
|
2461
2665
|
// every xs tag in tag order.
|
|
2462
|
-
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);
|
|
2463
2667
|
}
|
|
2464
2668
|
} else {
|
|
2465
2669
|
//unknown tag
|
|
@@ -2477,13 +2681,14 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2477
2681
|
} else {
|
|
2478
2682
|
var _DicomMessage$lookupT;
|
|
2479
2683
|
vrType = stream.readVR();
|
|
2684
|
+
wireVrType = vrType;
|
|
2480
2685
|
if (vrType === "UN" && (_DicomMessage$lookupT = DicomMessage.lookupTag(tagObj)) !== null && _DicomMessage$lookupT !== void 0 && _DicomMessage$lookupT.vr) {
|
|
2481
2686
|
vrType = DicomMessage.lookupTag(tagObj).vr;
|
|
2482
2687
|
if (vrType === "xs") {
|
|
2483
|
-
var _this$
|
|
2688
|
+
var _this$listener3;
|
|
2484
2689
|
// Same PixelRepresentation-driven US/SS resolution for
|
|
2485
2690
|
// explicit-VR UN elements whose dictionary VR is "xs".
|
|
2486
|
-
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);
|
|
2487
2692
|
}
|
|
2488
2693
|
vr = ValueRepresentation$1.parseUnknownVr(vrType);
|
|
2489
2694
|
} else {
|
|
@@ -2496,11 +2701,16 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2496
2701
|
length = stream.readUint16();
|
|
2497
2702
|
}
|
|
2498
2703
|
}
|
|
2704
|
+
var sequenceReadSyntax;
|
|
2705
|
+
if (!implicit && wireVrType === "UN" && isUnSequenceValue(stream.view, stream.offset, length, vr.type)) {
|
|
2706
|
+
vr = ValueRepresentation$1.createByTypeString("SQ");
|
|
2707
|
+
sequenceReadSyntax = IMPLICIT_LITTLE_ENDIAN;
|
|
2708
|
+
}
|
|
2499
2709
|
var punctuatedTag = DicomMetaDictionary.punctuateTag(tag);
|
|
2500
2710
|
var entry = DicomMetaDictionary.dictionary[punctuatedTag];
|
|
2501
2711
|
|
|
2502
2712
|
// Include both the string and object values for vr and tag
|
|
2503
|
-
var header = {
|
|
2713
|
+
var header = _objectSpread2({
|
|
2504
2714
|
vrObj: vr,
|
|
2505
2715
|
vr: vr.type,
|
|
2506
2716
|
tag: tag,
|
|
@@ -2508,7 +2718,9 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2508
2718
|
vm: entry === null || entry === void 0 ? void 0 : entry.vm,
|
|
2509
2719
|
name: entry === null || entry === void 0 ? void 0 : entry.name,
|
|
2510
2720
|
length: length === UNDEFINED_LENGTH ? -1 : length
|
|
2511
|
-
}
|
|
2721
|
+
}, sequenceReadSyntax && {
|
|
2722
|
+
sequenceReadSyntax: sequenceReadSyntax
|
|
2723
|
+
});
|
|
2512
2724
|
return header;
|
|
2513
2725
|
}
|
|
2514
2726
|
|
|
@@ -2522,12 +2734,14 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
2522
2734
|
key: "readSingle",
|
|
2523
2735
|
value: (function () {
|
|
2524
2736
|
var _readSingle = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(tagInfo, listener, options) {
|
|
2737
|
+
var _options$readSyntax2;
|
|
2525
2738
|
var length, stream, syntax, vr, values, times, i, _vr$read, value, _vr$read2, _value, delimiterChar, decoder, valuesForListener;
|
|
2526
2739
|
return _regeneratorRuntime().wrap(function (_context11) {
|
|
2527
2740
|
while (1) switch (_context11.prev = _context11.next) {
|
|
2528
2741
|
case 0:
|
|
2529
2742
|
length = tagInfo.length;
|
|
2530
|
-
stream = this.stream
|
|
2743
|
+
stream = this.stream;
|
|
2744
|
+
syntax = (_options$readSyntax2 = options === null || options === void 0 ? void 0 : options.readSyntax) !== null && _options$readSyntax2 !== void 0 ? _options$readSyntax2 : this.syntax;
|
|
2531
2745
|
_context11.next = 1;
|
|
2532
2746
|
return this.stream.ensureAvailable(length);
|
|
2533
2747
|
case 1:
|
|
@@ -3315,16 +3529,10 @@ var ImageNormalizer = /*#__PURE__*/function (_Normalizer) {
|
|
|
3315
3529
|
//
|
|
3316
3530
|
// shared
|
|
3317
3531
|
var SpacingBetweenSlices = Math.abs(distance1 - distance0);
|
|
3318
|
-
ds.SharedFunctionalGroupsSequence = {
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
PixelMeasuresSequence: {
|
|
3323
|
-
PixelSpacing: dataset0.PixelSpacing,
|
|
3324
|
-
SpacingBetweenSlices: SpacingBetweenSlices,
|
|
3325
|
-
SliceThickness: SpacingBetweenSlices
|
|
3326
|
-
}
|
|
3327
|
-
};
|
|
3532
|
+
ds.SharedFunctionalGroupsSequence = ImageNormalizer.sharedImagePlaneGroups(dataset0, {
|
|
3533
|
+
SpacingBetweenSlices: SpacingBetweenSlices,
|
|
3534
|
+
SliceThickness: SpacingBetweenSlices
|
|
3535
|
+
});
|
|
3328
3536
|
ds.ReferencedSeriesSequence = {
|
|
3329
3537
|
SeriesInstanceUID: dataset0.SeriesInstanceUID,
|
|
3330
3538
|
ReferencedInstanceSequence: []
|
|
@@ -3337,15 +3545,12 @@ var ImageNormalizer = /*#__PURE__*/function (_Normalizer) {
|
|
|
3337
3545
|
// and set the referenced series uid
|
|
3338
3546
|
distanceDatasetPairs.forEach(function (pair) {
|
|
3339
3547
|
var dataset = pair[1];
|
|
3340
|
-
ds.PerFrameFunctionalGroupsSequence.push({
|
|
3341
|
-
PlanePositionSequence: {
|
|
3342
|
-
ImagePositionPatient: dataset.ImagePositionPatient
|
|
3343
|
-
},
|
|
3548
|
+
ds.PerFrameFunctionalGroupsSequence.push(_objectSpread2(_objectSpread2({}, ImageNormalizer.planePositionGroup(dataset)), {}, {
|
|
3344
3549
|
FrameVOILUTSequence: {
|
|
3345
3550
|
WindowCenter: dataset.WindowCenter,
|
|
3346
3551
|
WindowWidth: dataset.WindowWidth
|
|
3347
3552
|
}
|
|
3348
|
-
});
|
|
3553
|
+
}));
|
|
3349
3554
|
ds.ReferencedSeriesSequence.ReferencedInstanceSequence.push({
|
|
3350
3555
|
ReferencedSOPClassUID: dataset.SOPClassUID,
|
|
3351
3556
|
ReferencedSOPInstanceUID: dataset.SOPInstanceUID
|
|
@@ -3363,6 +3568,22 @@ var ImageNormalizer = /*#__PURE__*/function (_Normalizer) {
|
|
|
3363
3568
|
DimensionDescriptionLabel: "ImagePositionPatient"
|
|
3364
3569
|
}];
|
|
3365
3570
|
}
|
|
3571
|
+
|
|
3572
|
+
/**
|
|
3573
|
+
* Fills in the functional groups of a multiframe dataset.
|
|
3574
|
+
*
|
|
3575
|
+
* A missing or empty SharedFunctionalGroupsSequence is built from the
|
|
3576
|
+
* top-level image plane attributes; a one-item array is used as its item.
|
|
3577
|
+
* The shared item gets the list accessors (addAccessors), so both
|
|
3578
|
+
* `SharedFunctionalGroupsSequence.X` and `SharedFunctionalGroupsSequence[0].X`
|
|
3579
|
+
* work.
|
|
3580
|
+
* The PerFrameFunctionalGroupsSequence is filled up to the declared
|
|
3581
|
+
* NumberOfFrames with items at the top-level position, existing items keep
|
|
3582
|
+
* their content, and each item without a FrameContentSequence gets one.
|
|
3583
|
+
* Added items share the position but get increasing InStackPositionNumber.
|
|
3584
|
+
* Items beyond NumberOfFrames are kept unchanged; a null item there is
|
|
3585
|
+
* skipped and does not throw.
|
|
3586
|
+
*/
|
|
3366
3587
|
}, {
|
|
3367
3588
|
key: "normalizeMultiframe",
|
|
3368
3589
|
value: function normalizeMultiframe() {
|
|
@@ -3386,9 +3607,18 @@ var ImageNormalizer = /*#__PURE__*/function (_Normalizer) {
|
|
|
3386
3607
|
if (!ds.PresentationLUTShape) {
|
|
3387
3608
|
ds.PresentationLUTShape = "IDENTITY";
|
|
3388
3609
|
}
|
|
3610
|
+
if (Array.isArray(ds.SharedFunctionalGroupsSequence)) {
|
|
3611
|
+
// The shared group has one item; an empty array counts as missing
|
|
3612
|
+
ds.SharedFunctionalGroupsSequence = ds.SharedFunctionalGroupsSequence[0];
|
|
3613
|
+
}
|
|
3389
3614
|
if (!ds.SharedFunctionalGroupsSequence) {
|
|
3390
|
-
log.
|
|
3615
|
+
log.warn("Missing SharedFunctionalGroupsSequence; using the top-level image plane attributes");
|
|
3616
|
+
ds.SharedFunctionalGroupsSequence = ImageNormalizer.sharedImagePlaneGroups(ds, {
|
|
3617
|
+
SliceThickness: ds.SliceThickness,
|
|
3618
|
+
SpacingBetweenSlices: ds.SpacingBetweenSlices
|
|
3619
|
+
});
|
|
3391
3620
|
}
|
|
3621
|
+
ds.SharedFunctionalGroupsSequence = addAccessors(ds.SharedFunctionalGroupsSequence);
|
|
3392
3622
|
|
|
3393
3623
|
// TODO: special case!
|
|
3394
3624
|
if (ds.BodyPartExamined === "PROSTATE") {
|
|
@@ -3408,10 +3638,20 @@ var ImageNormalizer = /*#__PURE__*/function (_Normalizer) {
|
|
|
3408
3638
|
RescaleSlope: rescaleSlope,
|
|
3409
3639
|
RescaleType: "US"
|
|
3410
3640
|
};
|
|
3411
|
-
var
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3641
|
+
var frameCount = Math.max(this.datasets.length, Number(ds.NumberOfFrames) || 0);
|
|
3642
|
+
var perFrame = ds.PerFrameFunctionalGroupsSequence || [];
|
|
3643
|
+
ds.PerFrameFunctionalGroupsSequence = Array.isArray(perFrame) ? perFrame : [perFrame];
|
|
3644
|
+
while (ds.PerFrameFunctionalGroupsSequence.length < frameCount) {
|
|
3645
|
+
ds.PerFrameFunctionalGroupsSequence.push(ImageNormalizer.planePositionGroup(ds));
|
|
3646
|
+
}
|
|
3647
|
+
for (var frameNumber = 1; frameNumber <= frameCount; frameNumber++) {
|
|
3648
|
+
var _ds$PerFrameFunctiona, _ref;
|
|
3649
|
+
var item = (_ds$PerFrameFunctiona = ds.PerFrameFunctionalGroupsSequence)[_ref = frameNumber - 1] || (_ds$PerFrameFunctiona[_ref] = {});
|
|
3650
|
+
if (item.FrameContentSequence) {
|
|
3651
|
+
continue;
|
|
3652
|
+
}
|
|
3653
|
+
var dataset = this.datasets[frameNumber - 1] || {};
|
|
3654
|
+
item.FrameContentSequence = {
|
|
3415
3655
|
FrameAcquisitionDuration: 0,
|
|
3416
3656
|
StackID: 1,
|
|
3417
3657
|
InStackPositionNumber: frameNumber,
|
|
@@ -3419,12 +3659,10 @@ var ImageNormalizer = /*#__PURE__*/function (_Normalizer) {
|
|
|
3419
3659
|
};
|
|
3420
3660
|
var frameTime = dataset.AcquisitionDate + dataset.AcquisitionTime;
|
|
3421
3661
|
if (!isNaN(frameTime)) {
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
frameContentSequence.FrameReferenceDateTime = frameTime;
|
|
3662
|
+
item.FrameContentSequence.FrameAcquisitionDateTime = frameTime;
|
|
3663
|
+
item.FrameContentSequence.FrameReferenceDateTime = frameTime;
|
|
3425
3664
|
}
|
|
3426
|
-
|
|
3427
|
-
});
|
|
3665
|
+
}
|
|
3428
3666
|
|
|
3429
3667
|
//
|
|
3430
3668
|
// TODO: convert this to shared functional group not top level element
|
|
@@ -3450,7 +3688,7 @@ var ImageNormalizer = /*#__PURE__*/function (_Normalizer) {
|
|
|
3450
3688
|
count: 0
|
|
3451
3689
|
};
|
|
3452
3690
|
ds.PerFrameFunctionalGroupsSequence.forEach(function (functionalGroup) {
|
|
3453
|
-
if (functionalGroup.FrameVOILUT) {
|
|
3691
|
+
if (functionalGroup !== null && functionalGroup !== void 0 && functionalGroup.FrameVOILUT) {
|
|
3454
3692
|
var wc = functionalGroup.FrameVOILUTSequence.WindowCenter;
|
|
3455
3693
|
var ww = functionalGroup.FrameVOILUTSequence.WindowWidth;
|
|
3456
3694
|
if (functionalGroup.FrameVOILUTSequence && wc && ww) {
|
|
@@ -3509,6 +3747,29 @@ var ImageNormalizer = /*#__PURE__*/function (_Normalizer) {
|
|
|
3509
3747
|
value: function vec3Dot(a, b) {
|
|
3510
3748
|
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
3511
3749
|
}
|
|
3750
|
+
}, {
|
|
3751
|
+
key: "sharedImagePlaneGroups",
|
|
3752
|
+
value: function sharedImagePlaneGroups(dataset, pixelMeasures) {
|
|
3753
|
+
return {
|
|
3754
|
+
PlaneOrientationSequence: {
|
|
3755
|
+
ImageOrientationPatient: dataset.ImageOrientationPatient
|
|
3756
|
+
},
|
|
3757
|
+
PixelMeasuresSequence: _objectSpread2({
|
|
3758
|
+
PixelSpacing: dataset.PixelSpacing
|
|
3759
|
+
}, pixelMeasures)
|
|
3760
|
+
};
|
|
3761
|
+
}
|
|
3762
|
+
}, {
|
|
3763
|
+
key: "planePositionGroup",
|
|
3764
|
+
value: function planePositionGroup(dataset) {
|
|
3765
|
+
var position = dataset.ImagePositionPatient;
|
|
3766
|
+
return {
|
|
3767
|
+
PlanePositionSequence: {
|
|
3768
|
+
// A copy, so that no two frames share one array
|
|
3769
|
+
ImagePositionPatient: Array.isArray(position) ? position.slice() : position
|
|
3770
|
+
}
|
|
3771
|
+
};
|
|
3772
|
+
}
|
|
3512
3773
|
}]);
|
|
3513
3774
|
}(Normalizer);
|
|
3514
3775
|
var MRImageNormalizer = /*#__PURE__*/function (_ImageNormalizer) {
|
|
@@ -6297,7 +6558,7 @@ function h(matrix) {
|
|
|
6297
6558
|
var _matrix$shape = _slicedToArray(matrix.shape, 2),
|
|
6298
6559
|
rows = _matrix$shape[0],
|
|
6299
6560
|
cols = _matrix$shape[1];
|
|
6300
|
-
var result = ndarray(new
|
|
6561
|
+
var result = ndarray(new matrix.data.constructor(rows * cols), [rows, cols]);
|
|
6301
6562
|
for (var i = 0; i < rows; i++) {
|
|
6302
6563
|
for (var j = 0; j < cols; j++) {
|
|
6303
6564
|
result.set(i, j, matrix.get(i, cols - 1 - j));
|
|
@@ -6316,7 +6577,7 @@ function v(matrix) {
|
|
|
6316
6577
|
var _matrix$shape2 = _slicedToArray(matrix.shape, 2),
|
|
6317
6578
|
rows = _matrix$shape2[0],
|
|
6318
6579
|
cols = _matrix$shape2[1];
|
|
6319
|
-
var result = ndarray(new
|
|
6580
|
+
var result = ndarray(new matrix.data.constructor(rows * cols), [rows, cols]);
|
|
6320
6581
|
for (var j = 0; j < cols; j++) {
|
|
6321
6582
|
for (var i = 0; i < rows; i++) {
|
|
6322
6583
|
result.set(i, j, matrix.get(rows - 1 - i, j));
|
|
@@ -6335,7 +6596,7 @@ function rotateMatrix902D (matrix) {
|
|
|
6335
6596
|
var _matrix$shape = _slicedToArray(matrix.shape, 2),
|
|
6336
6597
|
rows = _matrix$shape[0],
|
|
6337
6598
|
cols = _matrix$shape[1];
|
|
6338
|
-
var result = ndarray(new
|
|
6599
|
+
var result = ndarray(new matrix.data.constructor(rows * cols), [cols, rows]);
|
|
6339
6600
|
var resultColsMinus1 = result.shape[1] - 1;
|
|
6340
6601
|
for (var i = 0; i < rows; i++) {
|
|
6341
6602
|
for (var j = 0; j < cols; j++) {
|
|
@@ -11972,12 +12233,8 @@ var Cornerstone3D = {
|
|
|
11972
12233
|
CORNERSTONE_3D_TAG: CORNERSTONE_3D_TAG
|
|
11973
12234
|
};
|
|
11974
12235
|
|
|
11975
|
-
// TODO: Is there a better name for this? RGBAInt?
|
|
11976
|
-
// Should we move it to Colors.js
|
|
11977
12236
|
function dicomlab2RGBA(cielab) {
|
|
11978
|
-
var rgba = Colors.
|
|
11979
|
-
return Math.round(x * 255);
|
|
11980
|
-
});
|
|
12237
|
+
var rgba = Colors.dicomlab2RGB8(cielab);
|
|
11981
12238
|
rgba.push(255);
|
|
11982
12239
|
return rgba;
|
|
11983
12240
|
}
|
|
@@ -12621,6 +12878,11 @@ var DICOMMicroscopyViewer = {
|
|
|
12621
12878
|
MeasurementReport: MeasurementReport$1
|
|
12622
12879
|
};
|
|
12623
12880
|
|
|
12881
|
+
/**
|
|
12882
|
+
* @deprecated The adapters moved to `@cornerstonejs/adapters`. Import them
|
|
12883
|
+
* from that package. `@dcmjs-org/dcmjs` keeps this export only for
|
|
12884
|
+
* compatibility with 0.x, and a later major release removes it.
|
|
12885
|
+
*/
|
|
12624
12886
|
var adapters = {
|
|
12625
12887
|
Cornerstone: Cornerstone,
|
|
12626
12888
|
Cornerstone3D: Cornerstone3D,
|
|
@@ -15673,11 +15935,12 @@ var constants = /*#__PURE__*/Object.freeze({
|
|
|
15673
15935
|
});
|
|
15674
15936
|
|
|
15675
15937
|
// Every entry below must be a real dictionary keyword
|
|
15676
|
-
// (DicomMetaDictionary.
|
|
15938
|
+
// (DicomMetaDictionary.entryForName()): cleanTags silently skips names that do not
|
|
15677
15939
|
// resolve, so a misspelled entry means the data it was meant to scrub is
|
|
15678
15940
|
// left in place (issue #345). Retired attributes use the dictionary's
|
|
15679
15941
|
// RETIRED_ keyword prefix. All 103 previously non-resolving names were
|
|
15680
15942
|
// mapped to their intended keywords; none had to be removed.
|
|
15943
|
+
// ResponsiblePersonRole was added to match 0.53.3.
|
|
15681
15944
|
var tagNamesToEmpty = [
|
|
15682
15945
|
// please override these in specificReplaceDefaults to have useful values
|
|
15683
15946
|
"PatientID", "PatientName",
|
|
@@ -15690,7 +15953,7 @@ var tagNamesToEmpty = [
|
|
|
15690
15953
|
// cat 2/3: CTP: set to increment dates
|
|
15691
15954
|
"InstanceCreationDate", "StudyDate", "ContentDate", "DateOfSecondaryCapture", "DateOfLastCalibration", "DateOfLastDetectorCalibration", "FrameAcquisitionDateTime", "FrameReferenceDateTime", "RETIRED_StudyVerifiedDate", "RETIRED_StudyReadDate", "RETIRED_ScheduledStudyStartDate", "RETIRED_ScheduledStudyStopDate", "RETIRED_StudyArrivalDate", "RETIRED_StudyCompletionDate", "RETIRED_ScheduledAdmissionDate", "RETIRED_ScheduledDischargeDate", "RETIRED_DischargeDate", "ScheduledProcedureStepStartDate", "ScheduledProcedureStepEndDate", "PerformedProcedureStepStartDate", "PerformedProcedureStepEndDate", "IssueDateOfImagingServiceRequest", "VerificationDateTime", "ObservationDateTime", "DateTime", "Date", "ReferencedDateTime",
|
|
15692
15955
|
// cat 3/3: CTP: set to remove using @remove
|
|
15693
|
-
"AcquisitionDate", "RETIRED_OverlayDate", "RETIRED_CurveDate", "AcquisitionDateTime", "SeriesTime", "AcquisitionTime", "RETIRED_OverlayTime", "RETIRED_CurveTime", "InstitutionName", "InstitutionAddress", "ReferringPhysicianAddress", "ReferringPhysicianTelephoneNumbers", "ReferringPhysicianIdentificationSequence", "TimezoneOffsetFromUTC", "StationName", "StudyDescription", "InstitutionalDepartmentName", "PhysiciansOfRecord", "PhysiciansOfRecordIdentificationSequence", "PerformingPhysicianName", "PerformingPhysicianIdentificationSequence", "NameOfPhysiciansReadingStudy", "PhysiciansReadingStudyIdentificationSequence", "OperatorsName", "OperatorIdentificationSequence", "AdmittingDiagnosesDescription", "AdmittingDiagnosesCodeSequence", "ReferencedStudySequence", "ReferencedPerformedProcedureStepSequence", "ReferencedPatientSequence", "ReferencedImageSequence", "DerivationDescription", "SourceImageSequence", "RETIRED_IdentifyingComments", "IssuerOfPatientID", "PatientBirthTime", "PatientInsurancePlanCodeSequence", "PatientPrimaryLanguageCodeSequence", "PatientPrimaryLanguageModifierCodeSequence", "OtherPatientIDs", "OtherPatientNames", "OtherPatientIDsSequence", "PatientBirthName", "PatientAge", "PatientSize", "PatientWeight", "PatientAddress", "RETIRED_InsurancePlanIdentification", "PatientMotherBirthName", "MilitaryRank", "BranchOfService", "MedicalRecordLocator", "MedicalAlerts", "Allergies", "CountryOfResidence", "RegionOfResidence", "PatientTelephoneNumbers", "EthnicGroup", "Occupation", "SmokingStatus", "AdditionalPatientHistory", "PregnancyStatus", "LastMenstrualDate", "PatientReligiousPreference", "PatientSexNeutered", "ResponsiblePerson", "ResponsibleOrganization", "PatientComments", "DeviceSerialNumber", "PlateID", "GeneratorID", "CassetteID", "GantryID",
|
|
15956
|
+
"AcquisitionDate", "RETIRED_OverlayDate", "RETIRED_CurveDate", "AcquisitionDateTime", "SeriesTime", "AcquisitionTime", "RETIRED_OverlayTime", "RETIRED_CurveTime", "InstitutionName", "InstitutionAddress", "ReferringPhysicianAddress", "ReferringPhysicianTelephoneNumbers", "ReferringPhysicianIdentificationSequence", "TimezoneOffsetFromUTC", "StationName", "StudyDescription", "InstitutionalDepartmentName", "PhysiciansOfRecord", "PhysiciansOfRecordIdentificationSequence", "PerformingPhysicianName", "PerformingPhysicianIdentificationSequence", "NameOfPhysiciansReadingStudy", "PhysiciansReadingStudyIdentificationSequence", "OperatorsName", "OperatorIdentificationSequence", "AdmittingDiagnosesDescription", "AdmittingDiagnosesCodeSequence", "ReferencedStudySequence", "ReferencedPerformedProcedureStepSequence", "ReferencedPatientSequence", "ReferencedImageSequence", "DerivationDescription", "SourceImageSequence", "RETIRED_IdentifyingComments", "IssuerOfPatientID", "PatientBirthTime", "PatientInsurancePlanCodeSequence", "PatientPrimaryLanguageCodeSequence", "PatientPrimaryLanguageModifierCodeSequence", "OtherPatientIDs", "OtherPatientNames", "OtherPatientIDsSequence", "PatientBirthName", "PatientAge", "PatientSize", "PatientWeight", "PatientAddress", "RETIRED_InsurancePlanIdentification", "PatientMotherBirthName", "MilitaryRank", "BranchOfService", "MedicalRecordLocator", "MedicalAlerts", "Allergies", "CountryOfResidence", "RegionOfResidence", "PatientTelephoneNumbers", "EthnicGroup", "Occupation", "SmokingStatus", "AdditionalPatientHistory", "PregnancyStatus", "LastMenstrualDate", "PatientReligiousPreference", "PatientSexNeutered", "ResponsiblePerson", "ResponsiblePersonRole", "ResponsibleOrganization", "PatientComments", "DeviceSerialNumber", "PlateID", "GeneratorID", "CassetteID", "GantryID",
|
|
15694
15957
|
// we keep - should be SoftwareVersions anyway
|
|
15695
15958
|
// "SoftwareVersion",
|
|
15696
15959
|
"ProtocolName", "AcquisitionDeviceProcessingDescription", "RETIRED_AcquisitionComments", "DetectorID", "AcquisitionProtocolDescription", "ContributionDescription", "RETIRED_ModifyingDeviceID", "RETIRED_ModifyingDeviceManufacturer", "RETIRED_ModifiedImageDescription", "ImageComments", "RETIRED_ImagePresentationComments", "RETIRED_StudyIDIssuer", "RETIRED_ScheduledStudyLocation", "RETIRED_ScheduledStudyLocationAETitle", "RETIRED_ReasonForStudy", "RequestingPhysician", "RequestingService", "RequestedProcedureDescription", "RequestedContrastAgent", "RETIRED_StudyComments", "AdmissionID", "RETIRED_IssuerOfAdmissionID", "RETIRED_ScheduledPatientInstitutionResidence", "AdmittingDate", "AdmittingTime", "RETIRED_DischargeDiagnosisDescription", "SpecialNeeds", "ServiceEpisodeID", "RETIRED_IssuerOfServiceEpisodeID", "ServiceEpisodeDescription", "CurrentPatientLocation", "PatientInstitutionResidence", "PatientState", "ReferencedPatientAliasSequence", "VisitComments", "ScheduledStationAETitle", "ScheduledPerformingPhysicianName", "ScheduledProcedureStepDescription", "ScheduledStationName", "ScheduledProcedureStepLocation", "PreMedication", "PerformedStationAETitle", "PerformedStationName", "PerformedLocation", "PerformedStationNameCodeSequence", "PerformedProcedureStepID", "PerformedProcedureStepDescription", "RequestAttributesSequence", "CommentsOnThePerformedProcedureStep", "AcquisitionContextSequence", "PatientTransportArrangements", "RequestedProcedureLocation", "NamesOfIntendedRecipientsOfResults", "IntendedRecipientsOfResultsIdentificationSequence", "PersonAddress", "PersonTelephoneNumbers", "RequestedProcedureComments", "RETIRED_ReasonForTheImagingServiceRequest", "OrderEnteredBy", "OrderEntererLocation", "OrderCallbackPhoneNumber", "ImagingServiceRequestComments", "ConfidentialityConstraintOnPatientDataDescription", "ScheduledStationNameCodeSequence", "ScheduledStationGeographicLocationCodeSequence", "PerformedStationGeographicLocationCodeSequence", "ScheduledHumanPerformersSequence", "ActualHumanPerformersSequence", "HumanPerformerOrganization", "HumanPerformerName", "VerifyingOrganization", "VerifyingObserverName", "AuthorObserverSequence", "ParticipantSequence", "CustodialOrganizationSequence", "VerifyingObserverIdentificationCodeSequence", "PersonName", "ContentSequence", "OverlayData", "RETIRED_OverlayComments", "IconImageSequence", "RETIRED_TopicSubject", "RETIRED_TopicAuthor", "RETIRED_TopicKeywords", "TextString", "RETIRED_Arbitrary", "RETIRED_TextComments", "RETIRED_ResultsIDIssuer", "RETIRED_InterpretationRecorder", "RETIRED_InterpretationTranscriber", "RETIRED_InterpretationText", "RETIRED_InterpretationAuthor", "RETIRED_InterpretationApproverSequence", "RETIRED_PhysicianApprovingInterpretation", "RETIRED_InterpretationDiagnosisDescription", "RETIRED_ResultsDistributionListSequence", "RETIRED_DistributionName", "RETIRED_DistributionAddress", "RETIRED_InterpretationIDIssuer", "RETIRED_Impressions", "RETIRED_ResultsComments", "DigitalSignaturesSequence", "DataSetTrailingPadding"];
|
|
@@ -15708,7 +15971,7 @@ function cleanTags(dict) {
|
|
|
15708
15971
|
}
|
|
15709
15972
|
var tags = customTagNamesToEmpty != undefined ? customTagNamesToEmpty : tagNamesToEmpty;
|
|
15710
15973
|
tags.forEach(function (tag) {
|
|
15711
|
-
var tagInfo = DicomMetaDictionary.
|
|
15974
|
+
var tagInfo = DicomMetaDictionary.entryForName(tag);
|
|
15712
15975
|
if (tagInfo && tagInfo.version != "PrivateTag") {
|
|
15713
15976
|
var tagNumber = tagInfo.tag,
|
|
15714
15977
|
tagString = Tag.fromPString(tagNumber).toCleanString();
|
|
@@ -15745,12 +16008,18 @@ var data = {
|
|
|
15745
16008
|
datasetToDict: datasetToDict,
|
|
15746
16009
|
datasetToBuffer: datasetToBuffer,
|
|
15747
16010
|
datasetToBlob: datasetToBlob,
|
|
16011
|
+
dictionary: dictionary,
|
|
16012
|
+
registerTag: registerTag,
|
|
15748
16013
|
// naturalized-dataset utilities (docs/specs/naturalized-dataset.md)
|
|
15749
16014
|
setVr: setVr,
|
|
15750
16015
|
setAttribute: setAttribute,
|
|
15751
16016
|
setPersonName: setPersonName,
|
|
15752
16017
|
definePrivateAliases: definePrivateAliases,
|
|
15753
|
-
frameDataset: frameDataset
|
|
16018
|
+
frameDataset: frameDataset,
|
|
16019
|
+
// private blocks of a DICOM JSON dict (NAT-U-PRIV-11)
|
|
16020
|
+
findPrivateBlock: findPrivateBlock,
|
|
16021
|
+
reservePrivateBlock: reservePrivateBlock,
|
|
16022
|
+
privateBlockKey: privateBlockKey
|
|
15754
16023
|
};
|
|
15755
16024
|
var async = {
|
|
15756
16025
|
AsyncDicomReader: AsyncDicomReader
|
|
@@ -15798,4 +16067,4 @@ ValueRepresentation.setTagClass(Tag);
|
|
|
15798
16067
|
// entries (src/eventStream.js, ...): the default entry is the 0.52 surface.
|
|
15799
16068
|
|
|
15800
16069
|
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 };
|
|
15801
|
-
//# sourceMappingURL=dcmjs.shared-
|
|
16070
|
+
//# sourceMappingURL=dcmjs.shared-oZ6PMYsB.js.map
|