Running Fiji from Terminal

fiji
imagej
plugin
macro
java-home

#1

Hello ImageJ team,

I am currently working on some fly wing imaging problems and was wondering if you could run a macros that I have created from terminal. I have created a macros which would automate all of the steps in Fiji, but now I need a wrapper that will initiate 1) Fiji 2) image that I am trying to process 3) run the macros that I wrote on the image 4) save outputs in a specific folder.

I have been looking into jython and trying to connect different tools in ImageJ/Fiji to tools in Jython, but I am running into some rode blocks.

If anyone have ideas of how I could initialize fiji in terminal that would be great.

This is the code that I have currently:

os.system("open -a fiji")
os.system("open -a fiji $Image_file")

I want:

os.system("open -a fiji $image_file $macros > $results_save_path $processed_image_save_path")

Thanks to everyone in advance for all of the help.


#2

Hi @erikagedvilaite

Check this wiki page:


#3

Thank you very much. I was able to get it working on MacOS machine after some playing around.


#4

Dear ImageJ Team:

I have compiled a ImageJ/Fiji code and when I try to run the command in my shell,
I get a message (code and error message shown bellow)

/Applications/Fiji.app/Contents/MacOS/ImageJ-macosx --headless -macro /Users/erikagedvilaite/Desktop/DataCreator.ijm 'path_file=/Users/erikagedvilaite/Desktop/Trial/1150218_001.TIF path_folder=/Users/erikagedvilaite/Desktop/Trial/1150218_001/'


Unable to find any JVMs matching version "1.8+".
Unable to find any JVMs matching version "1.8+".
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
Jan 21 14:23:50  ImageJ-macosx[1301] <Warning>: CGSConnectionByID: 0 is not a valid connection ID.
Jan 21 14:23:50  ImageJ-macosx[1301] <Warning>: CGSConnectionByID: 0 is not a valid connection ID.

Can you explain what is causing this error ?

Thank you for your time and help.

Best,

Erika


#5

Hi Erika,

In your terminal, add the option below to your command (be careful for back quotes)

 --java-home `/usr/libexec/java_home -v 1.8*`

If you still see the same error message, then your machine does not have recent Java Virtual Machine. You need Java Virtual Machine with version 1.8+. You could download and install it using the link below.

Java SE Development Kit 8u72
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Then run the above command with --java-home option again.

cheers,
Kota


#6

I’m also having problems running headless in MacOS. If I run a command as above in Terminal, I can actually get a macro to run but Fiji never exits, so I don’t get a shell prompt back unless I send a ‘Quit’ message from the Activity Monitor app. Headless mode is supposed to quit automatically, but putting an explicit run(“Quit”); at the end of macro does not help.

I’m ultimately trying to get the Grid/Collection plugin to run headless. I have a script that does what I want, but so far I can’t get it to run.

I have the latest JDK. Adding the --ij2 option does not help. Any suggestions, or any data or log that I could provide that might help figure this out? I am stumped (and cranky).

Thanks,
Ben


#7

Well, re-installing Fiji fixed the no-exit problem. So, no problem with a simple macro.

However, the Grid/Collection Stitching plugin is still gives “java.awt.HeadlessException.” I will start a new thread for this, since it seems like it may be specific to this plugin: