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

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?

All Slicer features are available to be used without GUI, from Python scripting. See many examples of automating segmentation using Python script here:

Great! Thanks a lot for the help!