Script to compute Voronoi diagrams/largest aorta diameter using VMTK

I have a large number of aorta segmentations (nifti masks), and I would like to figure out how to load each one and compute the largest diameter (aneurysm). It looks as if computing a Voronoi diagram using VMTK is an ideal solution, but I would like to write an extension to automatically load the segmentations from a folder, run the appropriate computations, and save the output. I would really appreciate it if someone could point me to any examples that I might start to learn from/adapt for this purpose.

From using the VMTK extension manually, I think the steps I would need to script are:

  1. Load the nifti mask as a volume (seemingly can’t be loaded as a segmentation without loading a corresponding volume as well)
  2. Apply a simple threshold to get a segmentation (mask will be 0 or 1)
  3. Simplify mesh/create model appropriate for VMTK processing
  4. Compute Voronoi diagram and centerlines
  5. Extract data as table(?) and/or save the largest diameter


To use VTK from a script in Slicer’s Python environment:

Instead of these steps, you can load the nifti mask directly as a segmentation node. See example.

If you want to run some additional Segment Editor effects, you can load the mask as a scalar volume and use it as master volume and then follow these examples.

You can use Extract Centerline module logic class from your own scripts or copy paste any parts of the modules into your scripts.

If the aneurysms are not just slightly dilated vessels but ballooning out then instead of centerline analysis you may consider segmenting the aneurysm sack and get shape properties using Segment Statistics module (there are many optional shape metrics that you can enable).

1 Like