Category Archives: R

Transfer data from R to Python with PyRserve and Bio7


Recently I discovered the package PyRserve for Python which connects Python with R using Rserve.

This is extremly useful because Bio7 already integrates Rserve and has special GUI interfaces available to transfer, e.g.,  data from spreadsheets, ImageJ image and selection data (also georeferenced),  Java simulation data, etc.

With this new Rserve connection this data can now easily transferred from Java and R to a Python workflow.

Python as a language is already supported in Bio7 with an integration of Jython (which runs on the Java platform a supported JVM language like Groovy, JavaScript, Scala, etc. and has a direct access to the Bio7 API).
In additon native Python can be executed with the default Bio7 Python editor if configured in the native preferences of Bio7 (running as an external process in a Bio7 Python shell if enabled).

However since Bio7 is based on Eclipse a more powerful editor for Python/Jython can be installed with PyDev which is a complete Python IDE for Eclipse and available as an Eclipse plugin which can be installed with the Bio7 (Eclipse) Update Manager

Here a video how PyDev can be installed in Bio7:

Please activate JavaScript to view this video.

Update Site PyDev:

If PyDev is installed you can create Python projects in Bio7 and execute Python and Jython scripts depending on the settings in it’s own process (e.g. with the action editor context menu-> Run As->Python Run) .

In addition it is possible to use a special Bio7 toolbar action (visible if the PyDev editor or Bio7 Python editor is opened) to interpret the content of the PyDev editor in the current Bio7 Jython or Python process (which is of no importance for the following use of PyRserve!).

PyRserve can be installed easily using the pip command in the python shell:

pip install PyRserve

or by using PyDev with the preferences dialog (see screenshot below).

After the installation we can start RServe from within R as usual ,e.g., with:


To connect Python to Rserve the following commands are suffcient:

import pyRserve
conn = pyRserve.connect()

More examples can be found in the PyRserve documentation.

However since the Bio7 functionality can be easily extended with scripts (which can be added dynamically to a menu copying them to a special scripts location, see screenshot below) I decided to write two short Groovy scripts to start and stop Rserve not controlled by the Bio7 Java connection interface (and if necessary disconnect R from a current Bio7 controlled Java connection).

The ‘Start_PyRserve’ script starts R and Rserve if not alive in the Bio7 R console and also disconnects from a running Java Rserve connection if activated.

Note that in Bio7 only one connection to Rserve is allowed (Rserve cooperative mode).

The ‘Stop_PyRserve’ script reconnects Python (closed in the Python scripts!) to shutdown Rserve and returns to the Bio7 console and R (Pydev has it’s own console).

This shutdown command is excecuted by an external Python process. To get the path for the Python interpreter we also have to set the Bio7 Python path (not PyDev!) in the Bio7 preferences (see Windows screenshot below – normally not necessary on Linux or when the Python interpreter is on the OS PATH!).

With this two scripts it is now (more secure) possible to start Rserve and use the Bio7 Java interface, e.g., to transfer image data to R (ImageJ to R), start the Python connection (which disconnects Java) and use the image data inside a Python workflow (see the second example).

Here a first example script to transfer random numbers (in PyDev use the context menu action ‘Runs As->Python Run’ of the editor to execute the Python script) with a PyRserve connection.

import pyRserve

conn = pyRserve.connect()
result = conn.eval("result<-runif(100)")
print (result)

Here another example script to plot a transferred image matrix in Python with matplotlib (8-bit, grayscale as double matrix) if available in the R workspace: (see this old video how to do this with Bio7):

import pyRserve 
import matplotlib.pylab as plt

conn = pyRserve.connect()
matrix = conn.eval("tryCatch({matrix<-imageMatrix}, error = function(e) {return ('NULL')})")
if matrix != 'NULL':
    # we have to transpose the image for a correct view!
    matrix = matrix.T

