@dcmjs-org/dcmjs 1.0.0-beta.7 → 1.0.0-beta.9
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 +189 -4
- 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-i-QMVPJh.cjs → dcmjs.shared-CvR7StGL.cjs} +3 -2
- package/build/{dcmjs.shared-i-QMVPJh.cjs.map → dcmjs.shared-CvR7StGL.cjs.map} +1 -1
- package/build/{dcmjs.shared-C5jsZ5KD.js → dcmjs.shared-DzVDSFp8.js} +4 -3
- package/build/{dcmjs.shared-C5jsZ5KD.js.map → dcmjs.shared-DzVDSFp8.js.map} +1 -1
- package/build/eventStream.cjs +1 -1
- package/build/eventStream.es.js +1 -1
- package/package.json +7 -7
package/build/dcmjs.cjs
CHANGED
package/build/dcmjs.es.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { D as DICOMWEB, j as adapters, k as anonymizer, l as async, m as constants, n as data, o as default, p as derivations, q as normalizers, s as sr, u as utilities } from './dcmjs.shared-
|
|
1
|
+
export { D as DICOMWEB, j as adapters, k as anonymizer, l as async, m as constants, n as data, o as default, p as derivations, q as normalizers, s as sr, u as utilities } from './dcmjs.shared-DzVDSFp8.js';
|
|
2
2
|
export { log } from '@dcmjs-org/core';
|
|
3
3
|
//# sourceMappingURL=dcmjs.es.js.map
|
package/build/dcmjs.js
CHANGED
|
@@ -9760,6 +9760,11 @@
|
|
|
9760
9760
|
value: function isBinary() {
|
|
9761
9761
|
return this._isBinary;
|
|
9762
9762
|
}
|
|
9763
|
+
}, {
|
|
9764
|
+
key: "isString",
|
|
9765
|
+
value: function isString() {
|
|
9766
|
+
return false;
|
|
9767
|
+
}
|
|
9763
9768
|
}, {
|
|
9764
9769
|
key: "allowMultiple",
|
|
9765
9770
|
value: function allowMultiple() {
|
|
@@ -9859,6 +9864,13 @@
|
|
|
9859
9864
|
var readOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
|
|
9860
9865
|
forceStoreRaw: false
|
|
9861
9866
|
};
|
|
9867
|
+
// a zero-length string element has no value, not one empty value
|
|
9868
|
+
if (length === 0 && this.isString()) {
|
|
9869
|
+
return {
|
|
9870
|
+
rawValue: [],
|
|
9871
|
+
value: []
|
|
9872
|
+
};
|
|
9873
|
+
}
|
|
9862
9874
|
if (this.fixed && this.maxLength) {
|
|
9863
9875
|
if (!length) return {
|
|
9864
9876
|
rawValue: this.defaultValue,
|
|
@@ -10085,6 +10097,11 @@
|
|
|
10085
10097
|
}
|
|
10086
10098
|
_inherits(AsciiStringRepresentation, _ValueRepresentation);
|
|
10087
10099
|
return _createClass(AsciiStringRepresentation, [{
|
|
10100
|
+
key: "isString",
|
|
10101
|
+
value: function isString() {
|
|
10102
|
+
return true;
|
|
10103
|
+
}
|
|
10104
|
+
}, {
|
|
10088
10105
|
key: "readBytes",
|
|
10089
10106
|
value: function readBytes(stream, length) {
|
|
10090
10107
|
return stream.readAsciiString(length);
|
|
@@ -10104,6 +10121,11 @@
|
|
|
10104
10121
|
}
|
|
10105
10122
|
_inherits(EncodedStringRepresentation, _ValueRepresentation2);
|
|
10106
10123
|
return _createClass(EncodedStringRepresentation, [{
|
|
10124
|
+
key: "isString",
|
|
10125
|
+
value: function isString() {
|
|
10126
|
+
return true;
|
|
10127
|
+
}
|
|
10128
|
+
}, {
|
|
10107
10129
|
key: "readBytes",
|
|
10108
10130
|
value: function readBytes(stream, length) {
|
|
10109
10131
|
return stream.readEncodedString(length);
|
|
@@ -12830,7 +12852,7 @@
|
|
|
12830
12852
|
*/
|
|
12831
12853
|
|
|
12832
12854
|
var BLOCK_KEY = /^([0-9A-Fa-f]{4}):(.+)$/;
|
|
12833
|
-
var ELEMENT_KEY = /^x([0-9A-Fa-f]{2})$/;
|
|
12855
|
+
var ELEMENT_KEY$1 = /^x([0-9A-Fa-f]{2})$/;
|
|
12834
12856
|
var HEX_TAG = /^[0-9A-Fa-f]{8}$/;
|
|
12835
12857
|
|
|
12836
12858
|
/** True for an 8-digit hex tag key, for example "00291001". */
|
|
@@ -12986,7 +13008,7 @@
|
|
|
12986
13008
|
onDataset("".concat(group, "00").concat(xx), key, null);
|
|
12987
13009
|
var _loop2 = function _loop2() {
|
|
12988
13010
|
var elementKey = _Object$keys3[_i3];
|
|
12989
|
-
var match = ELEMENT_KEY.exec(elementKey);
|
|
13011
|
+
var match = ELEMENT_KEY$1.exec(elementKey);
|
|
12990
13012
|
if (!match) return 1; // continue
|
|
12991
13013
|
var ee = match[1].toUpperCase();
|
|
12992
13014
|
var tag = "".concat(group).concat(xx).concat(ee);
|
|
@@ -13361,7 +13383,7 @@
|
|
|
13361
13383
|
if (elementKey === "creator" || elementKey === "reservedBlock") {
|
|
13362
13384
|
continue;
|
|
13363
13385
|
}
|
|
13364
|
-
var match = ELEMENT_KEY.exec(elementKey);
|
|
13386
|
+
var match = ELEMENT_KEY$1.exec(elementKey);
|
|
13365
13387
|
if (!match) {
|
|
13366
13388
|
log.warn("Unknown name in private block ".concat(key, ":"), elementKey);
|
|
13367
13389
|
continue;
|
|
@@ -14652,6 +14674,168 @@
|
|
|
14652
14674
|
fileStream.writeRawBytes(pako.deflateRaw(new Uint8Array(bodyStream.getBuffer())));
|
|
14653
14675
|
}
|
|
14654
14676
|
|
|
14677
|
+
var ELEMENT_KEY = /^x[0-9A-Fa-f]{2}$/;
|
|
14678
|
+
|
|
14679
|
+
/**
|
|
14680
|
+
* The view of one frame of a multi-frame naturalized dataset (PS3.3
|
|
14681
|
+
* C.7.6.16): the root attributes, then the attributes of the shared
|
|
14682
|
+
* functional groups, then the attributes of the per-frame functional groups
|
|
14683
|
+
* of that frame. A later level replaces an attribute of an earlier level.
|
|
14684
|
+
*
|
|
14685
|
+
* - The view is built when NumberOfFrames is above 1, or when it is 1 or
|
|
14686
|
+
* more and the dataset has a functional group sequence. A functional group
|
|
14687
|
+
* sequence can be missing or empty: the view then holds only the computed
|
|
14688
|
+
* attributes, for example the defaults of a multi-frame image that is not
|
|
14689
|
+
* enhanced. Any other dataset comes back unchanged, and the option
|
|
14690
|
+
* functions do not run.
|
|
14691
|
+
* - `frameNumber` is 1-based, and a numeric string is accepted. A frame
|
|
14692
|
+
* number that is not an integer from 1 to NumberOfFrames throws a
|
|
14693
|
+
* RangeError. A frame with no per-frame item reads the shared item and
|
|
14694
|
+
* the root.
|
|
14695
|
+
* - Each standard sequence (functional group macro) in a functional group
|
|
14696
|
+
* item gives the attributes of its first item. An item that holds a
|
|
14697
|
+
* SOPInstanceUID is reference or previous value data, and is skipped.
|
|
14698
|
+
* - A private block or a private hex-tag key directly in a functional group
|
|
14699
|
+
* item is skipped. With `options.privateMacros`, each private sequence
|
|
14700
|
+
* there (an SQ in `_vrMap`) is a macro too. A private block inside a macro
|
|
14701
|
+
* item is an attribute of the frame: it replaces a root block with the
|
|
14702
|
+
* same key, and its hex aliases read the frame's block.
|
|
14703
|
+
* - The view is an `Object.create` child of `dataset`. The functional group
|
|
14704
|
+
* attributes are its own keys, with their VRs in an own `_vrMap`, so
|
|
14705
|
+
* `denaturalizeDataset(view)` writes only those attributes. Root
|
|
14706
|
+
* attributes are inherited, so a change to the root shows in the view.
|
|
14707
|
+
* - `options.frameAttributes(view, { dataset, frameNumber })` returns the
|
|
14708
|
+
* computed attributes of the frame, for example an ImagePositionPatient
|
|
14709
|
+
* that a modality gives in another place. They become own enumerable keys
|
|
14710
|
+
* of the view and replace the merged values.
|
|
14711
|
+
* - `options.frameProperties(view, { dataset, frameNumber })` returns the
|
|
14712
|
+
* runtime properties of the frame, for example `frameNumber` or `imageId`.
|
|
14713
|
+
* They become own non-enumerable properties, so JSON and denaturalize
|
|
14714
|
+
* skip them.
|
|
14715
|
+
* - The views are cached on `dataset` in the non-enumerable
|
|
14716
|
+
* `_frameDatasets`, per set of options: pass the same function objects on
|
|
14717
|
+
* each call to use the cache. A change to a functional group item does not
|
|
14718
|
+
* show in a cached view: `delete dataset._frameDatasets` to rebuild the
|
|
14719
|
+
* views.
|
|
14720
|
+
*
|
|
14721
|
+
* docs/specs/naturalized-dataset.md (NAT-U-FRAME, NAT-I-FRAME) is the
|
|
14722
|
+
* specification.
|
|
14723
|
+
*
|
|
14724
|
+
* @param {Object} dataset - a naturalized dataset
|
|
14725
|
+
* @param {number|string} [frameNumber=1] - the 1-based frame number
|
|
14726
|
+
* @param {Object} [options]
|
|
14727
|
+
* @param {Function} [options.frameAttributes] - computed attributes
|
|
14728
|
+
* @param {Function} [options.frameProperties] - runtime properties
|
|
14729
|
+
* @param {boolean} [options.privateMacros=false] - read private macros
|
|
14730
|
+
* @returns {Object} the frame view, or `dataset`
|
|
14731
|
+
*/
|
|
14732
|
+
function frameDataset(dataset) {
|
|
14733
|
+
var frameNumber = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
14734
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
14735
|
+
var NumberOfFrames = dataset.NumberOfFrames,
|
|
14736
|
+
shared = dataset.SharedFunctionalGroupsSequence,
|
|
14737
|
+
perFrame = dataset.PerFrameFunctionalGroupsSequence;
|
|
14738
|
+
var frames = Number(NumberOfFrames);
|
|
14739
|
+
if (!(frames > 1 || frames > 0 && (shared || perFrame))) {
|
|
14740
|
+
return dataset;
|
|
14741
|
+
}
|
|
14742
|
+
frameNumber = Number(frameNumber);
|
|
14743
|
+
if (!Number.isInteger(frameNumber) || frameNumber < 1 || frameNumber > frames) {
|
|
14744
|
+
throw new RangeError("Frame number ".concat(frameNumber, " is not in 1 to ").concat(frames));
|
|
14745
|
+
}
|
|
14746
|
+
if (!Object.prototype.hasOwnProperty.call(dataset, "_frameDatasets")) {
|
|
14747
|
+
Object.defineProperty(dataset, "_frameDatasets", {
|
|
14748
|
+
value: new Map(),
|
|
14749
|
+
configurable: true
|
|
14750
|
+
});
|
|
14751
|
+
}
|
|
14752
|
+
var frameAttributes = options.frameAttributes,
|
|
14753
|
+
frameProperties = options.frameProperties,
|
|
14754
|
+
_options$privateMacro = options.privateMacros,
|
|
14755
|
+
privateMacros = _options$privateMacro === void 0 ? false : _options$privateMacro;
|
|
14756
|
+
var views = entry(entry(entry(dataset._frameDatasets, frameAttributes, Map), frameProperties, Map), privateMacros, Array);
|
|
14757
|
+
if (views[frameNumber]) return views[frameNumber];
|
|
14758
|
+
var view = Object.create(dataset);
|
|
14759
|
+
view._vrMap = _objectSpread2({}, dataset._vrMap);
|
|
14760
|
+
addFunctionalGroups(view, shared === null || shared === void 0 ? void 0 : shared[0], privateMacros);
|
|
14761
|
+
addFunctionalGroups(view, perFrame === null || perFrame === void 0 ? void 0 : perFrame[frameNumber - 1], privateMacros);
|
|
14762
|
+
var context = {
|
|
14763
|
+
dataset: dataset,
|
|
14764
|
+
frameNumber: frameNumber
|
|
14765
|
+
};
|
|
14766
|
+
defineValues(view, frameAttributes === null || frameAttributes === void 0 ? void 0 : frameAttributes(view, context), true);
|
|
14767
|
+
defineValues(view, frameProperties === null || frameProperties === void 0 ? void 0 : frameProperties(view, context), false);
|
|
14768
|
+
definePrivateAliases(view);
|
|
14769
|
+
views[frameNumber] = view;
|
|
14770
|
+
return view;
|
|
14771
|
+
}
|
|
14772
|
+
function entry(map, key, Type) {
|
|
14773
|
+
if (!map.has(key)) map.set(key, new Type());
|
|
14774
|
+
return map.get(key);
|
|
14775
|
+
}
|
|
14776
|
+
|
|
14777
|
+
// a plain own value: an inherited alias or PN setter must not run
|
|
14778
|
+
function defineValue(view, name, value, enumerable) {
|
|
14779
|
+
Object.defineProperty(view, name, {
|
|
14780
|
+
value: value,
|
|
14781
|
+
writable: true,
|
|
14782
|
+
enumerable: enumerable,
|
|
14783
|
+
configurable: true
|
|
14784
|
+
});
|
|
14785
|
+
}
|
|
14786
|
+
function defineValues(view, values, enumerable) {
|
|
14787
|
+
for (var _i = 0, _Object$keys = Object.keys(values || {}); _i < _Object$keys.length; _i++) {
|
|
14788
|
+
var name = _Object$keys[_i];
|
|
14789
|
+
defineValue(view, name, values[name], enumerable);
|
|
14790
|
+
}
|
|
14791
|
+
}
|
|
14792
|
+
|
|
14793
|
+
/** The sequences of a functional group item, private macros on request. */
|
|
14794
|
+
function macros(groups, privateMacros) {
|
|
14795
|
+
var sequences = [];
|
|
14796
|
+
var vrMap = groups._vrMap || {};
|
|
14797
|
+
for (var _i2 = 0, _Object$keys2 = Object.keys(groups); _i2 < _Object$keys2.length; _i2++) {
|
|
14798
|
+
var key = _Object$keys2[_i2];
|
|
14799
|
+
var value = groups[key];
|
|
14800
|
+
if (parsePrivateBlockKey(key, value)) {
|
|
14801
|
+
if (!privateMacros) continue;
|
|
14802
|
+
for (var _i3 = 0, _Object$keys3 = Object.keys(value); _i3 < _Object$keys3.length; _i3++) {
|
|
14803
|
+
var _vrMap$key;
|
|
14804
|
+
var elementKey = _Object$keys3[_i3];
|
|
14805
|
+
if (ELEMENT_KEY.test(elementKey) && ((_vrMap$key = vrMap[key]) === null || _vrMap$key === void 0 ? void 0 : _vrMap$key[elementKey]) === "SQ") {
|
|
14806
|
+
sequences.push(value[elementKey]);
|
|
14807
|
+
}
|
|
14808
|
+
}
|
|
14809
|
+
} else if (!isPrivateTag(key)) {
|
|
14810
|
+
sequences.push(value);
|
|
14811
|
+
} else if (privateMacros && vrMap[key] === "SQ") {
|
|
14812
|
+
sequences.push(value);
|
|
14813
|
+
}
|
|
14814
|
+
}
|
|
14815
|
+
return sequences;
|
|
14816
|
+
}
|
|
14817
|
+
function addFunctionalGroups(view, groups, privateMacros) {
|
|
14818
|
+
if (!groups) return;
|
|
14819
|
+
var _iterator = _createForOfIteratorHelper(macros(groups, privateMacros)),
|
|
14820
|
+
_step;
|
|
14821
|
+
try {
|
|
14822
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
14823
|
+
var sequence = _step.value;
|
|
14824
|
+
var item = sequence === null || sequence === void 0 ? void 0 : sequence[0];
|
|
14825
|
+
if (!item || _typeof(item) !== "object" || item.SOPInstanceUID) continue;
|
|
14826
|
+
for (var _i4 = 0, _Object$keys4 = Object.keys(item); _i4 < _Object$keys4.length; _i4++) {
|
|
14827
|
+
var name = _Object$keys4[_i4];
|
|
14828
|
+
if (name !== "_vrMap") defineValue(view, name, item[name], true);
|
|
14829
|
+
}
|
|
14830
|
+
Object.assign(view._vrMap, item._vrMap);
|
|
14831
|
+
}
|
|
14832
|
+
} catch (err) {
|
|
14833
|
+
_iterator.e(err);
|
|
14834
|
+
} finally {
|
|
14835
|
+
_iterator.f();
|
|
14836
|
+
}
|
|
14837
|
+
}
|
|
14838
|
+
|
|
14655
14839
|
/**
|
|
14656
14840
|
* Creates an information filter that tracks top-level DICOM attributes.
|
|
14657
14841
|
*
|
|
@@ -30101,7 +30285,8 @@
|
|
|
30101
30285
|
setVr: setVr,
|
|
30102
30286
|
setAttribute: setAttribute,
|
|
30103
30287
|
setPersonName: setPersonName,
|
|
30104
|
-
definePrivateAliases: definePrivateAliases
|
|
30288
|
+
definePrivateAliases: definePrivateAliases,
|
|
30289
|
+
frameDataset: frameDataset
|
|
30105
30290
|
};
|
|
30106
30291
|
var async = {
|
|
30107
30292
|
AsyncDicomReader: AsyncDicomReader
|