R Workshop ImageJ Conference 2012

Errata Conference Paper

Section 4 (Corrections are marked bold!)

Loading a text image into R from ImageJ:
yourImage<- read.table(“C:/Cell_Colony.txt”)

yourImage<-t(yourImage)#Data has to be transposed!

Loading a text image into ImageJ more efficiently and display it faster in R:
yourImage<-matrix( scan (“C:/Cell_Colony.txt”,n = 408*406),408,406,byrow = FALSE )

Conference Questions:

How to start Rserve on MacOSX:
-Use a terminal (located in the Utilities folder within the Applications folder)
to start the R binary (type “R” – should be in the global path)
-Load Rserve from within R (“library(Rserve)),
-Start Rserve (“Rserve()”) :

Transfer clipboard data on MacOSX:

R, ImageJ Examples

1. Call ImageJ from R with rJava

A JRE must be on the Systems PATH e.g.: C:\Program Files\Java\jre7\bin (Windows)
jvm.dll must be on the systems PATH, e.g.: C:\Program Files\Java\jre7\bin\client (Windows) – in some cases …bin\server
The R installation must be on the Systems PATH, e.g.: C:\Program Files\R\R-2.15.1\bin (Windows)

In R install the library rJava
> install.packages(“rJava”)

Example R script (source):


2. Call R form Java with JRI


Java classpath: JRI.jar, REngine.jar, JRIEngine.jar must be on the classpath (optional ij.jar if you use an IDE for development)

Add the following folders to the PATH variable of the system:

C:\Program Files\Java\jre7\bin\client (Windows)
C:\Program Files\R\R-2.15.2\bin (Windows)
C:\Program Files\R\R-2.15.2\library\rJava\jri (Windows)
C:\Program Files\R\R-2.15.2\bin\i386 (Windows)

If you use a shell, e.g. (Windows):
set PATH=%PATH%;C:\Program Files\R\R-2.15.2\library\rJava\jri;C:\Program Files\R\R-2.15.2\bin\i386;C:\Program Files\Java\jre7\bin\client;C:\Program Files\R\R-2.15.2\bin

Example JRI (source)

If you compile the JRI example with ImageJ please note that JRI can instantiate R only once in a process and R does not support re-inititalization.
Please restart ImageJ if you want to recompile and execute the example else the ImageJ application will crash!!!!!!

Leave a Reply

Your email address will not be published. Required fields are marked *