April 24, 2023, 5:28am
Using a local build of 5.3.0-2023-03-04 r31618 / b0b9be5 on Ubuntu 23.02 I get an error when I run the create segmentation node snippet from
Programmatically Create a SegmentationNode and LabelMapNode from Polygon Coordinates:
The last line
results in the error: [VTK] AddSegment: Unable to create master representation!
How do you create the master representation?
April 24, 2023, 11:12am
It is quite an old release example. Maybe now you need to set the master representation to planar contours. Or maybe you just haven’t installed SlicerRT extension.
Anyway, you can find a complete implementation for n this module that imports parallel contours from an OsiriX segmentation file that should work well:
This file has been truncated.
import vtk, qt, ctk, slicer
from slicer.ScriptedLoadableModule import *
from slicer.util import VTKObservationMixin
"""Uses ScriptedLoadableModule base class, available at:
def __init__(self, parent):
self.parent.title = "Import OsiriX ROI"
self.parent.categories = ["Utilities"]
Why do you need to create a segment from parallel contours? Are you implementing an importer for a new file format?
April 24, 2023, 11:44am
I was using it as an example of creating a segmentation from datapoints.
I am creating a module to process nuclear medicine dynamic images and one of the steps involves drawing a rectangular ROI to do count statistics. I currently use the scissors rectangle tool for the ROI but it would be better if the ROI could be adjusted after creation.
I want to make a box ROI in Markups and then convert it to a binary labelmap so I can run Mask Volume. The code snippet looked like it would help make the labelmap.