@cornerstonejs/dicom-image-loader 2.1.4 → 2.1.5

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/dist/esm/init.js CHANGED
@@ -2,8 +2,7 @@ import { setOptions } from './imageLoader/internal/index';
2
2
  import registerLoaders from './imageLoader/registerLoaders';
3
3
  import { getWebWorkerManager } from '@cornerstonejs/core';
4
4
  const workerFn = () => {
5
- const path = new URL('./decodeImageFrameWorker.js', import.meta.url);
6
- const instance = new Worker(path, { type: 'module' });
5
+ const instance = new Worker(new URL('./decodeImageFrameWorker.js', import.meta.url), { type: 'module' });
7
6
  return instance;
8
7
  };
9
8
  function init(options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/dicom-image-loader",
3
- "version": "2.1.4",
3
+ "version": "2.1.5",
4
4
  "description": "Cornerstone Image Loader for DICOM WADO-URI and WADO-RS and Local file",
5
5
  "keywords": [
6
6
  "DICOM",
@@ -119,7 +119,7 @@
119
119
  "uuid": "^9.0.0"
120
120
  },
121
121
  "peerDependencies": {
122
- "@cornerstonejs/core": "^2.1.4",
122
+ "@cornerstonejs/core": "^2.1.5",
123
123
  "dicom-parser": "^1.8.9"
124
124
  },
125
125
  "lint-staged": {
@@ -134,5 +134,5 @@
134
134
  "path": "./node_modules/cz-conventional-changelog"
135
135
  }
136
136
  },
137
- "gitHead": "051d3e5add8fbf1edeb435f559d68136aef63cd2"
137
+ "gitHead": "0d41c41af381224b181100e98bd0a0d55e9d149b"
138
138
  }
