# AddSegment error

**URL:** https://discourse.slicer.org/t/addsegment-error/29080
**Category:** Development
**Tags:** segmentation
**Created:** [April 24, 2023, 5:28am UTC](https://discourse.slicer.org/t/addsegment-error/29080 "2023-04-24T05:28:38Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![pearsonm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pearsonm/32/18514_2.png) [@pearsonm](https://discourse.slicer.org/u/pearsonm)
#### Post date: [April 24, 2023, 5:28am UTC](https://discourse.slicer.org/t/addsegment-error/29080/1 "2023-04-24T05:28:38Z")

</div>

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](https://discourse.slicer.org/t/programmatically-create-a-segmentationnode-and-labelmapnode-from-polygon-coordinates/8448/4):

The last line  
`segmentationNode.GetSegmentation().AddSegment(segment)`  
results in the error: [VTK] AddSegment: Unable to create master representation!

How do you create the master representation?

---

<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: [April 24, 2023, 11:12am UTC](https://discourse.slicer.org/t/addsegment-error/29080/2 "2023-04-24T11:12:32Z")

</div>

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:

> <https://github.com/PerkLab/SlicerSandbox/blob/master/ImportOsirixROI/ImportOsirixROI.py>

Why do you need to create a segment from parallel contours? Are you implementing an importer for a new file format?

---

<div class="post-metadata">

### Author: ![pearsonm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pearsonm/32/18514_2.png) [@pearsonm](https://discourse.slicer.org/u/pearsonm)
#### Post date: [April 24, 2023, 11:44am UTC](https://discourse.slicer.org/t/addsegment-error/29080/3 "2023-04-24T11:44:07Z")

</div>

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.
