Skip to content

fix: Add SRProbe and SRRectangleROI sub-types#5858

Open
igoroctaviano wants to merge 4 commits intomasterfrom
fix/scoord3d-points-bounding-boxes-labels
Open

fix: Add SRProbe and SRRectangleROI sub-types#5858
igoroctaviano wants to merge 4 commits intomasterfrom
fix/scoord3d-points-bounding-boxes-labels

Conversation

@igoroctaviano
Copy link
Contributor

@igoroctaviano igoroctaviano commented Feb 27, 2026

Screenshot 2026-02-27 at 10 18 57 Screenshot 2026-02-27 at 10 19 04

Context

Fixes ImagingDataCommons#107

Improves DICOM SR annotation visualization. Per maintainer feedback: create sub-types of Probe and RectangleROI with custom configuration rather than modifying base tools. SRProbe and SRRectangleROI show the semantic label (e.g. "Lesion" from Finding concept) instead of intensity/coordinates or area/stats, and are used only for SR hydration—they do not replace Probe/RectangleROI in the toolbar.

Client feedback addressed:

  • Point annotations (Probe): Show label instead of intensity/coordinates; make annotations locked (non-movable).
  • Bounding box annotations (RectangleROI): Show label matching right panel; area/intensity stats off by default; make annotations locked.

Changes & Results

New SR subtypes

  • SRProbe – sub-type of Probe; getSRProbeTextLines returns only the label.
  • SRRectangleROI – sub-type of RectangleROI; getSRRectangleROITextLines returns only the label.

Files added

  • extensions/cornerstone-dicom-sr/src/utils/srToolGetTextLines.ts – getTextLines implementations for SR subtypes.

Files modified

  • extensions/cornerstone-dicom-sr/src/tools/toolNames.ts – added SRProbe, SRRectangleROI.
  • extensions/cornerstone-dicom-sr/src/init.ts – register SRProbe and SRRectangleROI tool instances with getTextLines; dashed line styles.
  • extensions/cornerstone-dicom-sr/src/utils/hydrateStructuredReport.ts – use SRProbe/SRRectangleROI as toolNameForRendering when hydrating Probe/RectangleROI; always lock hydrated annotations.
  • extensions/cornerstone-dicom-sr/src/utils/addSRAnnotation.ts – set isLocked: true and call locking.setAnnotationLocked() for preview annotations.
  • extensions/cornerstone-dicom-sr/src/utils/getLabelFromDCMJSImportedToolData.js – fallback to finding.CodeMeaning for standard DICOM codes (e.g. "Lesion").
  • modes/basic/src/initToolGroups.ts – add SRProbe, SRRectangleROI as passive tools (default, MPR, SRToolGroup).
  • modes/basic-test-mode/src/initToolGroups.ts – same.
  • modes/usAnnotation/src/initToolGroups.js – same.
  • extensions/cornerstone/src/utils/measurementServiceMappings/measurementServiceMappingsFactory.ts – SRProbe → POINT, SRRectangleROI → RECTANGLE.
  • extensions/cornerstone/src/initMeasurementService.ts – add SRProbe, SRRectangleROI to supported tools.
  • extensions/cornerstone/src/utils/measurementServiceMappings/constants/supportedTools.js – add SRProbe, SRRectangleROI.

Design decisions

  • Probe and RectangleROI remain in the toolbar; SRProbe and SRRectangleROI are passive tools for hydration display only.
  • Base ProbeTool and RectangleROITool unchanged; only subtypes added.

Testing

  1. Load a study with DICOM SR measurements (SCOORD point and/or SCOORD rectangle).
  2. Hydrate the SR display set.
  3. Verify point annotations show label (e.g. "Lesion") instead of intensity/coordinates.
  4. Verify rectangle annotations show label instead of area/intensity stats.
  5. Verify all SR annotations are locked (non-movable).
  6. Verify Probe and RectangleROI still appear and work in the toolbar for user-created annotations.

E2E snapshots may need regeneration for Scoord3dProbe, ScoordRectangle:

cd Viewers && cross-env TEST_ENV=true npx playwright test tests/Scoord3dProbe.spec.ts tests/ScoordRectangle.spec.ts --update-snapshots

Checklist

PR

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

Suggested PR title: feat(cornerstone-dicom-sr): add SRProbe and SRRectangleROI subtypes for label-only SR hydration

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:

Greptile Summary

Adds SRProbe and SRRectangleROI subtypes for DICOM SR annotation visualization. These subtypes display semantic labels (e.g. "Lesion" from Finding concept) instead of intensity/coordinates or area/stats. Subtypes are passive tools used only for SR hydration, not added to toolbar - base Probe/RectangleROI remain unchanged.

Key changes:

  • New srToolGetTextLines.ts with label-only getTextLines implementations
  • SR subtypes registered in init.ts with custom getTextLines and dashed line styles
  • hydrateStructuredReport.ts maps Probe→SRProbe, RectangleROI→SRRectangleROI for rendering
  • All SR annotations now locked by default for medical device safety
  • Improved label fallback logic in getLabelFromDCMJSImportedToolData.js
  • Measurement service mappings added for SR subtypes
  • Tool groups updated across all modes to include SR subtypes as passive tools

Issue found:

  • usAnnotation mode uses static import without null-checking, unlike other modes that use conditional spreading - could cause runtime error if SR extension not loaded

Confidence Score: 4/5

  • Safe to merge after fixing the null-check issue in usAnnotation mode
  • Well-structured implementation with clean separation of concerns. The SR subtyping approach maintains backward compatibility. However, there's a critical bug in usAnnotation mode where SRToolNames is accessed without null-checking, which could cause runtime errors. Once fixed, this is a solid implementation.
  • Pay close attention to modes/usAnnotation/src/initToolGroups.js - needs null-check fix before merge

Important Files Changed

Filename Overview
extensions/cornerstone-dicom-sr/src/utils/srToolGetTextLines.ts New file: clean implementation of getTextLines functions for SR subtypes that return label-only text
extensions/cornerstone-dicom-sr/src/init.ts Registers SRProbe and SRRectangleROI tool instances with custom getTextLines; adds dashed line styles
extensions/cornerstone-dicom-sr/src/utils/hydrateStructuredReport.ts Uses SRProbe/SRRectangleROI as toolNameForRendering for SR hydration; always locks SR annotations for safety
modes/usAnnotation/src/initToolGroups.js Added SRProbe and SRRectangleROI, but uses static import without null-checking - potential runtime error

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[DICOM SR with Point/Rectangle] --> B[hydrateStructuredReport]
    B --> C{annotationType?}
    C -->|Probe| D[Use SRProbe as toolNameForRendering]
    C -->|RectangleROI| E[Use SRRectangleROI as toolNameForRendering]
    C -->|Other| F[Use original annotationType]
    D --> G[Register with measurementService]
    E --> G
    F --> G
    G --> H[Lock annotation - setAnnotationLocked]
    H --> I{Render annotation}
    I --> J[getSRProbeTextLines]
    I --> K[getSRRectangleROITextLines]
    J --> L[Display label only e.g. 'Lesion']
    K --> L
    L --> M[Annotation rendered with dashed lines]
Loading

Last reviewed commit: c93d001

(5/5) You can turn off certain types of comments like style here!

@netlify
Copy link

netlify bot commented Feb 27, 2026

Deploy Preview for ohif-dev canceled.

Name Link
🔨 Latest commit 7816ec6
🔍 Latest deploy log https://app.netlify.com/projects/ohif-dev/deploys/69a19d647c455400082585fe

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

12 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@cypress
Copy link

cypress bot commented Feb 27, 2026

Viewers    Run #6054

Run Properties:  status check passed Passed #6054  •  git commit 7816ec66fa: Update usAnnotation to use same sr handling as basic modes
Project Viewers
Branch Review fix/scoord3d-points-bounding-boxes-labels
Run status status check passed Passed #6054
Run duration 02m 20s
Commit git commit 7816ec66fa: Update usAnnotation to use same sr handling as basic modes
Committer Igor Octaviano
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 37
View all changes introduced in this branch ↗︎

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.

Revisit visualization of planar annotations from SR

1 participant