Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Labkit incompatible with batch mode #85

Open
SebastienTs opened this issue Feb 13, 2022 · 10 comments
Open

Labkit incompatible with batch mode #85

SebastienTs opened this issue Feb 13, 2022 · 10 comments

Comments

@SebastienTs
Copy link

Labkit seems incompatible with batch mode when calling it from a macro. I hint that it comes from the fact that the results is a virtual stack. Would it be possible to add a flag so that the results is not a virtual stack (when predicting a stack of modest size).

@haesleinhuepf
Copy link

Hi @SebastienTs ,

I'm following up this discussion and your email. Can you please provide more details? For example the macro you are trying to run and the corresponding model together with an example image would be great. It is otherwise very hard to reproduce your issue.

See also: https://en.wikipedia.org/wiki/Minimal_working_example

Thanks!

Robert

@SebastienTs
Copy link
Author

SebastienTs commented Feb 17, 2022

Whatever the image and classifier, this macro runs fine:

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

while this doesn't (no output):

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

Same behaviour when setting use_gpu=0

Tested on Windows 10 x64 with ImageJ2 2.3.0/1.53f; Java 1.8.0_172 [amd64]

@SebastienTs
Copy link
Author

SebastienTs commented Feb 25, 2022

Actually, the problem seems more generic since other imglib based plugins returning results as virtual stacks suffer from a similar issue, or do not output anything. One example is Process > Filters > Frangi Vesselness.

Would it be possible to add an option available from the dialog box to perform the computations not lazily and return a non virtual stack (which would hopefully not interfere with batch mode)?

@maarzt
Copy link
Collaborator

maarzt commented Feb 25, 2022

Hi @SebastienTs,

Sorry I for the late response. I'm on parental leave right now. I will have a look at this next week. Your are right.

The problem is probably not in Labkit itself, but caused by the fact that Labkit is base so much on imglib2 and scijava.
Any idea why the virtual stacks would cause trouble in batch mode?

@maarzt
Copy link
Collaborator

maarzt commented Feb 25, 2022

I didn't come across a single line of good source code while debugging this code.

There is a method Interpreter.addBatchModeImage(ImagePlus) this method is called correctly to add the output image the Interpreter.imageTable. All the images in the imageTable will be show when setBatchMode("exit & display") is called.

The problem now is with LegacyImageMap, it gets an "DisplayUpdateEvent' and calls Harmoizer.reBuildImagePlusData() on the output image which calls LegacyUtils.deleteImagePlus() and the deleteImagePlus calls removeBatchModeImage...
anyway LegacyImageMap needs a complete rewrite...

@maarzt
Copy link
Collaborator

maarzt commented Mar 7, 2022

@SebastienTs The problem is caused by a bug in https://github.com/imagej/imagej-legacy. I created two PRs imagej/imagej-legacy#272, imagej/imagej-legacy#273 that will fix this.

You may download and install this imagej-legacy.jar into your Fiji, if you don't want to wait for the PRs to be merged and released.

@SebastienTs
Copy link
Author

SebastienTs commented Mar 7, 2022

@maarzt Thanks for looking into it. I have tried the new .jar. It works with a small glitch: in batch mode the image "output" generated by the plugin is not active by default after execution (when it is without batch mode).

@maarzt
Copy link
Collaborator

maarzt commented Mar 8, 2022

glitch: in batch mode the image "output" generated by the plugin is not active by default after execution (when it is without batch mode).

Hi @SebastienTs, that's an interesting glitch. Maybe I can a fix for that as well. How do you see which image is active in batch mode?

@SebastienTs
Copy link
Author

SebastienTs commented Mar 8, 2022 via email

@maarzt
Copy link
Collaborator

maarzt commented Mar 21, 2022

I could reproduce the problem. This script scales the segmented image:

run("Leaf");
run("Segment Image With Labkit", "segmenter_file=/home/arzt/leaf.classifier use_gpu=false");
run("Scale...", "x=0.5 y=0.5 width=254 height=223 interpolation=Bilinear average create");

But when I enable batch mode, the input image (leaf.jpg) is scaled instead.

setBatchMode(true);
run("Leaf");
run("Segment Image With Labkit", "segmenter_file=/home/arzt/leaf.classifier use_gpu=false");
setBatchMode("exit & show");
run("Scale...", "x=0.5 y=0.5 width=254 height=223 interpolation=Bilinear average create");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants