# Incomplete Python Wrapping of vtkSegmentation

**URL:** <https://discourse.slicer.org/t/incomplete-python-wrapping-of-vtksegmentation/24396>\
**Category:** Development\
**Created:** [July 19, 2022, 5:48pm UTC](https://discourse.slicer.org/t/incomplete-python-wrapping-of-vtksegmentation/24396 "2022-07-19T17:48:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![edwardwang1](https://avatars.discourse-cdn.com/v4/letter/e/858c86/32.png) [@edwardwang1](https://discourse.slicer.org/u/edwardwang1)\
**Post date:** [July 19, 2022, 5:48pm UTC](https://discourse.slicer.org/t/incomplete-python-wrapping-of-vtksegmentation/24396/1 "2022-07-19T17:48:25Z")

</div>

Hi there,

As per my other [thread](https://discourse.slicer.org/t/converting-segmentationnode-to-labelmap-takes-a-long-time-through-python/23696/8), I have been trying to access some C++ functions through Python. Specifically, I am trying to access the [GetPossibleConversions](https://apidocs.slicer.org/master/classvtkSegmentation.html#a30d20a695d3e12469f4a176afe61f4e6) function of vtkSegmentation. The function was not available through Release Slicer(4.11 and 5.1). I have just built Slicer5.1 (and SlicerRT) from source on Windows 10, and the function is still not available.

Could someone point me to some documentation on how to wrapping VTK objects for Python? My understanding is that the process should be automatic, but I can’t figure out why some functions are wrapped and not others.

Thanks,  
Edward

---

<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:** [July 19, 2022, 11:50pm UTC](https://discourse.slicer.org/t/incomplete-python-wrapping-of-vtksegmentation/24396/2 "2022-07-19T23:50:22Z")

</div>

This method returns a very complex structure (vector of C++ object vectors and associated values), that cannot be automatically Python-wrapped. In the next two weeks I’ll add Python-wrappable, vtkObject based classes for storing segmentation conversion paths and parameters. These will make conversion methods available in Python.

---

<div class="post-metadata">

**Author:** ![edwardwang1](https://avatars.discourse-cdn.com/v4/letter/e/858c86/32.png) [@edwardwang1](https://discourse.slicer.org/u/edwardwang1)\
**Post date:** [July 20, 2022, 12:21am UTC](https://discourse.slicer.org/t/incomplete-python-wrapping-of-vtksegmentation/24396/3 "2022-07-20T00:21:53Z")

</div>

Hey Andras,

Thanks for doing this for me. If there’s any way that I can help (i.e. testing), please let me know. I’m unfamiliar with C++ but willing to learn!

---

<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:** [August 21, 2022, 7:58am UTC](https://discourse.slicer.org/t/incomplete-python-wrapping-of-vtksegmentation/24396/4 "2022-08-21T07:58:12Z")

</div>

The pull request that allows custom segment conversions via Python interface is under review and it’ll be most likely integrated in a few days:

> <https://github.com/Slicer/Slicer/pull/6507>
>
> Previously, complex STL containers were used that were not Python-wrappable. Now… conversion paths and parameters are all VTK objects.
> This allows converting segmentations using a custom path, when there are multiple conversion paths are available.
> For example, multiple conversion paths are available after installing SlicerRT extension, which provides additional segment representations and conversion rules.
