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
108 stars 61 forks source link

Cannot use Macro to load classifier #31

Open yanningzuo opened 7 years ago

yanningzuo commented 7 years ago

Hi,

It seems to be some problems with the "load classifier" macro command. I tried several time with the command as below,but overtime it said "cannot load classifier":

run("Trainable Weka Segmentation"); selectWindow("Trainable Weka Segmentation v3.1.2"); call("trainableSegmentation.Weka_Segmentation.loadClassifier", "/Users/lab-public/Desktop/Green.model"); call("trainableSegmentation.Weka_Segmentation.getProbability"); selectWindow("Probability maps");

I used macro recorder and checked a few times. Probably there's something wrong with the Weka.

Thanks!

yanningzuo commented 7 years ago

It says Caused by: java.lang.NullPointerException at trainableSegmentation.Weka_Segmentation$CustomWindow.setButtonsEnabled(Weka_Segmentation.java:1110) at trainableSegmentation.Weka_Segmentation.loadClassifier(Weka_Segmentation.java:2735)

yanningzuo commented 7 years ago

Just found it's working on PC but not Mac

iarganda commented 7 years ago

Thanks for reporting! It probably has to do with the dialog to choose the classifier file. I'll fix it as soon as I can.

yanningzuo commented 7 years ago

Thank you so much!

Yanning Zuo Staff Research Associate, Hong Lab

Department of Biological Chemistry Department of Neurobiology David Geffen School of Medicine University of California, Los Angeles

On Fri, Sep 16, 2016 at 1:42 AM, Ignacio Arganda-Carreras < notifications@github.com> wrote:

Thanks for reporting! It probably has to do with the dialog to choose the classifier file. I'll fix it as soon as I can.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fiji/Trainable_Segmentation/issues/31#issuecomment-247548887, or mute the thread https://github.com/notifications/unsubscribe-auth/ATCJgkxx9jF19dWgn1eyuojT82JgE2_lks5qqlZ7gaJpZM4J-fwr .

iarganda commented 7 years ago

It seems it is a known problem of the open dialog system. Can you please try again after selecting the "Use JFileChooser to open/save" option in the Edit > Options > Input/Output... menu?

It should look like this: screenshot from 2016-09-21 16 06 52

iarganda commented 7 years ago

@yanningzuo Did you finally test if my proposed solution fixed the issue?

yanningzuo commented 7 years ago

Hi Ignacio,

Very sorry for the late reply... I was using PC and I just confirmed that Mac still couldn't open classifier after selecting the "Use JFileChooser to open/save" and using version 3.2.4.

Thank you so much for reminding me!

Best regards,

Yanning

iarganda commented 7 years ago

Hello @yanningzuo, It works the other way around. If you are using a Mac, you should uncheck the "Use JFileChooser to open/save" option. It seems there is a problem with JFileChooser on Mac OS.

yanningzuo commented 7 years ago

Hi Ignacio,

I actually tried both ways but neither worked on Mac...

iarganda commented 7 years ago

Weird! Which version of Mac OS and Java do you have?

yanningzuo commented 7 years ago

I am using OS X Yosemite 10.10.5 and did not install Java on my Mac

iarganda commented 7 years ago

I just noticed you are not using version 3.2.5 which enforces the use of other dialogs instead of JFileChooser if the option is unchecked. Can you please try with that version of the plugin?

yanningzuo commented 7 years ago

Actually, I am using the latest version 3.2.5 updated today. I remember it was 3.2.4 last night

This is my most recent code:

selectWindow("Result of Clipboard-1"); run("Trainable Weka Segmentation"); selectWindow("Trainable Weka Segmentation v3.2.5"); call("trainableSegmentation.Weka_Segmentation.loadClassifier", "/Users/lab-public/Desktop/Green.model"); call("trainableSegmentation.Weka_Segmentation.getProbability");

iarganda commented 7 years ago

I see, and this only happens from a macro? You might need to add a wait command after calling the plugin so it has time to load. This works for me:

selectWindow("Result of Clipboard-1");
run("Trainable Weka Segmentation");
wait( 2000 );
selectWindow("Trainable Weka Segmentation v3.2.5");
call("trainableSegmentation.Weka_Segmentation.loadClassifier", "/Users/lab-public/Desktop/Green.model");
call("trainableSegmentation.Weka_Segmentation.getProbability");
imagesc-bot commented 2 years ago

This issue has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/java-lang-nullpointerexception-during-trainable-weka-segmentation-scripting/24002/3