I want to run slicer from within python, to execute a script that builds a scene automatically from a JSON file telling it what files to load. I think I’ve solved everything except how to tell slicer the location of the JSON file. There are several options I can think of:
- Run
Slicer --python-script myscript.py
, first setting an environment variablejson_file
that is then checked by myscript.py. - Run
Slicer --python-code mymodule.myscript(<json_file>)
, where my code inserts the correct string for <json_file> before running slicer - Same as above, but run
Slicer -c
instead ofSlicer --python_code
All of these feel pretty kludgy for something that seems like it would be common. Is there some other way I’m not thinking of? Is there a preferred way to give arguments when running a python script within Slicer as part of a batch job?