cornerstone-nifti-image-loader
Version:
Cornerstone ImageLoader for NIfTI
8 lines • 198 kB
JavaScript
/*! cornerstone-nifti-image-loader - 1.0.0 - 2018-11-11 | (c) 2018 Flywheel Exchange, LLC | https://github.com/flywheel-io/cornerstone-nifti-image-loader */
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("cornerstoneNIFTIImageLoader",[],e):"object"==typeof exports?exports.cornerstoneNIFTIImageLoader=e():t.cornerstoneNIFTIImageLoader=e()}("undefined"!=typeof self?self:this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=41)}([function(t,e){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.external=void 0;var i=n(44),a=r(i),o=n(54),s=r(o),u=window.cornerstone,l=a.default,h={set cornerstone(t){u=t,(0,s.default)(u)},get cornerstone(){return u},set niftiReader(t){l=t},get niftiReader(){return l}};e.external=h},function(t,e,n){"use strict";function r(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var i="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;e.assign=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var n=e.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(var i in n)r(n,i)&&(t[i]=n[i])}}return t},e.shrinkBuf=function(t,e){return t.length===e?t:t.subarray?t.subarray(0,e):(t.length=e,t)};var a={arraySet:function(t,e,n,r,i){if(e.subarray&&t.subarray)return void t.set(e.subarray(n,n+r),i);for(var a=0;a<r;a++)t[i+a]=e[n+a]},flattenChunks:function(t){var e,n,r,i,a,o;for(r=0,e=0,n=t.length;e<n;e++)r+=t[e].length;for(o=new Uint8Array(r),i=0,e=0,n=t.length;e<n;e++)a=t[e],o.set(a,i),i+=a.length;return o}},o={arraySet:function(t,e,n,r,i){for(var a=0;a<r;a++)t[i+a]=e[n+a]},flattenChunks:function(t){return[].concat.apply([],t)}};e.setTyped=function(t){t?(e.Buf8=Uint8Array,e.Buf16=Uint16Array,e.Buf32=Int32Array,e.assign(e,a)):(e.Buf8=Array,e.Buf16=Array,e.Buf32=Array,e.assign(e,o))},e.setTyped(i)},function(t,e){"function"==typeof Object.create?t.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(t,e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}},function(t,e){function n(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function i(t){if(h===setTimeout)return setTimeout(t,0);if((h===n||!h)&&setTimeout)return h=setTimeout,setTimeout(t,0);try{return h(t,0)}catch(e){try{return h.call(null,t,0)}catch(e){return h.call(this,t,0)}}}function a(t){if(f===clearTimeout)return clearTimeout(t);if((f===r||!f)&&clearTimeout)return f=clearTimeout,clearTimeout(t);try{return f(t)}catch(e){try{return f.call(null,t)}catch(e){return f.call(this,t)}}}function o(){m&&d&&(m=!1,d.length?p=d.concat(p):g=-1,p.length&&s())}function s(){if(!m){var t=i(o);m=!0;for(var e=p.length;e;){for(d=p,p=[];++g<e;)d&&d[g].run();g=-1,e=p.length}d=null,m=!1,a(t)}}function u(t,e){this.fun=t,this.array=e}function l(){}var h,f,c=t.exports={};!function(){try{h="function"==typeof setTimeout?setTimeout:n}catch(t){h=n}try{f="function"==typeof clearTimeout?clearTimeout:r}catch(t){f=r}}();var d,p=[],m=!1,g=-1;c.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];p.push(new u(t,e)),1!==p.length||m||i(s)},u.prototype.run=function(){this.fun.apply(null,this.array)},c.title="browser",c.browser=!0,c.env={},c.argv=[],c.version="",c.versions={},c.on=l,c.addListener=l,c.once=l,c.off=l,c.removeListener=l,c.removeAllListeners=l,c.emit=l,c.prependListener=l,c.prependOnceListener=l,c.listeners=function(t){return[]},c.binding=function(t){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(t){throw new Error("process.chdir is not supported")},c.umask=function(){return 0}},function(t,e,n){"use strict";function r(t){if(!(this instanceof r))return new r(t);l.call(this,t),h.call(this,t),t&&!1===t.readable&&(this.readable=!1),t&&!1===t.writable&&(this.writable=!1),this.allowHalfOpen=!0,t&&!1===t.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",i)}function i(){this.allowHalfOpen||this._writableState.ended||o(a,this)}function a(t){t.end()}var o=n(10),s=Object.keys||function(t){var e=[];for(var n in t)e.push(n);return e};t.exports=r;var u=n(7);u.inherits=n(3);var l=n(34),h=n(38);u.inherits(r,l);for(var f=s(h.prototype),c=0;c<f.length;c++){var d=f[c];r.prototype[d]||(r.prototype[d]=h.prototype[d])}Object.defineProperty(r.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(t){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}}),r.prototype._destroy=function(t,e){this.push(null),this.end(),o(e,t)}},function(t,e,n){"use strict";(function(t){function r(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function i(t,e){if(r()<e)throw new RangeError("Invalid typed array length");return a.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e),t.__proto__=a.prototype):(null===t&&(t=new a(e)),t.length=e),t}function a(t,e,n){if(!(a.TYPED_ARRAY_SUPPORT||this instanceof a))return new a(t,e,n);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return l(this,t)}return o(this,t,e,n)}function o(t,e,n,r){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?c(t,e,n,r):"string"==typeof e?h(t,e,n):d(t,e)}function s(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function u(t,e,n,r){return s(e),e<=0?i(t,e):void 0!==n?"string"==typeof r?i(t,e).fill(n,r):i(t,e).fill(n):i(t,e)}function l(t,e){if(s(e),t=i(t,e<0?0:0|p(e)),!a.TYPED_ARRAY_SUPPORT)for(var n=0;n<e;++n)t[n]=0;return t}function h(t,e,n){if("string"==typeof n&&""!==n||(n="utf8"),!a.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|g(e,n);t=i(t,r);var o=t.write(e,n);return o!==r&&(t=t.slice(0,o)),t}function f(t,e){var n=e.length<0?0:0|p(e.length);t=i(t,n);for(var r=0;r<n;r+=1)t[r]=255&e[r];return t}function c(t,e,n,r){if(e.byteLength,n<0||e.byteLength<n)throw new RangeError("'offset' is out of bounds");if(e.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");return e=void 0===n&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,n):new Uint8Array(e,n,r),a.TYPED_ARRAY_SUPPORT?(t=e,t.__proto__=a.prototype):t=f(t,e),t}function d(t,e){if(a.isBuffer(e)){var n=0|p(e.length);return t=i(t,n),0===t.length?t:(e.copy(t,0,0,n),t)}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||K(e.length)?i(t,0):f(t,e);if("Buffer"===e.type&&$(e.data))return f(t,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function p(t){if(t>=r())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r().toString(16)+" bytes");return 0|t}function m(t){return+t!=t&&(t=0),a.alloc(+t)}function g(t,e){if(a.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return H(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return G(t).length;default:if(r)return H(t).length;e=(""+e).toLowerCase(),r=!0}}function _(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if(n>>>=0,e>>>=0,n<=e)return"";for(t||(t="utf8");;)switch(t){case"hex":return D(this,e,n);case"utf8":case"utf-8":return A(this,e,n);case"ascii":return P(this,e,n);case"latin1":case"binary":return F(this,e,n);case"base64":return S(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function v(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function y(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=a.from(e,r)),a.isBuffer(e))return 0===e.length?-1:b(t,e,n,r,i);if("number"==typeof e)return e&=255,a.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):b(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function b(t,e,n,r,i){function a(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}var o=1,s=t.length,u=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;o=2,s/=2,u/=2,n/=2}var l;if(i){var h=-1;for(l=n;l<s;l++)if(a(t,l)===a(e,-1===h?0:l-h)){if(-1===h&&(h=l),l-h+1===u)return h*o}else-1!==h&&(l-=l-h),h=-1}else for(n+u>s&&(n=s-u),l=n;l>=0;l--){for(var f=!0,c=0;c<u;c++)if(a(t,l+c)!==a(e,c)){f=!1;break}if(f)return l}return-1}function w(t,e,n,r){n=Number(n)||0;var i=t.length-n;r?(r=Number(r))>i&&(r=i):r=i;var a=e.length;if(a%2!=0)throw new TypeError("Invalid hex string");r>a/2&&(r=a/2);for(var o=0;o<r;++o){var s=parseInt(e.substr(2*o,2),16);if(isNaN(s))return o;t[n+o]=s}return o}function I(t,e,n,r){return X(H(e,t.length-n),t,n,r)}function T(t,e,n,r){return X(V(e),t,n,r)}function x(t,e,n,r){return T(t,e,n,r)}function E(t,e,n,r){return X(G(e),t,n,r)}function N(t,e,n,r){return X(Z(e,t.length-n),t,n,r)}function S(t,e,n){return 0===e&&n===t.length?W.fromByteArray(t):W.fromByteArray(t.slice(e,n))}function A(t,e,n){n=Math.min(t.length,n);for(var r=[],i=e;i<n;){var a=t[i],o=null,s=a>239?4:a>223?3:a>191?2:1;if(i+s<=n){var u,l,h,f;switch(s){case 1:a<128&&(o=a);break;case 2:u=t[i+1],128==(192&u)&&(f=(31&a)<<6|63&u)>127&&(o=f);break;case 3:u=t[i+1],l=t[i+2],128==(192&u)&&128==(192&l)&&(f=(15&a)<<12|(63&u)<<6|63&l)>2047&&(f<55296||f>57343)&&(o=f);break;case 4:u=t[i+1],l=t[i+2],h=t[i+3],128==(192&u)&&128==(192&l)&&128==(192&h)&&(f=(15&a)<<18|(63&u)<<12|(63&l)<<6|63&h)>65535&&f<1114112&&(o=f)}}null===o?(o=65533,s=1):o>65535&&(o-=65536,r.push(o>>>10&1023|55296),o=56320|1023&o),r.push(o),i+=s}return k(r)}function k(t){var e=t.length;if(e<=J)return String.fromCharCode.apply(String,t);for(var n="",r=0;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=J));return n}function P(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;i<n;++i)r+=String.fromCharCode(127&t[i]);return r}function F(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;i<n;++i)r+=String.fromCharCode(t[i]);return r}function D(t,e,n){var r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);for(var i="",a=e;a<n;++a)i+=Y(t[a]);return i}function C(t,e,n){for(var r=t.slice(e,n),i="",a=0;a<r.length;a+=2)i+=String.fromCharCode(r[a]+256*r[a+1]);return i}function U(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,n,r,i,o){if(!a.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function M(t,e,n,r){e<0&&(e=65535+e+1);for(var i=0,a=Math.min(t.length-n,2);i<a;++i)t[n+i]=(e&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function R(t,e,n,r){e<0&&(e=4294967295+e+1);for(var i=0,a=Math.min(t.length-n,4);i<a;++i)t[n+i]=e>>>8*(r?i:3-i)&255}function B(t,e,n,r,i,a){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function L(t,e,n,r,i){return i||B(t,e,n,4,3.4028234663852886e38,-3.4028234663852886e38),Q.write(t,e,n,r,23,4),n+4}function j(t,e,n,r,i){return i||B(t,e,n,8,1.7976931348623157e308,-1.7976931348623157e308),Q.write(t,e,n,r,52,8),n+8}function z(t){if(t=q(t).replace(tt,""),t.length<2)return"";for(;t.length%4!=0;)t+="=";return t}function q(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function Y(t){return t<16?"0"+t.toString(16):t.toString(16)}function H(t,e){e=e||1/0;for(var n,r=t.length,i=null,a=[],o=0;o<r;++o){if((n=t.charCodeAt(o))>55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&a.push(239,191,189);continue}if(o+1===r){(e-=3)>-1&&a.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&a.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&a.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;a.push(n)}else if(n<2048){if((e-=2)<0)break;a.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;a.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return a}function V(t){for(var e=[],n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}function Z(t,e){for(var n,r,i,a=[],o=0;o<t.length&&!((e-=2)<0);++o)n=t.charCodeAt(o),r=n>>8,i=n%256,a.push(i),a.push(r);return a}function G(t){return W.toByteArray(z(t))}function X(t,e,n,r){for(var i=0;i<r&&!(i+n>=e.length||i>=t.length);++i)e[i+n]=t[i];return i}function K(t){return t!==t}/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
* @license MIT
*/
var W=n(71),Q=n(72),$=n(30);e.Buffer=a,e.SlowBuffer=m,e.INSPECT_MAX_BYTES=50,a.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=r(),a.poolSize=8192,a._augment=function(t){return t.__proto__=a.prototype,t},a.from=function(t,e,n){return o(null,t,e,n)},a.TYPED_ARRAY_SUPPORT&&(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0})),a.alloc=function(t,e,n){return u(null,t,e,n)},a.allocUnsafe=function(t){return l(null,t)},a.allocUnsafeSlow=function(t){return l(null,t)},a.isBuffer=function(t){return!(null==t||!t._isBuffer)},a.compare=function(t,e){if(!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var n=t.length,r=e.length,i=0,o=Math.min(n,r);i<o;++i)if(t[i]!==e[i]){n=t[i],r=e[i];break}return n<r?-1:r<n?1:0},a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(t,e){if(!$(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return a.alloc(0);var n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var r=a.allocUnsafe(e),i=0;for(n=0;n<t.length;++n){var o=t[n];if(!a.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(r,i),i+=o.length}return r},a.byteLength=g,a.prototype._isBuffer=!0,a.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)v(this,e,e+1);return this},a.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)v(this,e,e+3),v(this,e+1,e+2);return this},a.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)v(this,e,e+7),v(this,e+1,e+6),v(this,e+2,e+5),v(this,e+3,e+4);return this},a.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?A(this,0,t):_.apply(this,arguments)},a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===a.compare(this,t)},a.prototype.inspect=function(){var t="",n=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),"<Buffer "+t+">"},a.prototype.compare=function(t,e,n,r,i){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,r>>>=0,i>>>=0,this===t)return 0;for(var o=i-r,s=n-e,u=Math.min(o,s),l=this.slice(r,i),h=t.slice(e,n),f=0;f<u;++f)if(l[f]!==h[f]){o=l[f],s=h[f];break}return o<s?-1:s<o?1:0},a.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},a.prototype.indexOf=function(t,e,n){return y(this,t,e,n,!0)},a.prototype.lastIndexOf=function(t,e,n){return y(this,t,e,n,!1)},a.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-e;if((void 0===n||n>i)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var a=!1;;)switch(r){case"hex":return w(this,t,e,n);case"utf8":case"utf-8":return I(this,t,e,n);case"ascii":return T(this,t,e,n);case"latin1":case"binary":return x(this,t,e,n);case"base64":return E(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,t,e,n);default:if(a)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),a=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var J=4096;a.prototype.slice=function(t,e){var n=this.length;t=~~t,e=void 0===e?n:~~e,t<0?(t+=n)<0&&(t=0):t>n&&(t=n),e<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t);var r;if(a.TYPED_ARRAY_SUPPORT)r=this.subarray(t,e),r.__proto__=a.prototype;else{var i=e-t;r=new a(i,void 0);for(var o=0;o<i;++o)r[o]=this[o+t]}return r},a.prototype.readUIntLE=function(t,e,n){t|=0,e|=0,n||U(t,e,this.length);for(var r=this[t],i=1,a=0;++a<e&&(i*=256);)r+=this[t+a]*i;return r},a.prototype.readUIntBE=function(t,e,n){t|=0,e|=0,n||U(t,e,this.length);for(var r=this[t+--e],i=1;e>0&&(i*=256);)r+=this[t+--e]*i;return r},a.prototype.readUInt8=function(t,e){return e||U(t,1,this.length),this[t]},a.prototype.readUInt16LE=function(t,e){return e||U(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUInt16BE=function(t,e){return e||U(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUInt32LE=function(t,e){return e||U(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUInt32BE=function(t,e){return e||U(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||U(t,e,this.length);for(var r=this[t],i=1,a=0;++a<e&&(i*=256);)r+=this[t+a]*i;return i*=128,r>=i&&(r-=Math.pow(2,8*e)),r},a.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||U(t,e,this.length);for(var r=e,i=1,a=this[t+--r];r>0&&(i*=256);)a+=this[t+--r]*i;return i*=128,a>=i&&(a-=Math.pow(2,8*e)),a},a.prototype.readInt8=function(t,e){return e||U(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},a.prototype.readInt16LE=function(t,e){e||U(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt16BE=function(t,e){e||U(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt32LE=function(t,e){return e||U(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return e||U(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readFloatLE=function(t,e){return e||U(t,4,this.length),Q.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return e||U(t,4,this.length),Q.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return e||U(t,8,this.length),Q.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return e||U(t,8,this.length),Q.read(this,t,!1,52,8)},a.prototype.writeUIntLE=function(t,e,n,r){if(t=+t,e|=0,n|=0,!r){O(this,t,e,n,Math.pow(2,8*n)-1,0)}var i=1,a=0;for(this[e]=255&t;++a<n&&(i*=256);)this[e+a]=t/i&255;return e+n},a.prototype.writeUIntBE=function(t,e,n,r){if(t=+t,e|=0,n|=0,!r){O(this,t,e,n,Math.pow(2,8*n)-1,0)}var i=n-1,a=1;for(this[e+i]=255&t;--i>=0&&(a*=256);)this[e+i]=t/a&255;return e+n},a.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||O(this,t,e,1,255,0),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},a.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||O(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):M(this,t,e,!0),e+2},a.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||O(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):M(this,t,e,!1),e+2},a.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||O(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):R(this,t,e,!0),e+4},a.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||O(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):R(this,t,e,!1),e+4},a.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);O(this,t,e,n,i-1,-i)}var a=0,o=1,s=0;for(this[e]=255&t;++a<n&&(o*=256);)t<0&&0===s&&0!==this[e+a-1]&&(s=1),this[e+a]=(t/o>>0)-s&255;return e+n},a.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);O(this,t,e,n,i-1,-i)}var a=n-1,o=1,s=0;for(this[e+a]=255&t;--a>=0&&(o*=256);)t<0&&0===s&&0!==this[e+a+1]&&(s=1),this[e+a]=(t/o>>0)-s&255;return e+n},a.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||O(this,t,e,1,127,-128),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},a.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||O(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):M(this,t,e,!0),e+2},a.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||O(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):M(this,t,e,!1),e+2},a.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||O(this,t,e,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):R(this,t,e,!0),e+4},a.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):R(this,t,e,!1),e+4},a.prototype.writeFloatLE=function(t,e,n){return L(this,t,e,!0,n)},a.prototype.writeFloatBE=function(t,e,n){return L(this,t,e,!1,n)},a.prototype.writeDoubleLE=function(t,e,n){return j(this,t,e,!0,n)},a.prototype.writeDoubleBE=function(t,e,n){return j(this,t,e,!1,n)},a.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);var i,o=r-n;if(this===t&&n<e&&e<r)for(i=o-1;i>=0;--i)t[i+e]=this[i+n];else if(o<1e3||!a.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)t[i+e]=this[i+n];else Uint8Array.prototype.set.call(t,this.subarray(n,n+o),e);return o},a.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===t.length){var i=t.charCodeAt(0);i<256&&(t=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!a.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0);var o;if("number"==typeof t)for(o=e;o<n;++o)this[o]=t;else{var s=a.isBuffer(t)?t:H(new a(t,r).toString()),u=s.length;for(o=0;o<n-e;++o)this[o+e]=s[o%u]}return this};var tt=/[^+\/0-9A-Za-z-_]/g}).call(e,n(0))},function(t,e,n){(function(t){function n(t){return Array.isArray?Array.isArray(t):"[object Array]"===g(t)}function r(t){return"boolean"==typeof t}function i(t){return null===t}function a(t){return null==t}function o(t){return"number"==typeof t}function s(t){return"string"==typeof t}function u(t){return"symbol"==typeof t}function l(t){return void 0===t}function h(t){return"[object RegExp]"===g(t)}function f(t){return"object"==typeof t&&null!==t}function c(t){return"[object Date]"===g(t)}function d(t){return"[object Error]"===g(t)||t instanceof Error}function p(t){return"function"==typeof t}function m(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t}function g(t){return Object.prototype.toString.call(t)}e.isArray=n,e.isBoolean=r,e.isNull=i,e.isNullOrUndefined=a,e.isNumber=o,e.isString=s,e.isSymbol=u,e.isUndefined=l,e.isRegExp=h,e.isObject=f,e.isDate=c,e.isError=d,e.isFunction=p,e.isPrimitive=m,e.isBuffer=t.isBuffer}).call(e,n(6).Buffer)},function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t){return void 0!==t}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),o=function(){function t(e,n,i){var a=n.dimension,o=n.index;r(this,t),this.filePath=e,this.slice={dimension:a,index:o},this.timePoint=i}return a(t,[{key:"url",get:function(){var t="nifti:"+this.filePath;return(i(this.slice.dimension)||i(this.slice.index))&&(t+="#"),i(this.slice.dimension)&&(t+=this.slice.dimension,i(this.slice.index)&&(t+="-")),i(this.slice.index)&&(t+=this.slice.index),i(this.timePoint)&&(t+=",t-"+this.timePoint),t}}],[{key:"fromURL",value:function(e){var n=/^nifti:([^#]+)(?:#(?:(?=[xyz])(?:([xyz])(?:(?=-[\d]+)-([\d]+))?(?:,t-(\d+))?)|(?![xyz])([\d]+)))?$/,r=n.exec(e);if(!r)throw new Error("Not in a valid imageId format: "+e);return new t(r&&r[1],{dimension:r&&r[2]||"z",index:r&&parseInt(r[3]||r[5],0)||0},r&&r[4]&&parseInt(r[4],0)||0)}}]),t}();e.default=o},function(t,e,n){function r(t,e){return t[0]-e[0]}function i(){var t,e=this.stride,n=new Array(e.length);for(t=0;t<n.length;++t)n[t]=[Math.abs(e[t]),t];n.sort(r);var i=new Array(n.length);for(t=0;t<i.length;++t)i[t]=n[t][1];return i}function a(t,e){var n=["View",e,"d",t].join("");e<0&&(n="View_Nil"+t);var r="generic"===t;if(-1===e){var a="function "+n+"(a){this.data=a;};var proto="+n+".prototype;proto.dtype='"+t+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+n+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+n+"(a){return new "+n+"(a);}",o=new Function(a);return o()}if(0===e){var a="function "+n+"(a,d) {this.data = a;this.offset = d};var proto="+n+".prototype;proto.dtype='"+t+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+n+"_copy() {return new "+n+"(this.data,this.offset)};proto.pick=function "+n+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+n+"_get(){return "+(r?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+n+"_set(v){return "+(r?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+n+"(a,b,c,d){return new "+n+"(a,d)}",o=new Function("TrivialArray",a);return o(f[t][0])}var a=["'use strict'"],s=u(e),l=s.map(function(t){return"i"+t}),h="this.offset+"+s.map(function(t){return"this.stride["+t+"]*i"+t}).join("+"),c=s.map(function(t){return"b"+t}).join(","),d=s.map(function(t){return"c"+t}).join(",");a.push("function "+n+"(a,"+c+","+d+",d){this.data=a","this.shape=["+c+"]","this.stride=["+d+"]","this.offset=d|0}","var proto="+n+".prototype","proto.dtype='"+t+"'","proto.dimension="+e),a.push("Object.defineProperty(proto,'size',{get:function "+n+"_size(){return "+s.map(function(t){return"this.shape["+t+"]"}).join("*"),"}})"),1===e?a.push("proto.order=[0]"):(a.push("Object.defineProperty(proto,'order',{get:"),e<4?(a.push("function "+n+"_order(){"),2===e?a.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})"):3===e&&a.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):a.push("ORDER})")),a.push("proto.set=function "+n+"_set("+l.join(",")+",v){"),r?a.push("return this.data.set("+h+",v)}"):a.push("return this.data["+h+"]=v}"),a.push("proto.get=function "+n+"_get("+l.join(",")+"){"),r?a.push("return this.data.get("+h+")}"):a.push("return this.data["+h+"]}"),a.push("proto.index=function "+n+"_index(",l.join(),"){return "+h+"}"),a.push("proto.hi=function "+n+"_hi("+l.join(",")+"){return new "+n+"(this.data,"+s.map(function(t){return["(typeof i",t,"!=='number'||i",t,"<0)?this.shape[",t,"]:i",t,"|0"].join("")}).join(",")+","+s.map(function(t){return"this.stride["+t+"]"}).join(",")+",this.offset)}");var p=s.map(function(t){return"a"+t+"=this.shape["+t+"]"}),m=s.map(function(t){return"c"+t+"=this.stride["+t+"]"});a.push("proto.lo=function "+n+"_lo("+l.join(",")+"){var b=this.offset,d=0,"+p.join(",")+","+m.join(","));for(var g=0;g<e;++g)a.push("if(typeof i"+g+"==='number'&&i"+g+">=0){d=i"+g+"|0;b+=c"+g+"*d;a"+g+"-=d}");a.push("return new "+n+"(this.data,"+s.map(function(t){return"a"+t}).join(",")+","+s.map(function(t){return"c"+t}).join(",")+",b)}"),a.push("proto.step=function "+n+"_step("+l.join(",")+"){var "+s.map(function(t){return"a"+t+"=this.shape["+t+"]"}).join(",")+","+s.map(function(t){return"b"+t+"=this.stride["+t+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var g=0;g<e;++g)a.push("if(typeof i"+g+"==='number'){d=i"+g+"|0;if(d<0){c+=b"+g+"*(a"+g+"-1);a"+g+"=ceil(-a"+g+"/d)}else{a"+g+"=ceil(a"+g+"/d)}b"+g+"*=d}");a.push("return new "+n+"(this.data,"+s.map(function(t){return"a"+t}).join(",")+","+s.map(function(t){return"b"+t}).join(",")+",c)}");for(var _=new Array(e),v=new Array(e),g=0;g<e;++g)_[g]="a[i"+g+"]",v[g]="b[i"+g+"]";a.push("proto.transpose=function "+n+"_transpose("+l+"){"+l.map(function(t,e){return t+"=("+t+"===undefined?"+e+":"+t+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+n+"(this.data,"+_.join(",")+","+v.join(",")+",this.offset)}"),a.push("proto.pick=function "+n+"_pick("+l+"){var a=[],b=[],c=this.offset");for(var g=0;g<e;++g)a.push("if(typeof i"+g+"==='number'&&i"+g+">=0){c=(c+this.stride["+g+"]*i"+g+")|0}else{a.push(this.shape["+g+"]);b.push(this.stride["+g+"])}");a.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),a.push("return function construct_"+n+"(data,shape,stride,offset){return new "+n+"(data,"+s.map(function(t){return"shape["+t+"]"}).join(",")+","+s.map(function(t){return"stride["+t+"]"}).join(",")+",offset)}");var o=new Function("CTOR_LIST","ORDER",a.join("\n"));return o(f[t],i)}function o(t){if(l(t))return"buffer";if(h)switch(Object.prototype.toString.call(t)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped"}return Array.isArray(t)?"array":"generic"}function s(t,e,n,r){if(void 0===t){var i=f.array[0];return i([])}"number"==typeof t&&(t=[t]),void 0===e&&(e=[t.length]);var s=e.length;if(void 0===n){n=new Array(s);for(var u=s-1,l=1;u>=0;--u)n[u]=l,l*=e[u]}if(void 0===r){r=0;for(var u=0;u<s;++u)n[u]<0&&(r-=(e[u]-1)*n[u])}for(var h=o(t),c=f[h];c.length<=s+1;)c.push(a(h,c.length-1));var i=c[s+1];return i(t,e,n,r)}var u=n(61),l=n(62),h="undefined"!=typeof Float64Array,f={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],buffer:[],generic:[]};t.exports=s},function(t,e,n){"use strict";(function(e){function n(t,n,r,i){if("function"!=typeof t)throw new TypeError('"callback" argument must be a function');var a,o,s=arguments.length;switch(s){case 0:case 1:return e.nextTick(t);case 2:return e.nextTick(function(){t.call(null,n)});case 3:return e.nextTick(function(){t.call(null,n,r)});case 4:return e.nextTick(function(){t.call(null,n,r,i)});default:for(a=new Array(s-1),o=0;o<a.length;)a[o++]=arguments[o];return e.nextTick(function(){t.apply(null,a)})}}!e.version||0===e.version.indexOf("v0.")||0===e.version.indexOf("v1.")&&0!==e.version.indexOf("v1.8.")?t.exports=n:t.exports=e.nextTick}).call(e,n(4))},function(t,e,n){function r(t,e){for(var n in t)e[n]=t[n]}function i(t,e,n){return o(t,e,n)}var a=n(6),o=a.Buffer;o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?t.exports=a:(r(a,e),e.Buffer=i),r(o,i),i.from=function(t,e,n){if("number"==typeof t)throw new TypeError("Argument must not be a number");return o(t,e,n)},i.alloc=function(t,e,n){if("number"!=typeof t)throw new TypeError("Argument must be a number");var r=o(t);return void 0!==e?"string"==typeof n?r.fill(e,n):r.fill(e):r.fill(0),r},i.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return o(t)},i.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return a.SlowBuffer(t)}},function(t,e,n){"use strict";var r=r||{};r.Utils=r.Utils||{},r.Utils.crcTable=null,r.Utils.GUNZIP_MAGIC_COOKIE1=31,r.Utils.GUNZIP_MAGIC_COOKIE2=139,r.Utils.getStringAt=function(t,e,n){var r,i,a="";for(r=e;r<n;r+=1)0!==(i=t.getUint8(r))&&(a+=String.fromCharCode(i));return a},r.Utils.getByteAt=function(t,e){return t.getInt8(e)},r.Utils.getShortAt=function(t,e,n){return t.getInt16(e,n)},r.Utils.getIntAt=function(t,e,n){return t.getInt32(e,n)},r.Utils.getFloatAt=function(t,e,n){return t.getFloat32(e,n)},r.Utils.getDoubleAt=function(t,e,n){return t.getFloat64(e,n)},r.Utils.getLongAt=function(t,e,n){var i,a=[],o=0;for(i=0;i<8;i+=1)a[i]=r.Utils.getByteAt(t,e+i,n);for(i=a.length-1;i>=0;i--)o=256*o+a[i];return o},r.Utils.toArrayBuffer=function(t){var e,n,r;for(e=new ArrayBuffer(t.length),n=new Uint8Array(e),r=0;r<t.length;r+=1)n[r]=t[r];return e},r.Utils.isString=function(t){return"string"==typeof t||t instanceof String},r.Utils.formatNumber=function(t,e){var n=0;return n=r.Utils.isString(t)?Number(t):t,n=e?n.toPrecision(5):n.toPrecision(7),parseFloat(n)},r.Utils.makeCRCTable=function(){for(var t,e=[],n=0;n<256;n++){t=n;for(var r=0;r<8;r++)t=1&t?3988292384^t>>>1:t>>>1;e[n]=t}return e},r.Utils.crc32=function(t){for(var e=r.Utils.crcTable||(r.Utils.crcTable=r.Utils.makeCRCTable()),n=-1,i=0;i<t.byteLength;i++)n=n>>>8^e[255&(n^t.getUint8(i))];return(-1^n)>>>0},void 0!==t&&t.exports&&(t.exports=r.Utils)},function(t,e,n){"use strict";t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},function(t,e,n){"use strict";function r(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n={detail:e},r=new CustomEvent(t,n);i.external.cornerstone.events.dispatchEvent(r)}Object.defineProperty(e,"__esModule",{value:!0});var i=n(1);e.default={imageLoadProgress:function(t){return r("cornerstoneimageloadprogress",t)},imageLoadStart:function(t){return r("cornerstoneimageloadstart",t)},imageLoadEnd:function(t){return r("cornerstoneimageloadend",t)}}},function(t,e,n){"use strict";function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function i(t){var e=c.external.niftiReader,n=e.readHeader(t);o(e,n);var r=n.scl_inter,i=0===n.scl_slope?1:n.scl_slope,a=n.cal_max-n.cal_min,d=0===a,p=d?void 0:n.cal_min,m=d?void 0:n.cal_max,g=n.dims.slice(1,4),_=n.dims[0]>3?n.dims[4]:1,v={TypedArrayConstructor:u(e,n.datatypeCode),samplesPerPixel:f(n.dims),isDataInFloat:l(e,n.datatypeCode),isDataInColors:h(e,n.dims,n.datatypeCode)},y=n.pixDims.slice(1,4),b=s(n);return{slope:i,intercept:r,windowMinimumValue:p,windowMaximumValue:m,isWindowInfoAbsent:d,voxelLength:g,timeSlices:_,dataType:v,pixelSpacing:y,orientationMatrix:b,orientationString:n.convertNiftiSFormToNEMA(b),header:n}}function a(t,e){var n=c.external.niftiReader;e||(e=i(t));var r=e.dataType.TypedArrayConstructor,a=n.readImage(e.header,t),o=new r(a);return e.header.littleEndian||(o=(0,p.default)(e.header.datatypeCode,o)),{metaData:e,imageData:o}}function o(t,e){var n=void 0;switch(7&e.xyzt_units){case t.NIFTI1.UNITS_METER:n=1e3;break;case t.NIFTI1.UNITS_MICRON:n=.001;break;case t.NIFTI1.UNITS_MM:default:n=1}e.pixDims=e.pixDims.map(function(t,r){return r>0&&r<=e.dims[0]?t*n:t}),e.affine&&(e.affine=e.affine.map(function(t){return t.map(function(t){return t*n})})),(e.quatern_b||e.quatern_c||e.quatern_d)&&(e.quatern_b*=n,e.quatern_c*=n,e.quatern_d*=n),(e.qoffset_x||e.qoffset_y||e.qoffset_z)&&(e.qoffset_x*=n,e.qoffset_y*=n,e.qoffset_z*=n)}function s(t){if(t.affine&&t.sform_code>0)return t.affine;if(t.qform_code>0)return t.convertNiftiQFormToNiftiSForm(t.quatern_b,t.quatern_c,t.quatern_d,t.qoffset_x,t.qoffset_y,t.qoffset_z,t.pixDims[1],t.pixDims[2],t.pixDims[3],t.pixDims[0]);var e={x:t.pixDims[1],y:t.pixDims[2],z:t.pixDims[3]},n={x:-e.x*t.dims[1]/2,y:-e.y*t.dims[2]/2,z:-e.z*t.dims[3]/2};return[[e.x,0,0,n.x],[0,e.y,0,n.y],[0,0,e.z,n.z],[0,0,0,1]]}function u(t,e){var n;return(n={},r(n,t.NIFTI1.TYPE_UINT8,Uint8Array),r(n,t.NIFTI1.TYPE_UINT16,Uint16Array),r(n,t.NIFTI1.TYPE_UINT32,Uint32Array),r(n,t.NIFTI1.TYPE_INT8,Int8Array),r(n,t.NIFTI1.TYPE_INT16,Int16Array),r(n,t.NIFTI1.TYPE_INT32,Int32Array),r(n,t.NIFTI1.TYPE_FLOAT32,Float32Array),r(n,t.NIFTI1.TYPE_FLOAT64,Float64Array),r(n,t.NIFTI1.TYPE_RGB,Uint8Array),r(n,t.NIFTI1.TYPE_RGBA,Uint8Array),n)[e]}function l(t,e){var n;return(n={},r(n,t.NIFTI1.TYPE_UINT8,!1),r(n,t.NIFTI1.TYPE_UINT16,!1),r(n,t.NIFTI1.TYPE_UINT32,!1),r(n,t.NIFTI1.TYPE_INT8,!1),r(n,t.NIFTI1.TYPE_INT16,!1),r(n,t.NIFTI1.TYPE_INT32,!1),r(n,t.NIFTI1.TYPE_FLOAT32,!0),r(n,t.NIFTI1.TYPE_FLOAT64,!0),r(n,t.NIFTI1.TYPE_RGB,!1),r(n,t.NIFTI1.TYPE_RGBA,!1),n)[e]}function h(t,e,n){var i,a=f(e);return(i={},r(i,t.NIFTI1.TYPE_UINT8,!1),r(i,t.NIFTI1.TYPE_UINT16,!1),r(i,t.NIFTI1.TYPE_UINT32,!1),r(i,t.NIFTI1.TYPE_INT8,!1),r(i,t.NIFTI1.TYPE_INT16,!1),r(i,t.NIFTI1.TYPE_INT32,!1),r(i,t.NIFTI1.TYPE_FLOAT32,!1),r(i,t.NIFTI1.TYPE_FLOAT64,!1),r(i,t.NIFTI1.TYPE_RGB,3===a),r(i,t.NIFTI1.TYPE_RGBA,4===a),i)[n]}function f(t){return t[0]>=5?t[5]:1}Object.defineProperty(e,"__esModule",{value:!0}),e.parseNiftiHeader=i,e.parseNiftiFile=a;var c=n(1),d=n(65),p=function(t){return t&&t.__esModule?t:{default:t}}(d)},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var i=n(17),a=r(i),o=n(42),s=n(55),u=r(s),l=n(66),h=r(l),f=n(8),c=r(f),d=n(89),p=r(d),m=n(14),g=r(m),_={headers:{}},v={loadImage:function(t){var e=void 0;try{var n=c.default.fromURL(t),r=u.default.getInstance(_.headers);g.default.imageLoadStart(n),e=r.acquire(n).then(function(t){return t.slice(n)}).then(function(t){return a.default.add(n.url,t.compoundMetaData),g.default.imageLoadEnd(n),t.cornerstoneImageObject})}catch(t){e=Promise.reject(t)}return e=(0,p.default)(e),e.promise=e,e},loadVolumeTimepoint:function(t){var e=void 0;try{var n=c.default.fromURL(t),r=h.default.getInstance(_.headers);g.default.imageLoadStart(n),e=r.acquireTimepoint(n).then(function(t){return t.slice(n)}).then(function(t){return a.default.add(n.url,t.compoundMetaData),g.default.imageLoadEnd(n),t.cornerstoneImageObject})}catch(t){e=Promise.reject(t)}return e=(0,p.default)(e),e.promise=e,e},loadHeader:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=void 0;try{var r=c.default.fromURL(t),i=h.default.getInstance(_.headers);n=i.acquireHeaderOnly(r,e).then(function(t){return t.slice(r)}).then(function(t){return a.default.add(r.url,t.compoundMetaData),t.compoundMetaData})}catch(t){n=Promise.reject(t)}return n=(0,p.default)(n),n.promise=n,n},ImageId:c.default,streamingMode:!1,cornerstoneLoader:function(t){return this.streamingMode?this.loadVolumeTimepoint(t):this.loadImage(t)},register:function(t){var e=this;t.registerImageLoader("nifti",function(t){return e.cornerstoneLoader(t,e)}),t.metaData.addProvider(o.metaDataProvider)},configure:function(t){Object.assign(_,t)}};e.default=v},function(t,e,n){"use strict";function r(t,e){s[t]=e}function i(t){return s[t]}function a(t){s[t]=void 0}function o(){s=[]}Object.defineProperty(e,"__esModule",{value:!0});var s=[];e.default={add:r,get:i,remove:a,purge:o}},function(t,e,n){"use strict";var r=r||{};r.Utils=r.Utils||n(12),r.NIFTI1=r.NIFTI1||function(){this.littleEndian=!1,this.dim_info=0,this.dims=[],this.intent_p1=0,this.intent_p2=0,this.intent_p3=0,this.intent_code=0,this.datatypeCode=0,this.numBitsPerVoxel=0,this.slice_start=0,this.slice_end=0,this.slice_code=0,this.pixDims=[],this.vox_offset=0,this.scl_slope=1,this.scl_inter=0,this.xyzt_units=0,this.cal_max=0,this.cal_min=0,this.slice_duration=0,this.toffset=0,this.description="",this.aux_file="",this.intent_name="",this.qform_code=0,this.sform_code=0,this.quatern_b=0,this.quatern_c=0,this.quatern_d=0,this.qoffset_x=0,this.qoffset_y=0,this.qoffset_z=0,this.affine=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],this.magic=0,this.isHDR=!1,this.extensionFlag=[0,0,0,0],this.extensionSize=0,this.extensionCode=0},r.NIFTI1.TYPE_NONE=0,r.NIFTI1.TYPE_BINARY=1,r.NIFTI1.TYPE_UINT8=2,r.NIFTI1.TYPE_INT16=4,r.NIFTI1.TYPE_INT32=8,r.NIFTI1.TYPE_FLOAT32=16,r.NIFTI1.TYPE_COMPLEX64=32,r.NIFTI1.TYPE_FLOAT64=64,r.NIFTI1.TYPE_RGB24=128,r.NIFTI1.TYPE_INT8=256,r.NIFTI1.TYPE_UINT16=512,r.NIFTI1.TYPE_UINT32=768,r.NIFTI1.TYPE_INT64=1024,r.NIFTI1.TYPE_UINT64=1280,r.NIFTI1.TYPE_FLOAT128=1536,r.NIFTI1.TYPE_COMPLEX128=1792,r.NIFTI1.TYPE_COMPLEX256=2048,r.NIFTI1.XFORM_UNKNOWN=0,r.NIFTI1.XFORM_SCANNER_ANAT=1,r.NIFTI1.XFORM_ALIGNED_ANAT=2,r.NIFTI1.XFORM_TALAIRACH=3,r.NIFTI1.XFORM_MNI_152=4,r.NIFTI1.SPATIAL_UNITS_MASK=7,r.NIFTI1.TEMPORAL_UNITS_MASK=56,r.NIFTI1.UNITS_UNKNOWN=0,r.NIFTI1.UNITS_METER=1,r.NIFTI1.UNITS_MM=2,r.NIFTI1.UNITS_MICRON=3,r.NIFTI1.UNITS_SEC=8,r.NIFTI1.UNITS_MSEC=16,r.NIFTI1.UNITS_USEC=24,r.NIFTI1.UNITS_HZ=32,r.NIFTI1.UNITS_PPM=40,r.NIFTI1.UNITS_RADS=48,r.NIFTI1.MAGIC_COOKIE=348,r.NIFTI1.STANDARD_HEADER_SIZE=348,r.NIFTI1.MAGIC_NUMBER_LOCATION=344,r.NIFTI1.MAGIC_NUMBER=[110,43,49],r.NIFTI1.MAGIC_NUMBER2=[110,105,49],r.NIFTI1.EXTENSION_HEADER_SIZE=8,r.NIFTI1.prototype.readHeader=function(t){var e,n,i,a,o=new DataView(t),s=r.Utils.getIntAt(o,0,this.littleEndian);if(s!==r.NIFTI1.MAGIC_COOKIE&&(this.littleEndian=!0,s=r.Utils.getIntAt(o,0,this.littleEndian)),s!==r.NIFTI1.MAGIC_COOKIE)throw new Error("This does not appear to be a NIFTI file!");for(this.dim_info=r.Utils.getByteAt(o,39),e=0;e<8;e+=1)a=40+2*e,this.dims[e]=r.Utils.getShortAt(o,a,this.littleEndian);for(this.intent_p1=r.Utils.getFloatAt(o,56,this.littleEndian),this.intent_p2=r.Utils.getFloatAt(o,60,this.littleEndian),this.intent_p3=r.Utils.getFloatAt(o,64,this.littleEndian),this.intent_code=r.Utils.getShortAt(o,68,this.littleEndian),this.datatypeCode=r.Utils.getShortAt(o,70,this.littleEndian),this.numBitsPerVoxel=r.Utils.getShortAt(o,72,this.littleEndian),this.slice_start=r.Utils.getShortAt(o,74,this.littleEndian),e=0;e<8;e+=1)a=76+4*e,this.pixDims[e]=r.Utils.getFloatAt(o,a,this.littleEndian);for(this.vox_offset=r.Utils.getFloatAt(o,108,this.littleEndian),this.scl_slope=r.Utils.getFloatAt(o,112,this.littleEndian),this.scl_inter=r.Utils.getFloatAt(o,116,this.littleEndian),this.slice_end=r.Utils.getShortAt(o,120,this.littleEndian),this.slice_code=r.Utils.getByteAt(o,122),this.xyzt_units=r.Utils.getByteAt(o,123),this.cal_max=r.Utils.getFloatAt(o,124,this.littleEndian),this.cal_min=r.Utils.getFloatAt(o,128,this.littleEndian),this.slice_duration=r.Utils.getFloatAt(o,132,this.littleEndian),this.toffset=r.Utils.getFloatAt(o,136,this.littleEndian),this.description=r.Utils.getStringAt(o,148,228),this.aux_file=r.Utils.getStringAt(o,228,252),this.qform_code=r.Utils.getShortAt(o,252,this.littleEndian),this.sform_code=r.Utils.getShortAt(o,254,this.littleEndian),this.quatern_b=r.Utils.getFloatAt(o,256,this.littleEndian),this.quatern_c=r.Utils.getFloatAt(o,260,this.littleEndian),this.quatern_d=r.Utils.getFloatAt(o,264,this.littleEndian),this.qoffset_x=r.Utils.getFloatAt(o,268,this.littleEndian),this.qoffset_y=r.Utils.getFloatAt(o,272,this.littleEndian),this.qoffset_z=r.Utils.getFloatAt(o,276,this.littleEndian),n=0;n<3;n+=1)for(i=0;i<4;i+=1)a=280+4*(4*n+i),this.affine[n][i]=r.Utils.getFloatAt(o,a,this.littleEndian);this.affine[3][0]=0,this.affine[3][1]=0,this.affine[3][2]=0,this.affine[3][3]=1,this.intent_name=r.Utils.getStringAt(o,328,344),this.magic=r.Utils.getStringAt(o,344,348),this.isHDR=this.magic===r.NIFTI1.MAGIC_NUMBER2,o.byteLength>r.NIFTI1.MAGIC_COOKIE&&(this.extensionFlag[0]=r.Utils.getByteAt(o,348),this.extensionFlag[1]=r.Utils.getByteAt(o,349),this.extensionFlag[2]=r.Utils.getByteAt(o,350),this.extensionFlag[3]=r.Utils.getByteAt(o,351),this.extensionFlag[0]&&(this.extensionSize=this.getExtensionSize(o),this.extensionCode=this.getExtensionCode(o)))},r.NIFTI1.prototype.toFormattedString=function(){var t=r.Utils.formatNumber,e="";return e+="Dim Info = "+this.dim_info+"\n",e+="Image Dimensions (1-8): "+this.dims[0]+", "+this.dims[1]+", "+this.dims[2]+", "+this.dims[3]+", "+this.dims[4]+", "+this.dims[5]+", "+this.dims[6]+", "+this.dims[7]+"\n",e+="Intent Parameters (1-3): "+this.intent_p1+", "+this.intent_p2+", "+this.intent_p3+"\n",e+="Intent Code = "+this.intent_code+"\n",e+="Datatype = "+this.datatypeCode+" ("+this.getDatatypeCodeString(this.datatypeCode)+")\n",e+="Bits Per Voxel = "+this.numBitsPerVoxel+"\n",e+="Slice Start = "+this.slice_start+"\n",e+="Voxel Dimensions (1-8): "+t(this.pixDims[0])+", "+t(this.pixDims[1])+", "+t(this.pixDims[2])+", "+t(this.pixDims[3])+", "+t(this.pixDims[4])+", "+t(this.pixDims[5])+", "+t(this.pixDims[6])+", "+t(this.pixDims[7])+"\n",e+="Image Offset = "+this.vox_offset+"\n",e+="Data Scale: Slope = "+t(this.scl_slope)+" Intercept = "+t(this.scl_inter)+"\n",e+="Slice End = "+this.slice_end+"\n",e+="Slice Code = "+this.slice_code+"\n",e+="Units Code = "+this.xyzt_units+" ("+this.getUnitsCodeString(r.NIFTI1.SPATIAL_UNITS_MASK&this.xyzt_units)+", "+this.getUnitsCodeString(r.NIFTI1.TEMPORAL_UNITS_MASK&this.xyzt_units)+")\n",e+="Display Range: Max = "+t(this.cal_max)+" Min = "+t(this.cal_min)+"\n",e+="Slice Duration = "+this.slice_duration+"\n",e+="Time Axis Shift = "+this.toffset+"\n",e+='Description: "'+this.description+'"\n',e+='Auxiliary File: "'+this.aux_file+'"\n',e+="Q-Form Code = "+this.qform_code+" ("+this.getTransformCodeString(this.qform_code)+")\n",e+="S-Form Code = "+this.sform_code+" ("+this.getTransformCodeString(this.sform_code)+")\n",e+="Quaternion Parameters: b = "+t(this.quatern_b)+" c = "+t(this.quatern_c)+" d = "+t(this.quatern_d)+"\n",e+="Quaternion Offsets: x = "+this.qoffset_x+" y = "+this.qoffset_y+" z = "+this.qoffset_z+"\n",e+="S-Form Parameters X: "+t(this.affine[0][0])+", "+t(this.affine[0][1])+", "+t(this.affine[0][2])+", "+t(this.affine[0][3])+"\n",e+="S-Form Parameters Y: "+t(this.affine[1][0])+", "+t(this.affine[1][1])+", "+t(this.affine[1][2])+", "+t(this.affine[1][3])+"\n",e+="S-Form Parameters Z: "+t(this.affine[2][0])+", "+t(this.affine[2][1])+", "+t(this.affine[2][2])+", "+t(this.affine[2][3])+"\n",e+='Intent Name: "'+this.intent_name+'"\n',this.extensionFlag[0]&&(e+="Extension: Size = "+this.extensionSize+" Code = "+this.extensionCode+"\n"),e},r.NIFTI1.prototype.getDatatypeCodeString=function(t){return t===r.NIFTI1.TYPE_UINT8?"1-Byte Unsigned Integer":t===r.NIFTI1.TYPE_INT16?"2-Byte Signed Integer":t===r.NIFTI1.TYPE_INT32?"4-Byte Signed Integer":t===r.NIFTI1.TYPE_FLOAT32?"4-Byte Float":t===r.NIFTI1.TYPE_FLOAT64?"8-Byte Float":t===r.NIFTI1.TYPE_RGB24?"RGB":t===r.NIFTI1.TYPE_INT8?"1-Byte Signed Integer