As far as I’ve understood this there are 2 main ways to access Slicers Python API:
Using the built-in python console
Starting slicer with the --python-script or --python-code flag
But I want to have an external program running on the same machine as slicer. This program should then be able to control the running slicer instance via Slicers Python API.
Is this possible?
I would be grateful if you could point me to some ressources.
There are many ways to achieve this, depending on what you would like to achieve and what your programming environment is. A few examples:
SlicerWeb: expose Slicer’s Python environment as a web service. Well suited for applications that already use web requests.
SlicerOpenIGTLink: very lightweight socket-based protocol for real-time data transfer. Well suited for applications where you need to send dozens or hundreds of requests per second (e.g., continuous data streaming); or for clients that only have access to sockets and do not want to reimplement complex protocols, such as http. There is a native Python implementation: pyigtl.
SlicerJupyter: protocol for interacting with Slicer using standard Jupyter kernel protocol (quite simple protocol, but built on top of ZeroMQ middleware). Useful for applications that want to offer embedded Python console to Slicer and don’t want to implement a Slicer-specific protocol.