-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: targetbuffer check and scaling fix #522
base: master
Are you sure you want to change the base?
fix: targetbuffer check and scaling fix #522
Conversation
✅ Deploy Preview for cornerstone-wado-image-loader ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
const { rescaleSlope, rescaleIntercept, suvbw } = scalingParameters; | ||
const rescaleSlope = scalingParameters?.rescaleSlope || 1; | ||
const rescaleIntercept = scalingParameters?.rescaleIntercept || 0; | ||
const suvbw = scalingParameters?.suvbw || 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why should we go through headache of the scale and intercept for large arrays if they are undefiend? can we return early instead? Also don't think we get to here at all if rescaleSlope
and rescaleIntercept
are not numbers because of the check in decodeImageFrame
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So reviewing it looks like there is a check to see if slope/intercept exist before scaleArray is called:
cornerstoneWADOImageLoader/src/shared/decodeImageFrame.js
Lines 255 to 265 in a4d973e
if ( | |
typeof rescaleSlope === 'number' && | |
typeof rescaleIntercept === 'number' | |
) { | |
scaleArray( | |
imageFrame, | |
options.preScale, | |
pixelDataArray, | |
scalingParameters | |
); | |
} |
Additionally, if it is a PET modality and suvbw is not defined the other prescaling is ignored entirely (early return so no prescale). I'm not sure if this desirable because other scale params may exist.
This diff would set defaults and it shouldn't be more computationally expensive than current commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, I guess we can say that in this function always typeof rescaleSlope === 'number'
is true, so no need for scalingParameters?.rescaleSlope || 1;
right?
I guess you are right about the PT scenario
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Figured for readability I just follow the PET case since it doesn’t change the functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m okay either way, I can remove the || defaults too
src/shared/scaling/scaleArray.js
Outdated
const value = suvbw * (array[i] * rescaleSlope + rescaleIntercept); | ||
|
||
array[i] = value; | ||
if (value < 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't it be faster if we don't check on value < 0 if the isNegative is true
too ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this check!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see my comments
a4d973e
to
f5388f7
Compare
Prescaling can cause Uint16 type underflows which require the logic in
scaleArray
to account for negative values.