Login  Register

how can I call/execute/run a trained weka classifier from an ImageJ macro?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

how can I call/execute/run a trained weka classifier from an ImageJ macro?

Dionysios Lefkaditis
Hi everybody!

What I am trying to do is to classify an image using a trained WEKA model. I am well aware of the existence of the Advanced Weka Segmentation plugin of ImageJ/Fiji, but I am using a custom-made feature vector, which will not work with it.

Anyway, within an ImageJ macro I am trying to execute:

exec("java", "-cp", "/home/dionysis/weka-3-7-7/weka.jar", "weka.classifiers.trees.RandomForest",  "-T", "/home/dionysis/Desktop/CNH/cnh-data/2class-deffeat-data-20121218.arff", "-l", "/home/dionysis/Desktop/CNH/cnh-data/2class-deffeat-ranfor-classifier-20121218.model.model", "-p", "0", ">", "/home/dionysis/Desktop/testrun-data.out");

which in essence is running the terminal command for weka. In the linux terminal this is running fine, however, calling it within the macro it doesn't do anything. It does not even produce an error.

In the beginning, I thought the problem was that I was trying to run a java program on the system's JVM called from a java program running on a different JVM (ImageJ/Fiji are bundled with their own JVM). For this reason, I tried running ImageJ/Fiji using the system's JVM, but no luck.

I am also considering using the embedded weka of the Advanced Weka Segmentation plugin through the call() macro function, but I do not know how to proceed.

Does anybody have any hints on this? I would greatly appreciate it... Thanks!

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: how can I call/execute/run a trained weka classifier from an ImageJ macro?

Kota Miura
Hi Dionysios,

there is a detailed documentation on usages of call(...) function in macro
for Advanced Weka Segmentation plugin.

http://fiji.sc/wiki/index.php/Advanced_Weka_Segmentation#Macro_language_compatibility

HTH,

Cheers.
Kota

On Tue, Feb 5, 2013 at 12:01 PM, Dionysios Lefkaditis
<[hidden email]>wrote:

> Hi everybody!
>
> What I am trying to do is to classify an image using a trained WEKA model.
> I am well aware of the existence of the Advanced Weka Segmentation plugin
> of ImageJ/Fiji, but I am using a custom-made feature vector, which will not
> work with it.
>
> Anyway, within an ImageJ macro I am trying to execute:
>
> exec("java", "-cp", "/home/dionysis/weka-3-7-7/weka.jar",
> "weka.classifiers.trees.RandomForest",  "-T",
> "/home/dionysis/Desktop/CNH/cnh-data/2class-deffeat-data-20121218.arff",
> "-l",
> "/home/dionysis/Desktop/CNH/cnh-data/2class-deffeat-ranfor-classifier-20121218.model.model",
> "-p", "0", ">", "/home/dionysis/Desktop/testrun-data.out");
>
> which in essence is running the terminal command for weka. In the linux
> terminal this is running fine, however, calling it within the macro it
> doesn't do anything. It does not even produce an error.
>
> In the beginning, I thought the problem was that I was trying to run a
> java program on the system's JVM called from a java program running on a
> different JVM (ImageJ/Fiji are bundled with their own JVM). For this
> reason, I tried running ImageJ/Fiji using the system's JVM, but no luck.
>
> I am also considering using the embedded weka of the Advanced Weka
> Segmentation plugin through the call() macro function, but I do not know
> how to proceed.
>
> Does anybody have any hints on this? I would greatly appreciate it...
> Thanks!
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>



--

-------------------------------------------------------------*Dr. Kota Miura*

Scientist & IT Engineer
Centre for Molecular and Cellular Imaging,
European Molecular Biology Laboratory
Meyerhofstr. 1
69117 Heidelberg
GERMANY

Tel +49 6221 387 404

Mobile +49 160 95001177

Fax +49 6221 387 512

http://cmci.embl.de
-------------------------------------------------------------

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: how can I call/execute/run a trained weka classifier from an ImageJ macro?

Ignacio Arganda-Carreras
Hello Dionysios,

Have you tried running that command in a terminal? Did that work?

ignacio

On Tue, Feb 5, 2013 at 6:42 AM, Kota Miura <[hidden email]> wrote:

