Issue with "INTERSECT" segment editor effect programming (others are fine)

Hello All,

I’ve been working witht the segmentEditor Widget based on the code examples on the dev site and have been referencing the info here: Segment editor — 3D Slicer documentation

But for whatever reason I cannot get the “INTERSECT” option to work. I am able to get every other option (COPY, UNION, SUBTRACT, INVERT, CLEAR, FILL) to work properly, but when I choose INTERSECT it simply returns the first segment I pass, and not the overlap between the two.

My code can be found below… Has anybody been able to get INTERSECT to work properly?

segmentEditorWidget = slicer.qMRMLSegmentEditorWidget()
    segmentEditorWidget.setMRMLScene(slicer.mrmlScene)
    segmentEditorNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLSegmentEditorNode")
    segmentEditorWidget.setMRMLSegmentEditorNode(segmentEditorNode)
    
    segmentEditorWidget.setSegmentationNode(segmentationNodeNew)
    segmentEditorWidget.setActiveEffectByName("Logical operators")
    
    effect = segmentEditorWidget.activeEffect()
    effect.self().scriptedEffect.setParameter("Operation","UNION")
    selectedSegmentID = effect.self().scriptedEffect.parameterSetNode().GetSelectedSegmentID()
    effect.self().scriptedEffect.setParameter("BypassMasking", 1)
    effect.self().scriptedEffect.setParameter("ModifierSegmentID",segmentationNodeNew.GetSegmentation().GetNthSegmentID(1))
    effect.self().onApply()

This code snippet works well for me on Slicer-5.2.1:

segmentEditorWidget = slicer.modules.segmenteditor.widgetRepresentation().self().editor
segmentEditorWidget.setActiveEffectByName("Logical operators")
effect = segmentEditorWidget.activeEffect()
effect.self().scriptedEffect.setParameter("Operation","INTERSECT")
effect.self().scriptedEffect.setParameter("BypassMasking", "1")
effect.self().scriptedEffect.setParameter("ModifierSegmentID","Segment_2")
effect.self().onApply()
1 Like

A post was split to a new topic: Processing slows down after many iterations