Skip to content

fix: New growcut (fill) implementation#5954

Open
wayfarer3130 wants to merge 6 commits into
masterfrom
fix/grow-cut-suv-pt
Open

fix: New growcut (fill) implementation#5954
wayfarer3130 wants to merge 6 commits into
masterfrom
fix/grow-cut-suv-pt

Conversation

@wayfarer3130
Copy link
Copy Markdown
Contributor

@wayfarer3130 wayfarer3130 commented Apr 9, 2026

Context

The old growcut implementation had fundamental issues working with PT type series because of the size/setup of the PT.
This is being replaced by a newer version that uses teh currently displayed image as the base image for determining the cutoff, and uses a flood fill algorithm that is bounded to give reasonable performance for clicking.

Changes & Results

CS3D_REF: fix/grow-cut-suv-pt

Checkout the referenced branch and link/build/run

Mostly changed the growcut version tag to reference the new growcut algorithm.

Testing

If you are using speckled areas (like CT brain matter), check the checkbox to use the full area, otherwise select a bright OR
dark are (high contrast with an edge), and click the circle so there is some inside, some outside regions, and you click on an included point.

Using the full area one click, just click so the circle is entirely within the mottled area.

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:
  • [] Node version:
  • [] Browser:

Greptile Summary

This PR replaces the old growcut (RegionSegmentPlusTool) implementation with a new flood-fill based tool (RegionSegmentPlusFloodFillTool) that works correctly with PT-type series, and adds CI tooling to free a stale dev-server port before Playwright runs.

  • Flood fill tool swap: RegionSegmentPlusFloodFillTool is registered in place of RegionSegmentPlusTool everywhere; a new setRegionSegmentPlusFloodFillConfiguration command exposes Max Delta K / IJ sliders so users can bound growth in the slice and in-plane directions; a cancelMeasurement action is wired into rejectPreview so ESC also interrupts in-flight tool operations.
  • CI port cleanup: A new free-ohif-e2e-port.mjs utility kills stale processes on the dev-server port (default 3335) on macOS, Linux, and Windows; it is invoked both as a dedicated workflow step and embedded in the webServer command in playwright.config.ts, so it runs twice on CI (harmless but redundant).

Confidence Score: 5/5

The changes are safe to merge — the tool swap is a clean rename, the new configuration command degrades gracefully when called without parameters, and the CI port-cleanup script handles all error paths quietly.

All changed code paths handle missing data gracefully, the flood fill tool is imported from the established @cornerstonejs/tools package, and the CI additions are additive with no risk of breaking existing test infrastructure.

No files require special attention beyond the two observations noted on commandsModule.ts and toolbarButtons.ts.

Important Files Changed

Filename Overview
extensions/cornerstone/src/initCornerstoneTools.js Swaps RegionSegmentPlusTool for RegionSegmentPlusFloodFillTool in addTool calls and toolNames map; straightforward three-line replacement.
modes/segmentation/src/initToolGroups.ts Adds initial flood-fill configuration block (hoverPrecheckEnabled, intensityRangeStrategy, maxDeltaK/IJ, preview disabled) to the RegionSegmentPlus tool group entry.
modes/segmentation/src/toolbarButtons.ts Adds two range-slider options (Max Delta K / IJ) and setRegionSegmentPlusFloodFillConfiguration command; uses a hardcoded tool-name string in the evaluate array that could drift from the canonical toolNames.RegionSegmentPlus value.
extensions/cornerstone/src/commandsModule.ts Adds _clampToRange, _getRegionSegmentPlusLimits, cancelMeasurement, and setRegionSegmentPlusFloodFillConfiguration; the configuration action hard-codes intensityRangeStrategy on every invocation, overwriting any prior strategy change.
.scripts/ci/free-ohif-e2e-port.mjs New utility to kill processes occupying the Playwright dev-server port on macOS, Linux, and Windows before CI runs; error handling is thorough and cross-platform logic is sound.
playwright.config.ts Extracts port/URL into constants and prepends port-cleanup to the webServer command when CI=true; redundant with the new explicit workflow step but harmless.
.github/workflows/playwright.yml Adds a dedicated "Free OHIF e2e port" CI step before tests; the same cleanup also runs inside playwright.config.ts's webServer command, so it executes twice on CI.
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
modes/segmentation/src/toolbarButtons.ts:783
**Hardcoded tool name string may drift from canonical value**

