Skip to content

Fix: Segmentation "Hide All" fails when switching from 2D to 3D four-…#5995

Open
nithin-trenser wants to merge 3 commits into
OHIF:masterfrom
nithin-trenser:fix-seg-load-3d-hide-error
Open

Fix: Segmentation "Hide All" fails when switching from 2D to 3D four-…#5995
nithin-trenser wants to merge 3 commits into
OHIF:masterfrom
nithin-trenser:fix-seg-load-3d-hide-error

Conversation

@nithin-trenser
Copy link
Copy Markdown
Contributor

@nithin-trenser nithin-trenser commented May 6, 2026

Context

Fix issue: #5948

After loading a segmentation file in the 2D viewport, switching to the 3D four-up viewport causes the "Hide All" functionality to stop working. When the user selects "Hide All", the segmentations remain visible instead of being hidden.

Changes & Results

Refactor segmentation type selection to use explicit viewport-based logic.
For 3D viewports, enforce Surface; for 2D, allow Contour or default to Labelmap.
This change will ensure consistent behavior and prevent unsupported types from propagating

Seg-3d-four-up-hide-error.mp4

Testing

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: Ubuntu 24.04
  • Node version: 22
  • Browser: Chrome 147.0.7727.138

Greptile Summary

Fixes the "Hide All" regression that occurred when switching from a 2D viewport (with a Labelmap/Contour segmentation) to a 3D four-up layout. The root cause was that adding a Surface representation to the 3D viewport fired a SEGMENTATION_REPRESENTATION_MODIFIED event, and the old ?? Labelmap fallback would propagate Surface to fresh 2D viewports instead of defaulting to Labelmap.

  • The new ternary chain for non-3D viewports explicitly guards against Surface being assigned to a 2D viewport: Contour is kept as-is, any other non-Surface truthy value is passed through, and Surface (or null/undefined) falls back to Labelmap.
  • The 3D path is unchanged — Surface is always enforced there.

Confidence Score: 5/5

The change is narrow and well-targeted — it only affects the type-selection step inside the synchroniser callback, and the new logic correctly handles all current representation values (Labelmap, Contour, Surface) as well as null/undefined.

The fix is a single ternary chain that guards 2D viewports against receiving a Surface representation when the synchroniser fires after the 3D viewport is initialised. All existing cases (Contour preserved, Labelmap preserved, Surface → Labelmap, null → Labelmap) are handled correctly, and the 3D path is untouched.

No files require special attention.

Important Files Changed

Filename Overview
extensions/cornerstone/src/services/SyncGroupService/createHydrateSegmentationSynchronizer.ts Refactors the representation-type selection so a 2D viewport can no longer inherit a Surface representation propagated from the newly-added 3D viewport, fixing the "Hide All" regression.

Reviews (3): Last reviewed commit: "Merge branch 'master' into fix-seg-load-..." | Re-trigger Greptile

@netlify
Copy link
Copy Markdown

netlify Bot commented May 6, 2026

Deploy Preview for ohif-dev failed. Why did it fail? →

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

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@sen-trenser
Copy link
Copy Markdown

@sedghi Could you please take a look at this PR and provide your feedback?
Thanks!

@Belbin-GK
Copy link
Copy Markdown
Contributor

@wayfarer3130 Could you please review this PR?

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.

3 participants