fiji / Trainable_Segmentation

Fiji library to perform image segmentation based on the Weka learning schemes
https://imagej.net/Trainable_Weka_Segmentation
GNU General Public License v3.0
106 stars 60 forks source link

Classification not working in batch mode #59

Open christianrickert opened 3 years ago

christianrickert commented 3 years ago

Problem description

When starting the Trainable Weka Segmentation plugin in ImageJ's batch mode, an exception is thrown, and the classification is not performed.

unclassified

Expected behaviour

Since there is no user interaction required, when running the example macro, the classification should be performed. Change the argument of the first function call in the example macro from true to false to turn off ImageJ's batch mode and reproduce the correct result.

classified

Software versions

Short demo

(ImageJ macro)

// enter batch mode
setBatchMode(true);

// load image
run("Blobs (25K)");

// run Weka plugin
run("Trainable Weka Segmentation");
wait(3000);

// create example data
makeRectangle(13, 38, 33, 37);
call("trainableSegmentation.Weka_Segmentation.addTrace", "0", "1");
makeRectangle(80, 133, 22, 55);
call("trainableSegmentation.Weka_Segmentation.addTrace", "0", "1");
makeRectangle(181, 113, 26, 26);
call("trainableSegmentation.Weka_Segmentation.addTrace", "1", "1");
makeRectangle(91, 31, 31, 23);
call("trainableSegmentation.Weka_Segmentation.addTrace", "1", "1");

// train classifier
call("trainableSegmentation.Weka_Segmentation.trainClassifier");

// exit batch mode
setBatchMode("exit and display");

Exception

(Fiji Is Just) ImageJ 2.1.0/1.53f; Java 1.8.0_172 [64-bit]; Windows 10 10.0; 3262MB of 12288MB (26%)

java.lang.NullPointerException
    at trainableSegmentation.Weka_Segmentation.run(Weka_Segmentation.java:1305)
    at ij.IJ.runUserPlugIn(IJ.java:241)
    at ij.IJ.runPlugIn(IJ.java:204)
    at ij.Executer.runCommand(Executer.java:150)
    at ij.Executer.run(Executer.java:68)
    at ij.IJ.run(IJ.java:323)
    at ij.IJ.run(IJ.java:334)
    at ij.macro.Functions.doRun(Functions.java:691)
    at ij.macro.Functions.doFunction(Functions.java:98)
    at ij.macro.Interpreter.doStatement(Interpreter.java:278)
    at ij.macro.Interpreter.doStatements(Interpreter.java:264)
    at ij.macro.Interpreter.run(Interpreter.java:160)
    at ij.macro.Interpreter.run(Interpreter.java:93)
    at ij.macro.Interpreter.run(Interpreter.java:104)
    at ij.plugin.Macro_Runner.runMacro(Macro_Runner.java:162)
    at ij.IJ.runMacro(IJ.java:159)
    at ij.IJ.runMacro(IJ.java:148)
    at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1148)
    at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1144)
    at net.imagej.legacy.IJ1Helper.runMacroFriendly(IJ1Helper.java:1095)
    at net.imagej.legacy.IJ1Helper.runMacro(IJ1Helper.java:1144)
    at net.imagej.legacy.plugin.IJ1MacroEngine.eval(IJ1MacroEngine.java:145)
    at org.scijava.script.ScriptModule.run(ScriptModule.java:157)
    at org.scijava.module.ModuleRunner.run(ModuleRunner.java:165)
    at org.scijava.module.ModuleRunner.call(ModuleRunner.java:124)
    at org.scijava.module.ModuleRunner.call(ModuleRunner.java:63)
    at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:225)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

Log output

(Nothing)

It would be great, if the WTS plugin could work in ImageJ's batch mode: The processing speed is increased, when processing many images in a batch folder. In addition, the host system can be used while processing data in the background - images that pop up frequently make any other work virtually impossible.