# Resample segments in segmentation using Python scripting

**URL:** <https://discourse.slicer.org/t/resample-segments-in-segmentation-using-python-scripting/26411>\
**Category:** Development\
**Tags:** segmentation\
**Created:** [November 18, 2022, 11:57pm UTC](https://discourse.slicer.org/t/resample-segments-in-segmentation-using-python-scripting/26411 "2022-11-18T23:57:46Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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:** [November 23, 2022, 10:09pm UTC](https://discourse.slicer.org/t/resample-segments-in-segmentation-using-python-scripting/26411/4 "2022-11-23T22:09:22Z")

</div>

This should resample all the segments in the segmentation using the current geometry:

```python
segmentationNode = getNode('Segmentation')
segGeomLogic = slicer.vtkSlicerSegmentationGeometryLogic()
segGeomLogic.SetInputSegmentationNode(segmentationNode)
segGeomLogic.SetSourceGeometryNode(segmentationNode)
segGeomLogic.CalculateOutputGeometry()
segGeomLogic.ResampleLabelmapsInSegmentationNode()

```

---

_[View the full topic](https://discourse.slicer.org/t/resample-segments-in-segmentation-using-python-scripting/26411)._