`toolNames: ['RegionSegmentPlusFloodFill']` is a raw string literal, but the authoritative name is `RegionSegmentPlusFloodFillTool.toolName` (via `toolNames.RegionSegmentPlus` in `initCornerstoneTools.js`). If the tool class's static `toolName` property ever differs from `'RegionSegmentPlusFloodFill'` (e.g. after a rename), the evaluate check would silently stop matching and the "Create new segmentation" disabled-state guard would never fire. Using the imported `toolNames` constant would keep this in sync automatically.

### Issue 2 of 2
extensions/cornerstone/src/commandsModule.ts:2215-2230
**`intensityRangeStrategy` overwritten on every slider adjustment**

`setRegionSegmentPlusFloodFillConfiguration` always calls `toolGroup.setToolConfiguration` with `intensityRangeStrategy: 'canvasDiskTriClassLarge'` hard-coded. Any future code path that selects a different strategy (e.g., a "use full area" checkbox) would have it silently reset to `'canvasDiskTriClassLarge'` the next time a Max Delta K/IJ slider is moved. Consider reading the current strategy from the active tool configuration before writing it back, or add a dedicated strategy field to the toolbar options.

Reviews (5): Last reviewed commit: "Move server kill to different phase" | Re-trigger Greptile

@wayfarer3130 wayfarer3130 added the ohif-integration Causes a CS3D/OHIF integraiton build to be run label Apr 9, 2026
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 9, 2026

Deploy Preview for ohif-dev canceled.

Name Link
🔨 Latest commit be5773e
🔍 Latest deploy log https://app.netlify.com/projects/ohif-dev/deploys/6a0dddc9c2b2f20008db176f

Comment thread extensions/cornerstone/src/commandsModule.ts
Comment thread extensions/cornerstone/src/commandsModule.ts
Comment thread extensions/cornerstone/src/commandsModule.ts
@cypress
Copy link
Copy Markdown

cypress Bot commented Apr 16, 2026

Viewers    Run #6298

Run Properties:  status check failed Failed #6298  •  git commit be5773e9a2: Move server kill to different phase
Project Viewers
Branch Review fix/grow-cut-suv-pt
Run status status check failed Failed #6298
Run duration 02m 32s
Commit git commit be5773e9a2: Move server kill to different phase
Committer Bill Wallace
View all properties for this run ↗︎

Test results
Tests that failed  Failures 13
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 24
Tests that passed  Passing 0
View all changes introduced in this branch ↗︎

Tests for review

Failed  study-list/OHIFStudyList.spec.js • 1 failed test

View Output Video

Test Artifacts
OHIF Study List > Desktop resolution > Displays several studies initially Test Replay Screenshots Video
Failed  measurement-tracking/OHIFCornerstoneToolbar.spec.js • 1 failed test

View Output Video

Test Artifacts
OHIF Cornerstone Toolbar > checks if all primary buttons are being displayed Test Replay Screenshots Video
Failed  OHIFVideoDisplay.spec.js • 2 failed tests

View Output Video

Test Artifacts
OHIF Video Display > checks if series thumbnails are being displayed Test Replay Screenshots Video
OHIF Video Display > performs double-click to load thumbnail in active viewport Test Replay Screenshots Video
Failed  measurement-tracking/OHIFMeasurementPanel.spec.js • 1 failed test

View Output Video

Test Artifacts
OHIF Measurement Panel > checks if Measurements right panel can be hidden/displayed Test Replay Screenshots Video
Failed  customization/HangingProtocol.spec.js • 1 failed test

View Output Video

Test Artifacts
OHIF HP > Should display 3 up Test Replay Screenshots Video

The first 5 failed specs are shown, see all 12 specs in Cypress Cloud.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ohif-integration Causes a CS3D/OHIF integraiton build to be run

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant