copper3d 4.1.0 → 4.1.1
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 +0 -4
- package/ai-index/guides/orientation.md +8 -0
- package/ai-index/manifest.json +3 -3
- package/dist/bundle.esm.mjs +20 -8
- package/dist/bundle.umd.js +24 -12
- package/dist/orientation.cjs +276 -0
- package/dist/orientation.mjs +262 -0
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -58,10 +58,6 @@ with VitePress and deploys to GitHub Pages.
|
|
|
58
58
|
> rather than `copperRenderer`, and nothing from the 3.x segmentation engine. Everything now
|
|
59
59
|
> lives at the link above. Its sources remain in git history if you need them.
|
|
60
60
|
|
|
61
|
-
### Previous versions
|
|
62
|
-
|
|
63
|
-
Old: https://www.npmjs.com/package/copper3d_visualisation
|
|
64
|
-
Very old: https://www.npmjs.com/package/gltfloader-plugin-test
|
|
65
61
|
|
|
66
62
|
### Examples
|
|
67
63
|
|
|
@@ -147,6 +147,14 @@ const voxels = reorientVoxels(raw, geometry.dims, t);
|
|
|
147
147
|
const grid = reorientedGeometry(geometry, t);
|
|
148
148
|
```
|
|
149
149
|
|
|
150
|
+
In Node (a converter, a server, a test), prefer `copper3d/orientation`. It is the same
|
|
151
|
+
functions with nothing else attached — no three, no WebGL, no rest of the library — as ESM
|
|
152
|
+
or CommonJS.
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
import { canonicalTransform, geometryFromNrrd } from "copper3d/orientation";
|
|
156
|
+
```
|
|
157
|
+
|
|
150
158
|
::: tip Masks must be reoriented the same way
|
|
151
159
|
A mask you bring in from elsewhere is in *its* file's order. Put it through the same
|
|
152
160
|
`canonicalTransform` / `reorientVoxels` pair before handing it to `setMasksFromNIfTI`, or it
|
package/ai-index/manifest.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"copper3dVersion": "4.1.
|
|
4
|
-
"generatedAt": "2026-10-
|
|
3
|
+
"copper3dVersion": "4.1.1",
|
|
4
|
+
"generatedAt": "2026-10-20T07:56:20.942Z",
|
|
5
5
|
"symbolCount": 1204,
|
|
6
6
|
"guides": [
|
|
7
7
|
{
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"title": "Patient Orientation <Badge type=\"tip\" text=\"4.1.0\" />",
|
|
107
107
|
"summary": "Every volume `loadNrrd` returns is in the **canonical voxel order**, whatever order its file stores. That is what makes each view come out in the radiological convention without the caller doing anything.",
|
|
108
108
|
"lang": "en",
|
|
109
|
-
"bytes":
|
|
109
|
+
"bytes": 6387
|
|
110
110
|
},
|
|
111
111
|
{
|
|
112
112
|
"id": "rotation-pivot",
|
package/dist/bundle.esm.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import { PlaneGeometry, RawShaderMaterial, DoubleSide, Vector2, Color as Color$1, Mesh, EventDispatcher, MOUSE, Vector3, Quaternion, MathUtils, REVISION as REVISION$1 } from 'three';
|
|
3
|
-
import zlib from 'zlib';
|
|
4
3
|
import { NRRDLoader } from 'three/addons/loaders/NRRDLoader.js';
|
|
5
4
|
import { Volume } from 'three/addons/misc/Volume.js';
|
|
6
5
|
import { VolumeRenderShader1 } from 'three/addons/shaders/VolumeShader.js';
|
|
@@ -470,9 +469,22 @@ function createCommonjsModule(fn, module) {
|
|
|
470
469
|
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
471
470
|
}
|
|
472
471
|
|
|
472
|
+
function getCjsExportFromNamespace (n) {
|
|
473
|
+
return n && n['default'] || n;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
var _zlibShim = typeof process !== "undefined" && typeof process.getBuiltinModule === "function" ? process.getBuiltinModule("zlib") : {};
|
|
477
|
+
|
|
478
|
+
var _zlibShim$1 = /*#__PURE__*/Object.freeze({
|
|
479
|
+
__proto__: null,
|
|
480
|
+
'default': _zlibShim
|
|
481
|
+
});
|
|
482
|
+
|
|
483
|
+
var require$$0 = getCjsExportFromNamespace(_zlibShim$1);
|
|
484
|
+
|
|
473
485
|
var dicomParser_min = createCommonjsModule(function (module, exports) {
|
|
474
486
|
/*! dicom-parser - 1.8.12 - 2023-02-20 | (c) 2017 Chris Hafey | https://github.com/cornerstonejs/dicomParser */
|
|
475
|
-
!function(e,t){module.exports=t(zlib);}(commonjsGlobal,function(r){return a=[function(e,t){e.exports=r;},function(e,t,s){s.r(t),s.d(t,"isStringVr",function(){return d}),s.d(t,"isPrivateTag",function(){return f}),s.d(t,"parsePN",function(){return a}),s.d(t,"parseTM",function(){return n}),s.d(t,"parseDA",function(){return o}),s.d(t,"explicitElementToString",function(){return l}),s.d(t,"explicitDataSetToJS",function(){return u}),s.d(t,"createJPEGBasicOffsetTable",function(){return p}),s.d(t,"parseDicomDataSetExplicit",function(){return q}),s.d(t,"parseDicomDataSetImplicit",function(){return T}),s.d(t,"readFixedString",function(){return b}),s.d(t,"alloc",function(){return k}),s.d(t,"version",function(){return L}),s.d(t,"bigEndianByteArrayParser",function(){return N}),s.d(t,"ByteStream",function(){return J}),s.d(t,"sharedCopy",function(){return j}),s.d(t,"DataSet",function(){return w}),s.d(t,"findAndSetUNElementLength",function(){return y}),s.d(t,"findEndOfEncapsulatedElement",function(){return g}),s.d(t,"findItemDelimitationItemAndSetElementLength",function(){return x}),s.d(t,"littleEndianByteArrayParser",function(){return M}),s.d(t,"parseDicom",function(){return V}),s.d(t,"readDicomElementExplicit",function(){return B}),s.d(t,"readDicomElementImplicit",function(){return A}),s.d(t,"readEncapsulatedImageFrame",function(){return W}),s.d(t,"readEncapsulatedPixelData",function(){return K}),s.d(t,"readEncapsulatedPixelDataFromFragments",function(){return _}),s.d(t,"readPart10Header",function(){return G}),s.d(t,"readSequenceItemsExplicit",function(){return I}),s.d(t,"readSequenceItemsImplicit",function(){return F}),s.d(t,"readSequenceItem",function(){return S}),s.d(t,"readTag",function(){return h});var r={AE:!0,AS:!0,AT:!1,CS:!0,DA:!0,DS:!0,DT:!0,FL:!1,FD:!1,IS:!0,LO:!0,LT:!0,OB:!1,OD:!1,OF:!1,OW:!1,PN:!0,SH:!0,SL:!1,SQ:!1,SS:!1,ST:!0,TM:!0,UI:!0,UL:!1,UN:void 0,UR:!0,US:!1,UT:!0},d=function(e){return r[e]},f=function(e){e=parseInt(e[4],16);if(isNaN(e))throw "dicomParser.isPrivateTag: cannot parse last character of group";return e%2==1},a=function(e){if(void 0!==e){e=e.split("^");return {familyName:e[0],givenName:e[1],middleName:e[2],prefix:e[3],suffix:e[4]}}};function n(e,t){if(2<=e.length){var r=parseInt(e.substring(0,2),10),a=4<=e.length?parseInt(e.substring(2,4),10):void 0,n=6<=e.length?parseInt(e.substring(4,6),10):void 0,i=8<=e.length?e.substring(7,13):void 0,i=i?parseInt(i,10)*Math.pow(10,6-i.length):void 0;if(t&&(isNaN(r)||void 0!==a&&isNaN(a)||void 0!==n&&isNaN(n)||void 0!==i&&isNaN(i)||r<0||23<r||a&&(a<0||59<a)||n&&(n<0||59<n)||i&&(i<0||999999<i)))throw "invalid TM '".concat(e,"'");return {hours:r,minutes:a,seconds:n,fractionalSeconds:i}}if(t)throw "invalid TM '".concat(e,"'")}function i(e,t,r){return !isNaN(r)&&(0<t&&t<=12&&0<e&&e<=function(e,t){switch(e){case 2:return t%4==0&&t%100||t%400==0?29:28;case 9:case 4:case 6:case 11:return 30;default:return 31}}(t,r))}function o(e,t){if(e&&8===e.length){var r=parseInt(e.substring(0,4),10),a=parseInt(e.substring(4,6),10),n=parseInt(e.substring(6,8),10);if(t&&!0!==i(n,a,r))throw "invalid DA '".concat(e,"'");return {year:r,month:a,day:n}}if(t)throw "invalid DA '".concat(e,"'")}function l(n,e){if(void 0===n||void 0===e)throw "dicomParser.explicitElementToString: missing required parameters";if(void 0===e.vr)throw "dicomParser.explicitElementToString: cannot convert implicit element to string";var t,r=e.vr,i=e.tag;function a(e,t){for(var r="",a=0;a<e;a++)0!==a&&(r+="/"),r+=t.call(n,i,a).toString();return r}if(!0===d(r))t=n.string(i);else {if("AT"===r){var o=n.uint32(i);return void 0===o?void 0:"x".concat((o=o<0?4294967295+o+1:o).toString(16).toUpperCase())}"US"===r?t=a(e.length/2,n.uint16):"SS"===r?t=a(e.length/2,n.int16):"UL"===r?t=a(e.length/4,n.uint32):"SL"===r?t=a(e.length/4,n.int32):"FD"===r?t=a(e.length/8,n.double):"FL"===r&&(t=a(e.length/4,n.float));}return t}function u(e,t){if(void 0===e)throw "dicomParser.explicitDataSetToJS: missing required parameter dataSet";t=t||{omitPrivateAttibutes:!0,maxElementLength:128};var r,a={};for(r in e.elements){var n=e.elements[r];if(!0!==t.omitPrivateAttibutes||!f(r))if(n.items){for(var i=[],o=0;o<n.items.length;o++)i.push(u(n.items[o].dataSet,t));a[r]=i;}else {var s=void 0;n.length<t.maxElementLength&&(s=l(e,n)),a[r]=void 0!==s?s:{dataOffset:n.dataOffset,length:n.length};}}return a}function c(e,t){return 255===e.byteArray[t]&&217===e.byteArray[t+1]}function m(e,t,r){for(var a,n,i=r;i<t.fragments.length;i++)if(a=e,n=i,n=t.fragments[n],!(!c(a,n.position+n.length-2)&&!c(a,n.position+n.length-3)))return i}function p(e,t,r){if(void 0===e)throw "dicomParser.createJPEGBasicOffsetTable: missing required parameter dataSet";if(void 0===t)throw "dicomParser.createJPEGBasicOffsetTable: missing required parameter pixelDataElement";if("x7fe00010"!==t.tag)throw "dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010'";if(!0!==t.encapsulatedPixelData)throw "dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw "dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.basicOffsetTable)throw "dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.fragments)throw "dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(t.fragments.length<=0)throw "dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(r&&r.length<=0)throw "dicomParser.createJPEGBasicOffsetTable: parameter 'fragments' must not be zero length";r=r||t.fragments;for(var a=[],n=0;;){a.push(t.fragments[n].offset);var i=m(e,t,n);if(void 0===i||i===t.fragments.length-1)return a;n=i+1;}}function h(e){if(void 0===e)throw "dicomParser.readTag: missing required parameter 'byteStream'";var t=256*e.readUint16()*256,e=e.readUint16();return "x".concat("00000000".concat((t+e).toString(16)).substr(-8))}function g(e,t,r){if(void 0===e)throw "dicomParser.findEndOfEncapsulatedElement: missing required parameter 'byteStream'";if(void 0===t)throw "dicomParser.findEndOfEncapsulatedElement: missing required parameter 'element'";if(t.encapsulatedPixelData=!0,t.basicOffsetTable=[],t.fragments=[],"xfffee000"!==h(e))throw "dicomParser.findEndOfEncapsulatedElement: basic offset table not found";for(var a=e.readUint32()/4,n=0;n<a;n++){var i=e.readUint32();t.basicOffsetTable.push(i);}for(var o=e.position;e.position<e.byteArray.length;){var s=h(e),d=e.readUint32();if("xfffee0dd"===s)return e.seek(d),void(t.length=e.position-t.dataOffset);if("xfffee000"!==s)return r&&r.push("unexpected tag ".concat(s," while searching for end of pixel data element with undefined length")),d>e.byteArray.length-e.position&&(d=e.byteArray.length-e.position),t.fragments.push({offset:e.position-o-8,position:e.position,length:d}),e.seek(d),void(t.length=e.position-t.dataOffset);t.fragments.push({offset:e.position-o-8,position:e.position,length:d}),e.seek(d);}r&&r.push("pixel data element ".concat(t.tag," missing sequence delimiter tag xfffee0dd"));}function y(e,t){if(void 0===e)throw "dicomParser.findAndSetUNElementLength: missing required parameter 'byteStream'";for(var r=e.byteArray.length-8;e.position<=r;)if(65534===e.readUint16()){var a=e.readUint16();if(57565===a)return 0!==e.readUint32()&&e.warnings("encountered non zero length following item delimiter at position ".concat(e.position-4," while reading element of undefined length with tag ").concat(t.tag)),void(t.length=e.position-t.dataOffset)}t.length=e.byteArray.length-t.dataOffset,e.seek(e.byteArray.length-e.position);}function b(e,t,r){if(r<0)throw "dicomParser.readFixedString - length cannot be less than 0";if(t+r>e.length)throw "dicomParser.readFixedString: attempt to read past end of buffer";for(var a,n="",i=0;i<r;i++){if(0===(a=e[t+i]))return t+=r,n;n+=String.fromCharCode(a);}return n}function v(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a);}}function P(e,t){return void 0!==e.parser?e.parser:t}var w=function(){function a(e,t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),this.byteArrayParser=e,this.byteArray=t,this.elements=r;}var e,t;return e=a,(t=[{key:"uint16",value:function(e,t){e=this.elements[e];if(t=void 0!==t?t:0,e&&0!==e.length)return P(e,this.byteArrayParser).readUint16(this.byteArray,e.dataOffset+2*t)}},{key:"int16",value:function(e,t){e=this.elements[e];if(t=void 0!==t?t:0,e&&0!==e.length)return P(e,this.byteArrayParser).readInt16(this.byteArray,e.dataOffset+2*t)}},{key:"uint32",value:function(e,t){e=this.elements[e];if(t=void 0!==t?t:0,e&&0!==e.length)return P(e,this.byteArrayParser).readUint32(this.byteArray,e.dataOffset+4*t)}},{key:"int32",value:function(e,t){e=this.elements[e];if(t=void 0!==t?t:0,e&&0!==e.length)return P(e,this.byteArrayParser).readInt32(this.byteArray,e.dataOffset+4*t)}},{key:"float",value:function(e,t){e=this.elements[e];if(t=void 0!==t?t:0,e&&0!==e.length)return P(e,this.byteArrayParser).readFloat(this.byteArray,e.dataOffset+4*t)}},{key:"double",value:function(e,t){e=this.elements[e];if(t=void 0!==t?t:0,e&&0!==e.length)return P(e,this.byteArrayParser).readDouble(this.byteArray,e.dataOffset+8*t)}},{key:"numStringValues",value:function(e){e=this.elements[e];if(e&&0<e.length){e=b(this.byteArray,e.dataOffset,e.length).match(/\\/g);return null===e?1:e.length+1}}},{key:"string",value:function(e,t){e=this.elements[e];if(e&&e.Value)return e.Value;if(e&&0<e.length){e=b(this.byteArray,e.dataOffset,e.length);return 0<=t?e.split("\\")[t].trim():e.trim()}}},{key:"text",value:function(e,t){e=this.elements[e];if(e&&0<e.length){e=b(this.byteArray,e.dataOffset,e.length);return 0<=t?e.split("\\")[t].replace(/ +$/,""):e.replace(/ +$/,"")}}},{key:"floatString",value:function(e,t){var r=this.elements[e];if(r&&0<r.length){t=this.string(e,t=void 0!==t?t:0);if(void 0!==t)return parseFloat(t)}}},{key:"intString",value:function(e,t){var r=this.elements[e];if(r&&0<r.length){t=this.string(e,t=void 0!==t?t:0);if(void 0!==t)return parseInt(t)}}},{key:"attributeTag",value:function(e){var t=this.elements[e];if(t&&4===t.length){var r=P(t,this.byteArrayParser).readUint16,e=this.byteArray,t=t.dataOffset;return "x".concat("00000000".concat((256*r(e,t)*256+r(e,t+2)).toString(16)).substr(-8))}}}])&&v(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),a}();function x(e,t){if(void 0===e)throw "dicomParser.readDicomElementImplicit: missing required parameter 'byteStream'";for(var r=e.byteArray.length-8;e.position<=r;)if(65534===e.readUint16()){var a=e.readUint16();if(57357===a)return 0!==e.readUint32()&&e.warnings("encountered non zero length following item delimiter at position ".concat(e.position-4," while reading element of undefined length with tag ").concat(t.tag)),void(t.length=e.position-t.dataOffset)}t.length=e.byteArray.length-t.dataOffset,e.seek(e.byteArray.length-e.position);}var E=function(e,t){if(void 0!==e.vr)return "SQ"===e.vr;if(t.position+4<=t.byteArray.length){e=h(t);return t.seek(-4),"xfffee000"===e||"xfffee0dd"===e}return t.warnings.push("eof encountered before finding sequence item tag or sequence delimiter tag in peeking to determine VR"),!1};function A(e,t,r){if(void 0===e)throw "dicomParser.readDicomElementImplicit: missing required parameter 'byteStream'";var a=h(e),a={tag:a,vr:void 0!==r?r(a):void 0,length:e.readUint32(),dataOffset:e.position};return 4294967295===a.length&&(a.hadUndefinedLength=!0),a.tag===t||(!E(a,e)||f(a.tag)&&!a.hadUndefinedLength?a.hadUndefinedLength?x(e,a):e.seek(a.length):(F(e,a,r),f(a.tag)&&(a.items=void 0))),a}function S(e){if(void 0===e)throw "dicomParser.readSequenceItem: missing required parameter 'byteStream'";var t={tag:h(e),length:e.readUint32(),dataOffset:e.position};if("xfffee000"!==t.tag)throw "dicomParser.readSequenceItem: item tag (FFFE,E000) not found at offset ".concat(e.position);return t}function D(e,t){var r=S(e);return 4294967295===r.length?(r.hadUndefinedLength=!0,r.dataSet=function(e,t){for(var r={};e.position<e.byteArray.length;){var a=A(e,void 0,t);if("xfffee00d"===(r[a.tag]=a).tag)return new w(e.byteArrayParser,e.byteArray,r)}return e.warnings.push("eof encountered before finding sequence item delimiter in sequence item of undefined length"),new w(e.byteArrayParser,e.byteArray,r)}(e,t),r.length=e.position-r.dataOffset):(r.dataSet=new w(e.byteArrayParser,e.byteArray,{}),T(r.dataSet,e,e.position+r.length,{vrCallback:t})),r}function F(e,t,r){if(void 0===e)throw "dicomParser.readSequenceItemsImplicit: missing required parameter 'byteStream'";if(void 0===t)throw "dicomParser.readSequenceItemsImplicit: missing required parameter 'element'";t.items=[],(4294967295===t.length?function(e,t,r){for(;e.position+4<=e.byteArray.length;){var a=h(e);if(e.seek(-4),"xfffee0dd"===a)return t.length=e.position-t.dataOffset,e.seek(8);a=D(e,r);t.items.push(a);}e.warnings.push("eof encountered before finding sequence delimiter in sequence of undefined length"),t.length=e.byteArray.length-t.dataOffset;}:function(e,t,r){for(var a=t.dataOffset+t.length;e.position<a;){var n=D(e,r);t.items.push(n);}})(e,t,r);}function O(e,t){var r=S(e);return 4294967295===r.length?(r.hadUndefinedLength=!0,r.dataSet=function(e,t){for(var r={};e.position<e.byteArray.length;){var a=B(e,t);if("xfffee00d"===(r[a.tag]=a).tag)return new w(e.byteArrayParser,e.byteArray,r)}return t.push("eof encountered before finding item delimiter tag while reading sequence item of undefined length"),new w(e.byteArrayParser,e.byteArray,r)}(e,t),r.length=e.position-r.dataOffset):(r.dataSet=new w(e.byteArrayParser,e.byteArray,{}),q(r.dataSet,e,e.position+r.length)),r}function I(e,t,r){if(void 0===e)throw "dicomParser.readSequenceItemsExplicit: missing required parameter 'byteStream'";if(void 0===t)throw "dicomParser.readSequenceItemsExplicit: missing required parameter 'element'";t.items=[],(4294967295===t.length?function(e,t,r){for(;e.position+4<=e.byteArray.length;){var a=h(e);if(e.seek(-4),"xfffee0dd"===a)return t.length=e.position-t.dataOffset,e.seek(8);a=O(e,r);t.items.push(a);}r.push("eof encountered before finding sequence delimitation tag while reading sequence of undefined length"),t.length=e.position-t.dataOffset;}:function(e,t,r){for(var a=t.dataOffset+t.length;e.position<a;){var n=O(e,r);t.items.push(n);}})(e,t,r);}var U=function(e){return "OB"===e||"OD"===e||"OL"===e||"OW"===e||"SQ"===e||"OF"===e||"UC"===e||"UR"===e||"UT"===e||"UN"===e?4:2};function B(e,t,r){if(void 0===e)throw "dicomParser.readDicomElementExplicit: missing required parameter 'byteStream'";var a={tag:h(e),vr:e.readFixedString(2)};return 2===U(a.vr)?a.length=e.readUint16():(e.seek(2),a.length=e.readUint32()),a.dataOffset=e.position,4294967295===a.length&&(a.hadUndefinedLength=!0),a.tag===r||("SQ"===a.vr?I(e,a,t):4294967295===a.length?"x7fe00010"===a.tag?g(e,a,t):("UN"===a.vr?F:x)(e,a):e.seek(a.length)),a}function q(e,t,r){var a=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(r=void 0===r?t.byteArray.length:r,void 0===t)throw "dicomParser.parseDicomDataSetExplicit: missing required parameter 'byteStream'";if(r<t.position||r>t.byteArray.length)throw "dicomParser.parseDicomDataSetExplicit: invalid value for parameter 'maxP osition'";for(var n=e.elements;t.position<r;){var i=B(t,e.warnings,a.untilTag);if((n[i.tag]=i).tag===a.untilTag)return}if(t.position>r)throw "dicomParser:parseDicomDataSetExplicit: buffer overrun"}function T(e,t,r){var a=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(r=void 0===r?e.byteArray.length:r,void 0===t)throw "dicomParser.parseDicomDataSetImplicit: missing required parameter 'byteStream'";if(r<t.position||r>t.byteArray.length)throw "dicomParser.parseDicomDataSetImplicit: invalid value for parameter 'maxPosition'";for(var n=e.elements;t.position<r;){var i=A(t,a.untilTag,a.vrCallback);if((n[i.tag]=i).tag===a.untilTag)return}}function k(e,t){if("undefined"!=typeof Buffer&&e instanceof Buffer)return Buffer.alloc(t);if(e instanceof Uint8Array)return new Uint8Array(t);throw "dicomParser.alloc: unknown type for byteArray"}var L="1.8.12",N={readUint16:function(e,t){if(t<0)throw "bigEndianByteArrayParser.readUint16: position cannot be less than 0";if(t+2>e.length)throw "bigEndianByteArrayParser.readUint16: attempt to read past end of buffer";return (e[t]<<8)+e[t+1]},readInt16:function(e,t){if(t<0)throw "bigEndianByteArrayParser.readInt16: position cannot be less than 0";if(t+2>e.length)throw "bigEndianByteArrayParser.readInt16: attempt to read past end of buffer";t=(e[t]<<8)+e[t+1];return t=32768&t?t-65535-1:t},readUint32:function(e,t){if(t<0)throw "bigEndianByteArrayParser.readUint32: position cannot be less than 0";if(t+4>e.length)throw "bigEndianByteArrayParser.readUint32: attempt to read past end of buffer";return 256*(256*(256*e[t]+e[t+1])+e[t+2])+e[t+3]},readInt32:function(e,t){if(t<0)throw "bigEndianByteArrayParser.readInt32: position cannot be less than 0";if(t+4>e.length)throw "bigEndianByteArrayParser.readInt32: attempt to read past end of buffer";return (e[t]<<24)+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3]},readFloat:function(e,t){if(t<0)throw "bigEndianByteArrayParser.readFloat: position cannot be less than 0";if(t+4>e.length)throw "bigEndianByteArrayParser.readFloat: attempt to read past end of buffer";var r=new Uint8Array(4);return r[3]=e[t],r[2]=e[t+1],r[1]=e[t+2],r[0]=e[t+3],new Float32Array(r.buffer)[0]},readDouble:function(e,t){if(t<0)throw "bigEndianByteArrayParser.readDouble: position cannot be less than 0";if(t+8>e.length)throw "bigEndianByteArrayParser.readDouble: attempt to read past end of buffer";var r=new Uint8Array(8);return r[7]=e[t],r[6]=e[t+1],r[5]=e[t+2],r[4]=e[t+3],r[3]=e[t+4],r[2]=e[t+5],r[1]=e[t+6],r[0]=e[t+7],new Float64Array(r.buffer)[0]}};function j(e,t,r){if("undefined"!=typeof Buffer&&e instanceof Buffer)return e.slice(t,t+r);if(e instanceof Uint8Array)return new Uint8Array(e.buffer,e.byteOffset+t,r);throw "dicomParser.from: unknown type for byteArray"}function C(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a);}}var J=function(){function a(e,t,r){if(!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),void 0===e)throw "dicomParser.ByteStream: missing required parameter 'byteArrayParser'";if(void 0===t)throw "dicomParser.ByteStream: missing required parameter 'byteArray'";if(t instanceof Uint8Array==!1&&("undefined"==typeof Buffer||t instanceof Buffer==!1))throw "dicomParser.ByteStream: parameter byteArray is not of type Uint8Array or Buffer";if(r<0)throw "dicomParser.ByteStream: parameter 'position' cannot be less than 0";if(r>=t.length)throw "dicomParser.ByteStream: parameter 'position' cannot be greater than or equal to 'byteArray' length";this.byteArrayParser=e,this.byteArray=t,this.position=r||0,this.warnings=[];}var e,t;return e=a,(t=[{key:"seek",value:function(e){if(this.position+e<0)throw "dicomParser.ByteStream.prototype.seek: cannot seek to position < 0";this.position+=e;}},{key:"readByteStream",value:function(e){if(this.position+e>this.byteArray.length)throw "dicomParser.ByteStream.prototype.readByteStream: readByteStream - buffer overread";var t=j(this.byteArray,this.position,e);return this.position+=e,new a(this.byteArrayParser,t)}},{key:"getSize",value:function(){return this.byteArray.length}},{key:"readUint16",value:function(){var e=this.byteArrayParser.readUint16(this.byteArray,this.position);return this.position+=2,e}},{key:"readUint32",value:function(){var e=this.byteArrayParser.readUint32(this.byteArray,this.position);return this.position+=4,e}},{key:"readFixedString",value:function(e){var t=b(this.byteArray,this.position,e);return this.position+=e,t}}])&&C(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),a}(),M={readUint16:function(e,t){if(t<0)throw "littleEndianByteArrayParser.readUint16: position cannot be less than 0";if(t+2>e.length)throw "littleEndianByteArrayParser.readUint16: attempt to read past end of buffer";return e[t]+256*e[t+1]},readInt16:function(e,t){if(t<0)throw "littleEndianByteArrayParser.readInt16: position cannot be less than 0";if(t+2>e.length)throw "littleEndianByteArrayParser.readInt16: attempt to read past end of buffer";t=e[t]+(e[t+1]<<8);return t=32768&t?t-65535-1:t},readUint32:function(e,t){if(t<0)throw "littleEndianByteArrayParser.readUint32: position cannot be less than 0";if(t+4>e.length)throw "littleEndianByteArrayParser.readUint32: attempt to read past end of buffer";return e[t]+256*e[t+1]+256*e[t+2]*256+256*e[t+3]*256*256},readInt32:function(e,t){if(t<0)throw "littleEndianByteArrayParser.readInt32: position cannot be less than 0";if(t+4>e.length)throw "littleEndianByteArrayParser.readInt32: attempt to read past end of buffer";return e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24)},readFloat:function(e,t){if(t<0)throw "littleEndianByteArrayParser.readFloat: position cannot be less than 0";if(t+4>e.length)throw "littleEndianByteArrayParser.readFloat: attempt to read past end of buffer";var r=new Uint8Array(4);return r[0]=e[t],r[1]=e[t+1],r[2]=e[t+2],r[3]=e[t+3],new Float32Array(r.buffer)[0]},readDouble:function(e,t){if(t<0)throw "littleEndianByteArrayParser.readDouble: position cannot be less than 0";if(t+8>e.length)throw "littleEndianByteArrayParser.readDouble: attempt to read past end of buffer";var r=new Uint8Array(8);return r[0]=e[t],r[1]=e[t+1],r[2]=e[t+2],r[3]=e[t+3],r[4]=e[t+4],r[5]=e[t+5],r[6]=e[t+6],r[7]=e[t+7],new Float64Array(r.buffer)[0]}};function G(e){var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(void 0===e)throw "dicomParser.readPart10Header: missing required parameter 'byteArray'";var o=i.TransferSyntaxUID,s=new J(M,e);return function(){var e=function(){if(s.getSize()<=132&&o)return !1;if(s.seek(128),"DICM"===s.readFixedString(4))return !0;if(!(i||{}).TransferSyntaxUID)throw "dicomParser.readPart10Header: DICM prefix not found at location 132 - this is not a valid DICOM P10 file.";return s.seek(0),!1}(),t=[],r={};if(!e)return s.position=0,{elements:{x00020010:{tag:"x00020010",vr:"UI",Value:o}},warnings:t};for(;s.position<s.byteArray.length;){var a=s.position,n=B(s,t);if("x0002ffff"<n.tag){s.position=a;break}n.parser=M,r[n.tag]=n;}return (e=new w(s.byteArrayParser,s.byteArray,r)).warnings=s.warnings,e.position=s.position,e}()}var z="1.2.840.10008.1.2.2";function V(i){var o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(void 0===i)throw new Error("dicomParser.parseDicom: missing required parameter 'byteArray'");var e,a=function(e){if(void 0===e.elements.x00020010)throw new Error("dicomParser.parseDicom: missing required meta header attribute 0002,0010");e=e.elements.x00020010;return e&&e.Value||b(i,e.dataOffset,e.length)};function t(t){var e=a(t),r="1.2.840.10008.1.2"!==e,e=function(e,t){var r="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);if("1.2.840.10008.1.2.1.99"!==e)return new J(e===z?N:M,i,t);if(o&&o.inflater){e=o.inflater(i,t);return new J(M,e,0)}if(!0==r){var a=s(0),n=j(i,t,i.length-t),a=a.inflateRawSync(n),n=k(i,a.length+t);return i.copy(n,0,0,t),a.copy(n,t),new J(M,n,0)}if("undefined"==typeof pako)throw "dicomParser.parseDicom: no inflater available to handle deflate transfer syntax";return a=i.slice(t),n=pako.inflateRaw(a),(a=k(i,n.length+t)).set(i.slice(0,t),0),a.set(n,t),new J(M,a,0)}(e,t.position),t=new w(e.byteArrayParser,e.byteArray,{});t.warnings=e.warnings;try{(r?q:T)(t,e,e.byteArray.length,o);}catch(e){throw {exception:e,dataSet:t}}return t}return function(e,t){for(var r in e.elements)e.elements.hasOwnProperty(r)&&(t.elements[r]=e.elements[r]);return void 0!==e.warnings&&(t.warnings=e.warnings.concat(t.warnings)),t}(e=G(i,o),t(e))}var R=function(e,t,r){for(var a=0,n=t;n<t+r;n++)a+=e[n].length;return a};function _(e,t,r,a,n){if(n=n||t.fragments,void 0===e)throw "dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'dataSet'";if(void 0===t)throw "dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'pixelDataElement'";if(void 0===r)throw "dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'startFragmentIndex'";if(void 0===(a=a||1))throw "dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'numFragments'";if("x7fe00010"!==t.tag)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010";if(!0!==t.encapsulatedPixelData)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.basicOffsetTable)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.fragments)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(t.fragments.length<=0)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(r<0)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragmentIndex' must be >= 0";if(r>=t.fragments.length)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragmentIndex' must be < number of fragments";if(a<1)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'numFragments' must be > 0";if(r+a>t.fragments.length)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragment' + 'numFragments' < number of fragments";var i=new J(e.byteArrayParser,e.byteArray,t.dataOffset),t=S(i);if("xfffee000"!==t.tag)throw "dicomParser.readEncapsulatedPixelData: missing basic offset table xfffee000";i.seek(t.length);var o=i.position;if(1===a)return j(i.byteArray,o+n[r].offset+8,n[r].length);for(var t=R(n,r,a),s=k(i.byteArray,t),d=0,f=r;f<r+a;f++)for(var l=o+n[f].offset+8,u=0;u<n[f].length;u++)s[d++]=i.byteArray[l++];return s}var H=function(e,t){for(var r=0;r<e.length;r++)if(e[r].offset===t)return r},Q=function(e,t,r,a){if(e===t.length-1)return r.length-a;for(var n=t[e+1],i=a+1;i<r.length;i++)if(r[i].offset===n)return i-a;throw "dicomParser.calculateNumberOfFragmentsForFrame: could not find fragment with offset matching basic offset table"};function W(e,t,r,a,n){if(a=a||t.basicOffsetTable,n=n||t.fragments,void 0===e)throw "dicomParser.readEncapsulatedImageFrame: missing required parameter 'dataSet'";if(void 0===t)throw "dicomParser.readEncapsulatedImageFrame: missing required parameter 'pixelDataElement'";if(void 0===r)throw "dicomParser.readEncapsulatedImageFrame: missing required parameter 'frameIndex'";if(void 0===a)throw "dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' does not have basicOffsetTable";if("x7fe00010"!==t.tag)throw "dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010)";if(!0!==t.encapsulatedPixelData)throw "dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw "dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have undefined length";if(void 0===t.fragments)throw "dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have fragments";if(0===a.length)throw "dicomParser.readEncapsulatedImageFrame: basicOffsetTable has zero entries";if(r<0)throw "dicomParser.readEncapsulatedImageFrame: parameter 'frameIndex' must be >= 0";if(r>=a.length)throw "dicomParser.readEncapsulatedImageFrame: parameter 'frameIndex' must be < basicOffsetTable.length";var i=a[r],i=H(n,i);if(void 0===i)throw "dicomParser.readEncapsulatedImageFrame: unable to find fragment that matches basic offset table entry";return _(e,t,i,Q(r,a,n,i),n)}var $=!1;function K(e,t,r){if($||($=!0,console&&console.log&&console.log("WARNING: dicomParser.readEncapsulatedPixelData() has been deprecated")),void 0===e)throw "dicomParser.readEncapsulatedPixelData: missing required parameter 'dataSet'";if(void 0===t)throw "dicomParser.readEncapsulatedPixelData: missing required parameter 'element'";if(void 0===r)throw "dicomParser.readEncapsulatedPixelData: missing required parameter 'frame'";if("x7fe00010"!==t.tag)throw "dicomParser.readEncapsulatedPixelData: parameter 'element' refers to non pixel data tag (expected tag = x7fe00010)";if(!0!==t.encapsulatedPixelData)throw "dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw "dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.basicOffsetTable)throw "dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.fragments)throw "dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(r<0)throw "dicomParser.readEncapsulatedPixelData: parameter 'frame' must be >= 0";return 0!==t.basicOffsetTable.length?W(e,t,r):_(e,t,0,t.fragments.length)}t.default={isStringVr:d,isPrivateTag:f,parsePN:a,parseTM:n,parseDA:o,explicitElementToString:l,explicitDataSetToJS:u,createJPEGBasicOffsetTable:p,parseDicomDataSetExplicit:q,parseDicomDataSetImplicit:T,readFixedString:b,alloc:k,version:L,bigEndianByteArrayParser:N,ByteStream:J,sharedCopy:j,DataSet:w,findAndSetUNElementLength:y,findEndOfEncapsulatedElement:g,findItemDelimitationItemAndSetElementLength:x,littleEndianByteArrayParser:M,parseDicom:V,readDicomElementExplicit:B,readDicomElementImplicit:A,readEncapsulatedImageFrame:W,readEncapsulatedPixelData:K,readEncapsulatedPixelDataFromFragments:_,readPart10Header:G,readSequenceItemsExplicit:I,readSequenceItemsImplicit:F,readSequenceItem:S,readTag:h,LEI:"1.2.840.10008.1.2",LEE:"1.2.840.10008.1.2.1"};}],i={},n.m=a,n.c=i,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r});},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0});},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)n.d(r,a,function(e){return t[e]}.bind(null,a));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1);function n(e){if(i[e])return i[e].exports;var t=i[e]={i:e,l:!1,exports:{}};return a[e].call(t.exports,t,t.exports,n),t.l=!0,t.exports}var a,i;});
|
|
487
|
+
!function(e,t){module.exports=t(require$$0);}(commonjsGlobal,function(r){return a=[function(e,t){e.exports=r;},function(e,t,s){s.r(t),s.d(t,"isStringVr",function(){return d}),s.d(t,"isPrivateTag",function(){return f}),s.d(t,"parsePN",function(){return a}),s.d(t,"parseTM",function(){return n}),s.d(t,"parseDA",function(){return o}),s.d(t,"explicitElementToString",function(){return l}),s.d(t,"explicitDataSetToJS",function(){return u}),s.d(t,"createJPEGBasicOffsetTable",function(){return p}),s.d(t,"parseDicomDataSetExplicit",function(){return q}),s.d(t,"parseDicomDataSetImplicit",function(){return T}),s.d(t,"readFixedString",function(){return b}),s.d(t,"alloc",function(){return k}),s.d(t,"version",function(){return L}),s.d(t,"bigEndianByteArrayParser",function(){return N}),s.d(t,"ByteStream",function(){return J}),s.d(t,"sharedCopy",function(){return j}),s.d(t,"DataSet",function(){return w}),s.d(t,"findAndSetUNElementLength",function(){return y}),s.d(t,"findEndOfEncapsulatedElement",function(){return g}),s.d(t,"findItemDelimitationItemAndSetElementLength",function(){return x}),s.d(t,"littleEndianByteArrayParser",function(){return M}),s.d(t,"parseDicom",function(){return V}),s.d(t,"readDicomElementExplicit",function(){return B}),s.d(t,"readDicomElementImplicit",function(){return A}),s.d(t,"readEncapsulatedImageFrame",function(){return W}),s.d(t,"readEncapsulatedPixelData",function(){return K}),s.d(t,"readEncapsulatedPixelDataFromFragments",function(){return _}),s.d(t,"readPart10Header",function(){return G}),s.d(t,"readSequenceItemsExplicit",function(){return I}),s.d(t,"readSequenceItemsImplicit",function(){return F}),s.d(t,"readSequenceItem",function(){return S}),s.d(t,"readTag",function(){return h});var r={AE:!0,AS:!0,AT:!1,CS:!0,DA:!0,DS:!0,DT:!0,FL:!1,FD:!1,IS:!0,LO:!0,LT:!0,OB:!1,OD:!1,OF:!1,OW:!1,PN:!0,SH:!0,SL:!1,SQ:!1,SS:!1,ST:!0,TM:!0,UI:!0,UL:!1,UN:void 0,UR:!0,US:!1,UT:!0},d=function(e){return r[e]},f=function(e){e=parseInt(e[4],16);if(isNaN(e))throw "dicomParser.isPrivateTag: cannot parse last character of group";return e%2==1},a=function(e){if(void 0!==e){e=e.split("^");return {familyName:e[0],givenName:e[1],middleName:e[2],prefix:e[3],suffix:e[4]}}};function n(e,t){if(2<=e.length){var r=parseInt(e.substring(0,2),10),a=4<=e.length?parseInt(e.substring(2,4),10):void 0,n=6<=e.length?parseInt(e.substring(4,6),10):void 0,i=8<=e.length?e.substring(7,13):void 0,i=i?parseInt(i,10)*Math.pow(10,6-i.length):void 0;if(t&&(isNaN(r)||void 0!==a&&isNaN(a)||void 0!==n&&isNaN(n)||void 0!==i&&isNaN(i)||r<0||23<r||a&&(a<0||59<a)||n&&(n<0||59<n)||i&&(i<0||999999<i)))throw "invalid TM '".concat(e,"'");return {hours:r,minutes:a,seconds:n,fractionalSeconds:i}}if(t)throw "invalid TM '".concat(e,"'")}function i(e,t,r){return !isNaN(r)&&(0<t&&t<=12&&0<e&&e<=function(e,t){switch(e){case 2:return t%4==0&&t%100||t%400==0?29:28;case 9:case 4:case 6:case 11:return 30;default:return 31}}(t,r))}function o(e,t){if(e&&8===e.length){var r=parseInt(e.substring(0,4),10),a=parseInt(e.substring(4,6),10),n=parseInt(e.substring(6,8),10);if(t&&!0!==i(n,a,r))throw "invalid DA '".concat(e,"'");return {year:r,month:a,day:n}}if(t)throw "invalid DA '".concat(e,"'")}function l(n,e){if(void 0===n||void 0===e)throw "dicomParser.explicitElementToString: missing required parameters";if(void 0===e.vr)throw "dicomParser.explicitElementToString: cannot convert implicit element to string";var t,r=e.vr,i=e.tag;function a(e,t){for(var r="",a=0;a<e;a++)0!==a&&(r+="/"),r+=t.call(n,i,a).toString();return r}if(!0===d(r))t=n.string(i);else {if("AT"===r){var o=n.uint32(i);return void 0===o?void 0:"x".concat((o=o<0?4294967295+o+1:o).toString(16).toUpperCase())}"US"===r?t=a(e.length/2,n.uint16):"SS"===r?t=a(e.length/2,n.int16):"UL"===r?t=a(e.length/4,n.uint32):"SL"===r?t=a(e.length/4,n.int32):"FD"===r?t=a(e.length/8,n.double):"FL"===r&&(t=a(e.length/4,n.float));}return t}function u(e,t){if(void 0===e)throw "dicomParser.explicitDataSetToJS: missing required parameter dataSet";t=t||{omitPrivateAttibutes:!0,maxElementLength:128};var r,a={};for(r in e.elements){var n=e.elements[r];if(!0!==t.omitPrivateAttibutes||!f(r))if(n.items){for(var i=[],o=0;o<n.items.length;o++)i.push(u(n.items[o].dataSet,t));a[r]=i;}else {var s=void 0;n.length<t.maxElementLength&&(s=l(e,n)),a[r]=void 0!==s?s:{dataOffset:n.dataOffset,length:n.length};}}return a}function c(e,t){return 255===e.byteArray[t]&&217===e.byteArray[t+1]}function m(e,t,r){for(var a,n,i=r;i<t.fragments.length;i++)if(a=e,n=i,n=t.fragments[n],!(!c(a,n.position+n.length-2)&&!c(a,n.position+n.length-3)))return i}function p(e,t,r){if(void 0===e)throw "dicomParser.createJPEGBasicOffsetTable: missing required parameter dataSet";if(void 0===t)throw "dicomParser.createJPEGBasicOffsetTable: missing required parameter pixelDataElement";if("x7fe00010"!==t.tag)throw "dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010'";if(!0!==t.encapsulatedPixelData)throw "dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw "dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.basicOffsetTable)throw "dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.fragments)throw "dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(t.fragments.length<=0)throw "dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(r&&r.length<=0)throw "dicomParser.createJPEGBasicOffsetTable: parameter 'fragments' must not be zero length";r=r||t.fragments;for(var a=[],n=0;;){a.push(t.fragments[n].offset);var i=m(e,t,n);if(void 0===i||i===t.fragments.length-1)return a;n=i+1;}}function h(e){if(void 0===e)throw "dicomParser.readTag: missing required parameter 'byteStream'";var t=256*e.readUint16()*256,e=e.readUint16();return "x".concat("00000000".concat((t+e).toString(16)).substr(-8))}function g(e,t,r){if(void 0===e)throw "dicomParser.findEndOfEncapsulatedElement: missing required parameter 'byteStream'";if(void 0===t)throw "dicomParser.findEndOfEncapsulatedElement: missing required parameter 'element'";if(t.encapsulatedPixelData=!0,t.basicOffsetTable=[],t.fragments=[],"xfffee000"!==h(e))throw "dicomParser.findEndOfEncapsulatedElement: basic offset table not found";for(var a=e.readUint32()/4,n=0;n<a;n++){var i=e.readUint32();t.basicOffsetTable.push(i);}for(var o=e.position;e.position<e.byteArray.length;){var s=h(e),d=e.readUint32();if("xfffee0dd"===s)return e.seek(d),void(t.length=e.position-t.dataOffset);if("xfffee000"!==s)return r&&r.push("unexpected tag ".concat(s," while searching for end of pixel data element with undefined length")),d>e.byteArray.length-e.position&&(d=e.byteArray.length-e.position),t.fragments.push({offset:e.position-o-8,position:e.position,length:d}),e.seek(d),void(t.length=e.position-t.dataOffset);t.fragments.push({offset:e.position-o-8,position:e.position,length:d}),e.seek(d);}r&&r.push("pixel data element ".concat(t.tag," missing sequence delimiter tag xfffee0dd"));}function y(e,t){if(void 0===e)throw "dicomParser.findAndSetUNElementLength: missing required parameter 'byteStream'";for(var r=e.byteArray.length-8;e.position<=r;)if(65534===e.readUint16()){var a=e.readUint16();if(57565===a)return 0!==e.readUint32()&&e.warnings("encountered non zero length following item delimiter at position ".concat(e.position-4," while reading element of undefined length with tag ").concat(t.tag)),void(t.length=e.position-t.dataOffset)}t.length=e.byteArray.length-t.dataOffset,e.seek(e.byteArray.length-e.position);}function b(e,t,r){if(r<0)throw "dicomParser.readFixedString - length cannot be less than 0";if(t+r>e.length)throw "dicomParser.readFixedString: attempt to read past end of buffer";for(var a,n="",i=0;i<r;i++){if(0===(a=e[t+i]))return t+=r,n;n+=String.fromCharCode(a);}return n}function v(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a);}}function P(e,t){return void 0!==e.parser?e.parser:t}var w=function(){function a(e,t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),this.byteArrayParser=e,this.byteArray=t,this.elements=r;}var e,t;return e=a,(t=[{key:"uint16",value:function(e,t){e=this.elements[e];if(t=void 0!==t?t:0,e&&0!==e.length)return P(e,this.byteArrayParser).readUint16(this.byteArray,e.dataOffset+2*t)}},{key:"int16",value:function(e,t){e=this.elements[e];if(t=void 0!==t?t:0,e&&0!==e.length)return P(e,this.byteArrayParser).readInt16(this.byteArray,e.dataOffset+2*t)}},{key:"uint32",value:function(e,t){e=this.elements[e];if(t=void 0!==t?t:0,e&&0!==e.length)return P(e,this.byteArrayParser).readUint32(this.byteArray,e.dataOffset+4*t)}},{key:"int32",value:function(e,t){e=this.elements[e];if(t=void 0!==t?t:0,e&&0!==e.length)return P(e,this.byteArrayParser).readInt32(this.byteArray,e.dataOffset+4*t)}},{key:"float",value:function(e,t){e=this.elements[e];if(t=void 0!==t?t:0,e&&0!==e.length)return P(e,this.byteArrayParser).readFloat(this.byteArray,e.dataOffset+4*t)}},{key:"double",value:function(e,t){e=this.elements[e];if(t=void 0!==t?t:0,e&&0!==e.length)return P(e,this.byteArrayParser).readDouble(this.byteArray,e.dataOffset+8*t)}},{key:"numStringValues",value:function(e){e=this.elements[e];if(e&&0<e.length){e=b(this.byteArray,e.dataOffset,e.length).match(/\\/g);return null===e?1:e.length+1}}},{key:"string",value:function(e,t){e=this.elements[e];if(e&&e.Value)return e.Value;if(e&&0<e.length){e=b(this.byteArray,e.dataOffset,e.length);return 0<=t?e.split("\\")[t].trim():e.trim()}}},{key:"text",value:function(e,t){e=this.elements[e];if(e&&0<e.length){e=b(this.byteArray,e.dataOffset,e.length);return 0<=t?e.split("\\")[t].replace(/ +$/,""):e.replace(/ +$/,"")}}},{key:"floatString",value:function(e,t){var r=this.elements[e];if(r&&0<r.length){t=this.string(e,t=void 0!==t?t:0);if(void 0!==t)return parseFloat(t)}}},{key:"intString",value:function(e,t){var r=this.elements[e];if(r&&0<r.length){t=this.string(e,t=void 0!==t?t:0);if(void 0!==t)return parseInt(t)}}},{key:"attributeTag",value:function(e){var t=this.elements[e];if(t&&4===t.length){var r=P(t,this.byteArrayParser).readUint16,e=this.byteArray,t=t.dataOffset;return "x".concat("00000000".concat((256*r(e,t)*256+r(e,t+2)).toString(16)).substr(-8))}}}])&&v(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),a}();function x(e,t){if(void 0===e)throw "dicomParser.readDicomElementImplicit: missing required parameter 'byteStream'";for(var r=e.byteArray.length-8;e.position<=r;)if(65534===e.readUint16()){var a=e.readUint16();if(57357===a)return 0!==e.readUint32()&&e.warnings("encountered non zero length following item delimiter at position ".concat(e.position-4," while reading element of undefined length with tag ").concat(t.tag)),void(t.length=e.position-t.dataOffset)}t.length=e.byteArray.length-t.dataOffset,e.seek(e.byteArray.length-e.position);}var E=function(e,t){if(void 0!==e.vr)return "SQ"===e.vr;if(t.position+4<=t.byteArray.length){e=h(t);return t.seek(-4),"xfffee000"===e||"xfffee0dd"===e}return t.warnings.push("eof encountered before finding sequence item tag or sequence delimiter tag in peeking to determine VR"),!1};function A(e,t,r){if(void 0===e)throw "dicomParser.readDicomElementImplicit: missing required parameter 'byteStream'";var a=h(e),a={tag:a,vr:void 0!==r?r(a):void 0,length:e.readUint32(),dataOffset:e.position};return 4294967295===a.length&&(a.hadUndefinedLength=!0),a.tag===t||(!E(a,e)||f(a.tag)&&!a.hadUndefinedLength?a.hadUndefinedLength?x(e,a):e.seek(a.length):(F(e,a,r),f(a.tag)&&(a.items=void 0))),a}function S(e){if(void 0===e)throw "dicomParser.readSequenceItem: missing required parameter 'byteStream'";var t={tag:h(e),length:e.readUint32(),dataOffset:e.position};if("xfffee000"!==t.tag)throw "dicomParser.readSequenceItem: item tag (FFFE,E000) not found at offset ".concat(e.position);return t}function D(e,t){var r=S(e);return 4294967295===r.length?(r.hadUndefinedLength=!0,r.dataSet=function(e,t){for(var r={};e.position<e.byteArray.length;){var a=A(e,void 0,t);if("xfffee00d"===(r[a.tag]=a).tag)return new w(e.byteArrayParser,e.byteArray,r)}return e.warnings.push("eof encountered before finding sequence item delimiter in sequence item of undefined length"),new w(e.byteArrayParser,e.byteArray,r)}(e,t),r.length=e.position-r.dataOffset):(r.dataSet=new w(e.byteArrayParser,e.byteArray,{}),T(r.dataSet,e,e.position+r.length,{vrCallback:t})),r}function F(e,t,r){if(void 0===e)throw "dicomParser.readSequenceItemsImplicit: missing required parameter 'byteStream'";if(void 0===t)throw "dicomParser.readSequenceItemsImplicit: missing required parameter 'element'";t.items=[],(4294967295===t.length?function(e,t,r){for(;e.position+4<=e.byteArray.length;){var a=h(e);if(e.seek(-4),"xfffee0dd"===a)return t.length=e.position-t.dataOffset,e.seek(8);a=D(e,r);t.items.push(a);}e.warnings.push("eof encountered before finding sequence delimiter in sequence of undefined length"),t.length=e.byteArray.length-t.dataOffset;}:function(e,t,r){for(var a=t.dataOffset+t.length;e.position<a;){var n=D(e,r);t.items.push(n);}})(e,t,r);}function O(e,t){var r=S(e);return 4294967295===r.length?(r.hadUndefinedLength=!0,r.dataSet=function(e,t){for(var r={};e.position<e.byteArray.length;){var a=B(e,t);if("xfffee00d"===(r[a.tag]=a).tag)return new w(e.byteArrayParser,e.byteArray,r)}return t.push("eof encountered before finding item delimiter tag while reading sequence item of undefined length"),new w(e.byteArrayParser,e.byteArray,r)}(e,t),r.length=e.position-r.dataOffset):(r.dataSet=new w(e.byteArrayParser,e.byteArray,{}),q(r.dataSet,e,e.position+r.length)),r}function I(e,t,r){if(void 0===e)throw "dicomParser.readSequenceItemsExplicit: missing required parameter 'byteStream'";if(void 0===t)throw "dicomParser.readSequenceItemsExplicit: missing required parameter 'element'";t.items=[],(4294967295===t.length?function(e,t,r){for(;e.position+4<=e.byteArray.length;){var a=h(e);if(e.seek(-4),"xfffee0dd"===a)return t.length=e.position-t.dataOffset,e.seek(8);a=O(e,r);t.items.push(a);}r.push("eof encountered before finding sequence delimitation tag while reading sequence of undefined length"),t.length=e.position-t.dataOffset;}:function(e,t,r){for(var a=t.dataOffset+t.length;e.position<a;){var n=O(e,r);t.items.push(n);}})(e,t,r);}var U=function(e){return "OB"===e||"OD"===e||"OL"===e||"OW"===e||"SQ"===e||"OF"===e||"UC"===e||"UR"===e||"UT"===e||"UN"===e?4:2};function B(e,t,r){if(void 0===e)throw "dicomParser.readDicomElementExplicit: missing required parameter 'byteStream'";var a={tag:h(e),vr:e.readFixedString(2)};return 2===U(a.vr)?a.length=e.readUint16():(e.seek(2),a.length=e.readUint32()),a.dataOffset=e.position,4294967295===a.length&&(a.hadUndefinedLength=!0),a.tag===r||("SQ"===a.vr?I(e,a,t):4294967295===a.length?"x7fe00010"===a.tag?g(e,a,t):("UN"===a.vr?F:x)(e,a):e.seek(a.length)),a}function q(e,t,r){var a=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(r=void 0===r?t.byteArray.length:r,void 0===t)throw "dicomParser.parseDicomDataSetExplicit: missing required parameter 'byteStream'";if(r<t.position||r>t.byteArray.length)throw "dicomParser.parseDicomDataSetExplicit: invalid value for parameter 'maxP osition'";for(var n=e.elements;t.position<r;){var i=B(t,e.warnings,a.untilTag);if((n[i.tag]=i).tag===a.untilTag)return}if(t.position>r)throw "dicomParser:parseDicomDataSetExplicit: buffer overrun"}function T(e,t,r){var a=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(r=void 0===r?e.byteArray.length:r,void 0===t)throw "dicomParser.parseDicomDataSetImplicit: missing required parameter 'byteStream'";if(r<t.position||r>t.byteArray.length)throw "dicomParser.parseDicomDataSetImplicit: invalid value for parameter 'maxPosition'";for(var n=e.elements;t.position<r;){var i=A(t,a.untilTag,a.vrCallback);if((n[i.tag]=i).tag===a.untilTag)return}}function k(e,t){if("undefined"!=typeof Buffer&&e instanceof Buffer)return Buffer.alloc(t);if(e instanceof Uint8Array)return new Uint8Array(t);throw "dicomParser.alloc: unknown type for byteArray"}var L="1.8.12",N={readUint16:function(e,t){if(t<0)throw "bigEndianByteArrayParser.readUint16: position cannot be less than 0";if(t+2>e.length)throw "bigEndianByteArrayParser.readUint16: attempt to read past end of buffer";return (e[t]<<8)+e[t+1]},readInt16:function(e,t){if(t<0)throw "bigEndianByteArrayParser.readInt16: position cannot be less than 0";if(t+2>e.length)throw "bigEndianByteArrayParser.readInt16: attempt to read past end of buffer";t=(e[t]<<8)+e[t+1];return t=32768&t?t-65535-1:t},readUint32:function(e,t){if(t<0)throw "bigEndianByteArrayParser.readUint32: position cannot be less than 0";if(t+4>e.length)throw "bigEndianByteArrayParser.readUint32: attempt to read past end of buffer";return 256*(256*(256*e[t]+e[t+1])+e[t+2])+e[t+3]},readInt32:function(e,t){if(t<0)throw "bigEndianByteArrayParser.readInt32: position cannot be less than 0";if(t+4>e.length)throw "bigEndianByteArrayParser.readInt32: attempt to read past end of buffer";return (e[t]<<24)+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3]},readFloat:function(e,t){if(t<0)throw "bigEndianByteArrayParser.readFloat: position cannot be less than 0";if(t+4>e.length)throw "bigEndianByteArrayParser.readFloat: attempt to read past end of buffer";var r=new Uint8Array(4);return r[3]=e[t],r[2]=e[t+1],r[1]=e[t+2],r[0]=e[t+3],new Float32Array(r.buffer)[0]},readDouble:function(e,t){if(t<0)throw "bigEndianByteArrayParser.readDouble: position cannot be less than 0";if(t+8>e.length)throw "bigEndianByteArrayParser.readDouble: attempt to read past end of buffer";var r=new Uint8Array(8);return r[7]=e[t],r[6]=e[t+1],r[5]=e[t+2],r[4]=e[t+3],r[3]=e[t+4],r[2]=e[t+5],r[1]=e[t+6],r[0]=e[t+7],new Float64Array(r.buffer)[0]}};function j(e,t,r){if("undefined"!=typeof Buffer&&e instanceof Buffer)return e.slice(t,t+r);if(e instanceof Uint8Array)return new Uint8Array(e.buffer,e.byteOffset+t,r);throw "dicomParser.from: unknown type for byteArray"}function C(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a);}}var J=function(){function a(e,t,r){if(!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),void 0===e)throw "dicomParser.ByteStream: missing required parameter 'byteArrayParser'";if(void 0===t)throw "dicomParser.ByteStream: missing required parameter 'byteArray'";if(t instanceof Uint8Array==!1&&("undefined"==typeof Buffer||t instanceof Buffer==!1))throw "dicomParser.ByteStream: parameter byteArray is not of type Uint8Array or Buffer";if(r<0)throw "dicomParser.ByteStream: parameter 'position' cannot be less than 0";if(r>=t.length)throw "dicomParser.ByteStream: parameter 'position' cannot be greater than or equal to 'byteArray' length";this.byteArrayParser=e,this.byteArray=t,this.position=r||0,this.warnings=[];}var e,t;return e=a,(t=[{key:"seek",value:function(e){if(this.position+e<0)throw "dicomParser.ByteStream.prototype.seek: cannot seek to position < 0";this.position+=e;}},{key:"readByteStream",value:function(e){if(this.position+e>this.byteArray.length)throw "dicomParser.ByteStream.prototype.readByteStream: readByteStream - buffer overread";var t=j(this.byteArray,this.position,e);return this.position+=e,new a(this.byteArrayParser,t)}},{key:"getSize",value:function(){return this.byteArray.length}},{key:"readUint16",value:function(){var e=this.byteArrayParser.readUint16(this.byteArray,this.position);return this.position+=2,e}},{key:"readUint32",value:function(){var e=this.byteArrayParser.readUint32(this.byteArray,this.position);return this.position+=4,e}},{key:"readFixedString",value:function(e){var t=b(this.byteArray,this.position,e);return this.position+=e,t}}])&&C(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),a}(),M={readUint16:function(e,t){if(t<0)throw "littleEndianByteArrayParser.readUint16: position cannot be less than 0";if(t+2>e.length)throw "littleEndianByteArrayParser.readUint16: attempt to read past end of buffer";return e[t]+256*e[t+1]},readInt16:function(e,t){if(t<0)throw "littleEndianByteArrayParser.readInt16: position cannot be less than 0";if(t+2>e.length)throw "littleEndianByteArrayParser.readInt16: attempt to read past end of buffer";t=e[t]+(e[t+1]<<8);return t=32768&t?t-65535-1:t},readUint32:function(e,t){if(t<0)throw "littleEndianByteArrayParser.readUint32: position cannot be less than 0";if(t+4>e.length)throw "littleEndianByteArrayParser.readUint32: attempt to read past end of buffer";return e[t]+256*e[t+1]+256*e[t+2]*256+256*e[t+3]*256*256},readInt32:function(e,t){if(t<0)throw "littleEndianByteArrayParser.readInt32: position cannot be less than 0";if(t+4>e.length)throw "littleEndianByteArrayParser.readInt32: attempt to read past end of buffer";return e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24)},readFloat:function(e,t){if(t<0)throw "littleEndianByteArrayParser.readFloat: position cannot be less than 0";if(t+4>e.length)throw "littleEndianByteArrayParser.readFloat: attempt to read past end of buffer";var r=new Uint8Array(4);return r[0]=e[t],r[1]=e[t+1],r[2]=e[t+2],r[3]=e[t+3],new Float32Array(r.buffer)[0]},readDouble:function(e,t){if(t<0)throw "littleEndianByteArrayParser.readDouble: position cannot be less than 0";if(t+8>e.length)throw "littleEndianByteArrayParser.readDouble: attempt to read past end of buffer";var r=new Uint8Array(8);return r[0]=e[t],r[1]=e[t+1],r[2]=e[t+2],r[3]=e[t+3],r[4]=e[t+4],r[5]=e[t+5],r[6]=e[t+6],r[7]=e[t+7],new Float64Array(r.buffer)[0]}};function G(e){var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(void 0===e)throw "dicomParser.readPart10Header: missing required parameter 'byteArray'";var o=i.TransferSyntaxUID,s=new J(M,e);return function(){var e=function(){if(s.getSize()<=132&&o)return !1;if(s.seek(128),"DICM"===s.readFixedString(4))return !0;if(!(i||{}).TransferSyntaxUID)throw "dicomParser.readPart10Header: DICM prefix not found at location 132 - this is not a valid DICOM P10 file.";return s.seek(0),!1}(),t=[],r={};if(!e)return s.position=0,{elements:{x00020010:{tag:"x00020010",vr:"UI",Value:o}},warnings:t};for(;s.position<s.byteArray.length;){var a=s.position,n=B(s,t);if("x0002ffff"<n.tag){s.position=a;break}n.parser=M,r[n.tag]=n;}return (e=new w(s.byteArrayParser,s.byteArray,r)).warnings=s.warnings,e.position=s.position,e}()}var z="1.2.840.10008.1.2.2";function V(i){var o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(void 0===i)throw new Error("dicomParser.parseDicom: missing required parameter 'byteArray'");var e,a=function(e){if(void 0===e.elements.x00020010)throw new Error("dicomParser.parseDicom: missing required meta header attribute 0002,0010");e=e.elements.x00020010;return e&&e.Value||b(i,e.dataOffset,e.length)};function t(t){var e=a(t),r="1.2.840.10008.1.2"!==e,e=function(e,t){var r="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);if("1.2.840.10008.1.2.1.99"!==e)return new J(e===z?N:M,i,t);if(o&&o.inflater){e=o.inflater(i,t);return new J(M,e,0)}if(!0==r){var a=s(0),n=j(i,t,i.length-t),a=a.inflateRawSync(n),n=k(i,a.length+t);return i.copy(n,0,0,t),a.copy(n,t),new J(M,n,0)}if("undefined"==typeof pako)throw "dicomParser.parseDicom: no inflater available to handle deflate transfer syntax";return a=i.slice(t),n=pako.inflateRaw(a),(a=k(i,n.length+t)).set(i.slice(0,t),0),a.set(n,t),new J(M,a,0)}(e,t.position),t=new w(e.byteArrayParser,e.byteArray,{});t.warnings=e.warnings;try{(r?q:T)(t,e,e.byteArray.length,o);}catch(e){throw {exception:e,dataSet:t}}return t}return function(e,t){for(var r in e.elements)e.elements.hasOwnProperty(r)&&(t.elements[r]=e.elements[r]);return void 0!==e.warnings&&(t.warnings=e.warnings.concat(t.warnings)),t}(e=G(i,o),t(e))}var R=function(e,t,r){for(var a=0,n=t;n<t+r;n++)a+=e[n].length;return a};function _(e,t,r,a,n){if(n=n||t.fragments,void 0===e)throw "dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'dataSet'";if(void 0===t)throw "dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'pixelDataElement'";if(void 0===r)throw "dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'startFragmentIndex'";if(void 0===(a=a||1))throw "dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'numFragments'";if("x7fe00010"!==t.tag)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010";if(!0!==t.encapsulatedPixelData)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.basicOffsetTable)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.fragments)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(t.fragments.length<=0)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(r<0)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragmentIndex' must be >= 0";if(r>=t.fragments.length)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragmentIndex' must be < number of fragments";if(a<1)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'numFragments' must be > 0";if(r+a>t.fragments.length)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragment' + 'numFragments' < number of fragments";var i=new J(e.byteArrayParser,e.byteArray,t.dataOffset),t=S(i);if("xfffee000"!==t.tag)throw "dicomParser.readEncapsulatedPixelData: missing basic offset table xfffee000";i.seek(t.length);var o=i.position;if(1===a)return j(i.byteArray,o+n[r].offset+8,n[r].length);for(var t=R(n,r,a),s=k(i.byteArray,t),d=0,f=r;f<r+a;f++)for(var l=o+n[f].offset+8,u=0;u<n[f].length;u++)s[d++]=i.byteArray[l++];return s}var H=function(e,t){for(var r=0;r<e.length;r++)if(e[r].offset===t)return r},Q=function(e,t,r,a){if(e===t.length-1)return r.length-a;for(var n=t[e+1],i=a+1;i<r.length;i++)if(r[i].offset===n)return i-a;throw "dicomParser.calculateNumberOfFragmentsForFrame: could not find fragment with offset matching basic offset table"};function W(e,t,r,a,n){if(a=a||t.basicOffsetTable,n=n||t.fragments,void 0===e)throw "dicomParser.readEncapsulatedImageFrame: missing required parameter 'dataSet'";if(void 0===t)throw "dicomParser.readEncapsulatedImageFrame: missing required parameter 'pixelDataElement'";if(void 0===r)throw "dicomParser.readEncapsulatedImageFrame: missing required parameter 'frameIndex'";if(void 0===a)throw "dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' does not have basicOffsetTable";if("x7fe00010"!==t.tag)throw "dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010)";if(!0!==t.encapsulatedPixelData)throw "dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw "dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have undefined length";if(void 0===t.fragments)throw "dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have fragments";if(0===a.length)throw "dicomParser.readEncapsulatedImageFrame: basicOffsetTable has zero entries";if(r<0)throw "dicomParser.readEncapsulatedImageFrame: parameter 'frameIndex' must be >= 0";if(r>=a.length)throw "dicomParser.readEncapsulatedImageFrame: parameter 'frameIndex' must be < basicOffsetTable.length";var i=a[r],i=H(n,i);if(void 0===i)throw "dicomParser.readEncapsulatedImageFrame: unable to find fragment that matches basic offset table entry";return _(e,t,i,Q(r,a,n,i),n)}var $=!1;function K(e,t,r){if($||($=!0,console&&console.log&&console.log("WARNING: dicomParser.readEncapsulatedPixelData() has been deprecated")),void 0===e)throw "dicomParser.readEncapsulatedPixelData: missing required parameter 'dataSet'";if(void 0===t)throw "dicomParser.readEncapsulatedPixelData: missing required parameter 'element'";if(void 0===r)throw "dicomParser.readEncapsulatedPixelData: missing required parameter 'frame'";if("x7fe00010"!==t.tag)throw "dicomParser.readEncapsulatedPixelData: parameter 'element' refers to non pixel data tag (expected tag = x7fe00010)";if(!0!==t.encapsulatedPixelData)throw "dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw "dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.basicOffsetTable)throw "dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.fragments)throw "dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(r<0)throw "dicomParser.readEncapsulatedPixelData: parameter 'frame' must be >= 0";return 0!==t.basicOffsetTable.length?W(e,t,r):_(e,t,0,t.fragments.length)}t.default={isStringVr:d,isPrivateTag:f,parsePN:a,parseTM:n,parseDA:o,explicitElementToString:l,explicitDataSetToJS:u,createJPEGBasicOffsetTable:p,parseDicomDataSetExplicit:q,parseDicomDataSetImplicit:T,readFixedString:b,alloc:k,version:L,bigEndianByteArrayParser:N,ByteStream:J,sharedCopy:j,DataSet:w,findAndSetUNElementLength:y,findEndOfEncapsulatedElement:g,findItemDelimitationItemAndSetElementLength:x,littleEndianByteArrayParser:M,parseDicom:V,readDicomElementExplicit:B,readDicomElementImplicit:A,readEncapsulatedImageFrame:W,readEncapsulatedPixelData:K,readEncapsulatedPixelDataFromFragments:_,readPart10Header:G,readSequenceItemsExplicit:I,readSequenceItemsImplicit:F,readSequenceItem:S,readTag:h,LEI:"1.2.840.10008.1.2",LEE:"1.2.840.10008.1.2.1"};}],i={},n.m=a,n.c=i,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r});},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0});},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)n.d(r,a,function(e){return t[e]}.bind(null,a));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1);function n(e){if(i[e])return i[e].exports;var t=i[e]={i:e,l:!1,exports:{}};return a[e].call(t.exports,t,t.exports,n),t.l=!0,t.exports}var a,i;});
|
|
476
488
|
|
|
477
489
|
});
|
|
478
490
|
|
|
@@ -2339,7 +2351,7 @@ var ControllerFactory = function ControllerFactory(object, property) {
|
|
|
2339
2351
|
function requestAnimationFrame$1(callback) {
|
|
2340
2352
|
setTimeout(callback, 1000 / 60);
|
|
2341
2353
|
}
|
|
2342
|
-
var requestAnimationFrame$1$1 = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || requestAnimationFrame$1;
|
|
2354
|
+
var requestAnimationFrame$1$1 = typeof window === "undefined" ? requestAnimationFrame$1 : window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || requestAnimationFrame$1;
|
|
2343
2355
|
|
|
2344
2356
|
var CenteredDiv = function () {
|
|
2345
2357
|
function CenteredDiv() {
|
|
@@ -2418,7 +2430,7 @@ var CenteredDiv = function () {
|
|
|
2418
2430
|
|
|
2419
2431
|
var styleSheet = ___$insertStyle(".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .cr.function .property-name{width:100%}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n");
|
|
2420
2432
|
|
|
2421
|
-
css.inject(styleSheet);
|
|
2433
|
+
if (typeof document !== "undefined") css.inject(styleSheet);
|
|
2422
2434
|
var CSS_NAMESPACE = 'dg';
|
|
2423
2435
|
var HIDE_KEY_CODE = 72;
|
|
2424
2436
|
var CLOSE_BUTTON_HEIGHT = 20;
|
|
@@ -2684,7 +2696,7 @@ GUI._keydownHandler = function (e) {
|
|
|
2684
2696
|
GUI.toggleHide();
|
|
2685
2697
|
}
|
|
2686
2698
|
};
|
|
2687
|
-
dom.bind(window, 'keydown', GUI._keydownHandler, false);
|
|
2699
|
+
if (typeof window !== "undefined") dom.bind(window, 'keydown', GUI._keydownHandler, false);
|
|
2688
2700
|
Common.extend(GUI.prototype,
|
|
2689
2701
|
{
|
|
2690
2702
|
add: function add(object, property) {
|
|
@@ -22029,15 +22041,15 @@ function checkThreeRevision(built, loaded) {
|
|
|
22029
22041
|
}
|
|
22030
22042
|
|
|
22031
22043
|
// import * as kiwrious from "copper3d_plugin_heart_k";
|
|
22032
|
-
// "v4.1.
|
|
22044
|
+
// "v4.1.1" is injected at build time by rollup @rollup/plugin-replace, sourced from package.json version.
|
|
22033
22045
|
// When copper3d is consumed from local source (no rollup replace step), the identifier is undefined and
|
|
22034
22046
|
// referencing it throws a ReferenceError — guard it so local loading still works.
|
|
22035
22047
|
let _revision = "unknown";
|
|
22036
22048
|
try {
|
|
22037
|
-
_revision = "v4.1.
|
|
22049
|
+
_revision = "v4.1.1";
|
|
22038
22050
|
}
|
|
22039
22051
|
catch (_a) {
|
|
22040
|
-
/* "v4.1.
|
|
22052
|
+
/* "v4.1.1" not injected (local source build) */
|
|
22041
22053
|
}
|
|
22042
22054
|
const REVISION = _revision;
|
|
22043
22055
|
// "186" is three's revision at build time, injected the same way.
|
package/dist/bundle.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('three'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'three', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.copper3d = {}, global.THREE, global.
|
|
5
|
-
})(this, (function (exports, THREE,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('three'), require('three/addons/loaders/NRRDLoader.js'), require('three/addons/misc/Volume.js'), require('three/addons/shaders/VolumeShader.js'), require('three/addons/geometries/DecalGeometry.js'), require('three/addons/loaders/OBJLoader.js'), require('three/addons/controls/OrbitControls.js'), require('three/addons/loaders/RGBELoader.js'), require('three/addons/libs/stats.module.js'), require('three/addons/loaders/GLTFLoader.js'), require('three/addons/loaders/KTX2Loader.js'), require('three/addons/loaders/DRACOLoader.js'), require('three/addons/loaders/VTKLoader.js'), require('three/addons/controls/TrackballControls.js'), require('three/addons/lines/Line2.js'), require('three/addons/lines/LineGeometry.js'), require('three/addons/lines/LineMaterial.js'), require('three/addons/utils/BufferGeometryUtils.js')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'three', 'three/addons/loaders/NRRDLoader.js', 'three/addons/misc/Volume.js', 'three/addons/shaders/VolumeShader.js', 'three/addons/geometries/DecalGeometry.js', 'three/addons/loaders/OBJLoader.js', 'three/addons/controls/OrbitControls.js', 'three/addons/loaders/RGBELoader.js', 'three/addons/libs/stats.module.js', 'three/addons/loaders/GLTFLoader.js', 'three/addons/loaders/KTX2Loader.js', 'three/addons/loaders/DRACOLoader.js', 'three/addons/loaders/VTKLoader.js', 'three/addons/controls/TrackballControls.js', 'three/addons/lines/Line2.js', 'three/addons/lines/LineGeometry.js', 'three/addons/lines/LineMaterial.js', 'three/addons/utils/BufferGeometryUtils.js'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.copper3d = {}, global.THREE, global.NRRDLoader_js, global.Volume_js, global.VolumeShader_js, null, global.OBJLoader_js, global.OrbitControls_js, global.RGBELoader_js, global.Stats, global.GLTFLoader_js, global.KTX2Loader_js, global.DRACOLoader_js, global.VTKLoader_js, global.TrackballControls_js, global.Line2_js, global.LineGeometry_js, global.LineMaterial_js, global.BufferGeometryUtils_js));
|
|
5
|
+
})(this, (function (exports, THREE, NRRDLoader_js, Volume_js, VolumeShader_js, DecalGeometry_js, OBJLoader_js, OrbitControls_js, RGBELoader_js, Stats, GLTFLoader_js, KTX2Loader_js, DRACOLoader_js, VTKLoader_js, TrackballControls_js, Line2_js, LineGeometry_js, LineMaterial_js, BufferGeometryUtils_js) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
|
|
28
|
-
var zlib__default = /*#__PURE__*/_interopDefaultLegacy(zlib);
|
|
29
28
|
var Stats__default = /*#__PURE__*/_interopDefaultLegacy(Stats);
|
|
30
29
|
|
|
31
30
|
class Controls {
|
|
@@ -479,9 +478,22 @@
|
|
|
479
478
|
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
480
479
|
}
|
|
481
480
|
|
|
481
|
+
function getCjsExportFromNamespace (n) {
|
|
482
|
+
return n && n['default'] || n;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
var _zlibShim = typeof process !== "undefined" && typeof process.getBuiltinModule === "function" ? process.getBuiltinModule("zlib") : {};
|
|
486
|
+
|
|
487
|
+
var _zlibShim$1 = /*#__PURE__*/Object.freeze({
|
|
488
|
+
__proto__: null,
|
|
489
|
+
'default': _zlibShim
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
var require$$0 = getCjsExportFromNamespace(_zlibShim$1);
|
|
493
|
+
|
|
482
494
|
var dicomParser_min = createCommonjsModule(function (module, exports) {
|
|
483
495
|
/*! dicom-parser - 1.8.12 - 2023-02-20 | (c) 2017 Chris Hafey | https://github.com/cornerstonejs/dicomParser */
|
|
484
|
-
!function(e,t){module.exports=t(zlib__default["default"]);}(commonjsGlobal,function(r){return a=[function(e,t){e.exports=r;},function(e,t,s){s.r(t),s.d(t,"isStringVr",function(){return d}),s.d(t,"isPrivateTag",function(){return f}),s.d(t,"parsePN",function(){return a}),s.d(t,"parseTM",function(){return n}),s.d(t,"parseDA",function(){return o}),s.d(t,"explicitElementToString",function(){return l}),s.d(t,"explicitDataSetToJS",function(){return u}),s.d(t,"createJPEGBasicOffsetTable",function(){return p}),s.d(t,"parseDicomDataSetExplicit",function(){return q}),s.d(t,"parseDicomDataSetImplicit",function(){return T}),s.d(t,"readFixedString",function(){return b}),s.d(t,"alloc",function(){return k}),s.d(t,"version",function(){return L}),s.d(t,"bigEndianByteArrayParser",function(){return N}),s.d(t,"ByteStream",function(){return J}),s.d(t,"sharedCopy",function(){return j}),s.d(t,"DataSet",function(){return w}),s.d(t,"findAndSetUNElementLength",function(){return y}),s.d(t,"findEndOfEncapsulatedElement",function(){return g}),s.d(t,"findItemDelimitationItemAndSetElementLength",function(){return x}),s.d(t,"littleEndianByteArrayParser",function(){return M}),s.d(t,"parseDicom",function(){return V}),s.d(t,"readDicomElementExplicit",function(){return B}),s.d(t,"readDicomElementImplicit",function(){return A}),s.d(t,"readEncapsulatedImageFrame",function(){return W}),s.d(t,"readEncapsulatedPixelData",function(){return K}),s.d(t,"readEncapsulatedPixelDataFromFragments",function(){return _}),s.d(t,"readPart10Header",function(){return G}),s.d(t,"readSequenceItemsExplicit",function(){return I}),s.d(t,"readSequenceItemsImplicit",function(){return F}),s.d(t,"readSequenceItem",function(){return S}),s.d(t,"readTag",function(){return h});var r={AE:!0,AS:!0,AT:!1,CS:!0,DA:!0,DS:!0,DT:!0,FL:!1,FD:!1,IS:!0,LO:!0,LT:!0,OB:!1,OD:!1,OF:!1,OW:!1,PN:!0,SH:!0,SL:!1,SQ:!1,SS:!1,ST:!0,TM:!0,UI:!0,UL:!1,UN:void 0,UR:!0,US:!1,UT:!0},d=function(e){return r[e]},f=function(e){e=parseInt(e[4],16);if(isNaN(e))throw "dicomParser.isPrivateTag: cannot parse last character of group";return e%2==1},a=function(e){if(void 0!==e){e=e.split("^");return {familyName:e[0],givenName:e[1],middleName:e[2],prefix:e[3],suffix:e[4]}}};function n(e,t){if(2<=e.length){var r=parseInt(e.substring(0,2),10),a=4<=e.length?parseInt(e.substring(2,4),10):void 0,n=6<=e.length?parseInt(e.substring(4,6),10):void 0,i=8<=e.length?e.substring(7,13):void 0,i=i?parseInt(i,10)*Math.pow(10,6-i.length):void 0;if(t&&(isNaN(r)||void 0!==a&&isNaN(a)||void 0!==n&&isNaN(n)||void 0!==i&&isNaN(i)||r<0||23<r||a&&(a<0||59<a)||n&&(n<0||59<n)||i&&(i<0||999999<i)))throw "invalid TM '".concat(e,"'");return {hours:r,minutes:a,seconds:n,fractionalSeconds:i}}if(t)throw "invalid TM '".concat(e,"'")}function i(e,t,r){return !isNaN(r)&&(0<t&&t<=12&&0<e&&e<=function(e,t){switch(e){case 2:return t%4==0&&t%100||t%400==0?29:28;case 9:case 4:case 6:case 11:return 30;default:return 31}}(t,r))}function o(e,t){if(e&&8===e.length){var r=parseInt(e.substring(0,4),10),a=parseInt(e.substring(4,6),10),n=parseInt(e.substring(6,8),10);if(t&&!0!==i(n,a,r))throw "invalid DA '".concat(e,"'");return {year:r,month:a,day:n}}if(t)throw "invalid DA '".concat(e,"'")}function l(n,e){if(void 0===n||void 0===e)throw "dicomParser.explicitElementToString: missing required parameters";if(void 0===e.vr)throw "dicomParser.explicitElementToString: cannot convert implicit element to string";var t,r=e.vr,i=e.tag;function a(e,t){for(var r="",a=0;a<e;a++)0!==a&&(r+="/"),r+=t.call(n,i,a).toString();return r}if(!0===d(r))t=n.string(i);else {if("AT"===r){var o=n.uint32(i);return void 0===o?void 0:"x".concat((o=o<0?4294967295+o+1:o).toString(16).toUpperCase())}"US"===r?t=a(e.length/2,n.uint16):"SS"===r?t=a(e.length/2,n.int16):"UL"===r?t=a(e.length/4,n.uint32):"SL"===r?t=a(e.length/4,n.int32):"FD"===r?t=a(e.length/8,n.double):"FL"===r&&(t=a(e.length/4,n.float));}return t}function u(e,t){if(void 0===e)throw "dicomParser.explicitDataSetToJS: missing required parameter dataSet";t=t||{omitPrivateAttibutes:!0,maxElementLength:128};var r,a={};for(r in e.elements){var n=e.elements[r];if(!0!==t.omitPrivateAttibutes||!f(r))if(n.items){for(var i=[],o=0;o<n.items.length;o++)i.push(u(n.items[o].dataSet,t));a[r]=i;}else {var s=void 0;n.length<t.maxElementLength&&(s=l(e,n)),a[r]=void 0!==s?s:{dataOffset:n.dataOffset,length:n.length};}}return a}function c(e,t){return 255===e.byteArray[t]&&217===e.byteArray[t+1]}function m(e,t,r){for(var a,n,i=r;i<t.fragments.length;i++)if(a=e,n=i,n=t.fragments[n],!(!c(a,n.position+n.length-2)&&!c(a,n.position+n.length-3)))return i}function p(e,t,r){if(void 0===e)throw "dicomParser.createJPEGBasicOffsetTable: missing required parameter dataSet";if(void 0===t)throw "dicomParser.createJPEGBasicOffsetTable: missing required parameter pixelDataElement";if("x7fe00010"!==t.tag)throw "dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010'";if(!0!==t.encapsulatedPixelData)throw "dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw "dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.basicOffsetTable)throw "dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.fragments)throw "dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(t.fragments.length<=0)throw "dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(r&&r.length<=0)throw "dicomParser.createJPEGBasicOffsetTable: parameter 'fragments' must not be zero length";r=r||t.fragments;for(var a=[],n=0;;){a.push(t.fragments[n].offset);var i=m(e,t,n);if(void 0===i||i===t.fragments.length-1)return a;n=i+1;}}function h(e){if(void 0===e)throw "dicomParser.readTag: missing required parameter 'byteStream'";var t=256*e.readUint16()*256,e=e.readUint16();return "x".concat("00000000".concat((t+e).toString(16)).substr(-8))}function g(e,t,r){if(void 0===e)throw "dicomParser.findEndOfEncapsulatedElement: missing required parameter 'byteStream'";if(void 0===t)throw "dicomParser.findEndOfEncapsulatedElement: missing required parameter 'element'";if(t.encapsulatedPixelData=!0,t.basicOffsetTable=[],t.fragments=[],"xfffee000"!==h(e))throw "dicomParser.findEndOfEncapsulatedElement: basic offset table not found";for(var a=e.readUint32()/4,n=0;n<a;n++){var i=e.readUint32();t.basicOffsetTable.push(i);}for(var o=e.position;e.position<e.byteArray.length;){var s=h(e),d=e.readUint32();if("xfffee0dd"===s)return e.seek(d),void(t.length=e.position-t.dataOffset);if("xfffee000"!==s)return r&&r.push("unexpected tag ".concat(s," while searching for end of pixel data element with undefined length")),d>e.byteArray.length-e.position&&(d=e.byteArray.length-e.position),t.fragments.push({offset:e.position-o-8,position:e.position,length:d}),e.seek(d),void(t.length=e.position-t.dataOffset);t.fragments.push({offset:e.position-o-8,position:e.position,length:d}),e.seek(d);}r&&r.push("pixel data element ".concat(t.tag," missing sequence delimiter tag xfffee0dd"));}function y(e,t){if(void 0===e)throw "dicomParser.findAndSetUNElementLength: missing required parameter 'byteStream'";for(var r=e.byteArray.length-8;e.position<=r;)if(65534===e.readUint16()){var a=e.readUint16();if(57565===a)return 0!==e.readUint32()&&e.warnings("encountered non zero length following item delimiter at position ".concat(e.position-4," while reading element of undefined length with tag ").concat(t.tag)),void(t.length=e.position-t.dataOffset)}t.length=e.byteArray.length-t.dataOffset,e.seek(e.byteArray.length-e.position);}function b(e,t,r){if(r<0)throw "dicomParser.readFixedString - length cannot be less than 0";if(t+r>e.length)throw "dicomParser.readFixedString: attempt to read past end of buffer";for(var a,n="",i=0;i<r;i++){if(0===(a=e[t+i]))return t+=r,n;n+=String.fromCharCode(a);}return n}function v(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a);}}function P(e,t){return void 0!==e.parser?e.parser:t}var w=function(){function a(e,t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),this.byteArrayParser=e,this.byteArray=t,this.elements=r;}var e,t;return e=a,(t=[{key:"uint16",value:function(e,t){e=this.elements[e];if(t=void 0!==t?t:0,e&&0!==e.length)return P(e,this.byteArrayParser).readUint16(this.byteArray,e.dataOffset+2*t)}},{key:"int16",value:function(e,t){e=this.elements[e];if(t=void 0!==t?t:0,e&&0!==e.length)return P(e,this.byteArrayParser).readInt16(this.byteArray,e.dataOffset+2*t)}},{key:"uint32",value:function(e,t){e=this.elements[e];if(t=void 0!==t?t:0,e&&0!==e.length)return P(e,this.byteArrayParser).readUint32(this.byteArray,e.dataOffset+4*t)}},{key:"int32",value:function(e,t){e=this.elements[e];if(t=void 0!==t?t:0,e&&0!==e.length)return P(e,this.byteArrayParser).readInt32(this.byteArray,e.dataOffset+4*t)}},{key:"float",value:function(e,t){e=this.elements[e];if(t=void 0!==t?t:0,e&&0!==e.length)return P(e,this.byteArrayParser).readFloat(this.byteArray,e.dataOffset+4*t)}},{key:"double",value:function(e,t){e=this.elements[e];if(t=void 0!==t?t:0,e&&0!==e.length)return P(e,this.byteArrayParser).readDouble(this.byteArray,e.dataOffset+8*t)}},{key:"numStringValues",value:function(e){e=this.elements[e];if(e&&0<e.length){e=b(this.byteArray,e.dataOffset,e.length).match(/\\/g);return null===e?1:e.length+1}}},{key:"string",value:function(e,t){e=this.elements[e];if(e&&e.Value)return e.Value;if(e&&0<e.length){e=b(this.byteArray,e.dataOffset,e.length);return 0<=t?e.split("\\")[t].trim():e.trim()}}},{key:"text",value:function(e,t){e=this.elements[e];if(e&&0<e.length){e=b(this.byteArray,e.dataOffset,e.length);return 0<=t?e.split("\\")[t].replace(/ +$/,""):e.replace(/ +$/,"")}}},{key:"floatString",value:function(e,t){var r=this.elements[e];if(r&&0<r.length){t=this.string(e,t=void 0!==t?t:0);if(void 0!==t)return parseFloat(t)}}},{key:"intString",value:function(e,t){var r=this.elements[e];if(r&&0<r.length){t=this.string(e,t=void 0!==t?t:0);if(void 0!==t)return parseInt(t)}}},{key:"attributeTag",value:function(e){var t=this.elements[e];if(t&&4===t.length){var r=P(t,this.byteArrayParser).readUint16,e=this.byteArray,t=t.dataOffset;return "x".concat("00000000".concat((256*r(e,t)*256+r(e,t+2)).toString(16)).substr(-8))}}}])&&v(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),a}();function x(e,t){if(void 0===e)throw "dicomParser.readDicomElementImplicit: missing required parameter 'byteStream'";for(var r=e.byteArray.length-8;e.position<=r;)if(65534===e.readUint16()){var a=e.readUint16();if(57357===a)return 0!==e.readUint32()&&e.warnings("encountered non zero length following item delimiter at position ".concat(e.position-4," while reading element of undefined length with tag ").concat(t.tag)),void(t.length=e.position-t.dataOffset)}t.length=e.byteArray.length-t.dataOffset,e.seek(e.byteArray.length-e.position);}var E=function(e,t){if(void 0!==e.vr)return "SQ"===e.vr;if(t.position+4<=t.byteArray.length){e=h(t);return t.seek(-4),"xfffee000"===e||"xfffee0dd"===e}return t.warnings.push("eof encountered before finding sequence item tag or sequence delimiter tag in peeking to determine VR"),!1};function A(e,t,r){if(void 0===e)throw "dicomParser.readDicomElementImplicit: missing required parameter 'byteStream'";var a=h(e),a={tag:a,vr:void 0!==r?r(a):void 0,length:e.readUint32(),dataOffset:e.position};return 4294967295===a.length&&(a.hadUndefinedLength=!0),a.tag===t||(!E(a,e)||f(a.tag)&&!a.hadUndefinedLength?a.hadUndefinedLength?x(e,a):e.seek(a.length):(F(e,a,r),f(a.tag)&&(a.items=void 0))),a}function S(e){if(void 0===e)throw "dicomParser.readSequenceItem: missing required parameter 'byteStream'";var t={tag:h(e),length:e.readUint32(),dataOffset:e.position};if("xfffee000"!==t.tag)throw "dicomParser.readSequenceItem: item tag (FFFE,E000) not found at offset ".concat(e.position);return t}function D(e,t){var r=S(e);return 4294967295===r.length?(r.hadUndefinedLength=!0,r.dataSet=function(e,t){for(var r={};e.position<e.byteArray.length;){var a=A(e,void 0,t);if("xfffee00d"===(r[a.tag]=a).tag)return new w(e.byteArrayParser,e.byteArray,r)}return e.warnings.push("eof encountered before finding sequence item delimiter in sequence item of undefined length"),new w(e.byteArrayParser,e.byteArray,r)}(e,t),r.length=e.position-r.dataOffset):(r.dataSet=new w(e.byteArrayParser,e.byteArray,{}),T(r.dataSet,e,e.position+r.length,{vrCallback:t})),r}function F(e,t,r){if(void 0===e)throw "dicomParser.readSequenceItemsImplicit: missing required parameter 'byteStream'";if(void 0===t)throw "dicomParser.readSequenceItemsImplicit: missing required parameter 'element'";t.items=[],(4294967295===t.length?function(e,t,r){for(;e.position+4<=e.byteArray.length;){var a=h(e);if(e.seek(-4),"xfffee0dd"===a)return t.length=e.position-t.dataOffset,e.seek(8);a=D(e,r);t.items.push(a);}e.warnings.push("eof encountered before finding sequence delimiter in sequence of undefined length"),t.length=e.byteArray.length-t.dataOffset;}:function(e,t,r){for(var a=t.dataOffset+t.length;e.position<a;){var n=D(e,r);t.items.push(n);}})(e,t,r);}function O(e,t){var r=S(e);return 4294967295===r.length?(r.hadUndefinedLength=!0,r.dataSet=function(e,t){for(var r={};e.position<e.byteArray.length;){var a=B(e,t);if("xfffee00d"===(r[a.tag]=a).tag)return new w(e.byteArrayParser,e.byteArray,r)}return t.push("eof encountered before finding item delimiter tag while reading sequence item of undefined length"),new w(e.byteArrayParser,e.byteArray,r)}(e,t),r.length=e.position-r.dataOffset):(r.dataSet=new w(e.byteArrayParser,e.byteArray,{}),q(r.dataSet,e,e.position+r.length)),r}function I(e,t,r){if(void 0===e)throw "dicomParser.readSequenceItemsExplicit: missing required parameter 'byteStream'";if(void 0===t)throw "dicomParser.readSequenceItemsExplicit: missing required parameter 'element'";t.items=[],(4294967295===t.length?function(e,t,r){for(;e.position+4<=e.byteArray.length;){var a=h(e);if(e.seek(-4),"xfffee0dd"===a)return t.length=e.position-t.dataOffset,e.seek(8);a=O(e,r);t.items.push(a);}r.push("eof encountered before finding sequence delimitation tag while reading sequence of undefined length"),t.length=e.position-t.dataOffset;}:function(e,t,r){for(var a=t.dataOffset+t.length;e.position<a;){var n=O(e,r);t.items.push(n);}})(e,t,r);}var U=function(e){return "OB"===e||"OD"===e||"OL"===e||"OW"===e||"SQ"===e||"OF"===e||"UC"===e||"UR"===e||"UT"===e||"UN"===e?4:2};function B(e,t,r){if(void 0===e)throw "dicomParser.readDicomElementExplicit: missing required parameter 'byteStream'";var a={tag:h(e),vr:e.readFixedString(2)};return 2===U(a.vr)?a.length=e.readUint16():(e.seek(2),a.length=e.readUint32()),a.dataOffset=e.position,4294967295===a.length&&(a.hadUndefinedLength=!0),a.tag===r||("SQ"===a.vr?I(e,a,t):4294967295===a.length?"x7fe00010"===a.tag?g(e,a,t):("UN"===a.vr?F:x)(e,a):e.seek(a.length)),a}function q(e,t,r){var a=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(r=void 0===r?t.byteArray.length:r,void 0===t)throw "dicomParser.parseDicomDataSetExplicit: missing required parameter 'byteStream'";if(r<t.position||r>t.byteArray.length)throw "dicomParser.parseDicomDataSetExplicit: invalid value for parameter 'maxP osition'";for(var n=e.elements;t.position<r;){var i=B(t,e.warnings,a.untilTag);if((n[i.tag]=i).tag===a.untilTag)return}if(t.position>r)throw "dicomParser:parseDicomDataSetExplicit: buffer overrun"}function T(e,t,r){var a=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(r=void 0===r?e.byteArray.length:r,void 0===t)throw "dicomParser.parseDicomDataSetImplicit: missing required parameter 'byteStream'";if(r<t.position||r>t.byteArray.length)throw "dicomParser.parseDicomDataSetImplicit: invalid value for parameter 'maxPosition'";for(var n=e.elements;t.position<r;){var i=A(t,a.untilTag,a.vrCallback);if((n[i.tag]=i).tag===a.untilTag)return}}function k(e,t){if("undefined"!=typeof Buffer&&e instanceof Buffer)return Buffer.alloc(t);if(e instanceof Uint8Array)return new Uint8Array(t);throw "dicomParser.alloc: unknown type for byteArray"}var L="1.8.12",N={readUint16:function(e,t){if(t<0)throw "bigEndianByteArrayParser.readUint16: position cannot be less than 0";if(t+2>e.length)throw "bigEndianByteArrayParser.readUint16: attempt to read past end of buffer";return (e[t]<<8)+e[t+1]},readInt16:function(e,t){if(t<0)throw "bigEndianByteArrayParser.readInt16: position cannot be less than 0";if(t+2>e.length)throw "bigEndianByteArrayParser.readInt16: attempt to read past end of buffer";t=(e[t]<<8)+e[t+1];return t=32768&t?t-65535-1:t},readUint32:function(e,t){if(t<0)throw "bigEndianByteArrayParser.readUint32: position cannot be less than 0";if(t+4>e.length)throw "bigEndianByteArrayParser.readUint32: attempt to read past end of buffer";return 256*(256*(256*e[t]+e[t+1])+e[t+2])+e[t+3]},readInt32:function(e,t){if(t<0)throw "bigEndianByteArrayParser.readInt32: position cannot be less than 0";if(t+4>e.length)throw "bigEndianByteArrayParser.readInt32: attempt to read past end of buffer";return (e[t]<<24)+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3]},readFloat:function(e,t){if(t<0)throw "bigEndianByteArrayParser.readFloat: position cannot be less than 0";if(t+4>e.length)throw "bigEndianByteArrayParser.readFloat: attempt to read past end of buffer";var r=new Uint8Array(4);return r[3]=e[t],r[2]=e[t+1],r[1]=e[t+2],r[0]=e[t+3],new Float32Array(r.buffer)[0]},readDouble:function(e,t){if(t<0)throw "bigEndianByteArrayParser.readDouble: position cannot be less than 0";if(t+8>e.length)throw "bigEndianByteArrayParser.readDouble: attempt to read past end of buffer";var r=new Uint8Array(8);return r[7]=e[t],r[6]=e[t+1],r[5]=e[t+2],r[4]=e[t+3],r[3]=e[t+4],r[2]=e[t+5],r[1]=e[t+6],r[0]=e[t+7],new Float64Array(r.buffer)[0]}};function j(e,t,r){if("undefined"!=typeof Buffer&&e instanceof Buffer)return e.slice(t,t+r);if(e instanceof Uint8Array)return new Uint8Array(e.buffer,e.byteOffset+t,r);throw "dicomParser.from: unknown type for byteArray"}function C(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a);}}var J=function(){function a(e,t,r){if(!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),void 0===e)throw "dicomParser.ByteStream: missing required parameter 'byteArrayParser'";if(void 0===t)throw "dicomParser.ByteStream: missing required parameter 'byteArray'";if(t instanceof Uint8Array==!1&&("undefined"==typeof Buffer||t instanceof Buffer==!1))throw "dicomParser.ByteStream: parameter byteArray is not of type Uint8Array or Buffer";if(r<0)throw "dicomParser.ByteStream: parameter 'position' cannot be less than 0";if(r>=t.length)throw "dicomParser.ByteStream: parameter 'position' cannot be greater than or equal to 'byteArray' length";this.byteArrayParser=e,this.byteArray=t,this.position=r||0,this.warnings=[];}var e,t;return e=a,(t=[{key:"seek",value:function(e){if(this.position+e<0)throw "dicomParser.ByteStream.prototype.seek: cannot seek to position < 0";this.position+=e;}},{key:"readByteStream",value:function(e){if(this.position+e>this.byteArray.length)throw "dicomParser.ByteStream.prototype.readByteStream: readByteStream - buffer overread";var t=j(this.byteArray,this.position,e);return this.position+=e,new a(this.byteArrayParser,t)}},{key:"getSize",value:function(){return this.byteArray.length}},{key:"readUint16",value:function(){var e=this.byteArrayParser.readUint16(this.byteArray,this.position);return this.position+=2,e}},{key:"readUint32",value:function(){var e=this.byteArrayParser.readUint32(this.byteArray,this.position);return this.position+=4,e}},{key:"readFixedString",value:function(e){var t=b(this.byteArray,this.position,e);return this.position+=e,t}}])&&C(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),a}(),M={readUint16:function(e,t){if(t<0)throw "littleEndianByteArrayParser.readUint16: position cannot be less than 0";if(t+2>e.length)throw "littleEndianByteArrayParser.readUint16: attempt to read past end of buffer";return e[t]+256*e[t+1]},readInt16:function(e,t){if(t<0)throw "littleEndianByteArrayParser.readInt16: position cannot be less than 0";if(t+2>e.length)throw "littleEndianByteArrayParser.readInt16: attempt to read past end of buffer";t=e[t]+(e[t+1]<<8);return t=32768&t?t-65535-1:t},readUint32:function(e,t){if(t<0)throw "littleEndianByteArrayParser.readUint32: position cannot be less than 0";if(t+4>e.length)throw "littleEndianByteArrayParser.readUint32: attempt to read past end of buffer";return e[t]+256*e[t+1]+256*e[t+2]*256+256*e[t+3]*256*256},readInt32:function(e,t){if(t<0)throw "littleEndianByteArrayParser.readInt32: position cannot be less than 0";if(t+4>e.length)throw "littleEndianByteArrayParser.readInt32: attempt to read past end of buffer";return e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24)},readFloat:function(e,t){if(t<0)throw "littleEndianByteArrayParser.readFloat: position cannot be less than 0";if(t+4>e.length)throw "littleEndianByteArrayParser.readFloat: attempt to read past end of buffer";var r=new Uint8Array(4);return r[0]=e[t],r[1]=e[t+1],r[2]=e[t+2],r[3]=e[t+3],new Float32Array(r.buffer)[0]},readDouble:function(e,t){if(t<0)throw "littleEndianByteArrayParser.readDouble: position cannot be less than 0";if(t+8>e.length)throw "littleEndianByteArrayParser.readDouble: attempt to read past end of buffer";var r=new Uint8Array(8);return r[0]=e[t],r[1]=e[t+1],r[2]=e[t+2],r[3]=e[t+3],r[4]=e[t+4],r[5]=e[t+5],r[6]=e[t+6],r[7]=e[t+7],new Float64Array(r.buffer)[0]}};function G(e){var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(void 0===e)throw "dicomParser.readPart10Header: missing required parameter 'byteArray'";var o=i.TransferSyntaxUID,s=new J(M,e);return function(){var e=function(){if(s.getSize()<=132&&o)return !1;if(s.seek(128),"DICM"===s.readFixedString(4))return !0;if(!(i||{}).TransferSyntaxUID)throw "dicomParser.readPart10Header: DICM prefix not found at location 132 - this is not a valid DICOM P10 file.";return s.seek(0),!1}(),t=[],r={};if(!e)return s.position=0,{elements:{x00020010:{tag:"x00020010",vr:"UI",Value:o}},warnings:t};for(;s.position<s.byteArray.length;){var a=s.position,n=B(s,t);if("x0002ffff"<n.tag){s.position=a;break}n.parser=M,r[n.tag]=n;}return (e=new w(s.byteArrayParser,s.byteArray,r)).warnings=s.warnings,e.position=s.position,e}()}var z="1.2.840.10008.1.2.2";function V(i){var o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(void 0===i)throw new Error("dicomParser.parseDicom: missing required parameter 'byteArray'");var e,a=function(e){if(void 0===e.elements.x00020010)throw new Error("dicomParser.parseDicom: missing required meta header attribute 0002,0010");e=e.elements.x00020010;return e&&e.Value||b(i,e.dataOffset,e.length)};function t(t){var e=a(t),r="1.2.840.10008.1.2"!==e,e=function(e,t){var r="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);if("1.2.840.10008.1.2.1.99"!==e)return new J(e===z?N:M,i,t);if(o&&o.inflater){e=o.inflater(i,t);return new J(M,e,0)}if(!0==r){var a=s(0),n=j(i,t,i.length-t),a=a.inflateRawSync(n),n=k(i,a.length+t);return i.copy(n,0,0,t),a.copy(n,t),new J(M,n,0)}if("undefined"==typeof pako)throw "dicomParser.parseDicom: no inflater available to handle deflate transfer syntax";return a=i.slice(t),n=pako.inflateRaw(a),(a=k(i,n.length+t)).set(i.slice(0,t),0),a.set(n,t),new J(M,a,0)}(e,t.position),t=new w(e.byteArrayParser,e.byteArray,{});t.warnings=e.warnings;try{(r?q:T)(t,e,e.byteArray.length,o);}catch(e){throw {exception:e,dataSet:t}}return t}return function(e,t){for(var r in e.elements)e.elements.hasOwnProperty(r)&&(t.elements[r]=e.elements[r]);return void 0!==e.warnings&&(t.warnings=e.warnings.concat(t.warnings)),t}(e=G(i,o),t(e))}var R=function(e,t,r){for(var a=0,n=t;n<t+r;n++)a+=e[n].length;return a};function _(e,t,r,a,n){if(n=n||t.fragments,void 0===e)throw "dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'dataSet'";if(void 0===t)throw "dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'pixelDataElement'";if(void 0===r)throw "dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'startFragmentIndex'";if(void 0===(a=a||1))throw "dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'numFragments'";if("x7fe00010"!==t.tag)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010";if(!0!==t.encapsulatedPixelData)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.basicOffsetTable)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.fragments)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(t.fragments.length<=0)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(r<0)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragmentIndex' must be >= 0";if(r>=t.fragments.length)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragmentIndex' must be < number of fragments";if(a<1)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'numFragments' must be > 0";if(r+a>t.fragments.length)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragment' + 'numFragments' < number of fragments";var i=new J(e.byteArrayParser,e.byteArray,t.dataOffset),t=S(i);if("xfffee000"!==t.tag)throw "dicomParser.readEncapsulatedPixelData: missing basic offset table xfffee000";i.seek(t.length);var o=i.position;if(1===a)return j(i.byteArray,o+n[r].offset+8,n[r].length);for(var t=R(n,r,a),s=k(i.byteArray,t),d=0,f=r;f<r+a;f++)for(var l=o+n[f].offset+8,u=0;u<n[f].length;u++)s[d++]=i.byteArray[l++];return s}var H=function(e,t){for(var r=0;r<e.length;r++)if(e[r].offset===t)return r},Q=function(e,t,r,a){if(e===t.length-1)return r.length-a;for(var n=t[e+1],i=a+1;i<r.length;i++)if(r[i].offset===n)return i-a;throw "dicomParser.calculateNumberOfFragmentsForFrame: could not find fragment with offset matching basic offset table"};function W(e,t,r,a,n){if(a=a||t.basicOffsetTable,n=n||t.fragments,void 0===e)throw "dicomParser.readEncapsulatedImageFrame: missing required parameter 'dataSet'";if(void 0===t)throw "dicomParser.readEncapsulatedImageFrame: missing required parameter 'pixelDataElement'";if(void 0===r)throw "dicomParser.readEncapsulatedImageFrame: missing required parameter 'frameIndex'";if(void 0===a)throw "dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' does not have basicOffsetTable";if("x7fe00010"!==t.tag)throw "dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010)";if(!0!==t.encapsulatedPixelData)throw "dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw "dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have undefined length";if(void 0===t.fragments)throw "dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have fragments";if(0===a.length)throw "dicomParser.readEncapsulatedImageFrame: basicOffsetTable has zero entries";if(r<0)throw "dicomParser.readEncapsulatedImageFrame: parameter 'frameIndex' must be >= 0";if(r>=a.length)throw "dicomParser.readEncapsulatedImageFrame: parameter 'frameIndex' must be < basicOffsetTable.length";var i=a[r],i=H(n,i);if(void 0===i)throw "dicomParser.readEncapsulatedImageFrame: unable to find fragment that matches basic offset table entry";return _(e,t,i,Q(r,a,n,i),n)}var $=!1;function K(e,t,r){if($||($=!0,console&&console.log&&console.log("WARNING: dicomParser.readEncapsulatedPixelData() has been deprecated")),void 0===e)throw "dicomParser.readEncapsulatedPixelData: missing required parameter 'dataSet'";if(void 0===t)throw "dicomParser.readEncapsulatedPixelData: missing required parameter 'element'";if(void 0===r)throw "dicomParser.readEncapsulatedPixelData: missing required parameter 'frame'";if("x7fe00010"!==t.tag)throw "dicomParser.readEncapsulatedPixelData: parameter 'element' refers to non pixel data tag (expected tag = x7fe00010)";if(!0!==t.encapsulatedPixelData)throw "dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw "dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.basicOffsetTable)throw "dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.fragments)throw "dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(r<0)throw "dicomParser.readEncapsulatedPixelData: parameter 'frame' must be >= 0";return 0!==t.basicOffsetTable.length?W(e,t,r):_(e,t,0,t.fragments.length)}t.default={isStringVr:d,isPrivateTag:f,parsePN:a,parseTM:n,parseDA:o,explicitElementToString:l,explicitDataSetToJS:u,createJPEGBasicOffsetTable:p,parseDicomDataSetExplicit:q,parseDicomDataSetImplicit:T,readFixedString:b,alloc:k,version:L,bigEndianByteArrayParser:N,ByteStream:J,sharedCopy:j,DataSet:w,findAndSetUNElementLength:y,findEndOfEncapsulatedElement:g,findItemDelimitationItemAndSetElementLength:x,littleEndianByteArrayParser:M,parseDicom:V,readDicomElementExplicit:B,readDicomElementImplicit:A,readEncapsulatedImageFrame:W,readEncapsulatedPixelData:K,readEncapsulatedPixelDataFromFragments:_,readPart10Header:G,readSequenceItemsExplicit:I,readSequenceItemsImplicit:F,readSequenceItem:S,readTag:h,LEI:"1.2.840.10008.1.2",LEE:"1.2.840.10008.1.2.1"};}],i={},n.m=a,n.c=i,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r});},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0});},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)n.d(r,a,function(e){return t[e]}.bind(null,a));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1);function n(e){if(i[e])return i[e].exports;var t=i[e]={i:e,l:!1,exports:{}};return a[e].call(t.exports,t,t.exports,n),t.l=!0,t.exports}var a,i;});
|
|
496
|
+
!function(e,t){module.exports=t(require$$0);}(commonjsGlobal,function(r){return a=[function(e,t){e.exports=r;},function(e,t,s){s.r(t),s.d(t,"isStringVr",function(){return d}),s.d(t,"isPrivateTag",function(){return f}),s.d(t,"parsePN",function(){return a}),s.d(t,"parseTM",function(){return n}),s.d(t,"parseDA",function(){return o}),s.d(t,"explicitElementToString",function(){return l}),s.d(t,"explicitDataSetToJS",function(){return u}),s.d(t,"createJPEGBasicOffsetTable",function(){return p}),s.d(t,"parseDicomDataSetExplicit",function(){return q}),s.d(t,"parseDicomDataSetImplicit",function(){return T}),s.d(t,"readFixedString",function(){return b}),s.d(t,"alloc",function(){return k}),s.d(t,"version",function(){return L}),s.d(t,"bigEndianByteArrayParser",function(){return N}),s.d(t,"ByteStream",function(){return J}),s.d(t,"sharedCopy",function(){return j}),s.d(t,"DataSet",function(){return w}),s.d(t,"findAndSetUNElementLength",function(){return y}),s.d(t,"findEndOfEncapsulatedElement",function(){return g}),s.d(t,"findItemDelimitationItemAndSetElementLength",function(){return x}),s.d(t,"littleEndianByteArrayParser",function(){return M}),s.d(t,"parseDicom",function(){return V}),s.d(t,"readDicomElementExplicit",function(){return B}),s.d(t,"readDicomElementImplicit",function(){return A}),s.d(t,"readEncapsulatedImageFrame",function(){return W}),s.d(t,"readEncapsulatedPixelData",function(){return K}),s.d(t,"readEncapsulatedPixelDataFromFragments",function(){return _}),s.d(t,"readPart10Header",function(){return G}),s.d(t,"readSequenceItemsExplicit",function(){return I}),s.d(t,"readSequenceItemsImplicit",function(){return F}),s.d(t,"readSequenceItem",function(){return S}),s.d(t,"readTag",function(){return h});var r={AE:!0,AS:!0,AT:!1,CS:!0,DA:!0,DS:!0,DT:!0,FL:!1,FD:!1,IS:!0,LO:!0,LT:!0,OB:!1,OD:!1,OF:!1,OW:!1,PN:!0,SH:!0,SL:!1,SQ:!1,SS:!1,ST:!0,TM:!0,UI:!0,UL:!1,UN:void 0,UR:!0,US:!1,UT:!0},d=function(e){return r[e]},f=function(e){e=parseInt(e[4],16);if(isNaN(e))throw "dicomParser.isPrivateTag: cannot parse last character of group";return e%2==1},a=function(e){if(void 0!==e){e=e.split("^");return {familyName:e[0],givenName:e[1],middleName:e[2],prefix:e[3],suffix:e[4]}}};function n(e,t){if(2<=e.length){var r=parseInt(e.substring(0,2),10),a=4<=e.length?parseInt(e.substring(2,4),10):void 0,n=6<=e.length?parseInt(e.substring(4,6),10):void 0,i=8<=e.length?e.substring(7,13):void 0,i=i?parseInt(i,10)*Math.pow(10,6-i.length):void 0;if(t&&(isNaN(r)||void 0!==a&&isNaN(a)||void 0!==n&&isNaN(n)||void 0!==i&&isNaN(i)||r<0||23<r||a&&(a<0||59<a)||n&&(n<0||59<n)||i&&(i<0||999999<i)))throw "invalid TM '".concat(e,"'");return {hours:r,minutes:a,seconds:n,fractionalSeconds:i}}if(t)throw "invalid TM '".concat(e,"'")}function i(e,t,r){return !isNaN(r)&&(0<t&&t<=12&&0<e&&e<=function(e,t){switch(e){case 2:return t%4==0&&t%100||t%400==0?29:28;case 9:case 4:case 6:case 11:return 30;default:return 31}}(t,r))}function o(e,t){if(e&&8===e.length){var r=parseInt(e.substring(0,4),10),a=parseInt(e.substring(4,6),10),n=parseInt(e.substring(6,8),10);if(t&&!0!==i(n,a,r))throw "invalid DA '".concat(e,"'");return {year:r,month:a,day:n}}if(t)throw "invalid DA '".concat(e,"'")}function l(n,e){if(void 0===n||void 0===e)throw "dicomParser.explicitElementToString: missing required parameters";if(void 0===e.vr)throw "dicomParser.explicitElementToString: cannot convert implicit element to string";var t,r=e.vr,i=e.tag;function a(e,t){for(var r="",a=0;a<e;a++)0!==a&&(r+="/"),r+=t.call(n,i,a).toString();return r}if(!0===d(r))t=n.string(i);else {if("AT"===r){var o=n.uint32(i);return void 0===o?void 0:"x".concat((o=o<0?4294967295+o+1:o).toString(16).toUpperCase())}"US"===r?t=a(e.length/2,n.uint16):"SS"===r?t=a(e.length/2,n.int16):"UL"===r?t=a(e.length/4,n.uint32):"SL"===r?t=a(e.length/4,n.int32):"FD"===r?t=a(e.length/8,n.double):"FL"===r&&(t=a(e.length/4,n.float));}return t}function u(e,t){if(void 0===e)throw "dicomParser.explicitDataSetToJS: missing required parameter dataSet";t=t||{omitPrivateAttibutes:!0,maxElementLength:128};var r,a={};for(r in e.elements){var n=e.elements[r];if(!0!==t.omitPrivateAttibutes||!f(r))if(n.items){for(var i=[],o=0;o<n.items.length;o++)i.push(u(n.items[o].dataSet,t));a[r]=i;}else {var s=void 0;n.length<t.maxElementLength&&(s=l(e,n)),a[r]=void 0!==s?s:{dataOffset:n.dataOffset,length:n.length};}}return a}function c(e,t){return 255===e.byteArray[t]&&217===e.byteArray[t+1]}function m(e,t,r){for(var a,n,i=r;i<t.fragments.length;i++)if(a=e,n=i,n=t.fragments[n],!(!c(a,n.position+n.length-2)&&!c(a,n.position+n.length-3)))return i}function p(e,t,r){if(void 0===e)throw "dicomParser.createJPEGBasicOffsetTable: missing required parameter dataSet";if(void 0===t)throw "dicomParser.createJPEGBasicOffsetTable: missing required parameter pixelDataElement";if("x7fe00010"!==t.tag)throw "dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010'";if(!0!==t.encapsulatedPixelData)throw "dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw "dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.basicOffsetTable)throw "dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.fragments)throw "dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(t.fragments.length<=0)throw "dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(r&&r.length<=0)throw "dicomParser.createJPEGBasicOffsetTable: parameter 'fragments' must not be zero length";r=r||t.fragments;for(var a=[],n=0;;){a.push(t.fragments[n].offset);var i=m(e,t,n);if(void 0===i||i===t.fragments.length-1)return a;n=i+1;}}function h(e){if(void 0===e)throw "dicomParser.readTag: missing required parameter 'byteStream'";var t=256*e.readUint16()*256,e=e.readUint16();return "x".concat("00000000".concat((t+e).toString(16)).substr(-8))}function g(e,t,r){if(void 0===e)throw "dicomParser.findEndOfEncapsulatedElement: missing required parameter 'byteStream'";if(void 0===t)throw "dicomParser.findEndOfEncapsulatedElement: missing required parameter 'element'";if(t.encapsulatedPixelData=!0,t.basicOffsetTable=[],t.fragments=[],"xfffee000"!==h(e))throw "dicomParser.findEndOfEncapsulatedElement: basic offset table not found";for(var a=e.readUint32()/4,n=0;n<a;n++){var i=e.readUint32();t.basicOffsetTable.push(i);}for(var o=e.position;e.position<e.byteArray.length;){var s=h(e),d=e.readUint32();if("xfffee0dd"===s)return e.seek(d),void(t.length=e.position-t.dataOffset);if("xfffee000"!==s)return r&&r.push("unexpected tag ".concat(s," while searching for end of pixel data element with undefined length")),d>e.byteArray.length-e.position&&(d=e.byteArray.length-e.position),t.fragments.push({offset:e.position-o-8,position:e.position,length:d}),e.seek(d),void(t.length=e.position-t.dataOffset);t.fragments.push({offset:e.position-o-8,position:e.position,length:d}),e.seek(d);}r&&r.push("pixel data element ".concat(t.tag," missing sequence delimiter tag xfffee0dd"));}function y(e,t){if(void 0===e)throw "dicomParser.findAndSetUNElementLength: missing required parameter 'byteStream'";for(var r=e.byteArray.length-8;e.position<=r;)if(65534===e.readUint16()){var a=e.readUint16();if(57565===a)return 0!==e.readUint32()&&e.warnings("encountered non zero length following item delimiter at position ".concat(e.position-4," while reading element of undefined length with tag ").concat(t.tag)),void(t.length=e.position-t.dataOffset)}t.length=e.byteArray.length-t.dataOffset,e.seek(e.byteArray.length-e.position);}function b(e,t,r){if(r<0)throw "dicomParser.readFixedString - length cannot be less than 0";if(t+r>e.length)throw "dicomParser.readFixedString: attempt to read past end of buffer";for(var a,n="",i=0;i<r;i++){if(0===(a=e[t+i]))return t+=r,n;n+=String.fromCharCode(a);}return n}function v(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a);}}function P(e,t){return void 0!==e.parser?e.parser:t}var w=function(){function a(e,t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),this.byteArrayParser=e,this.byteArray=t,this.elements=r;}var e,t;return e=a,(t=[{key:"uint16",value:function(e,t){e=this.elements[e];if(t=void 0!==t?t:0,e&&0!==e.length)return P(e,this.byteArrayParser).readUint16(this.byteArray,e.dataOffset+2*t)}},{key:"int16",value:function(e,t){e=this.elements[e];if(t=void 0!==t?t:0,e&&0!==e.length)return P(e,this.byteArrayParser).readInt16(this.byteArray,e.dataOffset+2*t)}},{key:"uint32",value:function(e,t){e=this.elements[e];if(t=void 0!==t?t:0,e&&0!==e.length)return P(e,this.byteArrayParser).readUint32(this.byteArray,e.dataOffset+4*t)}},{key:"int32",value:function(e,t){e=this.elements[e];if(t=void 0!==t?t:0,e&&0!==e.length)return P(e,this.byteArrayParser).readInt32(this.byteArray,e.dataOffset+4*t)}},{key:"float",value:function(e,t){e=this.elements[e];if(t=void 0!==t?t:0,e&&0!==e.length)return P(e,this.byteArrayParser).readFloat(this.byteArray,e.dataOffset+4*t)}},{key:"double",value:function(e,t){e=this.elements[e];if(t=void 0!==t?t:0,e&&0!==e.length)return P(e,this.byteArrayParser).readDouble(this.byteArray,e.dataOffset+8*t)}},{key:"numStringValues",value:function(e){e=this.elements[e];if(e&&0<e.length){e=b(this.byteArray,e.dataOffset,e.length).match(/\\/g);return null===e?1:e.length+1}}},{key:"string",value:function(e,t){e=this.elements[e];if(e&&e.Value)return e.Value;if(e&&0<e.length){e=b(this.byteArray,e.dataOffset,e.length);return 0<=t?e.split("\\")[t].trim():e.trim()}}},{key:"text",value:function(e,t){e=this.elements[e];if(e&&0<e.length){e=b(this.byteArray,e.dataOffset,e.length);return 0<=t?e.split("\\")[t].replace(/ +$/,""):e.replace(/ +$/,"")}}},{key:"floatString",value:function(e,t){var r=this.elements[e];if(r&&0<r.length){t=this.string(e,t=void 0!==t?t:0);if(void 0!==t)return parseFloat(t)}}},{key:"intString",value:function(e,t){var r=this.elements[e];if(r&&0<r.length){t=this.string(e,t=void 0!==t?t:0);if(void 0!==t)return parseInt(t)}}},{key:"attributeTag",value:function(e){var t=this.elements[e];if(t&&4===t.length){var r=P(t,this.byteArrayParser).readUint16,e=this.byteArray,t=t.dataOffset;return "x".concat("00000000".concat((256*r(e,t)*256+r(e,t+2)).toString(16)).substr(-8))}}}])&&v(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),a}();function x(e,t){if(void 0===e)throw "dicomParser.readDicomElementImplicit: missing required parameter 'byteStream'";for(var r=e.byteArray.length-8;e.position<=r;)if(65534===e.readUint16()){var a=e.readUint16();if(57357===a)return 0!==e.readUint32()&&e.warnings("encountered non zero length following item delimiter at position ".concat(e.position-4," while reading element of undefined length with tag ").concat(t.tag)),void(t.length=e.position-t.dataOffset)}t.length=e.byteArray.length-t.dataOffset,e.seek(e.byteArray.length-e.position);}var E=function(e,t){if(void 0!==e.vr)return "SQ"===e.vr;if(t.position+4<=t.byteArray.length){e=h(t);return t.seek(-4),"xfffee000"===e||"xfffee0dd"===e}return t.warnings.push("eof encountered before finding sequence item tag or sequence delimiter tag in peeking to determine VR"),!1};function A(e,t,r){if(void 0===e)throw "dicomParser.readDicomElementImplicit: missing required parameter 'byteStream'";var a=h(e),a={tag:a,vr:void 0!==r?r(a):void 0,length:e.readUint32(),dataOffset:e.position};return 4294967295===a.length&&(a.hadUndefinedLength=!0),a.tag===t||(!E(a,e)||f(a.tag)&&!a.hadUndefinedLength?a.hadUndefinedLength?x(e,a):e.seek(a.length):(F(e,a,r),f(a.tag)&&(a.items=void 0))),a}function S(e){if(void 0===e)throw "dicomParser.readSequenceItem: missing required parameter 'byteStream'";var t={tag:h(e),length:e.readUint32(),dataOffset:e.position};if("xfffee000"!==t.tag)throw "dicomParser.readSequenceItem: item tag (FFFE,E000) not found at offset ".concat(e.position);return t}function D(e,t){var r=S(e);return 4294967295===r.length?(r.hadUndefinedLength=!0,r.dataSet=function(e,t){for(var r={};e.position<e.byteArray.length;){var a=A(e,void 0,t);if("xfffee00d"===(r[a.tag]=a).tag)return new w(e.byteArrayParser,e.byteArray,r)}return e.warnings.push("eof encountered before finding sequence item delimiter in sequence item of undefined length"),new w(e.byteArrayParser,e.byteArray,r)}(e,t),r.length=e.position-r.dataOffset):(r.dataSet=new w(e.byteArrayParser,e.byteArray,{}),T(r.dataSet,e,e.position+r.length,{vrCallback:t})),r}function F(e,t,r){if(void 0===e)throw "dicomParser.readSequenceItemsImplicit: missing required parameter 'byteStream'";if(void 0===t)throw "dicomParser.readSequenceItemsImplicit: missing required parameter 'element'";t.items=[],(4294967295===t.length?function(e,t,r){for(;e.position+4<=e.byteArray.length;){var a=h(e);if(e.seek(-4),"xfffee0dd"===a)return t.length=e.position-t.dataOffset,e.seek(8);a=D(e,r);t.items.push(a);}e.warnings.push("eof encountered before finding sequence delimiter in sequence of undefined length"),t.length=e.byteArray.length-t.dataOffset;}:function(e,t,r){for(var a=t.dataOffset+t.length;e.position<a;){var n=D(e,r);t.items.push(n);}})(e,t,r);}function O(e,t){var r=S(e);return 4294967295===r.length?(r.hadUndefinedLength=!0,r.dataSet=function(e,t){for(var r={};e.position<e.byteArray.length;){var a=B(e,t);if("xfffee00d"===(r[a.tag]=a).tag)return new w(e.byteArrayParser,e.byteArray,r)}return t.push("eof encountered before finding item delimiter tag while reading sequence item of undefined length"),new w(e.byteArrayParser,e.byteArray,r)}(e,t),r.length=e.position-r.dataOffset):(r.dataSet=new w(e.byteArrayParser,e.byteArray,{}),q(r.dataSet,e,e.position+r.length)),r}function I(e,t,r){if(void 0===e)throw "dicomParser.readSequenceItemsExplicit: missing required parameter 'byteStream'";if(void 0===t)throw "dicomParser.readSequenceItemsExplicit: missing required parameter 'element'";t.items=[],(4294967295===t.length?function(e,t,r){for(;e.position+4<=e.byteArray.length;){var a=h(e);if(e.seek(-4),"xfffee0dd"===a)return t.length=e.position-t.dataOffset,e.seek(8);a=O(e,r);t.items.push(a);}r.push("eof encountered before finding sequence delimitation tag while reading sequence of undefined length"),t.length=e.position-t.dataOffset;}:function(e,t,r){for(var a=t.dataOffset+t.length;e.position<a;){var n=O(e,r);t.items.push(n);}})(e,t,r);}var U=function(e){return "OB"===e||"OD"===e||"OL"===e||"OW"===e||"SQ"===e||"OF"===e||"UC"===e||"UR"===e||"UT"===e||"UN"===e?4:2};function B(e,t,r){if(void 0===e)throw "dicomParser.readDicomElementExplicit: missing required parameter 'byteStream'";var a={tag:h(e),vr:e.readFixedString(2)};return 2===U(a.vr)?a.length=e.readUint16():(e.seek(2),a.length=e.readUint32()),a.dataOffset=e.position,4294967295===a.length&&(a.hadUndefinedLength=!0),a.tag===r||("SQ"===a.vr?I(e,a,t):4294967295===a.length?"x7fe00010"===a.tag?g(e,a,t):("UN"===a.vr?F:x)(e,a):e.seek(a.length)),a}function q(e,t,r){var a=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(r=void 0===r?t.byteArray.length:r,void 0===t)throw "dicomParser.parseDicomDataSetExplicit: missing required parameter 'byteStream'";if(r<t.position||r>t.byteArray.length)throw "dicomParser.parseDicomDataSetExplicit: invalid value for parameter 'maxP osition'";for(var n=e.elements;t.position<r;){var i=B(t,e.warnings,a.untilTag);if((n[i.tag]=i).tag===a.untilTag)return}if(t.position>r)throw "dicomParser:parseDicomDataSetExplicit: buffer overrun"}function T(e,t,r){var a=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(r=void 0===r?e.byteArray.length:r,void 0===t)throw "dicomParser.parseDicomDataSetImplicit: missing required parameter 'byteStream'";if(r<t.position||r>t.byteArray.length)throw "dicomParser.parseDicomDataSetImplicit: invalid value for parameter 'maxPosition'";for(var n=e.elements;t.position<r;){var i=A(t,a.untilTag,a.vrCallback);if((n[i.tag]=i).tag===a.untilTag)return}}function k(e,t){if("undefined"!=typeof Buffer&&e instanceof Buffer)return Buffer.alloc(t);if(e instanceof Uint8Array)return new Uint8Array(t);throw "dicomParser.alloc: unknown type for byteArray"}var L="1.8.12",N={readUint16:function(e,t){if(t<0)throw "bigEndianByteArrayParser.readUint16: position cannot be less than 0";if(t+2>e.length)throw "bigEndianByteArrayParser.readUint16: attempt to read past end of buffer";return (e[t]<<8)+e[t+1]},readInt16:function(e,t){if(t<0)throw "bigEndianByteArrayParser.readInt16: position cannot be less than 0";if(t+2>e.length)throw "bigEndianByteArrayParser.readInt16: attempt to read past end of buffer";t=(e[t]<<8)+e[t+1];return t=32768&t?t-65535-1:t},readUint32:function(e,t){if(t<0)throw "bigEndianByteArrayParser.readUint32: position cannot be less than 0";if(t+4>e.length)throw "bigEndianByteArrayParser.readUint32: attempt to read past end of buffer";return 256*(256*(256*e[t]+e[t+1])+e[t+2])+e[t+3]},readInt32:function(e,t){if(t<0)throw "bigEndianByteArrayParser.readInt32: position cannot be less than 0";if(t+4>e.length)throw "bigEndianByteArrayParser.readInt32: attempt to read past end of buffer";return (e[t]<<24)+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3]},readFloat:function(e,t){if(t<0)throw "bigEndianByteArrayParser.readFloat: position cannot be less than 0";if(t+4>e.length)throw "bigEndianByteArrayParser.readFloat: attempt to read past end of buffer";var r=new Uint8Array(4);return r[3]=e[t],r[2]=e[t+1],r[1]=e[t+2],r[0]=e[t+3],new Float32Array(r.buffer)[0]},readDouble:function(e,t){if(t<0)throw "bigEndianByteArrayParser.readDouble: position cannot be less than 0";if(t+8>e.length)throw "bigEndianByteArrayParser.readDouble: attempt to read past end of buffer";var r=new Uint8Array(8);return r[7]=e[t],r[6]=e[t+1],r[5]=e[t+2],r[4]=e[t+3],r[3]=e[t+4],r[2]=e[t+5],r[1]=e[t+6],r[0]=e[t+7],new Float64Array(r.buffer)[0]}};function j(e,t,r){if("undefined"!=typeof Buffer&&e instanceof Buffer)return e.slice(t,t+r);if(e instanceof Uint8Array)return new Uint8Array(e.buffer,e.byteOffset+t,r);throw "dicomParser.from: unknown type for byteArray"}function C(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a);}}var J=function(){function a(e,t,r){if(!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),void 0===e)throw "dicomParser.ByteStream: missing required parameter 'byteArrayParser'";if(void 0===t)throw "dicomParser.ByteStream: missing required parameter 'byteArray'";if(t instanceof Uint8Array==!1&&("undefined"==typeof Buffer||t instanceof Buffer==!1))throw "dicomParser.ByteStream: parameter byteArray is not of type Uint8Array or Buffer";if(r<0)throw "dicomParser.ByteStream: parameter 'position' cannot be less than 0";if(r>=t.length)throw "dicomParser.ByteStream: parameter 'position' cannot be greater than or equal to 'byteArray' length";this.byteArrayParser=e,this.byteArray=t,this.position=r||0,this.warnings=[];}var e,t;return e=a,(t=[{key:"seek",value:function(e){if(this.position+e<0)throw "dicomParser.ByteStream.prototype.seek: cannot seek to position < 0";this.position+=e;}},{key:"readByteStream",value:function(e){if(this.position+e>this.byteArray.length)throw "dicomParser.ByteStream.prototype.readByteStream: readByteStream - buffer overread";var t=j(this.byteArray,this.position,e);return this.position+=e,new a(this.byteArrayParser,t)}},{key:"getSize",value:function(){return this.byteArray.length}},{key:"readUint16",value:function(){var e=this.byteArrayParser.readUint16(this.byteArray,this.position);return this.position+=2,e}},{key:"readUint32",value:function(){var e=this.byteArrayParser.readUint32(this.byteArray,this.position);return this.position+=4,e}},{key:"readFixedString",value:function(e){var t=b(this.byteArray,this.position,e);return this.position+=e,t}}])&&C(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),a}(),M={readUint16:function(e,t){if(t<0)throw "littleEndianByteArrayParser.readUint16: position cannot be less than 0";if(t+2>e.length)throw "littleEndianByteArrayParser.readUint16: attempt to read past end of buffer";return e[t]+256*e[t+1]},readInt16:function(e,t){if(t<0)throw "littleEndianByteArrayParser.readInt16: position cannot be less than 0";if(t+2>e.length)throw "littleEndianByteArrayParser.readInt16: attempt to read past end of buffer";t=e[t]+(e[t+1]<<8);return t=32768&t?t-65535-1:t},readUint32:function(e,t){if(t<0)throw "littleEndianByteArrayParser.readUint32: position cannot be less than 0";if(t+4>e.length)throw "littleEndianByteArrayParser.readUint32: attempt to read past end of buffer";return e[t]+256*e[t+1]+256*e[t+2]*256+256*e[t+3]*256*256},readInt32:function(e,t){if(t<0)throw "littleEndianByteArrayParser.readInt32: position cannot be less than 0";if(t+4>e.length)throw "littleEndianByteArrayParser.readInt32: attempt to read past end of buffer";return e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24)},readFloat:function(e,t){if(t<0)throw "littleEndianByteArrayParser.readFloat: position cannot be less than 0";if(t+4>e.length)throw "littleEndianByteArrayParser.readFloat: attempt to read past end of buffer";var r=new Uint8Array(4);return r[0]=e[t],r[1]=e[t+1],r[2]=e[t+2],r[3]=e[t+3],new Float32Array(r.buffer)[0]},readDouble:function(e,t){if(t<0)throw "littleEndianByteArrayParser.readDouble: position cannot be less than 0";if(t+8>e.length)throw "littleEndianByteArrayParser.readDouble: attempt to read past end of buffer";var r=new Uint8Array(8);return r[0]=e[t],r[1]=e[t+1],r[2]=e[t+2],r[3]=e[t+3],r[4]=e[t+4],r[5]=e[t+5],r[6]=e[t+6],r[7]=e[t+7],new Float64Array(r.buffer)[0]}};function G(e){var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(void 0===e)throw "dicomParser.readPart10Header: missing required parameter 'byteArray'";var o=i.TransferSyntaxUID,s=new J(M,e);return function(){var e=function(){if(s.getSize()<=132&&o)return !1;if(s.seek(128),"DICM"===s.readFixedString(4))return !0;if(!(i||{}).TransferSyntaxUID)throw "dicomParser.readPart10Header: DICM prefix not found at location 132 - this is not a valid DICOM P10 file.";return s.seek(0),!1}(),t=[],r={};if(!e)return s.position=0,{elements:{x00020010:{tag:"x00020010",vr:"UI",Value:o}},warnings:t};for(;s.position<s.byteArray.length;){var a=s.position,n=B(s,t);if("x0002ffff"<n.tag){s.position=a;break}n.parser=M,r[n.tag]=n;}return (e=new w(s.byteArrayParser,s.byteArray,r)).warnings=s.warnings,e.position=s.position,e}()}var z="1.2.840.10008.1.2.2";function V(i){var o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(void 0===i)throw new Error("dicomParser.parseDicom: missing required parameter 'byteArray'");var e,a=function(e){if(void 0===e.elements.x00020010)throw new Error("dicomParser.parseDicom: missing required meta header attribute 0002,0010");e=e.elements.x00020010;return e&&e.Value||b(i,e.dataOffset,e.length)};function t(t){var e=a(t),r="1.2.840.10008.1.2"!==e,e=function(e,t){var r="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);if("1.2.840.10008.1.2.1.99"!==e)return new J(e===z?N:M,i,t);if(o&&o.inflater){e=o.inflater(i,t);return new J(M,e,0)}if(!0==r){var a=s(0),n=j(i,t,i.length-t),a=a.inflateRawSync(n),n=k(i,a.length+t);return i.copy(n,0,0,t),a.copy(n,t),new J(M,n,0)}if("undefined"==typeof pako)throw "dicomParser.parseDicom: no inflater available to handle deflate transfer syntax";return a=i.slice(t),n=pako.inflateRaw(a),(a=k(i,n.length+t)).set(i.slice(0,t),0),a.set(n,t),new J(M,a,0)}(e,t.position),t=new w(e.byteArrayParser,e.byteArray,{});t.warnings=e.warnings;try{(r?q:T)(t,e,e.byteArray.length,o);}catch(e){throw {exception:e,dataSet:t}}return t}return function(e,t){for(var r in e.elements)e.elements.hasOwnProperty(r)&&(t.elements[r]=e.elements[r]);return void 0!==e.warnings&&(t.warnings=e.warnings.concat(t.warnings)),t}(e=G(i,o),t(e))}var R=function(e,t,r){for(var a=0,n=t;n<t+r;n++)a+=e[n].length;return a};function _(e,t,r,a,n){if(n=n||t.fragments,void 0===e)throw "dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'dataSet'";if(void 0===t)throw "dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'pixelDataElement'";if(void 0===r)throw "dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'startFragmentIndex'";if(void 0===(a=a||1))throw "dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'numFragments'";if("x7fe00010"!==t.tag)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010";if(!0!==t.encapsulatedPixelData)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.basicOffsetTable)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.fragments)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(t.fragments.length<=0)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(r<0)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragmentIndex' must be >= 0";if(r>=t.fragments.length)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragmentIndex' must be < number of fragments";if(a<1)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'numFragments' must be > 0";if(r+a>t.fragments.length)throw "dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragment' + 'numFragments' < number of fragments";var i=new J(e.byteArrayParser,e.byteArray,t.dataOffset),t=S(i);if("xfffee000"!==t.tag)throw "dicomParser.readEncapsulatedPixelData: missing basic offset table xfffee000";i.seek(t.length);var o=i.position;if(1===a)return j(i.byteArray,o+n[r].offset+8,n[r].length);for(var t=R(n,r,a),s=k(i.byteArray,t),d=0,f=r;f<r+a;f++)for(var l=o+n[f].offset+8,u=0;u<n[f].length;u++)s[d++]=i.byteArray[l++];return s}var H=function(e,t){for(var r=0;r<e.length;r++)if(e[r].offset===t)return r},Q=function(e,t,r,a){if(e===t.length-1)return r.length-a;for(var n=t[e+1],i=a+1;i<r.length;i++)if(r[i].offset===n)return i-a;throw "dicomParser.calculateNumberOfFragmentsForFrame: could not find fragment with offset matching basic offset table"};function W(e,t,r,a,n){if(a=a||t.basicOffsetTable,n=n||t.fragments,void 0===e)throw "dicomParser.readEncapsulatedImageFrame: missing required parameter 'dataSet'";if(void 0===t)throw "dicomParser.readEncapsulatedImageFrame: missing required parameter 'pixelDataElement'";if(void 0===r)throw "dicomParser.readEncapsulatedImageFrame: missing required parameter 'frameIndex'";if(void 0===a)throw "dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' does not have basicOffsetTable";if("x7fe00010"!==t.tag)throw "dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010)";if(!0!==t.encapsulatedPixelData)throw "dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw "dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have undefined length";if(void 0===t.fragments)throw "dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have fragments";if(0===a.length)throw "dicomParser.readEncapsulatedImageFrame: basicOffsetTable has zero entries";if(r<0)throw "dicomParser.readEncapsulatedImageFrame: parameter 'frameIndex' must be >= 0";if(r>=a.length)throw "dicomParser.readEncapsulatedImageFrame: parameter 'frameIndex' must be < basicOffsetTable.length";var i=a[r],i=H(n,i);if(void 0===i)throw "dicomParser.readEncapsulatedImageFrame: unable to find fragment that matches basic offset table entry";return _(e,t,i,Q(r,a,n,i),n)}var $=!1;function K(e,t,r){if($||($=!0,console&&console.log&&console.log("WARNING: dicomParser.readEncapsulatedPixelData() has been deprecated")),void 0===e)throw "dicomParser.readEncapsulatedPixelData: missing required parameter 'dataSet'";if(void 0===t)throw "dicomParser.readEncapsulatedPixelData: missing required parameter 'element'";if(void 0===r)throw "dicomParser.readEncapsulatedPixelData: missing required parameter 'frame'";if("x7fe00010"!==t.tag)throw "dicomParser.readEncapsulatedPixelData: parameter 'element' refers to non pixel data tag (expected tag = x7fe00010)";if(!0!==t.encapsulatedPixelData)throw "dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw "dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.basicOffsetTable)throw "dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.fragments)throw "dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(r<0)throw "dicomParser.readEncapsulatedPixelData: parameter 'frame' must be >= 0";return 0!==t.basicOffsetTable.length?W(e,t,r):_(e,t,0,t.fragments.length)}t.default={isStringVr:d,isPrivateTag:f,parsePN:a,parseTM:n,parseDA:o,explicitElementToString:l,explicitDataSetToJS:u,createJPEGBasicOffsetTable:p,parseDicomDataSetExplicit:q,parseDicomDataSetImplicit:T,readFixedString:b,alloc:k,version:L,bigEndianByteArrayParser:N,ByteStream:J,sharedCopy:j,DataSet:w,findAndSetUNElementLength:y,findEndOfEncapsulatedElement:g,findItemDelimitationItemAndSetElementLength:x,littleEndianByteArrayParser:M,parseDicom:V,readDicomElementExplicit:B,readDicomElementImplicit:A,readEncapsulatedImageFrame:W,readEncapsulatedPixelData:K,readEncapsulatedPixelDataFromFragments:_,readPart10Header:G,readSequenceItemsExplicit:I,readSequenceItemsImplicit:F,readSequenceItem:S,readTag:h,LEI:"1.2.840.10008.1.2",LEE:"1.2.840.10008.1.2.1"};}],i={},n.m=a,n.c=i,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r});},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0});},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)n.d(r,a,function(e){return t[e]}.bind(null,a));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1);function n(e){if(i[e])return i[e].exports;var t=i[e]={i:e,l:!1,exports:{}};return a[e].call(t.exports,t,t.exports,n),t.l=!0,t.exports}var a,i;});
|
|
485
497
|
|
|
486
498
|
});
|
|
487
499
|
|
|
@@ -2348,7 +2360,7 @@
|
|
|
2348
2360
|
function requestAnimationFrame$1(callback) {
|
|
2349
2361
|
setTimeout(callback, 1000 / 60);
|
|
2350
2362
|
}
|
|
2351
|
-
var requestAnimationFrame$1$1 = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || requestAnimationFrame$1;
|
|
2363
|
+
var requestAnimationFrame$1$1 = typeof window === "undefined" ? requestAnimationFrame$1 : window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || requestAnimationFrame$1;
|
|
2352
2364
|
|
|
2353
2365
|
var CenteredDiv = function () {
|
|
2354
2366
|
function CenteredDiv() {
|
|
@@ -2427,7 +2439,7 @@
|
|
|
2427
2439
|
|
|
2428
2440
|
var styleSheet = ___$insertStyle(".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .cr.function .property-name{width:100%}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n");
|
|
2429
2441
|
|
|
2430
|
-
css.inject(styleSheet);
|
|
2442
|
+
if (typeof document !== "undefined") css.inject(styleSheet);
|
|
2431
2443
|
var CSS_NAMESPACE = 'dg';
|
|
2432
2444
|
var HIDE_KEY_CODE = 72;
|
|
2433
2445
|
var CLOSE_BUTTON_HEIGHT = 20;
|
|
@@ -2693,7 +2705,7 @@
|
|
|
2693
2705
|
GUI.toggleHide();
|
|
2694
2706
|
}
|
|
2695
2707
|
};
|
|
2696
|
-
dom.bind(window, 'keydown', GUI._keydownHandler, false);
|
|
2708
|
+
if (typeof window !== "undefined") dom.bind(window, 'keydown', GUI._keydownHandler, false);
|
|
2697
2709
|
Common.extend(GUI.prototype,
|
|
2698
2710
|
{
|
|
2699
2711
|
add: function add(object, property) {
|
|
@@ -22038,15 +22050,15 @@
|
|
|
22038
22050
|
}
|
|
22039
22051
|
|
|
22040
22052
|
// import * as kiwrious from "copper3d_plugin_heart_k";
|
|
22041
|
-
// "v4.1.
|
|
22053
|
+
// "v4.1.1" is injected at build time by rollup @rollup/plugin-replace, sourced from package.json version.
|
|
22042
22054
|
// When copper3d is consumed from local source (no rollup replace step), the identifier is undefined and
|
|
22043
22055
|
// referencing it throws a ReferenceError — guard it so local loading still works.
|
|
22044
22056
|
let _revision = "unknown";
|
|
22045
22057
|
try {
|
|
22046
|
-
_revision = "v4.1.
|
|
22058
|
+
_revision = "v4.1.1";
|
|
22047
22059
|
}
|
|
22048
22060
|
catch (_a) {
|
|
22049
|
-
/* "v4.1.
|
|
22061
|
+
/* "v4.1.1" not injected (local source build) */
|
|
22050
22062
|
}
|
|
22051
22063
|
const REVISION = _revision;
|
|
22052
22064
|
// "186" is three's revision at build time, injected the same way.
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The canonical voxel order, and the rule that puts any volume into it.
|
|
7
|
+
*
|
|
8
|
+
* Canonical order: voxel index i increases toward the patient's Left, j toward Posterior, k
|
|
9
|
+
* toward Superior. Axis codes use the TOWARD convention of DICOM, nibabel and SimpleITK, so "LPS"
|
|
10
|
+
* names that order (legacy ITK and ITK-SNAP call the same order "RAI").
|
|
11
|
+
*
|
|
12
|
+
* Each native axis is assigned the anatomical axis it is nearest to and flipped when it points the
|
|
13
|
+
* other way. That is a permutation and flips, never a resampling, so obliquity stays in the
|
|
14
|
+
* geometry instead of being snapped away. With the voxels in this order, the fixed per-axis display
|
|
15
|
+
* mapping (SliceRenderPipeline.flipDisplayImageByAxis) shows every volume in the radiological
|
|
16
|
+
* convention, whatever order its file stores.
|
|
17
|
+
*
|
|
18
|
+
* The backend (app/geometry/canonical.py) implements the same rule for everything it reads and
|
|
19
|
+
* writes. The app holds both to one fixture, annotator-backend/tests/fixtures/orientation_cases.json.
|
|
20
|
+
*
|
|
21
|
+
* Pure: no DOM and no three, so it runs inside the NRRD worker as well as on the main thread.
|
|
22
|
+
*/
|
|
23
|
+
/** A volume whose patient orientation cannot be established. It is refused, never guessed. */
|
|
24
|
+
class OrientationError extends Error {
|
|
25
|
+
constructor(code, detail) {
|
|
26
|
+
super(`${code}: ${detail}`);
|
|
27
|
+
this.name = "OrientationError";
|
|
28
|
+
this.code = code;
|
|
29
|
+
this.detail = detail;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/** A screen axis more than 1 degree off an anatomical axis also gets that axis's letter (the rule
|
|
33
|
+
* of 3D Slicer's GetDirectionLabel). */
|
|
34
|
+
const LABEL_TOL = Math.sin((1 * Math.PI) / 180);
|
|
35
|
+
/** At 45 degrees an axis is equally near two anatomical axes, so it has no nearest one. */
|
|
36
|
+
const AMBIGUOUS_COS = Math.cos((45 * Math.PI) / 180) + 1e-9;
|
|
37
|
+
/** NRRD space -> the per-component signs that turn its coordinates into LPS. */
|
|
38
|
+
const LPS_SIGNS = {
|
|
39
|
+
"left-posterior-superior": [1, 1, 1],
|
|
40
|
+
lps: [1, 1, 1],
|
|
41
|
+
"right-anterior-superior": [-1, -1, 1],
|
|
42
|
+
ras: [-1, -1, 1],
|
|
43
|
+
"left-anterior-superior": [1, -1, 1],
|
|
44
|
+
las: [1, -1, 1],
|
|
45
|
+
};
|
|
46
|
+
const TIME_SPACES = new Set(["rast", "last", "lpst"]);
|
|
47
|
+
const NON_ANATOMICAL_SPACES = new Set(["3d-right-handed", "3d-left-handed"]);
|
|
48
|
+
/** TOWARD letter -> [patient axis in LPS, sign]. */
|
|
49
|
+
const LETTERS = {
|
|
50
|
+
L: [0, 1], R: [0, -1], P: [1, 1], A: [1, -1], S: [2, 1], I: [2, -1],
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Each view's screen-right and screen-down steps in canonical index space, as
|
|
54
|
+
* SliceRenderPipeline.flipDisplayImageByAxis draws them. A layout change there changes this
|
|
55
|
+
* table in the same commit.
|
|
56
|
+
*/
|
|
57
|
+
const VIEW_LAYOUT = {
|
|
58
|
+
z: [[1, 0, 0], [0, 1, 0]], // axial: right = +i, down = +j
|
|
59
|
+
y: [[1, 0, 0], [0, 0, -1]], // coronal: right = +i, down = -k
|
|
60
|
+
x: [[0, 1, 0], [0, 0, -1]], // sagittal: right = +j, down = -k
|
|
61
|
+
};
|
|
62
|
+
/** The longest header looked for; NRRD headers are a few hundred bytes. */
|
|
63
|
+
const MAX_HEADER_BYTES = 64 * 1024;
|
|
64
|
+
/**
|
|
65
|
+
* The text header of an NRRD document: everything before the first blank line. Read here instead
|
|
66
|
+
* of taken from three's NRRDLoader, which fills in identity directions when a file has none and so
|
|
67
|
+
* makes "no orientation" indistinguishable from "identity".
|
|
68
|
+
*/
|
|
69
|
+
function nrrdHeaderText(buffer) {
|
|
70
|
+
const bytes = new Uint8Array(buffer, 0, Math.min(buffer.byteLength, MAX_HEADER_BYTES));
|
|
71
|
+
if (String.fromCharCode(...bytes.subarray(0, 4)) !== "NRRD")
|
|
72
|
+
throw new Error("not an NRRD document (no NRRD magic)");
|
|
73
|
+
for (let n = 0; n < bytes.length - 1; n++) {
|
|
74
|
+
if (bytes[n] !== 0x0a)
|
|
75
|
+
continue;
|
|
76
|
+
const blankLf = bytes[n + 1] === 0x0a;
|
|
77
|
+
const blankCrlf = bytes[n + 1] === 0x0d && bytes[n + 2] === 0x0a;
|
|
78
|
+
if (blankLf || blankCrlf) {
|
|
79
|
+
const end = n > 0 && bytes[n - 1] === 0x0d ? n - 1 : n;
|
|
80
|
+
return new TextDecoder("latin1").decode(bytes.subarray(0, end));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
throw new Error("NRRD header has no terminating blank line");
|
|
84
|
+
}
|
|
85
|
+
/** Reads the orientation fields from an NRRD header's text. Comments and `key:=value` pairs are skipped. */
|
|
86
|
+
function readNrrdOrientationFields(headerText) {
|
|
87
|
+
var _a;
|
|
88
|
+
const out = { space: null, sizes: [], spaceDirections: null, spaceOrigin: null };
|
|
89
|
+
for (const line of headerText.split(/\r?\n/)) {
|
|
90
|
+
if (line.startsWith("#"))
|
|
91
|
+
continue;
|
|
92
|
+
const colon = line.indexOf(":");
|
|
93
|
+
if (colon < 0 || line[colon + 1] === "=")
|
|
94
|
+
continue;
|
|
95
|
+
const name = line.slice(0, colon).trim().toLowerCase();
|
|
96
|
+
const value = line.slice(colon + 1).trim();
|
|
97
|
+
if (name === "space")
|
|
98
|
+
out.space = value;
|
|
99
|
+
else if (name === "sizes")
|
|
100
|
+
out.sizes = value.split(/\s+/).map((n) => parseInt(n, 10));
|
|
101
|
+
else if (name === "space directions")
|
|
102
|
+
out.spaceDirections = parseVectors(value);
|
|
103
|
+
else if (name === "space origin")
|
|
104
|
+
out.spaceOrigin = (_a = parseVectors(value)[0]) !== null && _a !== void 0 ? _a : null;
|
|
105
|
+
}
|
|
106
|
+
return out;
|
|
107
|
+
}
|
|
108
|
+
/** An NRRD's geometry in LPS. Throws OrientationError when its patient orientation cannot be established. */
|
|
109
|
+
function geometryFromNrrd(fields) {
|
|
110
|
+
var _a;
|
|
111
|
+
const space = (_a = fields.space) === null || _a === void 0 ? void 0 : _a.trim();
|
|
112
|
+
if (!space) {
|
|
113
|
+
throw new OrientationError("no_space", "the header has no 'space' field, so its patient orientation is unknown");
|
|
114
|
+
}
|
|
115
|
+
const name = space.toLowerCase();
|
|
116
|
+
if (name.endsWith("-time") || TIME_SPACES.has(name)) {
|
|
117
|
+
throw new OrientationError("time_space", `space '${space}' is a time series; only 3D volumes are supported`);
|
|
118
|
+
}
|
|
119
|
+
if (name === "scanner-xyz") {
|
|
120
|
+
throw new OrientationError("scanner_space", "space 'scanner-xyz' is in scanner coordinates, whose patient orientation depends on how the patient lay (breast MRI is acquired prone)");
|
|
121
|
+
}
|
|
122
|
+
if (NON_ANATOMICAL_SPACES.has(name)) {
|
|
123
|
+
throw new OrientationError("non_anatomical_space", `space '${space}' has no anatomical meaning`);
|
|
124
|
+
}
|
|
125
|
+
const signs = LPS_SIGNS[name];
|
|
126
|
+
if (!signs)
|
|
127
|
+
throw new OrientationError("unknown_space", `space '${space}' is not a recognised anatomical space`);
|
|
128
|
+
const vectors = fields.spaceDirections;
|
|
129
|
+
if (!vectors || vectors.length === 0)
|
|
130
|
+
throw new OrientationError("no_directions", "the header has no 'space directions'");
|
|
131
|
+
if (fields.sizes.length !== 3 || vectors.length !== 3 || vectors.some((v) => v === null || v.length !== 3)) {
|
|
132
|
+
throw new OrientationError("not_3d", `expected 3 spatial axes, got sizes [${fields.sizes.join(", ")}]`);
|
|
133
|
+
}
|
|
134
|
+
if (!fields.spaceOrigin || fields.spaceOrigin.length !== 3) {
|
|
135
|
+
throw new OrientationError("no_origin", "the header has no 'space origin', so the grid has no patient position");
|
|
136
|
+
}
|
|
137
|
+
// "+ 0" turns a negated zero into 0, so a converted axis compares equal to the literal.
|
|
138
|
+
const directions = vectors.map((v) => v.map((c, x) => c * signs[x] + 0));
|
|
139
|
+
const origin = fields.spaceOrigin.map((c, x) => c * signs[x] + 0);
|
|
140
|
+
return checked({ dims: [fields.sizes[0], fields.sizes[1], fields.sizes[2]], directions, origin });
|
|
141
|
+
}
|
|
142
|
+
/** The transform into the voxel order that `codes` names (TOWARD), e.g. "LPS" or "RAI". */
|
|
143
|
+
function orientationTransform(geometry, codes = "LPS") {
|
|
144
|
+
const target = parseCodes(codes);
|
|
145
|
+
const spacing = spacingOf(geometry);
|
|
146
|
+
const units = geometry.directions.map((d, a) => d.map((c) => c / spacing[a]));
|
|
147
|
+
const nearest = units.map((u) => [0, 1, 2].reduce((best, x) => (Math.abs(u[x]) > Math.abs(u[best]) ? x : best), 0));
|
|
148
|
+
const strength = units.map((u, a) => Math.abs(u[nearest[a]]));
|
|
149
|
+
const obliquity = strength.map((s) => (Math.acos(Math.min(1, s)) * 180) / Math.PI);
|
|
150
|
+
if (strength.some((s) => s <= AMBIGUOUS_COS) || new Set(nearest).size !== 3) {
|
|
151
|
+
throw new OrientationError("ambiguous_oblique", `a voxel axis is ${Math.max(...obliquity).toFixed(1)} degrees from every anatomical axis, so it has no nearest one`);
|
|
152
|
+
}
|
|
153
|
+
const perm = [0, 0, 0];
|
|
154
|
+
const flip = [false, false, false];
|
|
155
|
+
const obliquityDeg = [0, 0, 0];
|
|
156
|
+
target.forEach(([patientAxis, sign], axis) => {
|
|
157
|
+
const native = nearest.indexOf(patientAxis);
|
|
158
|
+
perm[axis] = native;
|
|
159
|
+
flip[axis] = Math.sign(units[native][patientAxis]) !== sign;
|
|
160
|
+
obliquityDeg[axis] = obliquity[native];
|
|
161
|
+
});
|
|
162
|
+
return { perm, flip, obliquityDeg };
|
|
163
|
+
}
|
|
164
|
+
/** The transform into the canonical order (i->L, j->P, k->S). */
|
|
165
|
+
function canonicalTransform(geometry) {
|
|
166
|
+
return orientationTransform(geometry, "LPS");
|
|
167
|
+
}
|
|
168
|
+
function isIdentityTransform(transform) {
|
|
169
|
+
return transform.perm[0] === 0 && transform.perm[1] === 1 && transform.perm[2] === 2 && !transform.flip.some(Boolean);
|
|
170
|
+
}
|
|
171
|
+
/** The same grid described in the transform's voxel order. The origin moves to the new first voxel. */
|
|
172
|
+
function reorientedGeometry(geometry, transform) {
|
|
173
|
+
const origin = [...geometry.origin];
|
|
174
|
+
transform.perm.forEach((native, axis) => {
|
|
175
|
+
if (!transform.flip[axis])
|
|
176
|
+
return;
|
|
177
|
+
for (let x = 0; x < 3; x++)
|
|
178
|
+
origin[x] += (geometry.dims[native] - 1) * geometry.directions[native][x];
|
|
179
|
+
});
|
|
180
|
+
return {
|
|
181
|
+
dims: transform.perm.map((native) => geometry.dims[native]),
|
|
182
|
+
// "+ 0" turns a negated zero into 0 (see geometryFromNrrd).
|
|
183
|
+
directions: transform.perm.map((native, axis) => geometry.directions[native].map((c) => (transform.flip[axis] ? -c : c) + 0)),
|
|
184
|
+
origin,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Voxels (i fastest, as NRRD stores them) rewritten in the transform's order. The identity
|
|
189
|
+
* returns `data` itself, with no copy; any other transform returns a new array of the same type.
|
|
190
|
+
*/
|
|
191
|
+
function reorientVoxels(data, dims, transform) {
|
|
192
|
+
if (data.length !== dims[0] * dims[1] * dims[2]) {
|
|
193
|
+
throw new Error(`voxel count ${data.length} does not fill a ${dims.join("x")} grid`);
|
|
194
|
+
}
|
|
195
|
+
if (isIdentityTransform(transform))
|
|
196
|
+
return data;
|
|
197
|
+
const nativeStride = [1, dims[0], dims[0] * dims[1]];
|
|
198
|
+
const outDims = transform.perm.map((native) => dims[native]);
|
|
199
|
+
const step = transform.perm.map((native, axis) => (transform.flip[axis] ? -1 : 1) * nativeStride[native]);
|
|
200
|
+
let start = 0;
|
|
201
|
+
transform.perm.forEach((native, axis) => {
|
|
202
|
+
if (transform.flip[axis])
|
|
203
|
+
start += (dims[native] - 1) * nativeStride[native];
|
|
204
|
+
});
|
|
205
|
+
const out = new data.constructor(data.length);
|
|
206
|
+
let n = 0;
|
|
207
|
+
for (let c2 = 0, base2 = start; c2 < outDims[2]; c2++, base2 += step[2]) {
|
|
208
|
+
for (let c1 = 0, base1 = base2; c1 < outDims[1]; c1++, base1 += step[1]) {
|
|
209
|
+
for (let c0 = 0, index = base1; c0 < outDims[0]; c0++, index += step[0]) {
|
|
210
|
+
out[n++] = data[index];
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return out;
|
|
215
|
+
}
|
|
216
|
+
/** The orientation letters at each screen edge of a view of a canonical grid. */
|
|
217
|
+
function viewLabels(axis, geometry) {
|
|
218
|
+
const spacing = spacingOf(geometry);
|
|
219
|
+
const units = geometry.directions.map((d, a) => d.map((c) => c / spacing[a]));
|
|
220
|
+
const along = (step) => [0, 1, 2].map((x) => step[0] * units[0][x] + step[1] * units[1][x] + step[2] * units[2][x]);
|
|
221
|
+
const [rightStep, downStep] = VIEW_LAYOUT[axis];
|
|
222
|
+
const right = along(rightStep);
|
|
223
|
+
const down = along(downStep);
|
|
224
|
+
const negate = (v) => v.map((c) => -c);
|
|
225
|
+
return { left: letters(negate(right)), right: letters(right), top: letters(negate(down)), bottom: letters(down) };
|
|
226
|
+
}
|
|
227
|
+
function spacingOf(geometry) {
|
|
228
|
+
return geometry.directions.map((d) => Math.hypot(d[0], d[1], d[2]));
|
|
229
|
+
}
|
|
230
|
+
function letters(direction) {
|
|
231
|
+
return [0, 1, 2]
|
|
232
|
+
.filter((x) => Math.abs(direction[x]) > LABEL_TOL)
|
|
233
|
+
.sort((a, b) => Math.abs(direction[b]) - Math.abs(direction[a]))
|
|
234
|
+
.map((x) => (direction[x] > 0 ? "LPS" : "RAI")[x])
|
|
235
|
+
.join("");
|
|
236
|
+
}
|
|
237
|
+
function parseCodes(codes) {
|
|
238
|
+
if (codes.length !== 3 || [...codes].some((c) => !(c in LETTERS))) {
|
|
239
|
+
throw new Error(`not a three-letter orientation code: '${codes}'`);
|
|
240
|
+
}
|
|
241
|
+
const target = [...codes].map((c) => LETTERS[c]);
|
|
242
|
+
if (new Set(target.map(([patientAxis]) => patientAxis)).size !== 3) {
|
|
243
|
+
throw new Error(`orientation code '${codes}' names a patient axis twice`);
|
|
244
|
+
}
|
|
245
|
+
return target;
|
|
246
|
+
}
|
|
247
|
+
function parseVectors(text) {
|
|
248
|
+
const out = [];
|
|
249
|
+
for (const match of text.matchAll(/\(([^)]*)\)|none/gi)) {
|
|
250
|
+
out.push(match[1] === undefined ? null : match[1].split(",").map((c) => parseFloat(c)));
|
|
251
|
+
}
|
|
252
|
+
return out;
|
|
253
|
+
}
|
|
254
|
+
function checked(geometry) {
|
|
255
|
+
const values = [...geometry.directions.flat(), ...geometry.origin];
|
|
256
|
+
if (values.some((v) => !Number.isFinite(v))) {
|
|
257
|
+
throw new OrientationError("degenerate", "the geometry contains non-finite values");
|
|
258
|
+
}
|
|
259
|
+
const spacing = spacingOf(geometry);
|
|
260
|
+
if (spacing.some((s) => s <= 1e-12) || geometry.dims.some((n) => !(n >= 1))) {
|
|
261
|
+
throw new OrientationError("degenerate", `a voxel axis has no extent (dims [${geometry.dims.join(", ")}], spacing [${spacing.join(", ")}])`);
|
|
262
|
+
}
|
|
263
|
+
return geometry;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
exports.OrientationError = OrientationError;
|
|
267
|
+
exports.canonicalTransform = canonicalTransform;
|
|
268
|
+
exports.geometryFromNrrd = geometryFromNrrd;
|
|
269
|
+
exports.isIdentityTransform = isIdentityTransform;
|
|
270
|
+
exports.nrrdHeaderText = nrrdHeaderText;
|
|
271
|
+
exports.orientationTransform = orientationTransform;
|
|
272
|
+
exports.readNrrdOrientationFields = readNrrdOrientationFields;
|
|
273
|
+
exports.reorientVoxels = reorientVoxels;
|
|
274
|
+
exports.reorientedGeometry = reorientedGeometry;
|
|
275
|
+
exports.spacingOf = spacingOf;
|
|
276
|
+
exports.viewLabels = viewLabels;
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The canonical voxel order, and the rule that puts any volume into it.
|
|
3
|
+
*
|
|
4
|
+
* Canonical order: voxel index i increases toward the patient's Left, j toward Posterior, k
|
|
5
|
+
* toward Superior. Axis codes use the TOWARD convention of DICOM, nibabel and SimpleITK, so "LPS"
|
|
6
|
+
* names that order (legacy ITK and ITK-SNAP call the same order "RAI").
|
|
7
|
+
*
|
|
8
|
+
* Each native axis is assigned the anatomical axis it is nearest to and flipped when it points the
|
|
9
|
+
* other way. That is a permutation and flips, never a resampling, so obliquity stays in the
|
|
10
|
+
* geometry instead of being snapped away. With the voxels in this order, the fixed per-axis display
|
|
11
|
+
* mapping (SliceRenderPipeline.flipDisplayImageByAxis) shows every volume in the radiological
|
|
12
|
+
* convention, whatever order its file stores.
|
|
13
|
+
*
|
|
14
|
+
* The backend (app/geometry/canonical.py) implements the same rule for everything it reads and
|
|
15
|
+
* writes. The app holds both to one fixture, annotator-backend/tests/fixtures/orientation_cases.json.
|
|
16
|
+
*
|
|
17
|
+
* Pure: no DOM and no three, so it runs inside the NRRD worker as well as on the main thread.
|
|
18
|
+
*/
|
|
19
|
+
/** A volume whose patient orientation cannot be established. It is refused, never guessed. */
|
|
20
|
+
class OrientationError extends Error {
|
|
21
|
+
constructor(code, detail) {
|
|
22
|
+
super(`${code}: ${detail}`);
|
|
23
|
+
this.name = "OrientationError";
|
|
24
|
+
this.code = code;
|
|
25
|
+
this.detail = detail;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/** A screen axis more than 1 degree off an anatomical axis also gets that axis's letter (the rule
|
|
29
|
+
* of 3D Slicer's GetDirectionLabel). */
|
|
30
|
+
const LABEL_TOL = Math.sin((1 * Math.PI) / 180);
|
|
31
|
+
/** At 45 degrees an axis is equally near two anatomical axes, so it has no nearest one. */
|
|
32
|
+
const AMBIGUOUS_COS = Math.cos((45 * Math.PI) / 180) + 1e-9;
|
|
33
|
+
/** NRRD space -> the per-component signs that turn its coordinates into LPS. */
|
|
34
|
+
const LPS_SIGNS = {
|
|
35
|
+
"left-posterior-superior": [1, 1, 1],
|
|
36
|
+
lps: [1, 1, 1],
|
|
37
|
+
"right-anterior-superior": [-1, -1, 1],
|
|
38
|
+
ras: [-1, -1, 1],
|
|
39
|
+
"left-anterior-superior": [1, -1, 1],
|
|
40
|
+
las: [1, -1, 1],
|
|
41
|
+
};
|
|
42
|
+
const TIME_SPACES = new Set(["rast", "last", "lpst"]);
|
|
43
|
+
const NON_ANATOMICAL_SPACES = new Set(["3d-right-handed", "3d-left-handed"]);
|
|
44
|
+
/** TOWARD letter -> [patient axis in LPS, sign]. */
|
|
45
|
+
const LETTERS = {
|
|
46
|
+
L: [0, 1], R: [0, -1], P: [1, 1], A: [1, -1], S: [2, 1], I: [2, -1],
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Each view's screen-right and screen-down steps in canonical index space, as
|
|
50
|
+
* SliceRenderPipeline.flipDisplayImageByAxis draws them. A layout change there changes this
|
|
51
|
+
* table in the same commit.
|
|
52
|
+
*/
|
|
53
|
+
const VIEW_LAYOUT = {
|
|
54
|
+
z: [[1, 0, 0], [0, 1, 0]], // axial: right = +i, down = +j
|
|
55
|
+
y: [[1, 0, 0], [0, 0, -1]], // coronal: right = +i, down = -k
|
|
56
|
+
x: [[0, 1, 0], [0, 0, -1]], // sagittal: right = +j, down = -k
|
|
57
|
+
};
|
|
58
|
+
/** The longest header looked for; NRRD headers are a few hundred bytes. */
|
|
59
|
+
const MAX_HEADER_BYTES = 64 * 1024;
|
|
60
|
+
/**
|
|
61
|
+
* The text header of an NRRD document: everything before the first blank line. Read here instead
|
|
62
|
+
* of taken from three's NRRDLoader, which fills in identity directions when a file has none and so
|
|
63
|
+
* makes "no orientation" indistinguishable from "identity".
|
|
64
|
+
*/
|
|
65
|
+
function nrrdHeaderText(buffer) {
|
|
66
|
+
const bytes = new Uint8Array(buffer, 0, Math.min(buffer.byteLength, MAX_HEADER_BYTES));
|
|
67
|
+
if (String.fromCharCode(...bytes.subarray(0, 4)) !== "NRRD")
|
|
68
|
+
throw new Error("not an NRRD document (no NRRD magic)");
|
|
69
|
+
for (let n = 0; n < bytes.length - 1; n++) {
|
|
70
|
+
if (bytes[n] !== 0x0a)
|
|
71
|
+
continue;
|
|
72
|
+
const blankLf = bytes[n + 1] === 0x0a;
|
|
73
|
+
const blankCrlf = bytes[n + 1] === 0x0d && bytes[n + 2] === 0x0a;
|
|
74
|
+
if (blankLf || blankCrlf) {
|
|
75
|
+
const end = n > 0 && bytes[n - 1] === 0x0d ? n - 1 : n;
|
|
76
|
+
return new TextDecoder("latin1").decode(bytes.subarray(0, end));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
throw new Error("NRRD header has no terminating blank line");
|
|
80
|
+
}
|
|
81
|
+
/** Reads the orientation fields from an NRRD header's text. Comments and `key:=value` pairs are skipped. */
|
|
82
|
+
function readNrrdOrientationFields(headerText) {
|
|
83
|
+
var _a;
|
|
84
|
+
const out = { space: null, sizes: [], spaceDirections: null, spaceOrigin: null };
|
|
85
|
+
for (const line of headerText.split(/\r?\n/)) {
|
|
86
|
+
if (line.startsWith("#"))
|
|
87
|
+
continue;
|
|
88
|
+
const colon = line.indexOf(":");
|
|
89
|
+
if (colon < 0 || line[colon + 1] === "=")
|
|
90
|
+
continue;
|
|
91
|
+
const name = line.slice(0, colon).trim().toLowerCase();
|
|
92
|
+
const value = line.slice(colon + 1).trim();
|
|
93
|
+
if (name === "space")
|
|
94
|
+
out.space = value;
|
|
95
|
+
else if (name === "sizes")
|
|
96
|
+
out.sizes = value.split(/\s+/).map((n) => parseInt(n, 10));
|
|
97
|
+
else if (name === "space directions")
|
|
98
|
+
out.spaceDirections = parseVectors(value);
|
|
99
|
+
else if (name === "space origin")
|
|
100
|
+
out.spaceOrigin = (_a = parseVectors(value)[0]) !== null && _a !== void 0 ? _a : null;
|
|
101
|
+
}
|
|
102
|
+
return out;
|
|
103
|
+
}
|
|
104
|
+
/** An NRRD's geometry in LPS. Throws OrientationError when its patient orientation cannot be established. */
|
|
105
|
+
function geometryFromNrrd(fields) {
|
|
106
|
+
var _a;
|
|
107
|
+
const space = (_a = fields.space) === null || _a === void 0 ? void 0 : _a.trim();
|
|
108
|
+
if (!space) {
|
|
109
|
+
throw new OrientationError("no_space", "the header has no 'space' field, so its patient orientation is unknown");
|
|
110
|
+
}
|
|
111
|
+
const name = space.toLowerCase();
|
|
112
|
+
if (name.endsWith("-time") || TIME_SPACES.has(name)) {
|
|
113
|
+
throw new OrientationError("time_space", `space '${space}' is a time series; only 3D volumes are supported`);
|
|
114
|
+
}
|
|
115
|
+
if (name === "scanner-xyz") {
|
|
116
|
+
throw new OrientationError("scanner_space", "space 'scanner-xyz' is in scanner coordinates, whose patient orientation depends on how the patient lay (breast MRI is acquired prone)");
|
|
117
|
+
}
|
|
118
|
+
if (NON_ANATOMICAL_SPACES.has(name)) {
|
|
119
|
+
throw new OrientationError("non_anatomical_space", `space '${space}' has no anatomical meaning`);
|
|
120
|
+
}
|
|
121
|
+
const signs = LPS_SIGNS[name];
|
|
122
|
+
if (!signs)
|
|
123
|
+
throw new OrientationError("unknown_space", `space '${space}' is not a recognised anatomical space`);
|
|
124
|
+
const vectors = fields.spaceDirections;
|
|
125
|
+
if (!vectors || vectors.length === 0)
|
|
126
|
+
throw new OrientationError("no_directions", "the header has no 'space directions'");
|
|
127
|
+
if (fields.sizes.length !== 3 || vectors.length !== 3 || vectors.some((v) => v === null || v.length !== 3)) {
|
|
128
|
+
throw new OrientationError("not_3d", `expected 3 spatial axes, got sizes [${fields.sizes.join(", ")}]`);
|
|
129
|
+
}
|
|
130
|
+
if (!fields.spaceOrigin || fields.spaceOrigin.length !== 3) {
|
|
131
|
+
throw new OrientationError("no_origin", "the header has no 'space origin', so the grid has no patient position");
|
|
132
|
+
}
|
|
133
|
+
// "+ 0" turns a negated zero into 0, so a converted axis compares equal to the literal.
|
|
134
|
+
const directions = vectors.map((v) => v.map((c, x) => c * signs[x] + 0));
|
|
135
|
+
const origin = fields.spaceOrigin.map((c, x) => c * signs[x] + 0);
|
|
136
|
+
return checked({ dims: [fields.sizes[0], fields.sizes[1], fields.sizes[2]], directions, origin });
|
|
137
|
+
}
|
|
138
|
+
/** The transform into the voxel order that `codes` names (TOWARD), e.g. "LPS" or "RAI". */
|
|
139
|
+
function orientationTransform(geometry, codes = "LPS") {
|
|
140
|
+
const target = parseCodes(codes);
|
|
141
|
+
const spacing = spacingOf(geometry);
|
|
142
|
+
const units = geometry.directions.map((d, a) => d.map((c) => c / spacing[a]));
|
|
143
|
+
const nearest = units.map((u) => [0, 1, 2].reduce((best, x) => (Math.abs(u[x]) > Math.abs(u[best]) ? x : best), 0));
|
|
144
|
+
const strength = units.map((u, a) => Math.abs(u[nearest[a]]));
|
|
145
|
+
const obliquity = strength.map((s) => (Math.acos(Math.min(1, s)) * 180) / Math.PI);
|
|
146
|
+
if (strength.some((s) => s <= AMBIGUOUS_COS) || new Set(nearest).size !== 3) {
|
|
147
|
+
throw new OrientationError("ambiguous_oblique", `a voxel axis is ${Math.max(...obliquity).toFixed(1)} degrees from every anatomical axis, so it has no nearest one`);
|
|
148
|
+
}
|
|
149
|
+
const perm = [0, 0, 0];
|
|
150
|
+
const flip = [false, false, false];
|
|
151
|
+
const obliquityDeg = [0, 0, 0];
|
|
152
|
+
target.forEach(([patientAxis, sign], axis) => {
|
|
153
|
+
const native = nearest.indexOf(patientAxis);
|
|
154
|
+
perm[axis] = native;
|
|
155
|
+
flip[axis] = Math.sign(units[native][patientAxis]) !== sign;
|
|
156
|
+
obliquityDeg[axis] = obliquity[native];
|
|
157
|
+
});
|
|
158
|
+
return { perm, flip, obliquityDeg };
|
|
159
|
+
}
|
|
160
|
+
/** The transform into the canonical order (i->L, j->P, k->S). */
|
|
161
|
+
function canonicalTransform(geometry) {
|
|
162
|
+
return orientationTransform(geometry, "LPS");
|
|
163
|
+
}
|
|
164
|
+
function isIdentityTransform(transform) {
|
|
165
|
+
return transform.perm[0] === 0 && transform.perm[1] === 1 && transform.perm[2] === 2 && !transform.flip.some(Boolean);
|
|
166
|
+
}
|
|
167
|
+
/** The same grid described in the transform's voxel order. The origin moves to the new first voxel. */
|
|
168
|
+
function reorientedGeometry(geometry, transform) {
|
|
169
|
+
const origin = [...geometry.origin];
|
|
170
|
+
transform.perm.forEach((native, axis) => {
|
|
171
|
+
if (!transform.flip[axis])
|
|
172
|
+
return;
|
|
173
|
+
for (let x = 0; x < 3; x++)
|
|
174
|
+
origin[x] += (geometry.dims[native] - 1) * geometry.directions[native][x];
|
|
175
|
+
});
|
|
176
|
+
return {
|
|
177
|
+
dims: transform.perm.map((native) => geometry.dims[native]),
|
|
178
|
+
// "+ 0" turns a negated zero into 0 (see geometryFromNrrd).
|
|
179
|
+
directions: transform.perm.map((native, axis) => geometry.directions[native].map((c) => (transform.flip[axis] ? -c : c) + 0)),
|
|
180
|
+
origin,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Voxels (i fastest, as NRRD stores them) rewritten in the transform's order. The identity
|
|
185
|
+
* returns `data` itself, with no copy; any other transform returns a new array of the same type.
|
|
186
|
+
*/
|
|
187
|
+
function reorientVoxels(data, dims, transform) {
|
|
188
|
+
if (data.length !== dims[0] * dims[1] * dims[2]) {
|
|
189
|
+
throw new Error(`voxel count ${data.length} does not fill a ${dims.join("x")} grid`);
|
|
190
|
+
}
|
|
191
|
+
if (isIdentityTransform(transform))
|
|
192
|
+
return data;
|
|
193
|
+
const nativeStride = [1, dims[0], dims[0] * dims[1]];
|
|
194
|
+
const outDims = transform.perm.map((native) => dims[native]);
|
|
195
|
+
const step = transform.perm.map((native, axis) => (transform.flip[axis] ? -1 : 1) * nativeStride[native]);
|
|
196
|
+
let start = 0;
|
|
197
|
+
transform.perm.forEach((native, axis) => {
|
|
198
|
+
if (transform.flip[axis])
|
|
199
|
+
start += (dims[native] - 1) * nativeStride[native];
|
|
200
|
+
});
|
|
201
|
+
const out = new data.constructor(data.length);
|
|
202
|
+
let n = 0;
|
|
203
|
+
for (let c2 = 0, base2 = start; c2 < outDims[2]; c2++, base2 += step[2]) {
|
|
204
|
+
for (let c1 = 0, base1 = base2; c1 < outDims[1]; c1++, base1 += step[1]) {
|
|
205
|
+
for (let c0 = 0, index = base1; c0 < outDims[0]; c0++, index += step[0]) {
|
|
206
|
+
out[n++] = data[index];
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return out;
|
|
211
|
+
}
|
|
212
|
+
/** The orientation letters at each screen edge of a view of a canonical grid. */
|
|
213
|
+
function viewLabels(axis, geometry) {
|
|
214
|
+
const spacing = spacingOf(geometry);
|
|
215
|
+
const units = geometry.directions.map((d, a) => d.map((c) => c / spacing[a]));
|
|
216
|
+
const along = (step) => [0, 1, 2].map((x) => step[0] * units[0][x] + step[1] * units[1][x] + step[2] * units[2][x]);
|
|
217
|
+
const [rightStep, downStep] = VIEW_LAYOUT[axis];
|
|
218
|
+
const right = along(rightStep);
|
|
219
|
+
const down = along(downStep);
|
|
220
|
+
const negate = (v) => v.map((c) => -c);
|
|
221
|
+
return { left: letters(negate(right)), right: letters(right), top: letters(negate(down)), bottom: letters(down) };
|
|
222
|
+
}
|
|
223
|
+
function spacingOf(geometry) {
|
|
224
|
+
return geometry.directions.map((d) => Math.hypot(d[0], d[1], d[2]));
|
|
225
|
+
}
|
|
226
|
+
function letters(direction) {
|
|
227
|
+
return [0, 1, 2]
|
|
228
|
+
.filter((x) => Math.abs(direction[x]) > LABEL_TOL)
|
|
229
|
+
.sort((a, b) => Math.abs(direction[b]) - Math.abs(direction[a]))
|
|
230
|
+
.map((x) => (direction[x] > 0 ? "LPS" : "RAI")[x])
|
|
231
|
+
.join("");
|
|
232
|
+
}
|
|
233
|
+
function parseCodes(codes) {
|
|
234
|
+
if (codes.length !== 3 || [...codes].some((c) => !(c in LETTERS))) {
|
|
235
|
+
throw new Error(`not a three-letter orientation code: '${codes}'`);
|
|
236
|
+
}
|
|
237
|
+
const target = [...codes].map((c) => LETTERS[c]);
|
|
238
|
+
if (new Set(target.map(([patientAxis]) => patientAxis)).size !== 3) {
|
|
239
|
+
throw new Error(`orientation code '${codes}' names a patient axis twice`);
|
|
240
|
+
}
|
|
241
|
+
return target;
|
|
242
|
+
}
|
|
243
|
+
function parseVectors(text) {
|
|
244
|
+
const out = [];
|
|
245
|
+
for (const match of text.matchAll(/\(([^)]*)\)|none/gi)) {
|
|
246
|
+
out.push(match[1] === undefined ? null : match[1].split(",").map((c) => parseFloat(c)));
|
|
247
|
+
}
|
|
248
|
+
return out;
|
|
249
|
+
}
|
|
250
|
+
function checked(geometry) {
|
|
251
|
+
const values = [...geometry.directions.flat(), ...geometry.origin];
|
|
252
|
+
if (values.some((v) => !Number.isFinite(v))) {
|
|
253
|
+
throw new OrientationError("degenerate", "the geometry contains non-finite values");
|
|
254
|
+
}
|
|
255
|
+
const spacing = spacingOf(geometry);
|
|
256
|
+
if (spacing.some((s) => s <= 1e-12) || geometry.dims.some((n) => !(n >= 1))) {
|
|
257
|
+
throw new OrientationError("degenerate", `a voxel axis has no extent (dims [${geometry.dims.join(", ")}], spacing [${spacing.join(", ")}])`);
|
|
258
|
+
}
|
|
259
|
+
return geometry;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export { OrientationError, canonicalTransform, geometryFromNrrd, isIdentityTransform, nrrdHeaderText, orientationTransform, readNrrdOrientationFields, reorientVoxels, reorientedGeometry, spacingOf, viewLabels };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "copper3d",
|
|
3
3
|
"description": "A 3d visualisation package base on threejs provides multiple scenes and Nrrd image load funtion.",
|
|
4
|
-
"version": "4.1.
|
|
4
|
+
"version": "4.1.1",
|
|
5
5
|
"main": "dist/bundle.umd.js",
|
|
6
6
|
"module": "dist/bundle.esm.mjs",
|
|
7
7
|
"types": "dist/types/index.d.ts",
|
|
@@ -11,6 +11,11 @@
|
|
|
11
11
|
"import": "./dist/bundle.esm.mjs",
|
|
12
12
|
"require": "./dist/bundle.umd.js"
|
|
13
13
|
},
|
|
14
|
+
"./orientation": {
|
|
15
|
+
"types": "./dist/types/Utils/orientation.d.ts",
|
|
16
|
+
"import": "./dist/orientation.mjs",
|
|
17
|
+
"require": "./dist/orientation.cjs"
|
|
18
|
+
},
|
|
14
19
|
"./dist/css/*": "./dist/css/*",
|
|
15
20
|
"./package.json": "./package.json"
|
|
16
21
|
},
|