Skip to content

fix(WindowLevelTool): fix calculation of image dynamic range - #2147

Merged
sedghi merged 2 commits into
cornerstonejs:mainfrom
pwespi:fix-window-level-tool
Jul 9, 2025
Merged

fix(WindowLevelTool): fix calculation of image dynamic range#2147
sedghi merged 2 commits into
cornerstonejs:mainfrom
pwespi:fix-window-level-tool

Conversation

@pwespi

@pwespi pwespi commented Jun 16, 2025

Copy link
Copy Markdown
Contributor

Context

There is a type error in the calculation of the image dynamic range in the WindowLevelTool, which leads to a wrong multiplier.

Changes & Results

Fix calculation of image dynamic range in WindowLevelTool.

Testing

Checklist

PR

  • [] My Pull Request title is descriptive, accurate and follows the
    semantic-release format and guidelines.

Code

  • [] My code has been well-documented (function documentation, inline comments,
    etc.)

Public Documentation Updates

  • [] The documentation page has been updated as necessary for any public API
    additions or removals.

Tested Environment

  • [] "OS:
  • [] "Node version:
  • [] "Browser:

@sedghi sedghi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this just fixing our types?

@pwespi

pwespi commented Jun 16, 2025

Copy link
Copy Markdown
Contributor Author

is this just fixing our types?

No, it's fixing the calculation. Sorry the description might have been confusing. calculatedDynamicRange is of type [number, number], but the Math.min calculation needs the difference of the two numbers. So line 198 is the actual fix.

@pwespi
pwespi requested a review from sedghi July 8, 2025 13:50
@sedghi

sedghi commented Jul 8, 2025

Copy link
Copy Markdown
Member

can you see why unit test failing?

@pwespi

pwespi commented Jul 8, 2025

Copy link
Copy Markdown
Contributor Author

can you see why unit test failing?

There is a diff in some data:image/png;base64 data. I don't know how to interpret this.

@pwespi

pwespi commented Jul 8, 2025

Copy link
Copy Markdown
Contributor Author

Updated the ground truth window level image.

@pwespi

pwespi commented Jul 9, 2025

Copy link
Copy Markdown
Contributor Author

@sedghi tests are passing now.

@sedghi
sedghi merged commit 94fefd3 into cornerstonejs:main Jul 9, 2025
9 checks passed
@sedghi sedghi mentioned this pull request Aug 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants