I want to convert the centerline network generated from the segmentations of the Circle of Willis into a graph data structure. Currently the only way to do it in vmtk is to use the ‘vmtknetworkextraction’ class to do so - VMTK network extraction. However, it required the input to be a surface file.
In my case, I have a centerline tree hierarchical structure already generated in slicer as shown.
I can use the .json files containing the centerline curve information to create a graph using the NetworkX library in Python. But is there a way to directly convert the Centerline model_1.vtk file into a graph using the connectivity information stored as an ordered dictionary?
I am using the following code to get numpy arrays from the vtk file.
You could easily add an option to the Extract Centerline module in Slicer to create the graph representation you need. See source code here that generates a hierarchy of curves, with a little change you can put the point lists into a Python dictionary instead. If you send a pull request with the proposed changes then we’ll be happy to merge it.
Thank you @lassoan for the piece of code. Yes I will send out a pull request with the proposed changes soon.
Moreover, I also wanted to know if scalar values of ‘GroupIDsarray’, ‘TortuosityArray’ , ‘BlankingArray’ etc. can be incorporated in the centerline model. I generated the following plots by using the conventional vmtkscripts, but it does not always work correctly.
However, can we make any changes here in the base code to store values of other arrays as well?
Also would it be possible to run this function independently in a separate python code given the vtkpolymesh surface data and the endpoint co ordinates?
This has been done for the network curves but the centerline curves hold the real information.
Yes, sure. These are cell data (one value for each branch) and the values are saved in the table where you can easily look them up (by cell ID) but feel free to add it to the centerline tree model as well. Send a pull request with the proposed changes.
Yes, just send a pull request if you have any suggestion.
You can use the module from anywhere (from a Python script, without a GUI; from Jupyter notebooks, etc.). See complete example here:
Hi, can you share your code for generating centerline curves colored by centerlineIDs. I am trying to separate the centerlines into different segments (branches).
Thanks. I used the function to get the curve tree but I see that it is not very consistent with the centerline model near bifurcations. I was hoping I could just classify nodes and edges in the centerline model directly.