# Crop volume python script

**URL:** https://discourse.slicer.org/t/crop-volume-python-script/30034
**Category:** Development
**Tags:** segmentation, python, volume, cropping
**Created:** [June 14, 2023, 10:20am UTC](https://discourse.slicer.org/t/crop-volume-python-script/30034 "2023-06-14T10:20:14Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Mani\_Barathi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mani_barathi/32/66099_2.png) [@Mani\_Barathi](https://discourse.slicer.org/u/Mani_Barathi)
#### Post date: [June 14, 2023, 10:20am UTC](https://discourse.slicer.org/t/crop-volume-python-script/30034/1 "2023-06-14T10:20:14Z")

</div>

Please help me with the python scripting for crop volume to crop the brain?

---

<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: [June 16, 2023, 2:30pm UTC](https://discourse.slicer.org/t/crop-volume-python-script/30034/2 "2023-06-16T14:30:09Z")

</div>

Do you want to crop with a box-shaped ROI or you want to do skull stripping (blank out everything outside the brain)?

---

<div class="post-metadata">

### Author: ![Mani\_Barathi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mani_barathi/32/66099_2.png) [@Mani\_Barathi](https://discourse.slicer.org/u/Mani_Barathi)
#### Post date: [June 17, 2023, 3:39am UTC](https://discourse.slicer.org/t/crop-volume-python-script/30034/3 "2023-06-17T03:39:13Z")

</div>

I need python script for both blank out everything outside the brain and cropping box-shaped ROI

---

<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: [June 17, 2023, 1:15pm UTC](https://discourse.slicer.org/t/crop-volume-python-script/30034/4 "2023-06-17T13:15:29Z")

</div>

For skull stripping, I would recommend HDBet or SwissSkullStripper extension.

For cropping with an ROI box, you can use the logic class of the Crop volume module.

---

<div class="post-metadata">

### Author: ![Mani\_Barathi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mani_barathi/32/66099_2.png) [@Mani\_Barathi](https://discourse.slicer.org/u/Mani_Barathi)
#### Post date: [June 20, 2023, 11:42am UTC](https://discourse.slicer.org/t/crop-volume-python-script/30034/5 "2023-06-20T11:42:23Z")

</div>

please provide me the python script for swissskullstripper

---

<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: [June 28, 2023, 3:10am UTC](https://discourse.slicer.org/t/crop-volume-python-script/30034/6 "2023-06-28T03:10:43Z")

</div>

SwissSkullStripper is a CLI module that you can use from Python as described [here](https://slicer.readthedocs.io/en/latest/developer_guide/python_faq.html#how-to-run-a-cli-module-from-python).
