# How to call CreateNewROI and CropVolume in python script

**URL:** <https://discourse.slicer.org/t/how-to-call-createnewroi-and-cropvolume-in-python-script/40534>\
**Category:** Support\
**Created:** [December 5, 2024, 9:40pm UTC](https://discourse.slicer.org/t/how-to-call-createnewroi-and-cropvolume-in-python-script/40534 "2024-12-05T21:40:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amy\_Morton](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/amy_morton/32/67318_2.png) [@Amy\_Morton](https://discourse.slicer.org/u/Amy_Morton)\
**Post date:** [December 5, 2024, 9:40pm UTC](https://discourse.slicer.org/t/how-to-call-createnewroi-and-cropvolume-in-python-script/40534/1 "2024-12-05T21:40:53Z")

</div>

I would like to repeatedly create roi nodes and use them to create subvolumes… how do I call the underlying functions of the ui pushbuttons in the CropVolume module?

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/e/ae5e5519f412a0f59f9b548eb170f045578ce3b4.png)

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [December 7, 2024, 10:32pm UTC](https://discourse.slicer.org/t/how-to-call-createnewroi-and-cropvolume-in-python-script/40534/2 "2024-12-07T22:32:12Z")

</div>

Here are the general instructions:

[https://slicer.readthedocs.io/en/latest/developer\_guide/python\_faq.html#how-to-find-a-python-function-for-any-slicer-features](https://slicer.readthedocs.io/en/latest/developer_guide/python_faq.html#how-to-find-a-python-function-for-any-slicer-features)

You should avoid calling the callbacks for the buttons and instead have a look at the [underlying logic](https://github.com/Slicer/Slicer/blob/main/Modules/Loadable/CropVolume/Logic/vtkSlicerCropVolumeLogic.h) (it’s in c++ but you can call it from python).

---

<div class="post-metadata">

**Author:** ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)\
**Post date:** [December 8, 2024, 7:16am UTC](https://discourse.slicer.org/t/how-to-call-createnewroi-and-cropvolume-in-python-script/40534/3 "2024-12-08T07:16:59Z")

</div>

> [@Amy\_Morton](#):
>
> create roi nodes and use them to create subvolumes

You may find an example Python function [here](https://gitlab.com/chir-set/RcHacks7/-/blob/f368ea0272ee13dd09cfd224c272113868dd97f1/00-Lib.py.txt#L70).
