Hello,
I am working on a custom module where I need to add many (360) objects to an existing segmentation node. Although the code seems very simple it takes hours to finish. I am not sure what causes the slowdown. Maybe there is a way to add all objects in a batch without calling AddSegmentFromClosedSurfaceRepresentation for each object. I will greatly appreciate any help.
My code:
segmentationNode = slicer.mrmlScene.GetFirstNodeByName("My segmentation")
for wedge in wedges:
wedgeID = segmentationNode.AddSegmentFromClosedSurfaceRepresentation(wedge["wedgePD"], wedge["seg_name"], wedge["seg_colour"])
The time to execute AddSegmentFromClosedSurfaceRepresentation increases with the number of wedges added. Below is the time to execution time for first 30 steps
1st call to AddSegmentFromClosedSurfaceRepresentation finished in 0.009
2nd call to AddSegmentFromClosedSurfaceRepresentation finished in 0.188
3rd call to AddSegmentFromClosedSurfaceRepresentation finished in 0.248
…
10th call to AddSegmentFromClosedSurfaceRepresentation finished in 0.448
…
30th call to AddSegmentFromClosedSurfaceRepresentation finished in 1.101