# Threshold masking

**URL:** <https://discourse.slicer.org/t/threshold-masking/6833>\
**Category:** Support\
**Tags:** masking\
**Created:** [May 17, 2019, 12:53pm UTC](https://discourse.slicer.org/t/threshold-masking/6833 "2019-05-17T12:53:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![prorai](https://avatars.discourse-cdn.com/v4/letter/p/e8c25b/32.png) [@prorai](https://discourse.slicer.org/u/prorai)\
**Post date:** [May 17, 2019, 12:53pm UTC](https://discourse.slicer.org/t/threshold-masking/6833/1 "2019-05-17T12:53:32Z")

</div>

How can i apply threshold for masking in segmentation process, using python code?

---

<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:** [May 17, 2019, 12:55pm UTC](https://discourse.slicer.org/t/threshold-masking/6833/2 "2019-05-17T12:55:01Z")

</div>

See [examples of using segment editor from Python scripts in the script repository](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#How_to_run_segment_editor_effects_from_a_script).

---

<div class="post-metadata">

**Author:** ![prorai](https://avatars.discourse-cdn.com/v4/letter/p/e8c25b/32.png) [@prorai](https://discourse.slicer.org/u/prorai)\
**Post date:** [May 17, 2019, 2:54pm UTC](https://discourse.slicer.org/t/threshold-masking/6833/3 "2019-05-17T14:54:44Z")

</div>

> <https://gist.github.com/lassoan/2d5a5b73645f65a5eb6f8d5f97abf31b>

I’m using this seed grow example but i want to use threshold masking with this ,  
i tried effect.self().onUseForPaint() and its not working

---

<div class="post-metadata">

**Author:** ![prorai](https://avatars.discourse-cdn.com/v4/letter/p/e8c25b/32.png) [@prorai](https://discourse.slicer.org/u/prorai)\
**Post date:** [May 21, 2019, 2:39pm UTC](https://discourse.slicer.org/t/threshold-masking/6833/4 "2019-05-21T14:39:58Z")

</div>

Hi @lassoan , i tried seed grow with masking(applying threshold for paint) , and it works if i put the python code in python interactor in slicer .

same code i have added in my scriptable module and seed grow works normally but i’m not seeing masking is applied before seefGrow.
