Skip to content

Commit

Permalink
fix(windowLevelTool): WWWL multipler too high when burned in pixels a…
Browse files Browse the repository at this point in the history
…re present (#462)
  • Loading branch information
Ouwen authored Mar 7, 2023
1 parent 37f3c68 commit 47bfa46
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/tools/src/tools/WindowLevelTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,20 @@ class WindowLevelTool extends BaseTool {
const imageVolume = cache.getVolume(volumeId);
const { dimensions } = imageVolume;
const scalarData = imageVolume.getScalarData();
imageDynamicRange = this._getImageDynamicRangeFromMiddleSlice(
const calculatedDynamicRange = this._getImageDynamicRangeFromMiddleSlice(
scalarData,
dimensions
);
const BitsStored = imageVolume?.metadata?.BitsStored;
const metadataDynamicRange = BitsStored ? 2 ** BitsStored : Infinity;
// Burned in Pixels often use pixel values above the BitsStored.
// This results in a multiplier which is way higher than what you would
// want in practice. Thus we take the min between the metadata dynamic
// range and actual middel slice dynamic range.
imageDynamicRange = Math.min(
calculatedDynamicRange,
metadataDynamicRange
);
} else {
imageDynamicRange = this._getImageDynamicRangeFromViewport(viewport);
}
Expand All @@ -167,7 +177,6 @@ class WindowLevelTool extends BaseTool {
if (ratio > 1) {
multiplier = Math.round(ratio);
}

return multiplier;
}

Expand Down

0 comments on commit 47bfa46

Please sign in to comment.