Hi everyone
there is a way to run Octave script using Slicer ??

The simplest option is to create a command line script which can parse arguments and accept/write input/output as NRRD files. There is a pure-Matlab NRRD implementation here (if it is not compatible with Octave, the changes should hopefully be minimal).

Then, using the Slicer Execution Model (CLI), you can define an XML file specifying input and output arguments and types, and Slicer will automatically create a wrapper and graphical interface. Recent Slicer versions will recognize #! at the beginning of a script as a marker that the script can be run as a CLI. There are two Python examples I know of, here and here. Similar scripts and XML files could be written for Octave, provided you make the octave command available in the Slicer PATH. [edit: we would need to broaden the functionality to make this possible, but it should be a small change if/when someone needs it]

A more difficult approach would be to port the SlicerMatlabBridge. This is mostly pure-Matlab, except for the core part which communicates over OpenIGTLink; that part uses Java classes. Apparently it is possible to call Java from Octave, but Octave does not ship with a JVM the way Matlab does, so the syntax is different and you would need to do a potentially significant amount of work to port.

Of course, if you are not tied to Octave for some specific reason, then using Python is a very good option for similar scientific/technical computing work – and Python is very well-supported in Slicer.

1 Like

Slicer’s MatlabBridge can run Matlab commands from Slicer, which could be usable for Octave as well. Client (Slicer) side would work as is, server (Matlab) side probably needs some tuning (how Matlab/Octave server is started and how the TCP/IP communication is implemented).

However, due to booming of Python ecosystem in recent years and relative stagnation of Octave, it might be a better choice to switch to Python (which runs natively in Slicer).


thank you for this Answer ,i think i’ll switch to Python ,it’s more easier :smile:

1 Like