# Can we split an array of points in islands?

**URL:** <https://discourse.slicer.org/t/can-we-split-an-array-of-points-in-islands/18439>\
**Category:** Support\
**Created:** [June 30, 2021, 7:23pm UTC](https://discourse.slicer.org/t/can-we-split-an-array-of-points-in-islands/18439 "2021-06-30T19:23:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)\
**Post date:** [June 30, 2021, 7:23pm UTC](https://discourse.slicer.org/t/can-we-split-an-array-of-points-in-islands/18439/1 "2021-06-30T19:23:51Z")

</div>

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.

 ![Screenshot](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/7/5730a5ece76b77a28bc2414bab9c05cb39603b9c.jpeg)

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.

```auto
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.

---

<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:** [July 2, 2021, 3:59am UTC](https://discourse.slicer.org/t/can-we-split-an-array-of-points-in-islands/18439/2 "2021-07-02T03:59:53Z")

</div>

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](https://lassoan.github.io/SlicerSegmentationRecipes/Craniotomy/).

If you want to save this 10-20 seconds then you can use VMTK to split the branches fully automatically. See details [here](http://www.vmtk.org/tutorials/BranchSplitting.html) and example script [here](https://github.com/vmtk/vmtk/blob/63a3b990328d8dfaa6ffd31968fc341cad9dbe67/vmtkScripts/vmtkbranchclipper.py#L117-L139). 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.

---

<div class="post-metadata">

**Author:** ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)\
**Post date:** [July 2, 2021, 1:05pm UTC](https://discourse.slicer.org/t/can-we-split-an-array-of-points-in-islands/18439/3 "2021-07-02T13:05:07Z")

</div>

> [@lassoan](#):
>
> split the branches fully automatically. See details [here](http://www.vmtk.org/tutorials/BranchSplitting.html) and example script [here](https://github.com/vmtk/vmtk/blob/63a3b990328d8dfaa6ffd31968fc341cad9dbe67/vmtkScripts/vmtkbranchclipper.py#L117-L139).

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