# Perform "threshold" and "fill between slices" directly in python

**URL:** <https://discourse.slicer.org/t/perform-threshold-and-fill-between-slices-directly-in-python/13998>\
**Category:** Support\
**Created:** [October 12, 2020, 2:28pm UTC](https://discourse.slicer.org/t/perform-threshold-and-fill-between-slices-directly-in-python/13998 "2020-10-12T14:28:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fredrik](https://avatars.discourse-cdn.com/v4/letter/f/cab0a1/32.png) [@fredrik](https://discourse.slicer.org/u/fredrik)\
**Post date:** [October 12, 2020, 2:28pm UTC](https://discourse.slicer.org/t/perform-threshold-and-fill-between-slices-directly-in-python/13998/1 "2020-10-12T14:28:35Z")

</div>

Hi, I have a binary image where slices are already labeled, and want to generate a volume by interpolating between slices. I was able to do this easily in the 3D-slicer GUI by performing 1) a threshold segmentation and then 2) a fill between slices operation. However I wonder if it is possible to perform these operations directly in python without using the GUI?  
Thanks,  
Fredrik

---

<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:** [October 12, 2020, 2:31pm UTC](https://discourse.slicer.org/t/perform-threshold-and-fill-between-slices-directly-in-python/13998/2 "2020-10-12T14:31:02Z")

</div>

All Slicer features are available to be used without GUI, from Python scripting. See many examples of automating segmentation using Python script here: [https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#How\_to\_run\_segment\_editor\_effects\_from\_a\_script](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#How_to_run_segment_editor_effects_from_a_script)

---

<div class="post-metadata">

**Author:** ![fredrik](https://avatars.discourse-cdn.com/v4/letter/f/cab0a1/32.png) [@fredrik](https://discourse.slicer.org/u/fredrik)\
**Post date:** [October 13, 2020, 12:06pm UTC](https://discourse.slicer.org/t/perform-threshold-and-fill-between-slices-directly-in-python/13998/3 "2020-10-13T12:06:36Z")

</div>

Great! Thanks a lot for the help!
