Merging Centrelines

Hi everyone,

I used a programme to calculate the centrelines of a cardiovascular model I’ve been working on.
I then used a Python script to save each branch individually. It starts at one end of the model and follows each branch, saving them as a new .vtp file.
Therefore, at each point that the vessel splits, the branch leading to the point is saved and two new branch files begin. i.e a ‘Y’ shaped branch has 3 constituent files - 1 coming in, and 2 leaving.

Now I want to look at my data along the longest branch in the model, but due to how the Python script worked, this vessel is saved in 5 parts.
I’m very new to VMTK and Python, however I managed to use ‘vmtkappendsurfaces’ to join each of these together sequentially to get a file of the whole vessel.

The issue, as imaged, is that there is a slight gap where each of these vessels join. The end of one part is not exactly the start of the next. Hence when plotting data from along this line there are strange fluctuations in the graph that are unrealistic and visually unappealing.

Does anybody know of a script that will append my 5 lines together sequentially as I have done, but also interpolate the information inbetween, to create a continuous centreline?
I’ve taken a look at ‘vmtkcenterlinemerge’ although I don’t understand how it works and haven’t been able to successfully test it out. If this is the correct method, can anybody help me understand it please?
Current: ---- - -----
Desired: --------------

Any advice would be greatly appreciated.

You can use vtkStripper to merge curves that share points. If you miss a connection between branches then you can add it by using vtkLineSource and vtkAppendFilter.