Centerline extraction

I am new to ITK. I have a 3D model of a tubular structure and I am looking for a way to extract the centerline for it. Could someone help?

So far, I have tried using VMTK but it requires a closed model (end points are closed), but in my case I have a model with open ends.

I am looking for suggestions on how I can extract the centerline for this model. Thank you.

@Stephen_Aylward might have some suggestions.

Hi,

There are a few options.

  1. Render the object to a binary image and then extract the centerline that way. The downside is the lack of precision. An example of this is in the jupyter notebook: ITKTubeTK/Demo-SegmentVesselsFromBinaryImage.ipynb at master · InsightSoftwareConsortium/ITKTubeTK · GitHub

  2. See if the topology toolkit has a solution: https://topology-tool-kit.github.io/

  3. Check with the VTK forum, to see if there is a polydata-based solution.

Thanks for the suggestions, @Stephen_Aylward . For your first option,

I get the following error:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Input In [4], in <module>
----> 1 resample = ttk.ResampleImage.New(Input=im1, MakeIsotropic=True)
      2 resample.Update()
      3 im1Iso = resample.GetOutput()

File ~/anaconda3/envs/PT2/lib/python3.9/site-packages/itk/support/lazy.py:137, in LazyITKModule.__getattribute__(self, attr)
    135 module = self.__belong_lazy_attributes[attr]
    136 namespace = {}
--> 137 base.itk_load_swig_module(module, namespace)
    138 self.loaded_lazy_modules.add(module)
    139 for k, v in namespace.items():

File ~/anaconda3/envs/PT2/lib/python3.9/site-packages/itk/support/base.py:102, in itk_load_swig_module(name, namespace)
    100     deps = l_data.get_module_dependencies()
    101     for dep in deps:
--> 102         itk_load_swig_module(dep, namespace)
    104 if itkConfig.ImportCallback:
    105     itkConfig.ImportCallback(name, 0)

File ~/anaconda3/envs/PT2/lib/python3.9/site-packages/itk/support/base.py:102, in itk_load_swig_module(name, namespace)
    100     deps = l_data.get_module_dependencies()
    101     for dep in deps:
--> 102         itk_load_swig_module(dep, namespace)
    104 if itkConfig.ImportCallback:
    105     itkConfig.ImportCallback(name, 0)

    [... skipping similar frames: itk_load_swig_module at line 102 (3 times)]

File ~/anaconda3/envs/PT2/lib/python3.9/site-packages/itk/support/base.py:102, in itk_load_swig_module(name, namespace)
    100     deps = l_data.get_module_dependencies()
    101     for dep in deps:
--> 102         itk_load_swig_module(dep, namespace)
    104 if itkConfig.ImportCallback:
    105     itkConfig.ImportCallback(name, 0)

File ~/anaconda3/envs/PT2/lib/python3.9/site-packages/itk/support/base.py:98, in itk_load_swig_module(name, namespace)
     86 this_module.__templates_loaded = True
     88 # Now, we definitely need to load the template_feature instantiations from the
     89 # named module, and possibly also load the underlying SWIG module. Before
     90 # we can load the template_feature instantiations of this module, we need to load
   (...)
     96 # via the itk_base_global_module_data instance defined at the bottom of this file, which
     97 # knows how to find those configuration files.
---> 98 l_data = itk_base_global_module_data[name]
     99 if l_data:
    100     deps = l_data.get_module_dependencies()

KeyError: 'ITKImageGrid'

Is this because I am using

In [5]: itk.__version__
Out[5]: '5.3.0'

Did you install ITK via pip?

If so, could you please show me the output of pip list? It seems like there might be a version mis-match of itk and tubetk wheels.

Ideally the follow should work:
pip install --pre itk (to get itk v5.3rc03)
pip install itk-tubetk (to get itk-tubetk 1.1)

I suspect you’re using the (should be correct but might not be working) following
pip install itk
pip install itk-tubetk

The current version of tubetk is meant to work with the soon to be released v5.3…but I see that it still hasn’t been released on pypi yet, so that might be the source of your troubles. It is weird, however, that your itk.version_ reports 5.3.0, so I really need to learn more about your setup and then check with ITK gurus.

If you are compiling, then please let me know what OS, compiler, and ITK source code git tag you’re using.

Sorry for the troubles.

You are correct. With the first command it installed ITK 5.2.1, but when I use the second command, it uninstalled the previous version and installed 5.3rc3.

Based on your explanation this should work.

I tried a clean install in a different python environment and still the same result.

@Stephen_Aylward, just to update; I managed to convert my model to a volume and then use VMTK.

Great! Just in case someone else wants to replicate this, here is a video that shows a workflow that automatically closes open ends of the vessel tree using shrink-wrapping:

1 Like