@@ -1 +0,0 @@
1
- import bilinear from"./shared/scaling/bilinear";import replicate from"./shared/scaling/replicate";import{expose}from"comlink";import decodeLittleEndian from"./shared/decoders/decodeLittleEndian";import decodeBigEndian from"./shared/decoders/decodeBigEndian";import decodeRLE from"./shared/decoders/decodeRLE";import decodeJPEGBaseline8Bit from"./shared/decoders/decodeJPEGBaseline8Bit";import decodeJPEGBaseline12Bit from"./shared/decoders/decodeJPEGBaseline12Bit-js";import decodeJPEGLossless from"./shared/decoders/decodeJPEGLossless";import decodeJPEGLS from"./shared/decoders/decodeJPEGLS";import decodeJPEG2000 from"./shared/decoders/decodeJPEG2000";import decodeHTJ2K from"./shared/decoders/decodeHTJ2K";import applyModalityLUT from"./shared/scaling/scaleArray";import getMinMax from"./shared/getMinMax";import getPixelDataTypeFromMinMax from"./shared/getPixelDataTypeFromMinMax";import isColorImage from"./shared/isColorImage";const imageUtils={bilinear,replicate};async function decodeImageFrame(e,a,r,t,o,i){const n=(new Date).getTime();let s,l=null;switch(a){case"1.2.840.10008.1.2":case"1.2.840.10008.1.2.1":case"1.2.840.10008.1.2.1.99":l=decodeLittleEndian(e,r);break;case"1.2.840.10008.1.2.2":l=decodeBigEndian(e,r);break;case"1.2.840.10008.1.2.5":l=decodeRLE(e,r);break;case"1.2.840.10008.1.2.4.50":s={...e},l=decodeJPEGBaseline8Bit(r,s);break;case"1.2.840.10008.1.2.4.51":l=decodeJPEGBaseline12Bit(e,r);break;case"1.2.840.10008.1.2.4.57":case"1.2.840.10008.1.2.4.70":l=decodeJPEGLossless(e,r);break;case"1.2.840.10008.1.2.4.80":case"1.2.840.10008.1.2.4.81":s={signed:1===e.pixelRepresentation,bytesPerPixel:e.bitsAllocated<=8?1:2,...e},l=decodeJPEGLS(r,s);break;case"1.2.840.10008.1.2.4.90":case"1.2.840.10008.1.2.4.91":s={...e},l=decodeJPEG2000(r,s);break;case"3.2.840.10008.1.2.4.96":case"1.2.840.10008.1.2.4.201":case"1.2.840.10008.1.2.4.202":case"1.2.840.10008.1.2.4.203":s={...e},l=decodeHTJ2K(r,s);break;default:throw new Error(`no decoder for transfer syntax ${a}`)}if(!l)throw new Error("decodePromise not defined");const d=postProcessDecodedPixels(await l,o,n,t);return i?.(d),d}function postProcessDecodedPixels(e,a,r,t){const o=void 0!==e.pixelRepresentation&&1===e.pixelRepresentation,i=o&&void 0!==e.bitsStored?32-e.bitsStored:void 0;if(o&&void 0!==i)for(let a=0;a<e.pixelData.length;a++)e.pixelData[a]=e.pixelData[a]<<i>>i;let n=e.pixelData;e.pixelDataLength=e.pixelData.length;const{min:s,max:l}=getMinMax(e.pixelData),d={Uint8Array,Uint16Array,Int16Array,Float32Array},c=a.targetBuffer?.type,m=void 0===a.allowFloatRendering||a.allowFloatRendering,p=isColorImage(e.photometricInterpretation)&&void 0===a.targetBuffer?.offset,f=a.preScale?.enabled,g=f&&Object.values(a.preScale.scalingParameters).some((e=>"number"==typeof e&&!Number.isInteger(e))),u=!a.preScale.enabled||!m&&g;n=c&&!p?_handleTargetBuffer(a,e,d,n):a.preScale.enabled&&!u?_handlePreScaleSetup(a,s,l,e):_getDefaultPixelDataArray(s,l,e);let x=s,P=l;if(a.preScale.enabled&&!u){const r=a.preScale.scalingParameters;_validateScalingParameters(r);const{rescaleSlope:t,rescaleIntercept:o}=r;if("number"==typeof t&&"number"==typeof o){applyModalityLUT(n,r),e.preScale={...a.preScale,scaled:!0};const{rescaleIntercept:t,rescaleSlope:o,suvbw:i}=r;x=o*s+t,P=o*l+t,i&&(x*=i,P*=i)}}else u&&(e.preScale={enabled:!0,scaled:!1},x=s,P=l);e.pixelData=n,e.smallestPixelValue=x,e.largestPixelValue=P;const h=(new Date).getTime();return e.decodeTimeInMS=h-r,e}function _handleTargetBuffer(e,a,r,t){const{arrayBuffer:o,type:i,offset:n=0,length:s,rows:l}=e.targetBuffer,d=r[i];if(!d)throw new Error(`target array ${i} is not supported, or doesn't exist.`);l&&l!=a.rows&&scaleImageFrame(a,e.targetBuffer,d);const c=a.pixelDataLength,m=n,p=null!=s?s:c-m,f=a.pixelData;if(p!==f.length)throw new Error(`target array for image does not have the same length (${p}) as the decoded image length (${f.length}).`);const g=o?new d(o,m,p):new d(p);return g.set(f,0),g}function _handlePreScaleSetup(e,a,r,t){const o=e.preScale.scalingParameters;_validateScalingParameters(o);const{rescaleSlope:i,rescaleIntercept:n}=o;let s=a,l=r;return"number"==typeof i&&"number"==typeof n&&(s=i*a+n,l=i*r+n),_getDefaultPixelDataArray(s,l,t)}function _getDefaultPixelDataArray(e,a,r){const t=new(getPixelDataTypeFromMinMax(e,a))(r.pixelData.length);return t.set(r.pixelData,0),t}function _validateScalingParameters(e){if(!e)throw new Error("options.preScale.scalingParameters must be defined if preScale.enabled is true, and scalingParameters cannot be derived from the metadata providers.")}function createDestinationImage(e,a,r){const{samplesPerPixel:t}=e,{rows:o,columns:i}=a,n=o*i*t,s=new r(n),l=s.byteLength/n;return{pixelData:s,rows:o,columns:i,frameInfo:{...e.frameInfo,rows:o,columns:i},imageInfo:{...e.imageInfo,rows:o,columns:i,bytesPerPixel:l}}}function scaleImageFrame(e,a,r){const t=createDestinationImage(e,a,r),{scalingType:o="replicate"}=a;return imageUtils[o](e,t),Object.assign(e,t),e.pixelDataLength=e.pixelData.length,e}const obj={decodeTask:({imageFrame:e,transferSyntax:a,decodeConfig:r,options:t,pixelData:o,callbackFn:i})=>decodeImageFrame(e,a,o,r,t,i)};expose(obj);