IJ & R?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

IJ & R?

Gabriel Landini
Hi,
Does anybody have any experience in calling R (the stats language
http://www.r-project.org/ ) from within ImageJ?

Thanks,

Gabriel
Reply | Threaded
Open this post in threaded view
|

Re: IJ & R?

Andreas Jahnen
Hi Gabriel,

I have never used R with ImageJ, but I know a project that interfaces to
octave from Java:

http://jopas.sourceforge.net/index.html


So long,
Andreas

-----------------------------------------------------------------
Andreas Jahnen  -  Ingenieur de Recherche
[hidden email]
-----------------------------------------------------------------
CRP Henri Tudor  -  http://santec.tudor.lu
2A, rue Kalchesbrück
L-1852 Luxembourg
-----------------------------------------------------------------

ImageJ Interest Group <[hidden email]> wrote on 19.07.2007 22:37:04:

> Hi,
> Does anybody have any experience in calling R (the stats language
> http://www.r-project.org/ ) from within ImageJ?
>
> Thanks,
>
> Gabriel
Reply | Threaded
Open this post in threaded view
|

Re: IJ & R?

Dimiter Prodanov
In reply to this post by Gabriel Landini
Hi Gabriel,

you can take a look here:
http://wiki.r-project.org/rwiki/doku.php?id=packages:cran:rjava

I am also interested in writing such interface but as always more urgent
things pop up. From what I remember from the pilot study some packages
should have been compiled locally in C but may be this has already
changed.

Could you explain what is your idea?

Cheers

Dimiter

>
> Date:    Thu, 19 Jul 2007 21:37:04 +0100
> From:    Gabriel Landini <[hidden email]>
> Subject: IJ & R?
>
> Hi,
> Does anybody have any experience in calling R (the stats language
> http://www.r-project.org/ ) from within ImageJ?
>
> Thanks,
>
> Gabriel
>
Reply | Threaded
Open this post in threaded view
|

Re: IJ & R?

Thomas Boudier
In reply to this post by Gabriel Landini
Hi Gabriel,

I have tested launching R scripts from ImageJ, here is how to do it :

String cmd = ""R CMD BATCH path_to_your_R_script.R"
Process p = Runtime.getRuntime().exec(cmd);

That should work

Thomas

Gabriel Landini a écrit :
> Hi,
> Does anybody have any experience in calling R (the stats language
> http://www.r-project.org/ ) from within ImageJ?
>
> Thanks,
>
> Gabriel
>
>

--
/*****************************************************/
     Thomas Boudier, MCU Université Paris 6,
     UMR 7101 / IFR 83. Bat A 328, Jussieu.
     Tel : 01 44 27 35 78  Fax : 01 44 27 25 08
/****************************************************/
Reply | Threaded
Open this post in threaded view
|

Re: IJ & R?

dscho
In reply to this post by Andreas Jahnen
Hi,

On Fri, 20 Jul 2007, Andreas Jahnen wrote:

> I have never used R with ImageJ, but I know a project that interfaces to
> octave from Java:
>
> http://jopas.sourceforge.net/index.html

These are the Java/R adaptors I found (not tested, though):

http://www.rforge.net/rJava/

http://stats.math.uni-augsburg.de/JGR/

http://rosuda.org/JRI/

http://www.omegahat.org/RSJava/

Hth,
Dscho
Reply | Threaded
Open this post in threaded view
|

Re: IJ & R?

Gabriel Landini
In reply to this post by Thomas Boudier
On Friday 20 July 2007 08:35:13 Thomas Boudier wrote:
> Hi Gabriel,
>
> I have tested launching R scripts from ImageJ, here is how to do it :
>
> String cmd = ""R CMD BATCH path_to_your_R_script.R"
> Process p = Runtime.getRuntime().exec(cmd);
>
> That should work

That is great. Thank you.
Is there any way of getting R results back into IJ? Or it is only a one way
route?

Cheers,

Gabriel
Reply | Threaded
Open this post in threaded view
|

Re: IJ & R?

Gabriel Landini
In reply to this post by Dimiter Prodanov
On Friday 20 July 2007 08:31:28 Dimiter Prodanov wrote:
> you can take a look here:
> http://wiki.r-project.org/rwiki/doku.php?id=packages:cran:rjava

Thanks I will take a look (and thanks Thomas, Andreas and Dscho too).

> Could you explain what is your idea?

To be able to test and to fit data from IJ.
For instance, extract data with IJ, do some stats in R and make
decisions/classify/visualise the results back in the image.

At the moment it is a bit of a pain to do it through SPSS (it does not run
under linux). Since I think R is more powerful and I do not have to buy any
licenses I would like to explore this possibility.

Regards,

Gabriel
Reply | Threaded
Open this post in threaded view
|

Re: IJ & R?

Andy Weller
Dear all,

Gabriel's IJ/R related issues has prompted me to ask a stats related
question. This is slightly off-topic, so I apologize in advance, but
maybe somebody out there has some advice/recommendations...

I am relatively new to stats and R and have been getting more lost in it
everyday! For some time now we have been gathering:

a) some (continuous) ImageJ-based measurements that are "real world"
physical descriptions of organisms from microscope images, and

b) some (continuous) ImageJ-based "traditional" measurements (gray value
distribution, texture, etc.) that automatically acquired from the same
microscope images.

Initially I am after a reliable technique to obtain parsimony in both
datasets. I have tried several things (PCA, R^2, etc) but I get slightly
different results and I don't know which ones to trust, or whether
there's a more reliable technique...?!

After this I want to find out which measurements between the two
datasets correlate best. In essence, I want to find out which
"traditional" measurements mean the same thing as the "real world"
measurements.

I apologize again for the off-topic issue, but hopefully somebody out
there understands my intentions and has some pointers/suggestions to
help me in my quest?!

I look forward to your replies, Andy
Reply | Threaded
Open this post in threaded view
|

Re: IJ & R?

Thomas Boudier
In reply to this post by Gabriel Landini
I do everything by files, create input files to R into IJ, R creates
output files that I read in IJ. U can also try to "read" R output text
with something like this :

Process p = ....;

InputStream is = p.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String str;
while ((str = br.readLine()) != null) {
                                        System.out.println(str);
                        }
is.close();

// Wait for the process to complete.
int status = -1;
try {
        status = p.waitFor();
} catch (InterruptedException e) {System.out.println(e);}
} catch (java.io.IOException e) {System.out.println("error " + e);
}

Hope this helps

Thomas


Gabriel Landini a écrit :

> On Friday 20 July 2007 08:35:13 Thomas Boudier wrote:
>> Hi Gabriel,
>>
>> I have tested launching R scripts from ImageJ, here is how to do it :
>>
>> String cmd = ""R CMD BATCH path_to_your_R_script.R"
>> Process p = Runtime.getRuntime().exec(cmd);
>>
>> That should work
>
> That is great. Thank you.
> Is there any way of getting R results back into IJ? Or it is only a one way
> route?
>
> Cheers,
>
> Gabriel
>
>

--
/*****************************************************/
     Thomas Boudier, MCU Université Paris 6,
     UMR 7101 / IFR 83. Bat A 328, Jussieu.
     Tel : 01 44 27 35 78  Fax : 01 44 27 25 08
/****************************************************/
Reply | Threaded
Open this post in threaded view
|

Re: IJ & R?

Marcel
In reply to this post by Gabriel Landini
Hello Gabriel,

in the next week i will release an application (Bio7) which uses Rserve to transfer data to or from Java.
The application itself is an is an Integrated Development Environment for ecological modelling with a main focus on individual based modelling and spatially explicit models based on a Rich Client Platform(Eclipse).
In the Bio7 platform a custom version of ImageJ (version 1.35s) is embedded and several methods are available for the transfer of particle analysis data etc.

The application itself will be an OpenSource application and will be licensed under the GPL and the EPL
(Eclipse Puplic License).
A complete manual, lot of examples and a small Java API will also be available next week.
I've created a website for a preview.
Please follow:

http://www.uni-bielefeld.de/biologie/Oekosystembiologie/bio7app/index.html

Please have a look at the screenshots and the Flash tutorials to get an overview
of the application.
If you are interested i will post a message when i have released Bio7 !

With kind regards

Marcel




Reply | Threaded
Open this post in threaded view
|

Re: IJ & R?

David Hovis
In reply to this post by Thomas Boudier
I used to do something similar with the peak-fitting program Fityk.    
That approach works OK if you are only spitting out a few files.   I  
eventually got a new instrument that would generate data 100x faster  
and I was trying to write 512k files to generate a 512x512 image (two  
files per pixel).    That ended up thrashing one hard drive into  
oblivion.

Thankfully, the author of Fityk split the program into a library that  
I was able to get to work with JNI, so I didn't need to write the  
files anymore.  Not only did I no longer thrash my HD, it was at  
least 100x faster.

So my  advice would be to write text files if you're only going to be  
using it a little. If you don't delete the files, then they give you  
a convenient debugging point.  If you will be throwing a lot of data  
into R, then using the rJava or the RServe modules would be preferable.

--David

On Jul 20, 2007, at 6:38 AM, Thomas Boudier wrote:

> I do everything by files, create input files to R into IJ, R  
> creates output files that I read in IJ. U can also try to "read" R  
> output text with something like this :
>
> Process p = ....;
>
> InputStream is = p.getInputStream();
> InputStreamReader isr = new InputStreamReader(is);
> BufferedReader br = new BufferedReader(isr);
> String str;
> while ((str = br.readLine()) != null) {
> System.out.println(str);
> }
> is.close();
>
> // Wait for the process to complete.
> int status = -1;
> try {
> status = p.waitFor();
> } catch (InterruptedException e) {System.out.println(e);}
> } catch (java.io.IOException e) {System.out.println("error " + e);
> }
>
> Hope this helps
>
> Thomas
>
>
> Gabriel Landini a écrit :
>> On Friday 20 July 2007 08:35:13 Thomas Boudier wrote:
>>> Hi Gabriel,
>>>
>>> I have tested launching R scripts from ImageJ, here is how to do  
>>> it :
>>>
>>> String cmd = ""R CMD BATCH path_to_your_R_script.R"
>>> Process p = Runtime.getRuntime().exec(cmd);
>>>
>>> That should work
>> That is great. Thank you.
>> Is there any way of getting R results back into IJ? Or it is only  
>> a one way route?
>> Cheers,
>> Gabriel
>
> --
> /*****************************************************/
>     Thomas Boudier, MCU Université Paris 6,
>     UMR 7101 / IFR 83. Bat A 328, Jussieu.
>     Tel : 01 44 27 35 78  Fax : 01 44 27 25 08
> /****************************************************/