> Hi Dionysios,
>
> there is a detailed documentation on usages of call(...) function in macro
> for Advanced Weka Segmentation plugin.
>
>
> http://fiji.sc/wiki/index.php/Advanced_Weka_Segmentation#Macro_language_compatibility
>
> HTH,
>
> Cheers.
> Kota
>
> On Tue, Feb 5, 2013 at 12:01 PM, Dionysios Lefkaditis
> <[hidden email]>wrote:
>
> > Hi everybody!
> >
> > What I am trying to do is to classify an image using a trained WEKA
> model.
> > I am well aware of the existence of the Advanced Weka Segmentation plugin
> > of ImageJ/Fiji, but I am using a custom-made feature vector, which will
> not
> > work with it.
> >
> > Anyway, within an ImageJ macro I am trying to execute:
> >
> > exec("java", "-cp", "/home/dionysis/weka-3-7-7/weka.jar",
> > "weka.classifiers.trees.RandomForest",  "-T",
> > "/home/dionysis/Desktop/CNH/cnh-data/2class-deffeat-data-20121218.arff",
> > "-l",
> >
> "/home/dionysis/Desktop/CNH/cnh-data/2class-deffeat-ranfor-classifier-20121218.model.model",
> > "-p", "0", ">", "/home/dionysis/Desktop/testrun-data.out");
> >
> > which in essence is running the terminal command for weka. In the linux
> > terminal this is running fine, however, calling it within the macro it
> > doesn't do anything. It does not even produce an error.
> >
> > In the beginning, I thought the problem was that I was trying to run a
> > java program on the system's JVM called from a java program running on a
> > different JVM (ImageJ/Fiji are bundled with their own JVM). For this
> > reason, I tried running ImageJ/Fiji using the system's JVM, but no luck.
> >
> > I am also considering using the embedded weka of the Advanced Weka
> > Segmentation plugin through the call() macro function, but I do not know
> > how to proceed.
> >
> > Does anybody have any hints on this? I would greatly appreciate it...
> > Thanks!
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >
>
>
>
> --
>
> -------------------------------------------------------------*Dr. Kota
> Miura*
>
> Scientist & IT Engineer
> Centre for Molecular and Cellular Imaging,
> European Molecular Biology Laboratory
> Meyerhofstr. 1
> 69117 Heidelberg
> GERMANY
>
> Tel +49 6221 387 404
>
> Mobile +49 160 95001177
>
> Fax +49 6221 387 512
>
> http://cmci.embl.de
> -------------------------------------------------------------
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>



--
Ignacio Arganda-Carreras, Ph.D.
Seung's lab, 46-5065
Department of Brain and Cognitive Sciences
Massachusetts Institute of Technology
43 Vassar St.
Cambridge, MA 02139
USA

Phone: (001) 617-324-3747
Website: http://bioweb.cnb.csic.es/~iarganda/index_EN.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: how can I call/execute/run a trained weka classifier from an ImageJ macro?

Dionysios Lefkaditis
In reply to this post by Dionysios Lefkaditis
@Kota
Thanks you very much for your quick response! I was aware of this functionality and link that you have suggested and I have been using it extensively. Even if I thought your reply did not directly address my problem, it made me have a second look and I managed to solve the issue. I am grateful!


@Ignacio

Hello again!

Yes, the command works fine in the terminal, when properly formatted, of course. I even tried the simple:

exec("java", "-version");

and that doesn't work either! There must be something wrong when calling java. Unfortunately, there is absolutely no feedback, so I cannot investigate it further. Python code and any other executable on my system does work though.

Ignacio, I would like to take this opportunity and inform you of a bug in AWS. In the past, I had tried many times loading a trained classifier into AWS that used a reduced feature vector (after attribute selection in weka explorer). The classifiers would load successfully, but after feature calculation the classifier would fail/crash to classify the image(s). Today, after Kota's suggestion, I accidentally found that if any of the "Structure" features exist in the final feature vector will cause the classifier to crash when applying the classification to the images. These classifiers are working normally, though, when applied within the weka explorer.

I am attaching the corresponding log file. After the last lines are logged a pop up message appears saying "Could not apply Classifier!". I have the impression, but I cannot confirm that this might happen to classifiers with non-reduced feature vectors as long as "Structure" and maybe "Entropy" features are used. This issue has been bugging me for some time now and I have made all sorts of workarounds to try to avoid it. I hope you can resolve it.

Thanks!

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

Loading Weka classifier from /home/mobile/Desktop/cnh data/3class-mogtip-11feat-ranfor10-classifier-20130103b.model...
Field of view: max sigma = 16.0, min sigma = 8.0
Membrane thickness: 1, patch size: 19
Read class name: mog-tips
Read class name: corn
Read class name: background
Read header from /home/mobile/Desktop/cnh data/3class-mogtip-11feat-ranfor10-classifier-20130103b.model (number of attributes = 11)
Loaded /home/mobile/Desktop/cnh data/3class-mogtip-11feat-ranfor10-classifier-20130103b.model
Processing 2 image files in 2 thread(s)....
Processing image image051.bmp in thread 0
Processing slices of image051.bmp in 1 thread(s)...
Starting thread 0 processing 1 slices, starting with 1
Processing image image052.bmp in thread 1
Processing slices of image052.bmp in 1 thread(s)...
Starting thread 0 processing 1 slices, starting with 1
Creating features for slice 1...
Creating features for slice 1...
Filtering feature stack by selected attributes...
Filtering feature stack by selected attributes...
Classifying slice 1 in 1 thread(s)...
Classifying slice 1 in 1 thread(s)...



