Skip to content

Fix: FreeHandRoiTool Statistics Text Not Displayed#2723

Open
nithin-trenser wants to merge 1 commit into
cornerstonejs:mainfrom
nithin-trenser:fix-freehand-roi-stats-not-displayed
Open

Fix: FreeHandRoiTool Statistics Text Not Displayed#2723
nithin-trenser wants to merge 1 commit into
cornerstonejs:mainfrom
nithin-trenser:fix-freehand-roi-stats-not-displayed

Conversation

@nithin-trenser

@nithin-trenser nithin-trenser commented May 6, 2026

Copy link
Copy Markdown
Contributor

Context

Fix issue: #2645

After drawing an annotation using the PlanarFreeHandRoiTool, the statistics text (such as area, mean, etc.) is not displayed next to the annotation when switching from 2D MPR view to Frame view. The ROI is created and rendered correctly on the viewport, but the associated statistics label is missing.

Changes & Results

Added an additional condition to ensure statistics are recalculated when cached stats for the current targetId are missing. The check now triggers when the annotation is invalidated or when the cached statistics for the specified target are not available, preventing missing measurement values.

fix-freehand-roi-stat-display.mp4

Testing

  • Draw a measurement using the PlanarFreeHandRoiTool in the 2D MPR view.
  • Switch the layout to Frame view.
  • In the right-side panel, locate and click the created measurement.
  • Observe the annotation displayed on the viewport.

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: Ubuntu 24.04
  • Node version: 22
  • Browser: Chrome 147.0.7727.138

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@sen-trenser

Copy link
Copy Markdown

@sedghi Could you please take a look at this PR and provide your feedback?
Thanks!


if (annotation.invalidated) {
const { data, invalidated } = annotation;
const cachedStats = data && data.cachedStats;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

data?.cachedStats please


for (let j = 0; j < points.length; j++) {
const worldPosIndex = indexPoints[j].map(Math.floor);
const worldPosIndex = indexPoints[j].map((v) => Math.floor(v + 1e-3));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This isn't clear why you are doing this, nor that it is valid for things like WSI images.

@wayfarer3130 wayfarer3130 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you strip out the changes for worldPosIndex, or if they are really needed, then give a good explanation and make sure it really works reliably for data like WSI.
If you need ceiling/floor differences, then calculating both ceiling and floor rather than trying to do some not understandable logic that might not work reliably.

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.

3 participants