I am trying to get a home made Fiji script to sun inside Python by calling Fiji, but there's little documentation on how to do it. What I need is something like this:
def myfijiscript:
[CODE]
and then in Python:
fiji(myfijiscript)
is there a way to do this?
1 Answer 1
Python (or, to be precise, Jython) scripts within Fiji are executed using the org.python.util.PythonInterpreter class (see source code).
It doesn't make much sense to run a Jython script within a Java instance that is started from with Python, but have a look at those two questions concerning how to run external commands in python. You can save your script in a file myscript.py and then do:
call(["./ImageJ-linux64", "myscript.py"])
using the ImageJ launcher from the command line.
The other way is to use ImageJ as a library and just import the classes you need for your script, as others have suggested:
from ij import IJ
def myfijiscript():with parentheses. What's the problem with simply callingmyfijiscript()(after importing what is needed of course) ?