--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: how can I call/execute/run a trained weka classifier from an ImageJ macro?

Ignacio Arganda-Carreras
Dear Dionysios,

Thanks for reporting the bug! I just fixed it and uploaded the new version
of the plugin. Please, update Fiji and let me know if it works as expected.

Cheers!

ignacio

On Tue, Feb 5, 2013 at 1:05 PM, Dionysios Lefkaditis
<[hidden email]>wrote:

> @Kota
> Thanks you very much for your quick response! I was aware of this
> functionality and link that you have suggested and I have been using it
> extensively. Even if I thought your reply did not directly address my
> problem, it made me have a second look and I managed to solve the issue. I
> am grateful!
>
>
> @Ignacio
>
> Hello again!
>
> Yes, the command works fine in the terminal, when properly formatted, of
> course. I even tried the simple:
>
> exec("java", "-version");
>
> and that doesn't work either! There must be something wrong when calling
> java. Unfortunately, there is absolutely no feedback, so I cannot
> investigate it further. Python code and any other executable on my system
> does work though.
>
> Ignacio, I would like to take this opportunity and inform you of a bug in
> AWS. In the past, I had tried many times loading a trained classifier into
> AWS that used a reduced feature vector (after attribute selection in weka
> explorer). The classifiers would load successfully, but after feature
> calculation the classifier would fail/crash to classify the image(s).
> Today, after Kota's suggestion, I accidentally found that if any of the
> "Structure" features exist in the final feature vector will cause the
> classifier to crash when applying the classification to the images. These
> classifiers are working normally, though, when applied within the weka
> explorer.
>
> I am attaching the corresponding log file. After the last lines are logged
> a pop up message appears saying "Could not apply Classifier!". I have the
> impression, but I cannot confirm that this might happen to classifiers with
> non-reduced feature vectors as long as "Structure" and maybe "Entropy"
> features are used. This issue has been bugging me for some time now and I
> have made all sorts of workarounds to try to avoid it. I hope you can
> resolve it.
>
> Thanks!
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> Loading Weka classifier from /home/mobile/Desktop/cnh
> data/3class-mogtip-11feat-ranfor10-classifier-20130103b.model...
> Field of view: max sigma = 16.0, min sigma = 8.0
> Membrane thickness: 1, patch size: 19
> Read class name: mog-tips
> Read class name: corn
> Read class name: background
> Read header from /home/mobile/Desktop/cnh
> data/3class-mogtip-11feat-ranfor10-classifier-20130103b.model (number of
> attributes = 11)
> Loaded /home/mobile/Desktop/cnh
> data/3class-mogtip-11feat-ranfor10-classifier-20130103b.model
> Processing 2 image files in 2 thread(s)....
> Processing image image051.bmp in thread 0
> Processing slices of image051.bmp in 1 thread(s)...
> Starting thread 0 processing 1 slices, starting with 1
> Processing image image052.bmp in thread 1
> Processing slices of image052.bmp in 1 thread(s)...
> Starting thread 0 processing 1 slices, starting with 1
> Creating features for slice 1...
> Creating features for slice 1...
> Filtering feature stack by selected attributes...
> Filtering feature stack by selected attributes...
> Classifying slice 1 in 1 thread(s)...
> Classifying slice 1 in 1 thread(s)...
>
>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
>


--
Ignacio Arganda-Carreras, Ph.D.
Seung's lab, 46-5065
Department of Brain and Cognitive Sciences
Massachusetts Institute of Technology
43 Vassar St.
Cambridge, MA 02139
USA

Phone: (001) 617-324-3747
Website: http://bioweb.cnb.csic.es/~iarganda/index_EN.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

isosurfacing of 2P fluorescence images

Yu, Alex (NIH/NICHD) [F]
hi,
I have a bunch of images to be processed with cell membrane iso-surfacing. All these images were captured from FP labelled cells under Leica SP5 2P microscope. The boundaries of some of membrane structures such as vesicle/vacuoles are a little bit blur compared to plasma membrane. Is there any plugin available by which I can do isosurfacing of both PM and intracellular vesicle/vacuoles?  
Many thanks,
ALex
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html