Here a summary of the installation and configuration steps necessary for Bio7 to use PyRserve and execute Python scripts with the powerful PyDev editor:

  1. Install the PyDev editor and configure the Python path
  2. Install PyRserve (pip install PyRserve)
  3. Configure the Python path of Bio7 (Preferences Bio7->Preferences Native)
  4. Install the Groovy Start/Stop scripts for PyRserve (simply unzip in one scripts location – Open ‘Scripts->General->Open_Script_Location’ from the main Bio7 menu or in the context menu of the R-Shell view open General->Open_Script_Location’. Put them in an extra folder for a submenu!
  5. Start the ‘Start_PyRserve’ script to start Rserve (not Bio7 controlled!)
  6. Execute a Python script which connects and disconnects PyRserve
  7. Stop the server and shutdown Rserve with the ‘Stop_PyRserve’ script

Download Start/Stop PyRserve scripts here




Bio7 2.9 Released


A new release of Bio7 is available. The new Bio7 2.9 release comes with a plethora of new R features and bugfixes.

Screenshot MacOSX with dark theme and opened ‘R ImageJ Analysis’ perspective

Screenshot ‘R’ perspective Windows and opened R-Shell code completion

Release Notes:


  • Based on Eclipse 4.8
  • Improved the dark theme and the layout of the dark theme in many places
  • All editor font colors are now changed automatically to default optimized colors when using the dark theme
  • New ‘Switch Theme’ action available to easily switch to the dark theme or back to the default theme
  • Java updated to 1.8.181
  • New Fullscreen/Hide Menu action available (Main menu “Window” – Key: Strg+Shift+ 4)
  • New Hide and Show main menu actions available (useful to hide added plugin menus again)
  • Added pdf reader option “Okular” to open a R pdf plot with the okular application (used when the SWT browser + open external preference is selected)
  • Added a new Table API method to transfer a matrix array form Java more efficiently
  • Improved the WorldWind search function (using the photon geocoding API)
  • Improved the default font size for Swing components on Retina displays (e.g., ImageJ components)


  • Updated R for Windows to version 3.5.1
  • Added a new plot option to plot huge plots in a temporary folder and open them in ImageJ virtually (disk resident). The folder will automatically be opened after plotting (plot images have to be deleted manually!)


  • ImageJ Updated to 1.52f18
  • ImageJ toolbar improved for the dark theme (see screenshots)
  • Added a new ImageJ detach image menu in the ‘Window’ menu of the ImageJ-Canvas view

R Markdown:

  • Added syntax coloring of R markdown snippets
  • Added new context menu actions in menu “Text” (Find and replace, Toggle Block Selection, To Upper Case, To Lower Case)
  • Added a new context menu action to toggle word wrap, etc.

R editor:

  • Added a new warning and quickfix for possibly wrong comparisons of NULL, NA, NaN

  • Added a new option in the preferences for the new warning
  • Added new context menu actions in menu “Text” (Find and replace, Toggle Block Selection, To Upper Case, To Lower Case)
  • Improved the display for quickfix suggestion, warning and errors when the font is resized dynamically (especially for MacOSX)
  • The help browser for code completion popups now display help sites in dark mode if the Bio7 dark theme is enabled.

ImageJ Macro Editor

  • Added a general rename method to rename selected word occurences
  • Added new context menu actions in menu “Text” (Find and replace, Toggle Block Selection, To Upper Case, To Lower Case)
  • Added latest macro code completion function definitions

Download and Installation:


Just download the *.zip distribution file from and unzip it in your preferred location. Bio7 comes bundled with a Java Runtime Environment, R and Rserve distribution and works out of the box.


Download and extract the installation file from
For Linux you have to install R and Rserve (see Rserve installation below!).


Download and extract the installation file from

If you start Bio7 a warning or error can occur because of the changes how Apple treats signatures! To allow Bio7 to start see this instructions for Yosemite and Sierra:

OS X Yosemite: Open an app from an unidentified developer

macOS Sierra: Open an app from an unidentified developer

If you have still problems with Sierra see this solution!

In addition for MacOSX you have to install R and Rserve (see below!).

Linux and MacOSX Rserve (compiled for cooperative mode) installation:

To install Rserve open the R shell and then execute the menu action “Options -> Install Rserve (coop. mode) for R …” for different R versions. This will download an install Rserve in your default R library location, see video below (please make sure that your default Linux R library install location has writing permissions!). In cooperative mode only one connection at a time is allowed (which we want for this Desktop appl.) and all subsequent connections share the same namespace (default on Windows)!

Play Video

This video will be embedded from Youtube. The privacy policies of google apply.

Installation of Useful R Packages

R packages which are useful in combination with Bio7 can easily be installed with the R-Shell context menu “Packages” action:

R-Shell context menu->Packages->Install_Default_R_Packages

Bio7 Documentation

For more information about Bio7 please consult the soon updated Bio7 User Guide.

A plethora of Bio7 videotutorials for an introduction can be found on YouTube.

Debug Java in Bio7


In Bio7 R and Java code can be easily combined in the Bio7 platform. For instance to create Graphical User Interfaces in Java (with SWT or JavaFX), transfer image pixel/selection data from ImageJ and finally doing the analysis parts in R code/scripts which can be called from within Java (an easy to use API on top of Rserve in Bio7 is available, see, e.g., Groovy examples here).

However sometimes it is necessary to debug the Java language as part of such combined work. In Bio7 (based on Eclipse RCP) the very powerful Java debugging tools from Eclipse are available by default.

In addition in Bio7 it is possible to debug dynamically compiled Java classes in the same Bio7 process (using Java like a scripting language is a special feature of Bio7).

The video at the bottom of this page demonstrates the use of a remote debugging connection on the same computer (localhost connection) to debug dynamically compiled/executed Java code.

Debugging a Java process which has already started (Bio7 in this case) is only possible if Bio7 is started beforehand with the following Java arguments inside a shell to start a debug server connection:

Windows (started from the current directory = Bio7 installation directory):
Bio7.exe -vmargs -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000

Mac (given the full path to the Bio7 executable):
/Applications/ -vmargs -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000

Linux (started from the current directory = Bio7 installation directory):
./Bio7 -vmargs -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000

Furthermore the compiler debug information option has to be enabled in the Bio7 Java preferences (for the dynamic compilation process) and a seperate debug connection has to be started for this Java class (with the available Eclipse debug configuration dialog).

In the video below I (hopefully) demonstrate how you can (graphically) debug a simple cellular automata simulation like the Game of Life within a running Bio7 (Java) process.

Please activate JavaScript to view this video.

R Improvements for Bio7 2.8


The next release of Bio7 adds a lot of new R features and improvements. One minor change is that the default perspective after the startup of Bio7 now is the R perspective to emphazise the importance of R within this software.

The R-Shell view has been simplified and the R templates have been moved in it’s own simple view for an improved usability (see screenshot from R perspective below).

In addition the context menu has been enhanced to allow the creation of submenus from scripts found in folders and subfolders (recursively added) which you can create for a menu structure.
Scripts can be added created in R, JavaScript, Groovy, Jython, BeanShell, ImageJ Macros.
Java (with dependant classes) can be dynamically compiled and executed like a script, too.

Several improvements have also been added to the R-Shell and the R editor for an easier generation of valid R code. The R-Shell and the R editor now display R workspace objects with it’s class and structure in the code completion dialog (marked with a new workspace icon – see below).


R editor:

In the R editor a new quick fix function has been added to detect and install missing packages (from scanned default packages folder of an R installation – has to be enabled in the Bio7 R code analysis preferences).

Also the detection of missing package imports are fixable (when a function is called but the installed package declaration is missing in the code but the package is installed to deliver the function).

The code assistance in the R-Shell and in the R editor now offers completions for, e.g., dataframes (columns) in the %>% operator of piped function calls:

In addition code assistance is available for list, vectors, dataframes and arrays of named rows and columns, etc., when available in the current R environment.

Code completion for package functions can now easily added with the R-Shell or the R editor which loads the package function help for both interfaces. The editor will automatically be updated (see updated editor marking unknown functions in screencast below).

Numerous other features, improvements and bugfixes have been added, too.

Bio7 2.8 will hopefully be available soon at:

Overview videos on YouTube



Bio7 2.7 Retina-Display Fix for MacOSX


I recently discovered on a high dpi display (Retina-Display) enabled 13’’ notebook that the latest release of Bio7 for MacOSX is not displayed in high dpi but in a lower resolution which makes text and icons blurry (scaled) and unnecessary strains the eyes when editing R scripts with the R editor.

So I uploaded a new, fixed version for MacOSX.

However, to fix an already downloaded version of Bio7 you have to open open the ‘/’ file with a text editor (right-click on, execute ‘Show Package Contents’ and open ‘/Contents/Info.plist’) and add the following lines before the </dict> tag:


In addition to update the Info.plist file for the Operating System you have to open the Terminal (in ‘Applications/Utilities’) and execute the following command (default install directory – shell command is one line!):

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -v -f /Applications/

Here some screenshots from before and after the fix was applied on a Retina-Display (zoom in for details):



An updated version with the fix already applied can be downloaded here

See also:

Release notes for Bio7 2.7