How to obtain the complete center lines using VMTK?


I’m trying to obtain center lines from airway using VMTK. After dilating the pixels of airway, i got most of the center line, including from the small airway, looks like this:


my problem is, why the center lines are broken in the middle? and what would be the best way to get a complete center lines?


A similar problem seems to be happened here, the extract lines are not joined:

Please help or try to give some ideas how to achieve this. Thanks in advance.

It seems to be specific to your data set. Could you post the original segmentation (but at least the input mesh) so that we can reproduce this?

Thanks for your reply!

This is the original segmenataion and script.

Summary: I’ve tested your data set and everything worked well if I made branches a bit thicker. VMTK’s centerline extraction cannot seem to be able to track down endpoints though narrow, pointy tips.


I’ve imported the mask into a segmentation node Slicer and ran it through VMTK extension’s Extract centerline module:

# Load mask into labelmap volume
import numpy as np
d = np.load(r'c:\Users\andra\OneDrive\Projects\SlicerTesting5\20201019-AirwayNetworkAnalysis\PA000019.npz', allow_pickle=True)
volumeNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLLabelMapVolumeNode")
slicer.util.updateVolumeFromArray(volumeNode, d['isoMask'])

# Convert labelmap volume to segmentation node
segmentationNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLSegmentationNode")
slicer.vtkSlicerSegmentationsModuleLogic.ImportLabelmapToSegmentationNode(volumeNode, segmentationNode)

Automatic endpoint detection worked well:

Centerline detection did not succeed - path was not found to endpoints that were connected to the bronchial tree with a narrow branch/sharp tip:

I’ve fixed the narrow branches by oversampling the image by a factor of 2x (subdivide every voxel by 2x2x2) and applying Margin effect in Segment editor:

After this, centerline extraction worked flawlessly:

Original mask (in interactive web viewer):

Dilated mask (in interactive web viewer):