Is there an interactive command interpreter available for Fiji? I can type commands a macro and run them, but a real time option would be nice.
Hi @esiefker,
There is: Plugins > Scripting > Script Interpreter
and you can choose your preferred language .
John
The latest ImageJ daily build adds the Plugins>Macros>Interactive Interpreter command, which allows you to enter macro language and JavaScript commands and have them immediately interpreted. To upgrade, use the Help>Update ImageJ command and select âdaily buildâ from the drop down menu.
Here is an example session:
[Macro interactive mode. Type "help" for info.]
help
Type a function (e.g., "run('Invert')") to run it.
Enter an expression (e.g., "x/2" or "log(2)") to evaluate it.
Move cursor to end of line and press 'enter' to repeat.
"quit" - exit interactive mode
cmd+M - enter interactive mode
cmd+shift+F - open Function Finder
"js" - switch language to JavaScript
x=2
2.0
x/3
0.6666666666666666
sin(PI/3)
0.8660254037844386
run("Blobs (25K)");
run("invert")
Unrecognized command: "invert"
run("Invert")
close("*")
run("Invert")
There are no images open.
js
[JavaScript interactive mode. Type "help" for info.]
n=3
3
n/4
0.75
sin(PI/n)
ReferenceError: "sin" is not defined in nashorn:mozilla_compat.js
Math.sin(Math.PI/n)
0.8660254037844386
img = IJ.openImage("http://wsr.imagej.net/images/blobs.gif");
img["blobs.gif" (-8), 8-bit, 256x254x1x1x1]
ip = img.getProcessor()
ip[width=256, height=254, bits=8, min=0.0, max=255.0]
ip.getStats()
stats[count=65024, mean=103.26857775590551, min=8.0, max=248.0]
ip.blurGaussian(5);
ip.GetStats();
TypeError: ip.GetStats is not a function in <eval>
ip.getStats();
stats[count=65024, mean=103.36157418799213, min=34.0, max=238.0]
img.show()
ip.invert() // img.updateAndDraw() is automatic
quit
[Exiting interactive mode.]
Hello Wayne -
Very cool!
This is not a feature request, but more a question to satisfy my
curiosity: Can something similar be done for jython (python),
itself an interpreted language? Would there be any impediment
to adding jython to the Interactive Interpreter (other than the
obvious issue of time and resources)?
Thank, mm
Also related:
Hi folks,
Iâm happy to present you the SciJava Jupyter Kernel project.
The idea of this project is to build a Jupyter kernel on top of the SciJava framework.
As you may know, Scijava is the Java framework that power ImageJ and Fiji.
Jupyter is an open source project that âsupport interactive data science and scientific computing across all programming languagesâ. Interactive computing is allowed by the Jupyter Notebook. Find here some notebooks that will give you an idea of what we are talkiâŚ

Can something similar be done for jython (python),
itself an interpreted language?
Support for Jython, and Groovy, BeanShell, Scala, etc., could be added but I prefer to keep the Interactive Interpreter simple and only support the macro language and JavaScript. I like JavaScript because itâs JIT-compiled and included with the Java runtime. JavaScript runs the Help>Examples>Language>Sphere program (size=4096) in 1/2 second, whereas Jython requires 12 seconds.

