Skip to content

fix(tools): preserve continuous measurement coordinates#2803

Merged
sedghi merged 2 commits into
mainfrom
agent/fix-continuous-roi-area
Jul 13, 2026
Merged

fix(tools): preserve continuous measurement coordinates#2803
sedghi merged 2 commits into
mainfrom
agent/fix-continuous-roi-area

Conversation

@sedghi

@sedghi sedghi commented Jul 13, 2026

Copy link
Copy Markdown
Member

Summary

  • calculate Rectangle ROI physical width and height from continuous image indices
  • calculate Ultrasound Directional calibrated endpoints from continuous image indices
  • retain rounded image indices where tools intentionally sample voxels or define discrete bounds
  • add regression coverage for fractional Rectangle ROI and calibrated ultrasound coordinates

Why

Some measurement paths converted world handles to rounded voxel indices before calculating their reported values. This quantized Rectangle ROI area differently on volumes with different pixel spacing and quantized Ultrasound Directional measurements to whole pixels.

Impact

  • a shared Rectangle ROI reports consistent physical area across aligned volumes
  • calibrated US and ECG directional measurements preserve subpixel endpoint positions
  • intensity statistics and discrete tools continue to use integer voxel coordinates

Validation

  • pnpm test:unit:no-coverage packages/tools/test/RectangleROIArea.jest.js packages/tools/test/UltrasoundDirectionalTool.jest.js --runInBand
  • pnpm build:esm
  • commit hooks: oxlint and Prettier
  • git diff --check

Summary by CodeRabbit

  • Bug Fixes

    • Improved rectangular ROI area calculations by preserving fractional image coordinates, resulting in more accurate physical measurements.
    • Improved ultrasound directional measurements by using more precise coordinate conversions for calibrated values.
  • Tests

    • Added coverage validating accurate ROI area calculations.
    • Added coverage for calibrated ultrasound measurements, direction classification, units, and endpoint values.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 448935a2-5902-46cf-9145-94c57503096d

📥 Commits

Reviewing files that changed from the base of the PR and between 9a6e9ed and 2b8e493.

📒 Files selected for processing (4)
  • packages/tools/src/tools/annotation/RectangleROITool.ts
  • packages/tools/src/tools/annotation/UltrasoundDirectionalTool.ts
  • packages/tools/test/RectangleROIArea.jest.js
  • packages/tools/test/UltrasoundDirectionalTool.jest.js

📝 Walkthrough

Walkthrough

Rectangle ROI and ultrasound directional statistics now use continuous world-to-index transforms. New Jest tests verify continuous-coordinate area calculations, bounds, calibrated endpoint values, measurement classification, and units.

Changes

Continuous index measurements

Layer / File(s) Summary
Rectangle ROI continuous area calculation
packages/tools/src/tools/annotation/RectangleROITool.ts, packages/tools/test/RectangleROIArea.jest.js
Rectangle ROI handle positions and area dimensions use continuous image indices, with tests covering the calculated area and bounds.
Ultrasound directional continuous calibration
packages/tools/src/tools/annotation/UltrasoundDirectionalTool.ts, packages/tools/test/UltrasoundDirectionalTool.jest.js
Ultrasound directional endpoint conversions use continuous indices, with tests covering calibrated values, orientation, units, and unit metadata.

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

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning It covers summary, rationale, impact, and validation, but it omits the required template headings and leaves the checklist unchecked. Reformat the PR body to use Context, Changes & Results, Testing, and Checklist, and check the required PR/code/docs/environment items.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise, semantic-release compliant, and accurately reflects the main change.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/fix-continuous-roi-area

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.

@sedghi sedghi changed the title fix(tools): preserve continuous rectangle ROI area fix(tools): preserve continuous measurement coordinates Jul 13, 2026
@sedghi sedghi marked this pull request as ready for review July 13, 2026 15:15
@sedghi sedghi merged commit 991251a into main Jul 13, 2026
17 checks passed
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.

1 participant