Looping Over Segmentation Algorithm Targets Wrong Segment

We have got our segmentation algorithm working! Now we are looping over it to allow doctors to segment multiple vertebrae. Whenever we run our code in a for loop, the seed around the second point, F-2(purple in the diagram on the yellow slice), works. However, when we run the effect function, the algorithm works perfectly fine but adds the segmented piece to the first segmentation. Does anyone have any ideas why?

We think the issue is in these lines of code when looping:

segmentationNode.AddSegmentFromClosedSurfaceRepresentation(lumbarSeed.GetOutput(), “Lumbar-” + str(x+1), [random(), random(), random()])
segmentEditorWidget = slicer.qMRMLSegmentEditorWidget()
segmentEditorNode = slicer.vtkMRMLSegmentEditorNode()

Screen Shot 2020-07-09 at 9.41.52 AM

1 Like

This is exactly how the effect is supposed to work: incrementally add more parts to the current segment with each click.

If you want to create a separate segment for each click then create and select a new segment before each click.

1 Like

We also looked in the class reference linked below but we did not find anything.