Skip to content

Add measurement tools (distance, HU probe, ROI) to the viewer#31

Merged
aperson30 merged 1 commit into
mainfrom
aditya/viewer-measurement-tools
Jun 22, 2026
Merged

Add measurement tools (distance, HU probe, ROI) to the viewer#31
aperson30 merged 1 commit into
mainfrom
aditya/viewer-measurement-tools

Conversation

@aperson30

Copy link
Copy Markdown
Collaborator

What

Adds measurement tools to the case viewer:

  • Distance — click two points → length in mm
  • HU at point — click a point → Hounsfield value there
  • Rectangle ROI — drag a box → area + mean/max/min HU
  • Clear — removes all measurements (leaves the crosshair intact)

Built on Cornerstone's standard LengthTool / ProbeTool / RectangleROITool, added to the existing tool group alongside the crosshair/pan/zoom tools.

How it works

  • setActiveMeasurementTool() hands the primary mouse button to the selected measure tool and disables crosshair/pan while measuring; clicking the tool again (or the crosshair button) returns to navigation.
  • clearMeasurements() removes only measurement annotations, so the crosshair is preserved.
  • Annotations are recolored to cyan (resting) / white (selected) instead of Cornerstone's default yellow/green, which clashed with the colored organ masks. (Defaults are merged, not replaced, so the value-label fonts are preserved.)

Correctness

  • Distances use the volume's mm spacing from the NIfTI affine (the same geometry that aligns the MPR planes + masks).
  • HU readouts read the volume's scalar values, which are HU-calibrated — confirmed by the viewer's HU-defined window presets (Soft Tissue W400/C40, Bone W1800/C400, etc.) rendering correctly.
  • Recommended reviewer sanity check: probe air ≈ −1000, muscle ≈ 30–60, bone ≈ +300–1000 HU.

Testing

  • Typecheck (tsc -b) ✓
  • Vitest 32/32 ✓ (smoke-test mock updated with new exports)
  • Production build ✓
  • Manually verified in the viewer: distance, HU probe, ROI stats render with values; tool switching and Clear behave correctly.

- Register Cornerstone LengthTool / ProbeTool / RectangleROITool and add
  toolbar buttons for distance (mm), HU-at-point, and rectangle ROI (HU + area).
- setActiveMeasurementTool() hands the primary mouse button to the chosen
  measure tool and disables crosshair/pan while measuring; clearMeasurements()
  removes only measurement annotations, leaving the crosshair intact.
- Recolor measurement annotations to cyan (resting) / white (selected) so they
  read cleanly over the colored organ masks instead of the default yellow/green.
- Update the viewer smoke-test mock with the new exports.
@aperson30 aperson30 merged commit 1df0664 into main Jun 22, 2026
6 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