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

**URL:** <https://discourse.slicer.org/t/issue-with-intersect-segment-editor-effect-programming-others-are-fine/27872>\
**Category:** Support\
**Created:** [February 16, 2023, 5:29pm UTC](https://discourse.slicer.org/t/issue-with-intersect-segment-editor-effect-programming-others-are-fine/27872 "2023-02-16T17:29:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nrex45](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/nrex45/32/7664_2.png) [@nrex45](https://discourse.slicer.org/u/nrex45)\
**Post date:** [February 16, 2023, 5:29pm UTC](https://discourse.slicer.org/t/issue-with-intersect-segment-editor-effect-programming-others-are-fine/27872/1 "2023-02-16T17:29:15Z")

</div>

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](https://slicer.readthedocs.io/en/latest/developer_guide/modules/segmenteditor.html#effect-parameters)

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?

```auto
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()

```

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [February 16, 2023, 7:26pm UTC](https://discourse.slicer.org/t/issue-with-intersect-segment-editor-effect-programming-others-are-fine/27872/2 "2023-02-16T19:26:16Z")

</div>

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

```python
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()

```

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [February 19, 2023, 12:20am UTC](https://discourse.slicer.org/t/issue-with-intersect-segment-editor-effect-programming-others-are-fine/27872/3 "2023-02-19T00:20:55Z")

</div>

A post was split to a new topic: [Processing slows down after many iterations](https://discourse.slicer.org/t/processing-slows-down-after-many-iterations/27910)
