@cornerstonejs/dicom-image-loader 3.14.2 → 3.14.3

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.
@@ -50,10 +50,9 @@ function postProcessDecodedPixels(imageFrame, options, start, decodeConfig) {
50
50
  const disableScale = !options.preScale.enabled || (!canRenderFloat && hasFloatRescale);
51
51
  const type = options.targetBuffer?.type;
52
52
  if (type && options.preScale.enabled && !disableScale) {
53
- const { rescaleSlope, rescaleIntercept } = options.preScale.scalingParameters;
54
- const minAfterScale = rescaleSlope * minBeforeScale + rescaleIntercept;
55
- const maxAfterScale = rescaleSlope * maxBeforeScale + rescaleIntercept;
56
- invalidType = !validatePixelDataType(minAfterScale, maxAfterScale, typedArrayConstructors[type]);
53
+ const scalingParameters = options.preScale.scalingParameters;
54
+ const scaledValues = _calculateScaledMinMax(minBeforeScale, maxBeforeScale, scalingParameters);
55
+ invalidType = !validatePixelDataType(scaledValues.min, scaledValues.max, typedArrayConstructors[type]);
57
56
  }
58
57
  if (type && !invalidType) {
59
58
  pixelDataArray = _handleTargetBuffer(options, imageFrame, typedArrayConstructors, pixelDataArray);
@@ -69,7 +68,6 @@ function postProcessDecodedPixels(imageFrame, options, start, decodeConfig) {
69
68
  if (options.preScale.enabled && !disableScale) {
70
69
  const scalingParameters = options.preScale.scalingParameters;
71
70
  _validateScalingParameters(scalingParameters);
72
- const { rescaleSlope, rescaleIntercept } = scalingParameters;
73
71
  const isRequiredScaling = _isRequiredScaling(scalingParameters);
74
72
  if (isRequiredScaling) {
75
73
  applyModalityLUT(pixelDataArray, scalingParameters);
@@ -77,13 +75,9 @@ function postProcessDecodedPixels(imageFrame, options, start, decodeConfig) {
77
75
  ...options.preScale,
78
76
  scaled: true,
79
77
  };
80
- const { rescaleIntercept, rescaleSlope, suvbw } = scalingParameters;
81
- minAfterScale = rescaleSlope * minBeforeScale + rescaleIntercept;
82
- maxAfterScale = rescaleSlope * maxBeforeScale + rescaleIntercept;
83
- if (suvbw) {
84
- minAfterScale = minAfterScale * suvbw;
85
- maxAfterScale = maxAfterScale * suvbw;
86
- }
78
+ const scaledValues = _calculateScaledMinMax(minBeforeScale, maxBeforeScale, scalingParameters);
79
+ minAfterScale = scaledValues.min;
80
+ maxAfterScale = scaledValues.max;
87
81
  }
88
82
  }
89
83
  else if (disableScale) {
@@ -136,15 +130,8 @@ function _handleTargetBuffer(options, imageFrame, typedArrayConstructors, pixelD
136
130
  function _handlePreScaleSetup(options, minBeforeScale, maxBeforeScale, imageFrame) {
137
131
  const scalingParameters = options.preScale.scalingParameters;
138
132
  _validateScalingParameters(scalingParameters);
139
- const { rescaleSlope, rescaleIntercept } = scalingParameters;
140
- const areSlopeAndInterceptNumbers = typeof rescaleSlope === 'number' && typeof rescaleIntercept === 'number';
141
- let scaledMin = minBeforeScale;
142
- let scaledMax = maxBeforeScale;
143
- if (areSlopeAndInterceptNumbers) {
144
- scaledMin = rescaleSlope * minBeforeScale + rescaleIntercept;
145
- scaledMax = rescaleSlope * maxBeforeScale + rescaleIntercept;
146
- }
147
- return _getDefaultPixelDataArray(scaledMin, scaledMax, imageFrame);
133
+ const scaledValues = _calculateScaledMinMax(minBeforeScale, maxBeforeScale, scalingParameters);
134
+ return _getDefaultPixelDataArray(scaledValues.min, scaledValues.max, imageFrame);
148
135
  }
149
136
  function _getDefaultPixelDataArray(min, max, imageFrame) {
150
137
  const TypedArrayConstructor = getPixelDataTypeFromMinMax(min, max);
@@ -152,6 +139,36 @@ function _getDefaultPixelDataArray(min, max, imageFrame) {
152
139
  typedArray.set(imageFrame.pixelData, 0);
153
140
  return typedArray;
154
141
  }
142
+ function _calculateScaledMinMax(minValue, maxValue, scalingParameters) {
143
+ const { rescaleSlope, rescaleIntercept, modality, doseGridScaling, suvbw } = scalingParameters;
144
+ if (modality === 'PT' && typeof suvbw === 'number' && !isNaN(suvbw)) {
145
+ return {
146
+ min: suvbw * (minValue * rescaleSlope + rescaleIntercept),
147
+ max: suvbw * (maxValue * rescaleSlope + rescaleIntercept),
148
+ };
149
+ }
150
+ else if (modality === 'RTDOSE' &&
151
+ typeof doseGridScaling === 'number' &&
152
+ !isNaN(doseGridScaling)) {
153
+ return {
154
+ min: minValue * doseGridScaling,
155
+ max: maxValue * doseGridScaling,
156
+ };
157
+ }
158
+ else if (typeof rescaleSlope === 'number' &&
159
+ typeof rescaleIntercept === 'number') {
160
+ return {
161
+ min: rescaleSlope * minValue + rescaleIntercept,
162
+ max: rescaleSlope * maxValue + rescaleIntercept,
163
+ };
164
+ }
165
+ else {
166
+ return {
167
+ min: minValue,
168
+ max: maxValue,
169
+ };
170
+ }
171
+ }
155
172
  function _validateScalingParameters(scalingParameters) {
156
173
  if (!scalingParameters) {
157
174
  throw new Error('options.preScale.scalingParameters must be defined if preScale.enabled is true, and scalingParameters cannot be derived from the metadata providers.');
@@ -1 +1 @@
1
- export declare const version = "3.14.2";
1
+ export declare const version = "3.14.3";
@@ -1 +1 @@
1
- export const version = '3.14.2';
1
+ export const version = '3.14.3';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/dicom-image-loader",
3
- "version": "3.14.2",
3
+ "version": "3.14.3",
4
4
  "description": "Cornerstone Image Loader for DICOM WADO-URI and WADO-RS and Local file",
5
5
  "keywords": [
6
6
  "DICOM",
@@ -116,7 +116,7 @@
116
116
  "uuid": "^9.0.0"
117
117
  },
118
118
  "peerDependencies": {
119
- "@cornerstonejs/core": "^3.14.2",
119
+ "@cornerstonejs/core": "^3.14.3",
120
120
  "dicom-parser": "^1.8.9"
121
121
  },
122
122
  "lint-staged": {
@@ -131,5 +131,5 @@
131
131
  "path": "./node_modules/cz-conventional-changelog"
132
132
  }
133
133
  },
134
- "gitHead": "ea902cb312d7de54c8e2a199cbed690dfe543019"
134
+ "gitHead": "902ff8c03f0bb19963532fcf6286155ecbdd2d98"
135
135
  }