2

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?

Jan Eglinger
4,0981 gold badge29 silver badges54 bronze badges
asked Jul 18, 2013 at 9:24
3
  • I guess you mean def myfijiscript(): with parentheses. What's the problem with simply calling myfijiscript() (after importing what is needed of course) ? Commented Jul 18, 2013 at 9:30
  • 1
    I assume you checked fiji.sc/Scripting_toolbox#Python this link and it's not what you want, right? ;) Commented Jul 18, 2013 at 9:40
  • yeah, I did, and it's great for writing the script I want to use. Calling Fiji to run it from within Python, however, is where the problem is Commented Jul 18, 2013 at 10:14

1 Answer 1

3

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
answered Jul 1, 2014 at 12:53
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.