Can something similar be done for jython (python),
itself an interpreted language?
The script interpreter mentioned by @bogovicj above (Plugins > Scripting > Script Interpreter; included with Fiji) ships this functionality for several years now (for all supported script languages). Iâd be interested if it matches your requirements, or if thereâs anything missing to make it useful for you and others.
Hi @mountain_man:
There has been a Jython Interpreter since Fiji was created, pretty much. Perhaps 10 years.
For unknown reasons, the Jython Interpreter and others were moved a few years ago to the fiji-legacy update site. Activate it to get them.
The new âScripting Interpreterâ, despite all many faults (https://github.com/scijava/scijava-common/issues/308), can run Jython code interactively.
The âScript Editorâ now has a command prompt, AKA a script interpreter. So any language that is not compiled (like java) that runs in the Script Editor now has a script interpreter. The pull request is here https://github.com/scijava/script-editor/pull/28 and should be merged soon, bringing these new features of the Script Editor to a near-future fiji update.

For unknown reasons, the Jython Interpreter and others were moved a few years ago to the fiji-legacy update site.
For the record: the reasons were explained here:
Several legacy Fiji plugins as well as no-longer-needed dependent libraries have been retired from the ImageJ and Fiji update sites, migrating to a dedicated Fiji-Legacy update site . None of these plugins completed the transition to reproducible builds in late 2014. Many of them are dedicated script interpreters, which have now been replaced by a unified SciJava Script Interpreter which allows dynamic language switching.
Thanks for pointing to the original report on why the script interpreters were moved to the fiji-legacy update site. The report is unfortunate in that it announces the new Script Interpreter as replacing the old ones, when it didnât: the new one has a number of severe issues, such as not being able to store the command history (a pretty basic feature), in addition to having undergone limited testing (resulting in e.g. using â:langâ commands to switch languages, when in e.g. clojure the â:â is reserved for map keys), and a number of issues with the UI (lack of collapsible window displaying variables table, no info on what the variable table is for or why these variables are not available from the prompt).
Hello Albert (and John and Wayne et al.) -

Hi @mountain_man:
There has been a Jython Interpreter since Fiji was created, pretty much. Perhaps 10 years.
For unknown reasons, the Jython Interpreter and others were moved a few years ago to the fiji-legacy update site. Activate it to get them.
The new âScripting Interpreterâ, despite all many faults (https://github.com/scijava/scijava-common/issues/308), can run Jython code interactively.
The âScript Editorâ now has a command prompt, AKA a script interpreter. So any language that is not compiled (like java) that runs in the Script Editor now has a script interpreter. The pull request is here https://github.com/scijava/script-editor/pull/28 and should be merged soon, bringing these new features of the Script Editor to a near-future fiji update.
Okay, itâs starting to look like an embarrassment of riches. Does this
look right?
-
âScript Interpreterâ
Plugins > Scripting > Script Interpreter
Been around for a while; I just didnât know about it. -
âInteractive Interpreterâ
Plugins > Macros > Interactive Interpreter...
New with Wayneâs recentHelp > Update ImageJ...
-
âScript Editorâ
New > Script...
If I understand Albert correctly, the new âcommand promptâ
feature will be coming soon, but is not yet part of stock Fiji. -
A âlegacyâ âJython Interpreter and others,â not distributed
with stock Fiji, but available from the fiji-legacy update site.
A couple of questions: Which to use for common tasks? Do some offer
features (other than the obvious issue of specific language support) that
would be of use in special cases?
If I install the âlegacyâ interpreter(s) where will they show up in the Fiji
menu system?
Thanks to all for letting me know that this functionality exists. It should
be a nice convenience when monkeying around.
Thanks, mm
Hi @mountain_man,
The âlegacyâ interpreters actually work, as opposed to the new âScript Interpreterâ which has errors such as failing to save your entered command line history. These âlegacyâ interpreters will show up in the âPlugins - Scriptingâ menu.
For common tasks I use these âlegacyâ ones, been doing so for years.
Wayneâs new macro interpreter I havenât tried. I prefer a full-fledged programming language like python and clojure over macros.

The âlegacyâ interpreters actually work, as opposed to the new âScript Interpreterâ which has errors such as failing to save your entered command line history.
I feel obligated to push back on @albertcardonaâs vehemenceâI used the new Script Interpreter sometimes, and it works OK for me. Itâs true that there are some bugs we need to fix, but implying it âdoesnât workâ is highly unfair. It works for me and others. @mountain_man I suggest you simply try all available options for yourself and use the one(s) that work for your needs.
To complete your list above: there is yet another way to execute script one-liners, using the âhash bangâ (#!
) syntax in the search bar. It uses the same REPL instance as the Script Interpreter. Here is an example:

@mountain_man
To complete your list above: there is yet another way to execute script one-liners, using the âhash bangâ (#!
) syntax in the search bar.
Okay, @ctrueden, now youâre just messing with my head.