Convert planar contour to ribbon model in code

Hi there,
I have loaded a segmentation into 3D slicer as a planar contour, and am able to convert these planar contours into a Ribbon model representation manually in the segmentations module, by pressing ‘create’ for the Ribbon model under the Representations tab. I need to do this in order to see the contours in 2D view.

However, I have been searching but I cannot find out how I can do this conversion from planar contours to ribbon model programmatically in script. Could you help me?

I found the solution, it was very simple. In case anyone is interested:
segmentationNode = getNode(“Segmentation”)
segmentationNode.GetSegmentation().CreateRepresentation(“Ribbon model”)

This will create a representation in all segments, using the conversion path with the lowest cost. Conversion starts from the master representation, which in my case was “Planar contour”

1 Like