dicomweb-proxy
Version:
A proxy to translate between dicomweb and dimse
2 lines • 14.8 kB
JavaScript
;(self.webpackChunk=self.webpackChunk||[]).push([[5830],{5830:(e,t,a)=>{a.r(t),a.d(t,{FloatTypes:()=>y.A,Image:()=>c,ImageType:()=>o,IntTypes:()=>i.A,InterfaceTypes:()=>b.A,Mesh:()=>k,MeshType:()=>A,PixelTypes:()=>s,PolyData:()=>I,PolyDataType:()=>T,WorkerPool:()=>w,bufferToTypedArray:()=>r.A,castImage:()=>g,copyImage:()=>d,createWebWorker:()=>C,getDefaultWebWorker:()=>q,getFileExtension:()=>m,getMatrixElement:()=>h,getPipelineWorkerUrl:()=>V,getPipelinesBaseUrl:()=>Q,imageSharedBufferOrCopy:()=>p,meshToPolyData:()=>Y,polyDataToMesh:()=>Z,readDICOMTags:()=>J,readDICOMTagsArrayBuffer:()=>H,readImageArrayBuffer:()=>_,readImageBlob:()=>ee,readImageDICOMArrayBufferSeries:()=>X,readImageDICOMFileSeries:()=>K,readImageFile:()=>te,readImageFileSeries:()=>ae,readMeshArrayBuffer:()=>ne,readMeshFile:()=>re,runPipeline:()=>j,setDefaultWebWorker:()=>$,setPipelineWorkerUrl:()=>L,setPipelinesBaseUrl:()=>E,stackImages:()=>f,version:()=>n});const n="1.0.0-b.165";var r=a(47911),i=a(44835);const s={Unknown:"Unknown",Scalar:"Scalar",RGB:"RGB",RGBA:"RGBA",Offset:"Offset",Vector:"Vector",Point:"Point",CovariantVector:"CovariantVector",SymmetricSecondRankTensor:"SymmetricSecondRankTensor",DiffusionTensor3D:"DiffusionTensor3D",Complex:"Complex",FixedArray:"FixedArray",Array:"Array",Matrix:"Matrix",VariableLengthVector:"VariableLengthVector",VariableSizeMatrix:"VariableSizeMatrix"};const o=class{dimension;componentType;pixelType;components;constructor(e=2,t=i.A.UInt8,a=s.Scalar,n=1){this.dimension=e,this.componentType=t,this.pixelType=a,this.components=n}};const l=function(e,t,a,n,r){e[n+a*t]=r};const c=class{imageType;name="image";origin;spacing;direction;size;metadata;data;constructor(e=new o){this.imageType=e;const t=e.dimension;this.origin=new Array(t),this.origin.fill(0),this.spacing=new Array(t),this.spacing.fill(1),this.direction=new Float64Array(t*t),this.direction.fill(0);for(let e=0;e<t;e++)l(this.direction,t,e,e,1);this.size=new Array(t),this.size.fill(0),this.metadata=new Map,this.data=null}};const d=function(e){const t=new c(e.imageType);if(t.name=e.name,t.origin=Array.from(e.origin),t.spacing=Array.from(e.spacing),t.direction=e.direction.slice(),t.size=Array.from(e.size),null!==e.data){const a=e.data.constructor;t.data=new a(e.data.length),null!=t.data&&t.data.set(e.data,0)}return t},u="function"==typeof globalThis.SharedArrayBuffer;const p=function(e){if(null===e.data)return e;if(u){if(e.data.buffer instanceof SharedArrayBuffer)return e;const t=new SharedArrayBuffer(e.data.buffer.byteLength),a=new(0,e.data.constructor)(t);return null!==a&&a.set(e.data,0),e.data=a,e}return d(e)};const f=function(e){if(e.length<1)throw Error("At least one images is required.");const t=e[0];if(null===t.data)throw Error("Image data is null.");const a=new c(t.imageType);a.origin=Array.from(t.origin),a.spacing=Array.from(t.spacing);const n=a.imageType.dimension;a.direction=t.direction.slice();const r=n-1;a.size=Array.from(t.size);const i=e.reduce(((e,t)=>e+t.size[r]),0);a.size[r]=i;const s=a.size.reduce(((e,t)=>e*t),1)*a.imageType.components,o=t.data.constructor;a.data=new o(s);let l=a.imageType.components;for(let e=0;e<a.size.length-1;e++)l*=a.size[e];let d=0;if(null==a.data)throw Error("Could not create result image data.");for(let t=0;t<e.length;t++)a.data.set(e[t].data,l*d),d+=e[t].size[r];return a};const m=function(e){let t=e.slice(2+(e.lastIndexOf(".")-1>>>0));if("gz"===t.toLowerCase()){const a=e.slice(0,-3).lastIndexOf(".");t=e.slice(2+(a-1>>>0))}else if("cbor"===t.toLowerCase()){const a=e.slice(0,-5).lastIndexOf(".");t=e.slice(2+(a-1>>>0))}else if("zst"===t.toLowerCase()){const a=e.slice(0,-10).lastIndexOf(".");t=e.slice(2+(a-1>>>0))}else if("zip"===t.toLowerCase()){const a=e.slice(0,-4).lastIndexOf(".");t=e.slice(2+(a-1>>>0))}return t};const h=function(e,t,a,n){return e[n+a*t]};var y=a(74112);const g=function(e,t){const a={...e.imageType};if(void 0!==t&&void 0!==t.pixelType&&(a.pixelType=t.pixelType,t.pixelType===s.Scalar&&1!==a.components))throw new Error("Cannot cast multi-component image to a scalar image");void 0!==t&&void 0!==t.componentType&&t.componentType!==e.imageType.componentType&&(a.componentType=t.componentType);const n=new c(a);if(n.name=e.name,n.origin=Array.from(e.origin),n.spacing=Array.from(e.spacing),n.direction=e.direction.slice(),n.size=Array.from(e.size),n.metadata=new Map(JSON.parse(JSON.stringify(Array.from(e.metadata)))),null!==e.data)if(void 0!==t&&void 0!==t.componentType&&t.componentType!==e.imageType.componentType)switch(e.imageType.componentType){case i.A.UInt8:case i.A.Int8:case i.A.UInt16:case i.A.Int16:case i.A.UInt32:case i.A.Int32:case y.A.Float32:case y.A.Float64:switch(n.imageType.componentType){case i.A.UInt8:n.data=new Uint8Array(e.data);break;case i.A.Int8:n.data=new Int8Array(e.data);break;case i.A.UInt16:n.data=new Uint16Array(e.data);break;case i.A.Int16:n.data=new Int16Array(e.data);break;case i.A.UInt32:n.data=new Uint32Array(e.data);break;case i.A.Int32:n.data=new Int32Array(e.data);break;case y.A.Float32:n.data=new Float32Array(e.data);break;case y.A.Float64:n.data=new Float64Array(e.data);break;case i.A.UInt64:n.data=new BigUint64Array(e.data.length);for(let t=0;t<n.data.length;t++)n.data[t]=BigInt.asIntN(64,BigInt(e.data[t]));break;case i.A.Int64:n.data=new BigInt64Array(e.data.length);for(let t=0;t<n.data.length;t++)n.data[t]=BigInt.asUintN(64,BigInt(e.data[t]))}break;case i.A.UInt64:case i.A.Int64:switch(n.imageType.componentType){case i.A.UInt8:n.data=new Uint8Array(e.data.length);for(let t=0;t<n.data.length;t++)n.data[t]=Number(e.data[t]);break;case i.A.Int8:n.data=new Int8Array(e.data.length);for(let t=0;t<n.data.length;t++)n.data[t]=Number(e.data[t]);break;case i.A.UInt16:n.data=new Uint16Array(e.data.length);for(let t=0;t<n.data.length;t++)n.data[t]=Number(e.data[t]);break;case i.A.Int16:n.data=new Int16Array(e.data.length);for(let t=0;t<n.data.length;t++)n.data[t]=Number(e.data[t]);break;case i.A.UInt32:n.data=new Uint32Array(e.data.length);for(let t=0;t<n.data.length;t++)n.data[t]=Number(e.data[t]);break;case i.A.Int32:n.data=new Int32Array(e.data.length);for(let t=0;t<n.data.length;t++)n.data[t]=Number(e.data[t]);break;case y.A.Float32:n.data=new Float32Array(e.data.length);for(let t=0;t<n.data.length;t++)n.data[t]=Number(e.data[t]);break;case y.A.Float64:n.data=new Float64Array(e.data.length);for(let t=0;t<n.data.length;t++)n.data[t]=Number(e.data[t]);break;case i.A.UInt64:n.data=new BigUint64Array(e.data);break;case i.A.Int64:n.data=new BigInt64Array(e.data)}}else{const t=e.data.constructor;n.data=new t(e.data.length),null!=n.data&&n.data.set(e.data,0)}return n};const w=class{fcn;workerQueue;runInfo;constructor(e,t){this.fcn=t,this.workerQueue=new Array(e),this.workerQueue.fill(null),this.runInfo=[]}runTasks(e,t=null){const a={taskQueue:[],results:[],addingTasks:!1,postponed:!1,runningWorkers:0,index:0,completedTasks:0,progressCallback:t,canceled:!1};return this.runInfo.push(a),a.index=this.runInfo.length-1,{promise:new Promise(((t,n)=>{a.resolve=t,a.reject=n,a.results=new Array(e.length),a.completedTasks=0,a.addingTasks=!0,e.forEach(((e,t)=>{this.addTask(a.index,t,e)})),a.addingTasks=!1})),runId:a.index}}terminateWorkers(){for(let e=0;e<this.workerQueue.length;e++){const t=this.workerQueue[e];null!=t&&t.terminate(),this.workerQueue[e]=null}}cancel(e){const t=this.runInfo[e];null!=t&&(t.canceled=!0)}addTask(e,t,a){const n=this.runInfo[e];if(!0===n?.canceled)return n.reject("Remaining tasks canceled"),void this.clearTask(n.index);if(this.workerQueue.length>0){const r=this.workerQueue.pop();n.runningWorkers++,a[a.length-1].webWorker=r,this.fcn(...a).then((({webWorker:a,...r})=>{if(this.workerQueue.push(a),null!==this.runInfo[e])if(n.runningWorkers--,n.results[t]=r,n.completedTasks++,null!=n.progressCallback&&n.progressCallback(n.completedTasks,n.results.length),n.taskQueue.length>0){const t=n.taskQueue.shift();this.addTask(e,t[0],t[1])}else if(!n.addingTasks&&0===n.runningWorkers){const e=n.results;n.resolve(e),this.clearTask(n.index)}})).catch((e=>{n.reject(e),this.clearTask(n.index)}))}else 0!==n.runningWorkers||n.postponed?n.taskQueue.push([t,a]):(n.postponed=!0,setTimeout((()=>{n.postponed=!1,this.addTask(n.index,t,a)}),50))}clearTask(e){this.runInfo[e].results=[],this.runInfo[e].taskQueue=[],this.runInfo[e].progressCallback=null,this.runInfo[e].canceled=null,this.runInfo[e].reject=()=>{},this.runInfo[e].resolve=()=>{}}};const A=class{dimension;pointComponentType;pointPixelComponentType;pointPixelType;pointPixelComponents;cellComponentType;cellPixelComponentType;cellPixelType;cellPixelComponents;constructor(e=2,t=y.A.Float32,a=y.A.Float32,n=s.Scalar,r=1,o=i.A.Int32,l=y.A.Float32,c=s.Scalar,d=1){this.dimension=e,this.pointComponentType=t,this.pointPixelComponentType=a,this.pointPixelType=n,this.pointPixelComponents=r,this.cellComponentType=o,this.cellPixelComponentType=l,this.cellPixelType=c,this.cellPixelComponents=d}};const k=class{mt;meshType;name="mesh";numberOfPoints;points;numberOfPointPixels;pointData;numberOfCells;cells;cellBufferSize;numberOfCellPixels;cellData;constructor(e=new A){this.mt=e,this.meshType=e,this.name="mesh",this.numberOfPoints=0,this.points=null,this.numberOfPointPixels=0,this.pointData=null,this.numberOfCells=0,this.cellBufferSize=0,this.cells=null,this.numberOfCellPixels=0,this.cellData=null}};const T=class{pointPixelComponentType;pointPixelType;pointPixelComponents;cellPixelComponentType;cellPixelType;cellPixelComponents;constructor(e=y.A.Float32,t=s.Scalar,a=1,n=y.A.Float32,r=s.Scalar,i=1){this.pointPixelComponentType=e,this.pointPixelType=t,this.pointPixelComponents=a,this.cellPixelComponentType=n,this.cellPixelType=r,this.cellPixelComponents=i}};const I=class{polyDataType;name="PolyData";numberOfPoints;points;verticesBufferSize;vertices;linesBufferSize;lines;polygonsBufferSize;polygons;triangleStripsBufferSize;triangleStrips;numberOfPointPixels;pointData;numberOfCellPixels;cellData;constructor(e=new T){this.polyDataType=e,this.polyDataType=e,this.name="PolyData",this.numberOfPoints=0,this.points=new Float32Array,this.verticesBufferSize=0,this.vertices=null,this.linesBufferSize=0,this.lines=null,this.polygonsBufferSize=0,this.polygons=null,this.triangleStripsBufferSize=0,this.triangleStrips=null,this.numberOfPointPixels=0,this.pointData=null,this.numberOfCellPixels=0,this.cellData=null}};var b=a(16881),x=a(99178),P=a(17739);const C=async function(e){const t=e;let n=null;if(null===t)n=new Worker(new URL(a.p+a.u(6376),a.b),{type:void 0});else if(t.startsWith("http")){const e=await P.Ay.get(t,{responseType:"blob"}),a=URL.createObjectURL(e.data);n=new Worker(a,{type:"module"})}else n=new Worker(t,{type:"module"});return n};function S(e){const t=x.LV(e),a=e;return a.terminated=!1,a.workerProxy=t,a.originalTerminate=a.terminate,a.terminate=()=>{a.terminated=!0,a.workerProxy[x.A2](),a.originalTerminate()},{workerProxy:t,worker:a}}const U=async function(e,t){let a;if(null!=e){const t=e;return void 0!==t.workerProxy?(a=t.workerProxy,{workerProxy:a,worker:t}):S(e)}return S(await C(t))};const B=async function(e,t){let a="unknown";a="string"!=typeof e?e.href:e.startsWith("http")?e:void 0!==t?`${t}/${e}`:e,a.endsWith(".js")&&(a=a.substring(0,a.length-3)),a.endsWith(".wasm")&&(a=a.substring(0,a.length-5));const n=`${a}.wasm`,r=(await P.Ay.get(n,{responseType:"arraybuffer"})).data,i=`${a}.js`;return(await import(i)).default({wasmBinary:r})};var F=a(8792),D=a(46619),O=a(27295),z=a(50295),v=a(3099);let W,M;function E(e){W=e}function Q(){return W}function L(e){M=e}function V(){return M}const N=new Map;function R(){let e=Q();return void 0===e&&(e=new URL("/pipelines",document.location.origin).href),e}const j=async function(e,t,a,n,r){if(!await(async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])))()){const e="WebAssembly SIMD support is required -- please update your browser.";throw alert(e),new Error(e)}const i=r?.webWorker??null;if(!1===i){const i=await async function(e,t){let a=e,n=e;if("string"!=typeof e&&(a=new URL(e.href),n=a.href),N.has(n))return N.get(n);{const a=await B(e,t?.toString()??R());return N.set(n,a),a}}(e.toString(),r?.pipelineBaseUrl);return(0,F.A)(i,t,a,n)}let s=i;const o=r?.pipelineWorkerUrl??function(){let e=V();return void 0===e&&(e=null),e}(),l="string"!=typeof o&&void 0!==o?.href?o.href:o,{workerProxy:c,worker:d}=await U(s,l);s=d;const u=[];null!=n&&n.length>0&&n.forEach((function(e){if(e.type===b.A.BinaryStream){const t=e.data.data;u.push(t)}else if(e.type===b.A.BinaryFile){const t=e.data.data;u.push(t)}else if(e.type===b.A.Image){const t=e.data;null!==t.data&&u.push(...(0,O.A)(t))}else if(e.type===b.A.Mesh){const t=e.data;u.push(...(0,z.A)(t))}else if(e.type===b.A.PolyData){const t=e.data;u.push(...(0,v.A)(t))}}));const p=r?.pipelineBaseUrl??R(),f="string"!=typeof p&&void 0!==p?.href?p.href:p,m=null!=n?x.k0(n,(0,D.A)(u,r?.noCopy)):null,h=await c.runPipeline(e.toString(),f,t,a,m);return{returnValue:h.returnValue,stdout:h.stdout,stderr:h.stderr,outputs:h.outputs,webWorker:s}};let G=null;function $(e){G=e}function q(){return G}const J=async function(e,t,a=null){throw new Error("readDICOMTags is deprecated. Use readDicomTags from @itk-wasm/dicom instead.")};const H=async function(e,t,a=null){throw new Error("readDICOMTagsArrayBuffer is deprecated. Use readDicomTags from @itk-wasm/dicom instead.")},K=async(e,t)=>{throw new Error("readImageDICOMFileSeries is deprecated. Use readImageDicomFileSeries from @itk-wasm/dicom instead.")},X=async(e,t,a)=>{throw new Error("readImageDICOMArrayBufferSeries is deprecated. Use readImageDicomFileSeries from @itk-wasm/dicom instead.")};const Y=async function(e,t){throw new Error("This function has been migrated to the @itk-wasm/mesh-to-poly-data package.")};const Z=async function(e,t){throw new Error("This function has been migrated to the @itk-wasm/mesh-to-poly-data package.")};const _=async function(e,t,a,n){throw new Error("readImageArrayBuffer is deprecated. Use readImageFile from @itk-wasm/image-io instead.")};const ee=async function(e,t,a,n){throw new Error("readImageBlob is deprecated. Use readImageFile from @itk-wasm/image-io instead.")};const te=async function(e,t,a){throw new Error("readImageFile is deprecated. Use readImageFile from @itk-wasm/image-io instead.")};const ae=async function(e,t,a,n){throw new Error("readImageFileSeries is deprecated. Use readImageFileSeries from @itk-wasm/image-io instead.")};const ne=async function(e,t,a,n){throw new Error("readMeshArrayBuffer is deprecated. Use readMeshFile from @itk-wasm/mesh-io instead.")};const re=async function(e,t){throw new Error("readMeshFile is deprecated. Use readMeshFile from @itk-wasm/mesh-io instead.")}}}]);
//# sourceMappingURL=5830.bundle.bcb8ef64b7a02cbf9212.js.map