# Unable to set Logical effect's parameter from another effect

**URL:** <https://discourse.slicer.org/t/unable-to-set-logical-effects-parameter-from-another-effect/23790>\
**Category:** Support\
**Tags:** segmentation\
**Created:** [June 9, 2022, 9:07am UTC](https://discourse.slicer.org/t/unable-to-set-logical-effects-parameter-from-another-effect/23790 "2022-06-09T09:07:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dwij\_Mistry](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/dwij_mistry/32/15265_2.png) [@Dwij\_Mistry](https://discourse.slicer.org/u/Dwij_Mistry)\
**Post date:** [June 9, 2022, 9:07am UTC](https://discourse.slicer.org/t/unable-to-set-logical-effects-parameter-from-another-effect/23790/1 "2022-06-09T09:07:42Z")

</div>

use case:  
in one of our custom effect we want to perform union operation from logical effect.

problem:  
when we are setting

```auto
# selecting UNION OPERATION
slicer.util.getModuleWidget("SegmentationEditor").editor.OptionsGroupBox.EffectsOptionsFrame.Logical_operatorsOptionsFrame.methodSelectorComboBox.setCurrentIndex(1)

# selecting MODIFITER SEGMENT 
slicer.util.getModuleWidget("SegmentationEditor").editor.OptionsGroupBox.EffectsOptionsFrame.Logical_operatorsOptionsFrame.qMRMLSegmentsTableView.setSelectedSegmentIDs(['Segment_1'])

# selecting SELECTED SEGMENT
slicer.util.getModuleWidget("SegmentationEditor").editor.segmentTableGroupBox.Form.SegmentsTableView.setSelectedSegmentIDs(['Segment_2'])

# LOGICAL APPLY BUTTON CLICK (performing operation)
slicer.util.getModuleWidget("SegmentationEditor").editor.OptionsGroupBox.EffectsOptionsFrame.Logical_operatorsOptionsFrame.SegmentEditorLogicalEffectApply.click()

```

Modifier segment is selected by the code. but still Apply button is not enabled, so that we are unable to click the Apply button.

Moreover, is there any difference if we are selecting a segment by a code and when we are selecting a segment by mouse click operation?

Thank you very much in advance.

---

<div class="post-metadata">

**Author:** ![mau\_igna\_06](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mau_igna_06/32/9056_2.png) [@mau\_igna\_06](https://discourse.slicer.org/u/mau_igna_06)\
**Post date:** [June 9, 2022, 10:14pm UTC](https://discourse.slicer.org/t/unable-to-set-logical-effects-parameter-from-another-effect/23790/2 "2022-06-09T22:14:28Z")

</div>

Please look at this  
[https://slicer.readthedocs.io/en/latest/developer\_guide/modules/segmenteditor.html](https://slicer.readthedocs.io/en/latest/developer_guide/modules/segmenteditor.html)

And the set the parameters correspondingly

Then do:  
Effect.self.onApply()

Or something pretty similar

Hope it helps

---

<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:** [June 10, 2022, 2:05pm UTC](https://discourse.slicer.org/t/unable-to-set-logical-effects-parameter-from-another-effect/23790/3 "2022-06-10T14:05:02Z")

</div>

Yes, the correct way to change segmentation parameters is by modifying the segment editor node, and to run any processing you can call the methods of the segment editor effect object.

We cannot prevent developers directly manipulating Qt widgets, but then correct behavior cannot be guaranteed. If you just rearrange the layout or hide some buttons. However, simulating button clicks in arbitrary state of the effect will probably not work.
