Using Slicer and Slicer Modules from Command-Line

Hi Matt -

It sounds like you are on the right track - we try to support many different ways of accessing Slicer functionality but sometimes you do need to investigate a bit to decide what’s the most streamlined way to accomplish what you need. Some of these practices are changing a bit now that we have Python3 support.

For streamlined batch processing and command line use, the python interpreter (PythonSlicer) can be used to access all the packages installed in Slicer, but won’t have the application context so many things won’t be available (e.g. rendering etc). You can use slicer.util.pip_install() to add custom packages.

From a shell, you can run many of the CLI modules as commands, using Slicer’s launcher (e.g. Slicer --launch BRAINSFit), which is a very lightweight way to access the ITK based C++ code.

Or if you need a full environment where you can access any of the code you can use the full Slicer application and pass it whatever startup script you want (the expense is a little extra startup overhead).

Hope that helps,
Steve

3 Likes