Author Archives: Marcel Austenfeld

Eclipse ImageJ Plugin Update Released

12.02.2019

I released a new version of the ImageJ plugin which comes bundled with a feature complete ImageJ macro editor and an embedded Eclipse ImageJ interface.

Screenshot (Windows, Eclipse Darkest Dark Theme)

Screenshot Code Completion (Windows, Eclipse Darkest Dark Theme)

Release notes:

  • Updated ImageJ version 1.52m (1.52m12)
  • Improved the ImageJ canvas (Plot canvas and Image canvas are now opened as intended)
  • The ImageJ canvas replace method now works as intended (see, e.g., IJ_webcam capture plugin)
  • Improved plot canvas (zooming, actions, etc. are now working as intended)
  • Plot action buttons are now added below each plot (see screenshot below)
  • Added new actions (in the plugins menu) to interpret the current opened Eclipse editor sources (BeanShell, JavaScript, Jython and ImageJ macro) using the ImageJ interpreters (using, e.g., PyDev for Jython).
  • Added a new Java compile action (in the plugins menu) to compile the current opened Eclipse editor source (see screenshot below). To compile dynamically with ImageJ please use or adjust the ImageJ plugins path in the Eclipse preferences.
  • MouseWheel actions are now working as intended (use STRG+MouseWheel to zoom!)
  • Improved stability for drag and drop actions of multiple image files
  • Improved stability for MacOSX
  • Reorganized Eclipse plugins and features
  • ImageJ2 can now be optionally installed and is not bundled by default (now optional dependent of ImageJ). Customization is possible (plugin can be populated with maven command in Eclipse)
  • Added the latest ImageJ macro function templates
  • JavaFX (embed Swing in JavaFX and SWT panel) can now be optionally installed (but is not necessary by default)
  • Removed the outdated Albireo plugin dependency
  • Added key listeners for the tab when all images are closed (ImageJ keys!)
  • Improved the ImageJ macro hoover (workaround for SWT_AWT)
  • Added a workaround for repaint issues in MacOSX when switching perspectives with SWT_AWT
  • Added a workaround for MacOSX to receive key events again after focus lost (sometimes you need to press the mouse two times when the perspectives have been switched)
  • Fixed several rare occuring deadlock events on MacOSX

Installation:

It might be necessary to uninstall old plugin versions first!

To install the plugin the latest OpenJDK 11 is required and an installation of Eclipse 4.10 or 4.9.

The plugin is availabe from the Eclipse Marketplace Client:

https://marketplace.eclipse.org/content/imagej-plugin

As an alternative open the Help->Install new Software dialog and add the following update site:

https://bio7.github.io/imagej/

MacOSX Eclipse Fontsize Correction

To fix the default font size on Eclipse (a matter of taste) I wrote a short summary on the Github page how to fix the font size (see https://github.com/Bio7/EclipseImageJ1Plugin 1 – bottom page).

The plugin source and more information can be found on Github:

https://github.com/Bio7/EclipseImageJ1Plugin

The Road to OpenJDK 11

22.11.2018

it was a long road to the Java 11module system because a lot of bugs and settings had to be fixed for the next release of Bio7 which will be bundled with the OpenJDK as the default Java Runtime.

With Java 11 finally scaling of JavavFX, Swing and AWT components inside of Bio7 is supported on High DPI displays (SWT already supports this). However I have to make some more tests to remove the tiny drawing glitches if possible.

In additon with Java 11 SWT and JavaFX now support GTK 3 on Linux systems (see Ubuntu 18.10 screenshot below) still running on X11 which is default on Ubuntu (there are still some Wayland bugs which have to be resolved).

I already made some test exports on Linux and Windows and I think the next release (Bio7 3.0) will be available some time after the next Eclipse release which supports the Java 11 syntax completely.

 

Transfer data from R to Python with PyRserve and Bio7

29.08.2018

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.
Video-Link: https://youtu.be/-kySAN9doXQ

Update Site PyDev: http://www.pydev.org/updates/

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:

library(Rserve)
run.Rserve()

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)")
conn.close()
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')})")
conn.close()
if matrix != 'NULL':
    # we have to transpose the image for a correct view!
    matrix = matrix.T
    plt.imshow(matrix)
    plt.colorbar()
    plt.show()

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 Examples_PyRserve.zip 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

16.08.2018

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:

General:

  • 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)

R:

  • 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

  • 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:

Windows:

Just download the *.zip distribution file from https://bio7.org 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.

Linux:

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

MacOSX:

Download and extract the installation file from https://bio7.org.

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

27.06.2018

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/Bio7.app/Contents/MacOS/Bio7 -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.
Video-Link: https://www.youtube.com/watch?v=vKAGBGuQKlI