Using VMTK for analyzing pipe-like structures

The vascular modeling toolkit (VMTK) is a library originally developed for analysis of blood vessels. The idea is that you obtain radiological scans of blood vessels, reconstruct the geometric shape, and then carry out both statistical analysis of the shapes and flow simulation. There are a huge variety of scripts for performing various tasks. VMTK is based on VTK and uses much of the same data formats. In this post I’m going to try to figure out how useful VMTK is for analyzing general pipe structures that may or may not be in any way related to blood vessels. Most of the tutorials on VMTK assume the objects under study are blood vessels so this is probably somewhat uncharted territory. I created a half-torus in Meshlab and Meshmixer:


to see how useful VMTK is for analyzing it. The workflow of VMTK seems to be centered around:

3D scan Surface model Centerline Analysis Output geometry

‘Centerline’ means the centerline of the blood vessel or vessel-like structure. Here, we have no 3d scan, so we have to use the surface model to find the centerlines. I’m going to adapt the ideas used in this tutorial. The main script in VMTK that produces centerlines is called vmtkcenterlines. To use most VMTK scripts, though, we first have to convert our surfaces to the VTK mesh format (.vtp), which is an XML-based format. VMTK has a set of scripts for conversion to/from STL (and other common surface mesh formats) to vtp:

Note: For converting 3D voxel data, there are also two similar utility scripts: vmtkimagereader and vmtkimagewriter. There’s also scripts for conversion of 3D CFD meshes, which have ‘mesh’ in their name instead of ‘surface’.


vmtksurfacereader -ifile benttube.stl -ofile benttube.vtp

Converts the STL file to a VTP file. Now we’re ready to call vmtkcenterlines. To work, vmtkcenterlines needs you to select source points to draw the centerline between. By default, it opens an annoying GUI view for you to select the source points interactively. Thankfully, it has an option -seedselector which allows you to choose how the source points are picked. I’m going to use -seedselector openprofiles which chooses source points as the barycenter of the open parts of the mesh.

vmtkcenterlines -seedselector openprofiles -ifile benttube.vtp -ofile benttube_centerline.vtp

This still opens up a GUI, but shows the points by number which you can enter after pressing q.


This is still somewhat inconvenient for automating the workflow, but we can specify the inlet ids on the command line, completely eliminating the need for interactive selection:

vmtkcenterlines -seedselector profileidlist -sourceids 0 -targetids 1 -ifile benttube.vtp -ofile benttube_cl.vtp

A problem with this though is that we assume the ids are the same across all meshes we want to analyze, which may or may not be true. So for an automated workflow we probably have to look at specifying the source and target points as vertex coordinates.

The result is the following centerline:

vmtksurfaceviewer -i benttube_cl.vtp


Note that benttube_centerline.vtp just has the centerline mesh, not the parent mesh. To show them both together we need to combine them using vmtksurfacereader (look at the linked tutorial to see how to do this). To export the centerline in a format that can be read by external programs, use:

vmtksurfacewriter -ifile benttube_cl.vtp -ofile benttube_cl.dat



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s