Skip to content

fix(tools): read ProbeTool value on stack images other than the first - #2968

Open
jisuzzzz wants to merge 1 commit into
cornerstonejs:mainfrom
jisuzzzz:fix/probe-stack-value-non-first-slice
Open

jisuzzzz wants to merge 1 commit into
cornerstonejs:mainfrom
jisuzzzz:fix/probe-stack-value-non-first-slice

Conversation

@jisuzzzz

@jisuzzzz jisuzzzz commented Oct 7, 2026 •

Copy link
Copy Markdown

Context

Fixes #2967

On a StackViewport, ProbeTool draws the handle but no text box on any image other than the first one: cachedStats[targetId].value is undefined.

_calculateCachedStats overwrites ijk[2] with viewport.getCurrentImageIdIndex() (for display) and then reads the value with voxelManager.getAtIJKPoint(ijk). For a stack, getImageData().voxelManager holds a single image ([w, h, 1]), so any k ≥ 1 is out of range. This is a regression from 7c91439 (#2621); up to 83608ba the value was read before ijk[2] was overwritten.

Changes & Results

  • ProbeTool: read the value (US and default branches) with the image-space index; ijk[2] is still replaced with the stack index for display, so cachedStats.index is unchanged.
  • ProbeTool_test.js: new case that sets a two-image stack at index 1 and expects the value on the bar (255) and index[2] === 1. All existing Probe tests use setStack([imageId], 0), which is why this was not caught.

Before: the new test fails with Expected undefined to be 255. After: all 7 Probe tests pass.

Testing

KARMA_PACKAGE=tools KARMA_GREP="Probe Tool" npx karma start --single-run

Or manually: load a multi-image series in a stack viewport, scroll past the first image and place a probe — the text box now shows the index and value.

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. (no public API change)

Tested Environment

  • "OS: Windows 11 (10.0.26200)"
  • "Node version: 24.14.1"
  • "Browser: Chrome Headless (karma)"

Summary by CodeRabbit

  • Bug Fixes
    • Corrected voxel-value lookups for non-ECG stack images so Probe annotations report the value from the selected image while preserving the displayed stack index.
  • Tests
    • Added coverage for Probe annotations on the second image in a stack, including the reported value and stack index.

ProbeTool overwrote ijk[2] with the stack image index before reading the
value through the single-image voxelManager, so every slice except the
first returned undefined and no text box was drawn. Read the value with
the image-space index and keep the stack index for display only.

Regression from 7c91439 (cornerstonejs#2621). Fixes cornerstonejs#2967.
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b61b349f-0fe5-4f87-b58c-4bc6978cff38
📥 Commits

Reviewing files that changed from the base of the PR and between 5f2af21 and 52eb3b4.

📒 Files selected for processing (2)
  • packages/tools/src/tools/annotation/ProbeTool.ts
  • packages/tools/test/ProbeTool_test.js

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

ProbeTool now preserves the rounded image-space voxel index for non-ECG voxel lookups on stack viewports. A new test checks the probe value and stack index on the second image in a two-image stack.

Changes

Stack Probe Voxel Lookup

Layer / File(s) Summary
Voxel lookup and stack test
packages/tools/src/tools/annotation/ProbeTool.ts, packages/tools/test/ProbeTool_test.js
ProbeTool uses the preserved voxel index for non-ECG voxel lookups while retaining the adjusted index for display and enhanced-region calibration. The stack viewport test checks that the annotation references the second image, samples value 255, and reports stack index 1.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: sedghi

Merge Risk: ⚪ Minimal · up to 52eb3

The change addresses Probe values on later stack images, and no actionable merge-blocking issue remains after normal checks.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the fix for ProbeTool values on stack images beyond the first and follows the semantic-release format.
Description check ✅ Passed The description covers the context, changes, results, testing steps, checklist, and tested environment. It provides enough detail to understand and verify the fix.
Linked Issues check ✅ Passed Issue #2967 requires ProbeTool to show voxel values on stack images after the first while retaining the displayed stack index. ProbeTool.ts now copies the image-space IJK before replacing ijk[2], and …
Out of Scope Changes check ✅ Passed The changes are limited to the ProbeTool value lookup and a regression test for issue #2967. The test directly verifies the requested stack behavior. No unrelated changes appear in the whole-PR diff.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

[Bug] ProbeTool shows no value on stack viewports except the first slice (regression in #2621)

1 participant