Save a tree of centerline curves to json files using Python

Hello,

I have created a tree of centerline curves using functions from the “Extract Centerline” module, and now I want to save the curves in a file structure that can reflect the tree structure. In Slicer, I can do this by right click the stem curve → “Export to file…” → Check all the options.
Screenshot 2024-06-03 at 15.24.27
Screenshot 2024-06-03 at 15.25.01

This will save my curves in a folder structure that looks like this:

Now I wonder if there is a python command to do this easily as well? It will be great to add this to my automatic code that runs the centerline extraction.

Many thanks!

This code snippet in the script repository implements what you described.

2 Likes