Skip to content

Commit

Permalink
fix: fallback for small window levels
Browse files Browse the repository at this point in the history
  • Loading branch information
sedghi committed Dec 18, 2024
1 parent dcb9f77 commit eeb59e8
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/core/src/utilities/windowLevel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,18 @@ function toLowHighRange(
lower: number;
upper: number;
} {
const lower = windowCenter - 0.5 - (windowWidth - 1) / 2;
const upper = windowCenter - 0.5 + (windowWidth - 1) / 2;
if (windowWidth < 1 || windowCenter < 1) {
// use fallback
return {
lower: windowCenter - windowWidth / 2,
upper: windowCenter + windowWidth / 2,
};
}

return { lower, upper };
return {
lower: windowCenter - 0.5 - (windowWidth - 1) / 2,
upper: windowCenter - 0.5 + (windowWidth - 1) / 2,
};
}

export { toWindowLevel, toLowHighRange };

0 comments on commit eeb59e8

Please sign in to comment.