Skip to content

Conversation

@dxlin
Copy link
Contributor

@dxlin dxlin commented Jan 20, 2026

Context

A potential solution for
#5728
(Also a test noted in #5498)

Overlay UI is missing segmentations when they are added then removed from the segmentation panel as it is still contained in the viewport's display set list.

Changes & Results

Segmentation displayset layer is removed as part of the segmentation delete routine. Additionally, for segmentations created within viewer and not from an image source, it is cleaned up from the overall display set list (so as not to clutter the UI).

Testing

User is now able to add segmentation via overlay UI, delete (whether by accident or on purpose), and still add it back to same viewport via overlay UI without refreshing page.

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

System:
OS: Windows 11 10.0.26200
CPU: (16) x64 Intel(R) Core(TM) i7-10700 CPU @ 2.90GHz
Memory: 2.85 GB / 15.72 GB
Binaries:
Node: 22.16.0
Yarn: 1.22.22
npm: 10.9.2
Browsers:
Chrome: 144.0.7559.59
Edge: Chromium (143.0.3650.66)

  • [] OS:
  • [] Node version:
  • [] Browser:

dxlin added 2 commits January 19, 2026 21:13
-resolves segmentation missing from list (from when PACS)
-safety check for missing representation (for when segmentation is deleted)
@netlify
Copy link

netlify bot commented Jan 20, 2026

Deploy Preview for ohif-dev ready!

Name Link
🔨 Latest commit da73b2f
🔍 Latest deploy log https://app.netlify.com/projects/ohif-dev/deploys/698d4af2b597510008deb288
😎 Deploy Preview https://deploy-preview-5729--ohif-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@dxlin
Copy link
Contributor Author

dxlin commented Jan 20, 2026

Quick note that this only resolves for segmentations, RTStructs are still under investigation (is not able to be loaded a second time after the first delete).

@jbocce jbocce self-requested a review January 20, 2026 18:45
@jbocce
Copy link
Collaborator

jbocce commented Jan 20, 2026

Fixes #5728
Closes OHIF-2425

@jbocce jbocce changed the title Fix/update viewport ds list upon seg delete Fix/update viewport ds list upon seg delete - OHIF-2425 Jan 21, 2026
@dxlin
Copy link
Contributor Author

dxlin commented Jan 26, 2026

Hi @jbocce,

Latest commit for PR now correctly works for both segmentations and RTStructs. removeDisplaySetLayer handles segmentation representation so was not needed to be removed again.

As the commands for delete segmentation and removeDisplaySetLayer are pretty close, would it make sense to incorporate the displaySetService.deleteDisplaySet(segmentationid) snippet to removeDisplaySetLayer (this should also fix nothing happening when a segmentation created within the ohif is removed as a layer from overlay menu unless that is desired behaviour)?

Copy link
Collaborator

@jbocce jbocce left a comment

Choose a reason for hiding this comment

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

Thanks very much for this. See my comments. Also as I noted in a private conversation with you please address removing a segmentation from a viewport as well. See the video...

ScreenHunter.Jan.29.10.34.mp4

@dxlin
Copy link
Contributor Author

dxlin commented Jan 30, 2026

Added relevant code within removeSegmentationFromViewport as well; however, after pulling most recent commits (likely Jan. 27 ones) I'm running into a number of new issues with segmentations, will try to work through and apply suggestions noted in comments as well.

An example of new issue is I'm sometimes finding segmentations previously removed added back in now (additionally, adding segmentations to one viewport will end up adding it to other viewports with images that share a FoR).

@jbocce jbocce changed the title Fix/update viewport ds list upon seg delete - OHIF-2425 fix(segmentation overlay): update viewport ds list upon seg delete - OHIF-2425 Feb 12, 2026
- add segmentationExists check to getSopClassHandlerModule
- now firing SEGMENTATION_REMOVED and SEGMENTATION_REPRESENTATION_REMOVED events
- centralized segmentation removal in a listener
- when a segmentation is deleted (completely), remove it from all viewports it overlays
- when a segmentation is removed from a viewport, remove it as overlay from the viewport
eventTarget.removeEventListener(
csToolsEnums.Events.SEGMENTATION_REMOVED,
this._onSegmentationModifiedFromSource
this._onSegmentationRemovedFromSource
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this makes more sense than what was there before. Now we actually fire the SEGMENTATION_REMOVED event!

eventTarget.removeEventListener(
csToolsEnums.Events.SEGMENTATION_REPRESENTATION_REMOVED,
this._onSegmentationRepresentationModifiedFromSource
this._onSegmentationRepresentationRemovedFromSource
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same goes for this one.

loadPromises[SOPInstanceUID] &&
cachedRTStructsSEG.has(rtDisplaySet.displaySetInstanceUID)
cachedRTStructsSEG.has(rtDisplaySet.displaySetInstanceUID) &&
_segmentationExists(rtDisplaySet)
Copy link
Collaborator

Choose a reason for hiding this comment

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

When an RTSTRUCT contour segmentation was deleted completed and then reloaded it wouldn't. So this check forces the reload when it no longer exists.

@jbocce jbocce requested a review from sedghi February 12, 2026 03:41

const displaySet = displaySetService.getDisplaySetByUID(segmentationId);
if (displaySet) {
commandsManager.runCommand('removeDisplaySetLayer', {
Copy link
Member

Choose a reason for hiding this comment

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

what is removeDisplaySetLayer? i can't find it in our codebase

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