Skip to content

Commit

Permalink
fix(StreamingImageVolume): scaling bug for undefined parameters (#376)
Browse files Browse the repository at this point in the history
  • Loading branch information
sedghi authored Jan 18, 2023
1 parent 32e2718 commit a366d9d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
21 changes: 19 additions & 2 deletions packages/streaming-image-volume-loader/src/StreamingImageVolume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,10 +494,27 @@ export default class StreamingImageVolume extends ImageVolume {
* rescaleIntercept are different from the ones that were used to scale the
* image, we should scale the image again according to the new parameters.
*/
private _scaleIfNecessary(image, scalingParametersToUse) {
private _scaleIfNecessary(
image,
scalingParametersToUse: Types.ScalingParameters
) {
const imageIsAlreadyScaled = image.preScale?.scaled;
const noScalingParametersToUse =
!scalingParametersToUse ||
!scalingParametersToUse.rescaleIntercept ||
!scalingParametersToUse.rescaleSlope;

if (!imageIsAlreadyScaled && noScalingParametersToUse) {
// no need to scale the image
return image.getPixelData().slice(0);
}

if (!imageIsAlreadyScaled) {
if (
!imageIsAlreadyScaled &&
scalingParametersToUse &&
scalingParametersToUse.rescaleIntercept !== undefined &&
scalingParametersToUse.rescaleSlope !== undefined
) {
// if not already scaled, just scale the image.
// copy so that it doesn't get modified
const pixelDataCopy = image.getPixelData().slice(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function scaleArray(

if (scalingParameters.modality === 'PT') {
if (typeof suvbw !== 'number') {
return;
return array;
}

for (let i = 0; i < arrayLength; i++) {
Expand Down

0 comments on commit a366d9d

Please sign in to comment.