JavaFx scatter plot for ImageJ... a working example

Hi all,

In the process of updating my Dimensionality Reduction plugin, I decided to play around with JavaFx for visualisation and data interactivity purposes. Specifically, I desired to create a new plotting visualisation that would allow user interactivity. The native ImageJ scatter-plot is great in many ways and I have created a macro ‘hack’ (not posted here) to be able to select plotted data points that can then be related to the image/results-table-entry of origin. However, I felt that the node-based JavaFx application platform might be a more natural fit to achieve the kind of GUI-user interactions and datapoint-to-datapoint bindings that I envisaged would be useful to my plugin.

Anyway, rather than describe the progress on my plug-in per se (I can update an older thread on that in due time), I thought some of you might be interested in my working implementation of a JaxaFx plot in ImageJ. It was quite the challenge for me (as a non-professional programmer) on-and-off over the past 2 weeks, and especially these past two weekends. I also feel like I scoured the furthest corners of stackoverflow to overcome peculiar Swing-to-Fx handover limitations and intrinsic concurrency issues. All that being said, I now have a working Fx scatter plot with interactive nodes and a conventional data (array) input and output methodology. This is an example of a generated plot (by my plugin processing a stack of Images, in this case):

(NOTE: the plugin only outputs the JavaFx plot using UMAP atm).
There’s only one layout hardcoded into the plugin right now, but, as you can hopefully see, I made some efforts to make the appearance similar to a normal ImageJ scatter plot eg:

Normal ImageJ scatter

And now the groundwork is laid, it should be fairly trivial to allow users to change layouts via GUI setting in the future.

In terms of the plots being interactive, I currently have the legend set to allow dataset group display/hide toggling upon user mouse clicking of the legend icons:

And main-window point selections:

Clicking_a_plot_datapoint

Although, as I haven’t finished updating my plugin yet, clicking on plotted datapoints only updates the log window (as per the example image). For my plugin, I will have the corresponding input images automatically displayed from the input stack. FYI, this was the input stack in this example:

Olivetti_faces

Again, this post isn’t meant to update on my DR plugin, but perhaps to let any interested parties be aware that I have a working JavaFx plot template now implemented and tested.

I have a feeling that this kind of plot might be useful to others, generally, and, from a cursory search, I could not find another implementation like this anywhere. I do acknowledge that there may be some that I have have missed though :confused:. For instance, the ImageJ2 JavaFx advice for plugin developers page (Build ImageJ2 Plugin With JavaFX - ImageJ) doesn’t explicitly mention graph-plots and I didn’t see an equivalent example in @ctrueden’s JavaFx github repo (imagej-plugins-javafx/src/main/java/net/imagej/javafx at master · ctrueden/imagej-plugins-javafx · GitHub). I’m sort-of aware that other plug-ins may have independently incorporated JavaFx elements (windows and GUI interfaces). Apologies if me posting this does turn out to be redundant in the light of other initiatives.

If there is any appetite for it, I can perhaps focus on making the Fx plot a discrete entity? At the moment, it is not a replacement for the native ImageJ plotting window and plug-in API. In fact, right now, you cannot even zoom into the plot!

Before then (and if an independent plot development even does happen), feel free to access the source code for my current plug-in implementation here (Dimensionality Reduction_ImageJ plugin - Google Drive). It’s the EXPERIMENTAL file. Fair warning, the code could be a bit neater. Also, currently, to use the plug-in, the following javafx dependencies are required:

Sorry for the long post.

Kind regards.

1 Like