Hello, everyone
I am encountering an issue while merging centerlines using VMTK, and I would appreciate some assistance.
I used the “Extract Centerlines” module in 3D Slicer to extract centerlines from a cerebral vascular mesh and saved it as a VTP file. Next, I loaded the centerlines VTP file in VS Code with Python 3.10 and performed branch splitting using vmtk_branch_splitting. Then, I smoothed the centerlines using vmtk_centerline_smoothing.
Finally, I merged the centerlines from the same vessel using vmtk_centerlinemerge. After merging the centerlines (magenta centerlines) and displaying them using PyVista alongside the pre-merged (smoothed, green centerlines), it is clear that the merged centerlines (magenta) deviate significantly from the original path of the centerlines (green).
The step length during merging was adjusted, but the result did not change. Could you help me identify the cause and suggest improvements?
Here is the code I used:
from vmtk import vmtkscripts
import vtk
def load_vtp(file_name):
reader = vtk.vtkXMLPolyDataReader()
reader.SetFileName(file_name)
reader.Update()
polydata = reader.GetOutput()
return polydata
def vmtk_branch_splitting(centerlines):
branch_splitting = vmtkscripts.vmtkBranchExtractor()
branch_splitting.Centerlines = centerlines
branch_splitting.Execute()
splitted_centerlines = branch_splitting.Centerlines
return splitted_centerlines
def vmtk_centerline_smoothing(centerlines, num_iteration=100, smooth_factor=1.2):
smoother = vmtkscripts.vmtkCenterlineSmoothing()
smoother.Centerlines = centerlines
smoother.NumberOfSmoothingIterations = num_iteration
smoother.SmoothingFactor = smooth_factor
smoother.Execute()
smoothed_centerlines = smoother.Centerlines
return smoothed_centerlines
def vmtk_centerlinemerge(centerlines, step_length=0.1):
centerlinemerge = vmtkscripts.vmtkCenterlineMerge()
centerlinemerge.Centerlines = centerlines
centerlinemerge.Length = step_length
centerlinemerge.Execute()
merged_centerlines = centerlinemerge.Centerlines
return merged_centerlines
centerlines = load_vtp("Centerline model.vtp")
radius_array = centerlines.GetPointData().GetArray("Radius")
radius_array.SetName("MaximumInscribedSphereRadius")
splitted_centerlines = vmtk_branch_splitting(centerlines)
smoothed_centerlines = vmtk_centerline_smoothing(splitted_centerlines)
merged_splitted_centerlines = vmtk_centerlinemerge(smoothed_centerlines)
Thank you