Login  Register

Thresholder in headless macro mode results in NullPointerException

Posted by Konrad Rokicki on Oct 07, 2014; 2:32pm
URL: http://imagej.273.s1.nabble.com/Thresholder-in-headless-macro-mode-results-in-NullPointerException-tp5009940.html

Hi all,

I'm trying to run a macro on a cluster. I can use Xvfb, but it's very hard
to debug problems when dialog boxes popup while this is running on a
cluster. So I thought I'd try Fiji's headless mode:

ImageJ-linux64 --headless -macro macro.ijm

Most of the macro works well, but I can't seem to get the Thresholder to
work. I reduced the problem to a very simple macro:

open("test.tif");
setThreshold(77, 173);
run("Convert to Mask", "method=Default background=Dark black");

This results in a strange exception:

java.lang.NullPointerException
    at ij.plugin.Thresholder.convertStack(Thresholder.java:75)
    at ij.plugin.Thresholder.run(Thresholder.java:48)
    at ij.IJ.runPlugIn(IJ.java:172)
    at ij.Executer.runCommand(Executer.java:131)
    at ij.Executer.run(Executer.java:64)
    at ij.IJ.run(IJ.java:272)
    at ij.macro.Functions.doRun(Functions.java:591)
    at ij.macro.Functions.doFunction(Functions.java:89)
    at ij.macro.Interpreter.doStatement(Interpreter.java:227)
    at ij.macro.Interpreter.doStatements(Interpreter.java:215)
    at ij.macro.Interpreter.run(Interpreter.java:112)
    at ij.macro.Interpreter.run(Interpreter.java:82)
    at ij.macro.Interpreter.run(Interpreter.java:93)
    at ij.plugin.Macro_Runner.runMacro(Macro_Runner.java:153)
    at ij.plugin.Macro_Runner.runMacroFile(Macro_Runner.java:137)
    at ij.IJ.runMacroFile(IJ.java:133)
    at net.imagej.legacy.IJ1Helper.runMacroFile(IJ1Helper.java:802)
    at
net.imagej.legacy.LegacyCommandline$Macro.handle(LegacyCommandline.java:178)
    at
org.scijava.console.DefaultConsoleService.processArgs(DefaultConsoleService.java:75)
    at net.imagej.Main.launch(Main.java:64)
    at net.imagej.Main.main(Main.java:73)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at net.imagej.launcher.ClassLauncher.launch(ClassLauncher.java:258)
    at net.imagej.launcher.ClassLauncher.run(ClassLauncher.java:184)
    at net.imagej.launcher.ClassLauncher.main(ClassLauncher.java:76)

After inspecting the Plugin's source code, I can't find any reason this
exception might occur at that location. I'm guessing this has to do with
the way Fiji is instrumenting the dialog portions of the plugin to remove
the dependency on AWT?

The exception seems very similar to the one I was getting when I was trying
to use run("Colors...", "background=black"). I was able to fix that by
switching to setBackgroundColor(), so I wonder if there's also a workaround
for running the thresholder.

I should mention that I've tried using various versions of Fiji, including
the lifeline versions and the latest build.

Thank you,
Konrad

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html