I am trying to write a function that is triggered when the user selects a different segmentation in the segment editor module. I searched for such event methods but could not find the right one. My guess is that there is an event for the DisplayNode of the corresponding segmentation that is triggered when selecting a different segmentation. I tried to add an observer to each segmentation node like this without success.
# I tried this
segmentationNode.AddObserver(slicer.vtkMRMLSegmentationNode.SegmentationChangedEvent, self.onSegChanged)
# and this
segmentationNode.AddObserver(slicer.vtkMRMLSegmentationDisplayNode.MenuEvent, self.onSegChanged)
Here is a screenshot to further illustrate what I want to achieve.
I want to create an event method that triggers when “Segmentation_1” is changed to a different segmentation.
Hello Raj,
thanks for your reply, sadly I don’t work on this project anymore… I could not find a solution for this, but the problem was not that critical. It was a nice-to-have feature of the slicer plugin I made.
Hi @lassoan Andras Lasso,
Thanks for your response. segmentationNodeChanged signal didn’t work for my problem. This sends the signal when ever I changed the segmentation node, i.e., when a new image is loaded. currentSegmentIDChanged worked as I expected. This sends the signal whenever I change selection of the segment in the segment editor widget.