imagej / imagej-legacy

ImageJ+ImageJ2 compatibility layer
https://imagej.net/libs/imagej-legacy
BSD 2-Clause "Simplified" License
17 stars 25 forks source link

Results of a scijava Commands don't show up in batchmode #271

Closed maarzt closed 2 years ago

maarzt commented 2 years ago

This problem was noticed when running Labkit from an imagej macro. (see https://github.com/juglab/labkit-ui/issues/85)

This macro works fine:

CurrentImage = getTitle();
run("Segment Image With Labkit", "input="+CurrentImage+" segmenter_file=D:/Classifier.classifier use_gpu=1");

But when executed in batch mode the results don't show up any more:

CurrentImage = getTitle();
setBatchMode(true);
run("Segment Image With Labkit", "input="+CurrentImage+" segmenter_file=D:/Classifier.classifier use_gpu=1");
setBatchMode("exit & display");

I think this should be solve by rewriting IJ1 <-> IJ2 synchronization (#231).

maarzt commented 2 years ago

Batch mode changes the behaviour of IJ1 such that when ImagePlus.show() is called, the ImagePlus is not shown but added to an Interpreter.addBatchModeImage(ImagePlus) is executed instead. This also works fine when an scijava command is executed but the fulling line calls Interpreter.removeBatchModeImage(ImagePlus) and thereby deletes the image again. https://github.com/imagej/imagej-legacy/blob/c65f9dca8e1de812a234923b795e8052e7c58f63/src/main/java/net/imagej/legacy/translate/Harmonizer.java#L188

maarzt commented 2 years ago

This is a duplicated issue see #215.