Is there a way to do statistical analysis, such as ANOVA, in ImageJ macros? The ImageJ User Guide refers to "RImageJ — R bindings for ImageJ"; this would have been perfect but apparently it no longer exists.
The use case is this: I have two samples of image pixels and I would like to do Student's T test on them to see if the average pixel values from the samples can be considered equal within a level of confidence, i.e. the samples come from the same population. I could write the formulas for the test statistics and degrees of freedom in an ImageJ macro, but I would still need table of values for T distribution for different degrees of freedom. Thanks, Neil -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Neil,
On Nov 17, 2014, at 12:19, Neil Fazel <[hidden email]> wrote: > Is there a way to do statistical analysis, such as ANOVA, in ImageJ macros? The ImageJ User Guide refers to "RImageJ — R bindings for ImageJ"; this would have been perfect but apparently it no longer exists. I'm sorry to hear RImageJ is no longer maintained. I've added a note on the guide repository so it is not forgotten[1]. > The use case is this: I have two samples of image pixels and I would like to do Student's T test on them to see if the average pixel values from the samples can be considered equal within a level of confidence, i.e. the samples come from the same population. I could write the formulas for the test statistics and degrees of freedom in an ImageJ macro, but I would still need table of values for T distribution for different degrees of freedom. AFAIK it would be extremely cumbersome to use the ImageJ macro language to perform such t-tests. But it becomes rather simple to use the commons math library[2], that is part of Fiji. To use it you would have to use Java or one the Fiji scripting languages[3]. To get you started, here is a BeanShell example that you can run from the Fiji Script Editor (or the IJ1 built-in one if you have manually installed commons-math3.jar): https://gist.github.com/tferr/2490bf1c4028fbbbddea [1] https://github.com/tferr/IJ-guide/issues/10 [2] http://commons.apache.org/proper/commons-math/index.html [3] http://fiji.sc/Scripting_Help -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Neil Fazel
Here is an example how to call ImageJ from within R (library rJava required):
https://github.com/Bio7/Bio7/blob/master/ImageJ_Conference_2012/ImageJ_FromR/ImageJ_Example.R This is essentially what RImageJ in a similar way did (load ImageJ and then call the methods). Maybe this example can help you to create your own script. Another way would be to use Rserve or JRI from ImageJ, see here: https://github.com/Bio7/Bio7/tree/master/ImageJ_Conference_2012 There are several other options. Another interesting approach would be to use Renjin (R as a JVM language) as an ImageJ lib: http://www.renjin.org/ It is in an early stage but i guess some statistical test are already available: http://renjindemo.appspot.com/ |
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Marcel
Sorry I'm sending this again because there was a problem with my
previous post. Apologies if you get the following twice: I've looked into this myself - Reserve seems like the most pragmatic approach as you have access to all the functions in R. Calling ImageJ from R is much more limited - I don't think you can use every command available from within ImageJ. You can use Reserve to execute an R script. I would imagine you could save you results to a CSV file. Then use an R script to import them, run the tests and write the results to another file or to ij.prefs and then open with ImageJ. There are lovely plotting tools for R so this could be a very useful approach. Let me know if you'd like me to dig out an example. Good luck! R On 17/11/14 21:37, Bio7 wrote: > Here is an example how to call ImageJ from within R (library rJava required): > > https://github.com/Bio7/Bio7/blob/master/ImageJ_Conference_2012/ImageJ_FromR/ImageJ_Example.R > > This is essentially what RImageJ in a similar way did (load ImageJ and then > call the methods). > > Maybe this example can help you to create your own script. > > Another way would be to use Rserve or JRI from ImageJ, see here: > > https://github.com/Bio7/Bio7/tree/master/ImageJ_Conference_2012 > > > There are several other options. > > Another interesting approach would be to use Renjin (R as a JVM language) as > an ImageJ lib: > > http://www.renjin.org/ > > It is in an early stage but i guess some statistical test are already > available: > > http://renjindemo.appspot.com/ > > > > > > -- > View this message in context: http://imagej.1557.x6.nabble.com/access-R-from-ImageJ-macro-tp5010490p5010497.html > Sent from the ImageJ mailing list archive at Nabble.com. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- Dr Richard Mort MRC Human Genetics Unit MRC IGMM University of Edinburgh Western General Hospital Crewe Road Edinburgh. EH4 2XU, UK Tel: +44 (0)131 332 2471 Fax: +44 (0)131 467 8456 The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Dear all,
In the case you want to combine ImageJ / Fiji with R (or even other software) an alternative option may be to use knime (https://www.knime.org/). My best regards, Philippe Philippe CARL Laboratoire de Biophotonique et Pharmacologie UMR 7213 CNRS - Université de Strasbourg Faculté de Pharmacie 74 route du Rhin 67401 ILLKIRCH Tel : +33(0)3 68 85 41 84 -----Message d'origine----- De : ImageJ Interest Group [mailto:[hidden email]] De la part de Richard Mort Envoyé : mardi 18 novembre 2014 10:55 À : [hidden email] Objet : Re: access R from ImageJ macro Sorry I'm sending this again because there was a problem with my previous post. Apologies if you get the following twice: I've looked into this myself - Reserve seems like the most pragmatic approach as you have access to all the functions in R. Calling ImageJ from R is much more limited - I don't think you can use every command available from within ImageJ. You can use Reserve to execute an R script. I would imagine you could save you results to a CSV file. Then use an R script to import them, run the tests and write the results to another file or to ij.prefs and then open with ImageJ. There are lovely plotting tools for R so this could be a very useful approach. Let me know if you'd like me to dig out an example. Good luck! R On 17/11/14 21:37, Bio7 wrote: > Here is an example how to call ImageJ from within R (library rJava required): > > https://github.com/Bio7/Bio7/blob/master/ImageJ_Conference_2012/ImageJ > _FromR/ImageJ_Example.R > > This is essentially what RImageJ in a similar way did (load ImageJ and > then call the methods). > > Maybe this example can help you to create your own script. > > Another way would be to use Rserve or JRI from ImageJ, see here: > > https://github.com/Bio7/Bio7/tree/master/ImageJ_Conference_2012 > > > There are several other options. > > Another interesting approach would be to use Renjin (R as a JVM > language) as an ImageJ lib: > > http://www.renjin.org/ > > It is in an early stage but i guess some statistical test are already > available: > > http://renjindemo.appspot.com/ > > > > > > -- > View this message in context: > http://imagej.1557.x6.nabble.com/access-R-from-ImageJ-macro-tp5010490p > 5010497.html Sent from the ImageJ mailing list archive at Nabble.com. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- Dr Richard Mort MRC Human Genetics Unit MRC IGMM University of Edinburgh Western General Hospital Crewe Road Edinburgh. EH4 2XU, UK Tel: +44 (0)131 332 2471 Fax: +44 (0)131 467 8456 The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Neil Fazel
Hi Tiago,
Thank you for the tip, and the links. Is the commons math library also part of ImageJ? I will use Fiji if necessary, but would stick with ImageJ since I'm doing everything else in ImageJ. Best regards, Neil -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Neil Fazel
Hi Bio7,
Thank you for this information. Since I would like to call R from within ImageJ, your suggestion to use Rserve from ImageJ could work. To try it, I downloaded Rserve_Example.java and tried to compile. Apparently it's missing the REngine package. Do you know how I could get this to work on a Mac? Thanks, Neil /Applications/ImageJ/plugins/Downloaded/Rserve_Example.java:9: package org.rosuda.REngine does not exist import org.rosuda.REngine.REXPMismatchException; ^ /Applications/ImageJ/plugins/Downloaded/Rserve_Example.java:10: package org.rosuda.REngine.Rserve does not exist import org.rosuda.REngine.Rserve.RConnection; ^ /Applications/ImageJ/plugins/Downloaded/Rserve_Example.java:11: package org.rosuda.REngine.Rserve does not exist import org.rosuda.REngine.Rserve.RserveException; ^ /Applications/ImageJ/plugins/Downloaded/Rserve_Example.java:27: cannot find symbol symbol : class RConnection location: class Rserve_Example RConnection c = new RConnection(); ^ /Applications/ImageJ/plugins/Downloaded/Rserve_Example.java:27: cannot find symbol symbol : class RConnection location: class Rserve_Example RConnection c = new RConnection(); ^ /Applications/ImageJ/plugins/Downloaded/Rserve_Example.java:34: cannot find symbol symbol : class REXPMismatchException location: class Rserve_Example } catch (REXPMismatchException e) { ^ /Applications/ImageJ/plugins/Downloaded/Rserve_Example.java:38: cannot find symbol symbol : class RserveException location: class Rserve_Example } catch (RserveException e) { ^ 7 errors -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Neil,
> I downloaded Rserve_Example.java and tried to compile. Apparently it's > missing the REngine package. Do you know how I could get this to work > on a Mac? If you use Maven, you can model your design after this project: https://github.com/scijava/scripting-r That is a project to create an R script language that would enable support for R scripting directly within ImageJ, via RServe. It is not yet working though, and I do not currently have time to work on it, which is why I hesitated to reply until now. But if you are going to develop something using RServe, that POM could serve as a useful starting point. For further details, see: * http://imagej.net/Maven * https://github.com/imagej/minimal-ij1-plugin Regards, Curtis On Wed, Nov 19, 2014 at 4:02 PM, Neil Fazel <[hidden email]> wrote: > Hi Bio7, > > Thank you for this information. Since I would like to call R from within > ImageJ, your suggestion to use Rserve from ImageJ could work. To try it, I > downloaded Rserve_Example.java and tried to compile. Apparently it's > missing the REngine package. Do you know how I could get this to work on a > Mac? > > Thanks, > Neil > > > /Applications/ImageJ/plugins/Downloaded/Rserve_Example.java:9: package > org.rosuda.REngine does not exist > import org.rosuda.REngine.REXPMismatchException; > ^ > /Applications/ImageJ/plugins/Downloaded/Rserve_Example.java:10: package > org.rosuda.REngine.Rserve does not exist > import org.rosuda.REngine.Rserve.RConnection; > ^ > /Applications/ImageJ/plugins/Downloaded/Rserve_Example.java:11: package > org.rosuda.REngine.Rserve does not exist > import org.rosuda.REngine.Rserve.RserveException; > ^ > /Applications/ImageJ/plugins/Downloaded/Rserve_Example.java:27: cannot > find symbol > symbol : class RConnection > location: class Rserve_Example > RConnection c = new RConnection(); > ^ > /Applications/ImageJ/plugins/Downloaded/Rserve_Example.java:27: cannot > find symbol > symbol : class RConnection > location: class Rserve_Example > RConnection c = new RConnection(); > ^ > /Applications/ImageJ/plugins/Downloaded/Rserve_Example.java:34: cannot > find symbol > symbol : class REXPMismatchException > location: class Rserve_Example > } catch (REXPMismatchException e) { > ^ > /Applications/ImageJ/plugins/Downloaded/Rserve_Example.java:38: cannot > find symbol > symbol : class RserveException > location: class Rserve_Example > } catch (RserveException e) { > ^ > 7 errors > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Neil Fazel
Hello Neil,
you have to download the Rserve libs: http://rforge.net/Rserve/files/ (REngine.jar, RserveEngine.jar) Put them in the plugins folder of ImageJ. The you have to start R and install and start the Rserve package: > install.packages ("Rserve") The start Rserve: > library (Rserve) > Rserve() Now execute the example and everything should work. Apropos: if you are looking for some advance ImageJ R functionality you can try out Bio7: http://bio7.org which has implemented ImageJ and an R GUI as an Eclipse plugin. In this app i already implemented several methods to transfer image and selection data to R and vice versa, see the documentation here: http://bio7.org/documentation/Main.html#toc-Subsubsection-4.3.3.1 Since version 1.7 R plots are opened in the ImageJ canvas (as a R plot device) and from multiple plots an ImageJ stack is created - see the video presentation on this website: http://bio7.org/?p=2353 In the next weeks i will release a new version which adds e.g. the possibility to transfer ImageJ stack to a RasterStack in R or to transfer the Results Table as an R dataframe. Best regards Marcel |
Free forum by Nabble | Edit this page |