Feedbacks / Updating segment editor node after each paint/erase effect

Hi andras, @lassoan

Are there any way to check programmatically using python whether erase/paint has been done?

In our project, we are using erase effect to erase the portion of the segmentation node.
First, we set volume, segmentation, and segment for segment editor widget, and when our resection tool is on then we set to erase effect.

We want update/feedback in each bite of segmentation. But this is not happening.
a small portion of code is given below.

def turnONOrOFF(self, seg):
if self.turnToolSelector.currentText == ‘On’:
if self.resectToolTypeSelector.currentText == ‘Sphere Brush’:
seg.GetSegmentation().SetConversionParameter(‘Smoothing factor’, ‘0.0’)
self.segmentEditorWidget.setActiveEffectByName(“Erase”)
effect = self.segmentEditorWidget.activeEffect()
effect.setCommonParameter(“EditIn3DViews”, “1”)
effect.setCommonParameter(“BrushSphere”, “1”)
effect.setCommonParameter(“BrushAbsoluteDiameter”, 60)
print(self.segmentEditorNode)
else:
self.segmentEditorWidget.setActiveEffectByName(“Scissors”)
effect = self.segmentEditorWidget.activeEffect()
effect.setParameter(‘Shape’, ‘Rectangle’)
else:
self.segmentEditorWidget.setActiveEffectByName(“None”)
seg1 = slicer.mrmlScene.GetNodesByName(“Spine”).GetItemAsObject(0)
seg2 = slicer.mrmlScene.GetNodesByName(‘All Segments’).GetItemAsObject(0)
seg1.GetSegmentation().CreateRepresentation(‘Closed surface’, True)
seg2.GetSegmentation().CreateRepresentation(‘Closed surface’, True)
seg1.Modified()
seg2.Modified()

I have printed segmentEditorNode to see the attributes. I would like to see these attributes in every bite during erase effect.

What are possible options ?

Thank you !!

You can add an observer to various modified events of the segmentation node. It notifies you not just about paint/erase but about all editing operations.

Thank you @lassoan . It is really helpful.