Can we split an array of points in islands?

My final goal is to measure cross-section area of arterial segments.

The image below shows a segmented aorto-iliac aneurysm with a centerline in theaorta and the left iliac artery. The cross-section is moved along the Centerline Model with Cross-Section analysis module.

At the iliac level, two islands of the same segment are naturally drawn in the Red slice view. The code below gets the contour of both iliacs in an array of points, and creates a model with a 2D Delaunay filter. It’s necessarily a single model, corresponding to the array input.

def TryCut(self, center, normal):
    segmentation = slicer.util.getNode("Output Volume_1-segmentation")
    segment = segmentation.GetSegmentation().GetSegment("Output Volume_1")
    plane = vtk.vtkPlane()
    plane.SetOrigin(center)
    plane.SetNormal(normal)
    
    closedSurfacePolyData = vtk.vtkPolyData()
    segmentation.GetClosedSurfaceRepresentation("Output Volume_1", closedSurfacePolyData)
    
    planeCut = vtk.vtkCutter()
    planeCut.SetInputData(closedSurfacePolyData)
    planeCut.SetCutFunction(plane)
    planeCut.Update()
    
    if self.cutModelNode is not None:
        slicer.mrmlScene.RemoveNode(self.cutModelNode)
    self.cutModelNode = slicer.modules.models.logic().AddModel(planeCut.GetOutputPort())
    cutModelDisplayNode = self.cutModelNode.GetDisplayNode()
    cutModelDisplayNode.SetColor(0,0,1)
    cutModelDisplayNode.SetOpacity(1.0)
    
    delaunay = vtk.vtkDelaunay2D()
    delaunay.SetInputData(self.cutModelNode.GetPolyData())
    self.cutModelNode.SetPolyDataConnection(delaunay.GetOutputPort())

I wish to be able to splt the array output of vtkCutter in as many islands as there may be, identify each island array and get hold of each of them. This would permit to create a model around the current centerline point only.

I don’t know if it is possible at all, simply would be best. I suppose it should be possible, because the Islands module does manage unconnected objects, but I don’t have a signe clue how this could be done simply.

Thanks for any input.

A very simple solution is to assign one of the branches to another segment. It takes about 10-20 seconds. See step-by-step instructions here.

If you want to save this 10-20 seconds then you can use VMTK to split the branches fully automatically. See details here and example script here. It will probably take a few days to figure out how the filter works exactly, so it pays off if you need to segment more than 5000 cases.

That seems very interesting, I’ll delve into this ASAP. Didn’t know about that. Thanks.

1 Like