Side-by-side separate segmentation editing

Thanks very much for previous assistance.
I’m trying to create side-by-side views of different volumes (same patient, different MR acquisition sequences), with different segmentations active in each view. I have created two segmentation nodes, and I’m using the Segment Editor module.

  self.theSegmentEditorBase = slicer.modules.segmenteditor.widgetRepresentation()
  self.theSegmentEditorWidget = self.theSegmentEditorBase.self()

The problem I run into is that, I think to change which volume I’m segmenting, I have to change the Segment Editor master volume:

  self.theSegmentEditorWidget.editor.setMasterVolumeNode(self.SSFPVolumeNode)

When I do this, the displayed volume in both slice views changes to the master volume, and resets the displayed slice to the middle of the range. Also, the segmentation that I’m editing and the mouse cursor appear in both slice views, even when I get them to show different volumes.
I tried

        sliceComposite.SetDoPropagateVolumeSelection(False)

for each of the slice views, but it doesn’t seem to have an effect in this case.
Is there a way to accomplish what I’m trying to do?
Thanks.

I’ve added two features (available in tomorrow’s build) that will allow parallel editing:

  1. Automatic display of master node can be now disabled

  2. Editing of Segmentation nodes is restricted to those views where segmentation node is displayed in.

See details here:

https://github.com/Slicer/Slicer/commit/f039680b594552ebb7a37952771fcd7a7a1e4c0b

You may also want to decouple slice browsing between two sets of views (when you move slice views by Shift+MouseMove). To achieve that, make sure the two sets of views use a different view group.

1 Like

Thank you very much, I’ve downloaded the newest build, and I’ll try this out.
Regarding decoupling slice browsing, I’m actually linking the two slice views so that the slices shown are in the same axis and same position. With linking on, that’s working as I need it to.
Thanks again.

I’ve implemented the change, and it’s working well. The only thing I noticed is that the available Undo actions resets every time the segmentation node and master volume change. Is this the expected behaviour?

Yes, it is expected. History is stored in the Segment Editor node. You can have two Segment Editor widgets in your module GUI to avoid the need of changing the segmentation node and just hide the one that you don’t use.

1 Like

I’ve started trying to set up two segment editors, though I noticed that there is a singleton tag associated with vtkMRMLSegmentEditorNode in SegmentEditor.py. I’ve tried a couple of ways to define two editors, but without success. How can I create two functioning segment editors?

We haven’t considered having two segment editor active at the same time when we designed it, but it may be possible to set up.

Segment editor node does not have to be singleton, you can have more such nodes in the scene, just make sure you set the correct one in each segment editor widget.

Each widget will manage those views where the associated segmentation node is displayed in. So, you’ll have to make sure that you set up view node IDs for each segmentation node accordingly.

Can you tell us a bit about your workflow? Why do you find it useful to have two active segment editors?

Here’s a screenshot of what I have so far. It’s side-by-side MR image sets for the same patient’s leg. There is a common set of controls. I’m trying to get the Undo/Redo buttons working.
Right now, the segment editor’s active segmentation and master volume automatically change when the mouse moves from the Red to the Yellow view. When we were discussing this a few months ago, you said that every time the segmentation is changed in the editor, the undo history is forgotten, and suggested I could keep the undo history for both segmentations if I didn’t have to keep switching the active segmentation in the same editor.
Ultimately what I want is to be able to click “Undo” and have the previous change be undone, whichever one of the segmentations was last changed.

Why do you need to switch between two segmentation nodes? Would it be possible to keep all segments that you would like to edit in one segmentation?

I don’t think I can, from my understanding. The image sets have different dimensions, so I can’t use the same master volume node or reference image geometry.

You don’t need exactly matching geometry. You can choose a resolution in the segmentation’s internal labelmap that is sufficient for both volumes.

That’s a good suggestion, but I don’t think it will work for my application. I’m interested in the specific voxel values that correspond to the label maps.
I’ll shelve this task for now, and revisit it later. Perhaps I can request a feature of retaining undo histories for multiple Segmentations in the same segment editor?

Unless we have strong use cases, it is unlikely that we’ll implement maintaining history for multiple Segmentations (due to additional complexity of implementation and potentially increased memory need). If you really want to have such a feature then maybe we could add the necessary API to allow external implementation (for example, emit save state signals that you can use to maintain your own segmentation history objects).

That sounds good, thanks. I appreciate it.