# Issue with Margin Effect margin value sign

**URL:** <https://discourse.slicer.org/t/issue-with-margin-effect-margin-value-sign/19861>\
**Category:** Development\
**Tags:** segmentation\
**Created:** [September 26, 2021, 7:16am UTC](https://discourse.slicer.org/t/issue-with-margin-effect-margin-value-sign/19861 "2021-09-26T07:16:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sharada](https://avatars.discourse-cdn.com/v4/letter/s/ba8739/32.png) [@Sharada](https://discourse.slicer.org/u/Sharada)\
**Post date:** [September 26, 2021, 7:16am UTC](https://discourse.slicer.org/t/issue-with-margin-effect-margin-value-sign/19861/1 "2021-09-26T07:16:12Z")

</div>

Hello,

I have a weird issue with the margin effect in the Segmentation module. The mask seems to grow when I try to shrink it. I apologize in advance if there might be a simple oversight.

Code:

slicer.app.processEvents()  
segmentEditorWidget.setActiveEffectByName(“Margin”)  
effect = segmentEditorWidget.activeEffect()  
effect.setParameter(“Operation”, “Shrink”)  
effect.setParameter(“MarginSize”, “1”)  
effect.self().onApply()

Before:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/9/49ff150068094b158ce09109d50b382a6b8ead93.jpeg)

After:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/7/2/72ae9e6e0f3ce9dd7ad9b85703fe560e07f24e62.jpeg)

What am I doing wrong?

Thanks,  
Sharada

---

<div class="post-metadata">

**Author:** ![Sharada](https://avatars.discourse-cdn.com/v4/letter/s/ba8739/32.png) [@Sharada](https://discourse.slicer.org/u/Sharada)\
**Post date:** [September 26, 2021, 11:08pm UTC](https://discourse.slicer.org/t/issue-with-margin-effect-margin-value-sign/19861/2 "2021-09-26T23:08:17Z")

</div>

Never mind, I had to pass in -1 instead of 1 for margin size. It seems a little strange to do when the operation is already specified as shrink.

---

<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:** [September 27, 2021, 3:09am UTC](https://discourse.slicer.org/t/issue-with-margin-effect-margin-value-sign/19861/3 "2021-09-27T03:09:09Z")

</div>

There is no such parameter of the Margin Effect as `Operation` or `MarginSize`. The list of parameter names are described in the [Developer documentation]) [Segment editor — 3D Slicer documentation](https://slicer.readthedocs.io/en/latest/developer_guide/modules/segmenteditor.html#margin)).

---

<div class="post-metadata">

**Author:** ![Sharada](https://avatars.discourse-cdn.com/v4/letter/s/ba8739/32.png) [@Sharada](https://discourse.slicer.org/u/Sharada)\
**Post date:** [September 27, 2021, 3:16am UTC](https://discourse.slicer.org/t/issue-with-margin-effect-margin-value-sign/19861/4 "2021-09-27T03:16:44Z")

</div>

Okay, makes perfect sense what I was doing wrong now. Thank you!
