Extracting Centerlines of a CAD Model Through a Python Script in Slicer

Hello there,

I am very new and novice to Slicer. The project that I am currently involved with requires me to extract the center line of the 3D body organ’s model (e.g., intestine, etc.). More specifically, I need to prepare a python script whose output is the center line of a given model.

I am aware of “Vascular Modeling Toolkit” and its accompanied CenterLineComputation module. However, problems that I am currently facing are:

  1. When I use this addson and subsequently, generate and save the .vtk center line of the 3D model, the .vtk object is empty.
  2. I need to find a tutorial to learn on how to write python extension (preferably extensions) under Slicer to automate the center line computation and saving the resulting center line.

I will be grateful if you can kindly assist me on finding my right starting point.

I highly appreciate your cooperation.

Sincerely,
Soheil

You can segment the intestines using Segment Editor, then export the segment to labelmap, and get centerline points as markup fiducials using Extract skeleton module. You can create smooth line from markups using Markups to model extension. You need to use a recent nightly version of Slicer.

Dear Andras Lasso,

I am thankful for your kind reply and instructions for exporting the centerline. It is, indeed, very helpful.

However, it appears to be through the use of GUI. I highly appreciate it if you kindly advise how I may do this process through a Python script.

I thank you for your time and kind cooperation and look forward to hearing from you.

Sincerely,

Soheil

All operations that are available through the GUI can be performed using Python scripting, too. You can run CLI module (such as “Extract skeleton”) from Python as described here. If you have issues figuring out how to perform any particular operation from Python then let us know.

Hi Andras,

Thank you very much for your kind responses to my previous inquiries. I have been able to extract the centerlines from a 3D CAD model.

At this point, I need to do the same thing using a medical image. Is the “Centerline Computation” from Vascular Modeling Toolkit still applicable for medical images or there is another package/extension I need to use for this purpose. I am asking this question since all my attempt for using the aforementioned package on a .mrb image results in crashing the Slicer (the pop-up window with a message “Slicer stopped …”).

I thank you for your time and kind cooperation and look forward to hearing from you.

Sincerely,
Soheil

Hi, Soheil
Have you solved your problem that the centerline computation causes crashing the Slicer? I encountered the same crashing Slicer problem when I used the centerline computation.