Extracting Data from VMTK Centerline

Hi,

I am using VMTK’s centreline computation tool to extract a skeleton of a respiratory system (from a stl file, converted to binary label map). I have previewed the skeleton and pressed start to begin extracting data (this took a long time, my computer thought slicer stopped responding at several intervals but I continued running - maybe this is a factor).

Screenshot%20from%202019-06-17%2019-02-11

However, eventually it finished and I have this skeleton. My issue is now, how to extract data on coordinates i.e. end points and branch points?

The tutorial on this uses an older version of Slicer than I have and appears fairly straight forward, however there are no clear means to extract data from the module on this version.

Any help would be greatly appreciated.

Best,
Josh

Result of centerline detection is a vtkPolyData that you can access by calling:

centerlineModel = getNode('CenterlineComputationModel')
centerlinePoly = centerlineModel.GetPolyData()

You can then access point positions as you would do for any vtkPolydata. For example:

Get first point position:

centerlinePoly.GetPoints().GetPoint(0)

Get point IDs of the first line segment:

pointIds = vtk.vtkIdList()
centerlinePoly.GetLines().GetCell(0, pointIds)

Thanks for your fast reply Andras. I followed your code through and it works fine up to the last line which returns nothing, as shown below:

>>> centerlineModel = getNode('CenterlineComputationModel')
>>> centerlinePoly = centerlineModel.GetPolyData()
>>> centerlinePoly.GetPoints().GetPoint(0)
(-236.95960998535156, 237.93817138671875, 101.977294921875)
>>> 
>>> pointIds = vtk.vtkIdList()
>>> centerlinePoly.GetLines().GetCell(0, pointIds)
>>> print centerlinePoly.GetLines().GetCell(0, pointIds)
None

Can you give any advice on how to proceed? My intention was to use the centerline computation to extract coordinates of centerpoints and branch points (and I was hoping these would be clearly defined in the output file for ease of scripting the recognition of this, is this so?).

Apologies but I am a complete newbie when it comes to vtk and 3D Slicer.

If it helps, I found the ID list to be empty
>>> pointIds = vtk.vtkIdList()
>>> print pointIds
vtkIdList (0x6562580)
Debug: Off
Modified Time: 98975746
Reference Count: 1
Registered Events: (none)
Number of Ids: 0

pointIds is a vtkIdList object, contain a list of point IDs. For example, you can get number of points in it using GetNumberOfIds and get Nth point ID using GetId. Check out VTK examples site to see examples of using VTK objects in Python.

1 Like