# Resample segmentation to higher resolution

**URL:** <https://discourse.slicer.org/t/resample-segmentation-to-higher-resolution/37425>\
**Category:** Development\
**Tags:** segmentation, segmentations, segment-editor\
**Created:** [July 17, 2024, 11:00am UTC](https://discourse.slicer.org/t/resample-segmentation-to-higher-resolution/37425 "2024-07-17T11:00:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mabe2416](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@mabe2416](https://discourse.slicer.org/u/mabe2416)\
**Post date:** [July 17, 2024, 11:00am UTC](https://discourse.slicer.org/t/resample-segmentation-to-higher-resolution/37425/1 "2024-07-17T11:00:22Z")

</div>

Operating system: Windows 10  
Slicer version: 5.6.2

Hi,  
I am trying to run the code of the script repository: [Script repository — 3D Slicer documentation](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#resample-segmentation-to-higher-resolution)

However, I get: NameError: name ‘segmentationGeometryLogic’ is not defined.

And if I add, segmentationGeometryLogic = slicer.vtkSlicerSegmentationGeometryLogic()

AttributeError: ‘vtkSlicerSegmentationsModuleLogicPython.vtkSlicerS’ object has no attribute ‘SetReferenceImageGeometryInSegmentationNode’

Any help would be greatly appreciated!  
Thanks,  
Maria

---

<div class="post-metadata">

**Author:** ![Barrie](https://avatars.discourse-cdn.com/v4/letter/b/838e76/32.png) [@Barrie](https://discourse.slicer.org/u/Barrie)\
**Post date:** [August 27, 2025, 1:05pm UTC](https://discourse.slicer.org/t/resample-segmentation-to-higher-resolution/37425/2 "2025-08-27T13:05:29Z")

</div>

I just tripped over this too. The example is clearly missing some code.

Did you find a solution that works? If so, can you share it? I’m looking to try this…

Thanks!!!

---

<div class="post-metadata">

**Author:** ![Barrie](https://avatars.discourse-cdn.com/v4/letter/b/838e76/32.png) [@Barrie](https://discourse.slicer.org/u/Barrie)\
**Post date:** [August 27, 2025, 1:08pm UTC](https://discourse.slicer.org/t/resample-segmentation-to-higher-resolution/37425/3 "2025-08-27T13:08:19Z")

</div>

Found this, which might be helpful. Haven’t tried it yet, YMMV:

> [@Change segmentation oversampling factor](https://discourse.slicer.org/t/change-segmentation-oversampling-factor/19025/5):
>
> @lassoan Thanks for your help again! The source code of vtkSlicerSegmentationGeometryLogic::ResampleLabelmapsInSegmentationNode is really helpful, and I finally completed this function correctly based on the source code. The issues aren’t technical issues, and since it works right now, there’s no needs to worry about upgrading. For those who are interested, here is my code. segmentIDs = vtk.vtkStringArray() segmentationNode.GetSegmentation().GetSegmentIDs(segmentIDs) #Create desired geometry…

---

<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:** [August 27, 2025, 1:21pm UTC](https://discourse.slicer.org/t/resample-segmentation-to-higher-resolution/37425/4 "2025-08-27T13:21:00Z")

</div>

It would be great if someone could submit a PR to fix the script.

---

<div class="post-metadata">

**Author:** ![Barrie](https://avatars.discourse-cdn.com/v4/letter/b/838e76/32.png) [@Barrie](https://discourse.slicer.org/u/Barrie)\
**Post date:** [August 27, 2025, 1:31pm UTC](https://discourse.slicer.org/t/resample-segmentation-to-higher-resolution/37425/5 "2025-08-27T13:31:44Z")

</div>

Wish I were less of a “script kiddie in 3D Slicer land”, that’d be fun.

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [August 27, 2025, 1:36pm UTC](https://discourse.slicer.org/t/resample-segmentation-to-higher-resolution/37425/6 "2025-08-27T13:36:43Z")

</div>

This should do it

> <https://github.com/Slicer/Slicer/pull/8679>
>
> Re https://discourse.slicer.org/t/resample-segmentation-to-higher-resolution/374…25

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [August 27, 2025, 6:27pm UTC](https://discourse.slicer.org/t/resample-segmentation-to-higher-resolution/37425/7 "2025-08-27T18:27:07Z")

</div>

🙏 @cpinter 💯

The pull request has been reviewed & integrated 🚀
