How can I call 3D Slicer fully externally and automate a workflow?

Hey there folks.

I’m working on a software assignment where my goal is to help automate a couple of tasks for my employer. My employer uses 3D Slicer, Meshlab and eventually Blender to make a 3D model from Dicom files and then work on them in Blender. The final product should ideally be an all-emcompassing Blender add-on, so my employer can focus on working in Blender as much as possible. I’m still exploring the possibilities though.

The only thing I need Meshlab for is to do a quick cleanup of the model, and that can be done fully via Python without needing to run Meshlab. Ideally I’d like to do something like that with 3D Slicer. Is this possible? And how can I approach that?

On this same forum I found out about pyigtl, but from what I understand this requires that 3D Slicer is installed and currently running. Is there a way to call 3D Slicer fully externally, have it do some tasks on Dicom files, and export an STL model? That way I could then feed that into Meshlab, and then into Blender.

Yes, you will need to install Slicer one form or the other. Then you can drive it without invoking the UI either through directly interacting with SlicerPython, or using it through Jupyter notebook.

1 Like

You can also set up the Web Server module in Slicer to accept commands (send it python scripts) to automate any process from the outside.

1 Like

If you do have Slicer installed and you know what you want it to do in the form a python script (e.g. load DICOM, create model, export model), then a quick and easy approach is to run the script in slicer headlessly.

Ooh, awesome. Thank you for the replies, everybody. This gives me a few entry points that I can try out.