@Kota Can you explain your issue over here?

Did you launch ImageJ with the server running (either start server inside Fiji, or run with --server flag)


Hi @kephale

Thanks for this great module for Atom. Exciting…

  1. Stated Fiji server from the Fiji menu bar (Plugins > Utilities > Start Server)
  2. Confirmed that the server is working (curl localhost:8080/modules returns the list)
  3. Launch Atom editor, and from the menu, I selected Packages > atom-imagej-mode > Run Script

I tried running a script with just one line

 print "test"`

Where should it be printed?


Can you try having it return an image? Something like this:

# @IOService io "/Users/kharrington/BrevisSwarm_control.png" )


I replaced the image path to my local image but nothing happened yet. Is there any way to see the process in verbose mode?


Your imagej should have some output from imagej-server in your console, that could be informative here. If there is a failure it should happen and be indicated there.


BTW, what OS are you using?


Sending command from terminal

curl localhost:8080/modules/'command:net.imagej.ops.math.PrimitiveMath$IntegerAdd'

does trigger logging

0:0:0:0:0:0:0:1 - - [30/Apr/2018:16:56:35 +0000] "GET /modules/command:net.imagej.ops.math.PrimitiveMath$IntegerAdd HTTP/1.1" 200 754 "-" "curl/7.55.1" 5

In the Console window of Fiji, but “Run Script” does not trigger any logging. Configuration (ij path) should be OK, I reconfirmed.

BTW, what OS are you using?


java.version: 1.8.0_121
java.vendor: Oracle Corporation Mac OS X
os.version: 10.11.6
os.arch: x86_64
file.separator: /
path.separator: :
line.separator: miura
user.home: /Users/miura
user.dir: /Applications/ US
file.encoding: UTF-8
java.home: /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre
java.class.path: /Applications/
java.ext.dirs: /Users/miura/Library/Java/Extensions:/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/ext:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java /var/folders/tz/kbnr321x74d9n23hvxxv0p_w0000gp/T/

IJ.getVersion: 2.0.0-rc-65/1.52a
IJ.getFullVersion: 1.52a99
IJ.isJava16: true
IJ.isJava17: true
IJ.isJava18: true
IJ.isJava19: false
IJ.isLinux: false
IJ.isMacintosh: true
IJ.isMacOSX: true
IJ.isWindows: false
IJ.is64Bit: true

IJ.getDir(“imagej”): /Applications/
IJ.getDir(“home”): /Users/miura/
IJ.getDir(“plugins”): /Applications/
IJ.getDir(“macros”): /Applications/
IJ.getDir(“luts”): /Applications/
IJ.getDir(“current”): /Users/miura/Downloads/
IJ.getDir(“temp”): /tmp/
IJ.getDir(“default”): /Users/miura/Downloads/
IJ.getDir(“image”): /Users/miura/Downloads/


When I send run script command from command palette, the command is sent to Fiji and I see the following line in the console.

0:0:0:0:0:0:0:1 - - [30/Apr/2018:23:35:12 +0000] "POST /modules/command:net.imagej.server.external.ScriptEval?process=false HTTP/1.1" 200 48 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Atom/1.26.1 Chrome/58.0.3029.110 Electron/1.7.11 Safari/537.36" 157


Ok that is the response that is expected. And nothing shows up in your Fiji? When you make an open image call it should open the image inside ImageJ. If you try to manually send a command to the imagej-server does the image open up? e.g. (noting you’ll have to change the path to the image again)

curl -XPOST -H "Content-Type: application/json" -d '{"language":"py","script":"# @IOService io\n\n\"/Users/kharrington/BrevisSwarm_control.png\")"}' localhost:8080/modules/'command:net.imagej.server.external.ScriptEval'?process=false

curl -XPOST -H "Content-Type: application/json" -d '{"language":"py","script":"# @IOService io\n\n\"/Users/miura/Downloads/blinkingtracks.png\")"}' localhost:8080/modules/'command:net.imagej.server.external.ScriptEval'?process=false

yes, This terminal command does work and the image opens.


@Kota thanks for sticking this out. I pushed an uploaded package to APM that has a config flag for getting outputs via electron alert (not elegant, but we’ll improve the outputs in the future). If you run:

Then you should get a dictionary like {"outputs":{"result":"test"}}

Also note that the files need to be saved before you can use the run_script command, because the language is detected via the file extension.

Please let me know if this works. Thank you!


@kephale thanks for upgrades. I configured with “alert”.

Now what I see is

  1. “Run Script” via command palette with the clojure script triggers
    a. pop-up window with "{“outputs”:{“result”:“test”}}"
    b. in fiji, a new window script:script.clj with a row 1 “result” and “test”

“Run Script” command using the menu tree does not trigger these events.


Aha! Fixed in the latest update. This problem shouldn’t come up in the future. It was caused by me changing the package name too many times and not updating the menus appropriately.

Thank you for finding this one @Kota!


great, now it’s working, the image is opened and shown.

Just some questions: for an image to be shown, it works if the opening of the image is in the last line

; @UIService ui
; @IOService io

(.open io "/Users/miura/Downloads/blinkingtracks.png")

but does not open if there is a different last line.

; @UIService ui
; @IOService io

(.open io "/Users/miura/Downloads/blinkingtracks.png")


I think this is the expected behavior as the output relies on the IOService: so I forgot how to show the image in the middle of the script. Could you give me a tip?


You have to explicitly tell the UIService to show the image. This should work:

; @UIService ui
; @IOService io

(.show ui (.open io "/Users/miura/Downloads/blinkingtracks.png"))



Thanks a lot @kephale !


Note that this is the “old”, comment-based syntax for script parameters. The recommended syntax is language-agnostic and always uses hash-at (#@) for parameter declaration.

From the documentation on the Script Parameters wiki page:

Parameter declarations begin with #@. Each such line contains a single parameter declaration or script directive and nothing else.

The advantage of the new syntax is that it can be used at any place in the script and is not restricted to the script header (i.e. it can be used with a license header, for example).

For illustration, your script would then look like this:

#@ UIService ui
#@ IOService io

(.show ui (.open io "/Users/miura/Downloads/blinkingtracks.png"))



No, there is a good reason this syntax is used.

We do not use this syntax in fun.imagej because we need our code to run outside of ImageJ as well (every fun.imagej script behaves the same when run as a standalone Clojure program or as a SciJava script). # is a special character for the macro reader in Clojure. It is possible that one could utilize the fact that #_ triggers the expression commenting macro, but then the code should actually read like: #_(UIService ui)


Thanks for the clarification.

If a script is run outside ImageJ, how do you get the inputs declared by the script parameters (as they’re real comments and not parsed then, right?) ?


That is a great point. It is true that the Clojure snippet I posted earlier in this thread wouldn’t run on its own. It was just a concise test snippet.

In general fun.imagej functions have a local context that they use, so you either explicitly establish bindings to a new SciJava Context/ImageJ Gateway, or use the recursive assumption common in functional languages that your scope/context is already correctly configured. There will be an update in the near future that make it easier to control your SciJava context.

fun.imagej allows for a more idiomatic way of writing Clojure, and I really just wanted to make a point that Clojure scripters can’t use the “new” SciJava syntax in standard Clojure environments because the # symbol is a part of the Clojure language. I brought this up when the syntax was being presented last year, but IIRC the release was already cut. That said, if the scripts only need to work in SciJava the #@UIService ui syntax can suffice.