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()
segmentEditorWidget.setMRMLScene(slicer.mrmlScene)
segmentEditorNode = slicer.vtkMRMLSegmentEditorNode()
slicer.mrmlScene.AddNode(segmentEditorNode)
segmentEditorWidget.setMRMLSegmentEditorNode(segmentEditorNode)
segmentEditorWidget.setSegmentationNode(segmentationNode)
segmentEditorWidget.setMasterVolumeNode(masterVolumeNode)