0

I have a somewhat conceptual question, so apologies for being non-specific.

I’m a biologist and work with image analysis. I’m working on a methods publication, which includes image analysis with an ImageJ script that I developed and data analysis using our R package. Ideally we would like to publish our data, distribute the macro and make the R analysis available through a web application. The goal is to make the method available for people with little computer literacy.

So I’m trying to understand if I need to develop my macro into a plugin. So far from what I understand developing a plugin will likely to speed up the analysis of large data sets, be compile safe and enable automatic updates.

My ImageJ macro is pretty simple. It utilizes a bunch of ImageJ commands from several already available plugins.

The interface was made so that the user does not need to be ImageJ-literate, with dialogs to specify input folders and set some of the parameters. The end result is a bunch of images and .csv files that can be further used for analysis in R. It also documents what analysis was done and saves some intermediate files.

It has been working very nicely and I’ve tried it on Mac OS, Windows and Linux platforms. However with large data sets the macro can become pretty slow.

I have poor Java skills so developing a plugin will take a lot of time and learning on my end.

So I’m contemplating if I could publish the script as it is, or if it would be sort of irresponsible to release a code that can cause bugs, runs slowly and is not updated automatically. Or are there any alternatives or maybe simpler ways to convert a script into a plugin.

I would really appreciate any comments or advice!

Patrick
  • 5,526
  • 14
  • 64
  • 101
Anastasia
  • 1
  • 2

2 Answers2

1

So I’m contemplating if I could publish the script as it is, or if it would be sort of irresponsible to release a code that can cause bugs, runs slowly and is not updated automatically. Or are there any alternatives or maybe simpler ways to convert a script into a plugin.

This question is likely off-topic for StackOverflow. If you have not done so already, I would suggest posting it on the ImageJ Forum, which is geared for exactly this sort of discussion.

When in doubt, I would always advise publishing your code as-is rather than sitting on it. It is good enough! If you are embarrassed, you can include an explicit disclaimer, or even use a license like the CRAPL to convey the context of the code's development. It is good that you are considering the ramifications of releasing broken or buggy code, but it should suffice to document the ways in which the code falls short.

I agree with your assessment that developing ImageJ macros is easier than developing using one of the other supported scripting languages, even if those other languages are ultimately more powerful.

Note that you can call macros from scripts, and vice versa. So you could write a script and then call your macro from it, if that makes things easier.

Note also that ImageJ does include a JVM-based version of R called Renjin, although there is no documentation on using it yet. This could potentially make your life easier with respect to your R-based functionality, depending which R packages you use (not all of them are available for Renjin).

Or are there any alternatives or maybe simpler ways to convert a script into a plugin.

You can use the Macro Recorder to record in a language such as JavaScript. This greatly facilitates generating the correct lines of code for use in any of the full-fledged scripting languages, often with minimal or no changes to the syntax depending on which script language you are targeting.

Finally, to distribute your functionality to end users, I strongly suggest you peruse the Distribution page of the ImageJ wiki, which covers the best practices of doing that.

ctrueden
  • 6,751
  • 3
  • 37
  • 69
  • Thanks ctrueden for such a detailed answer. So eventually I translated the most crucial part of my script using macro recorder just as you suggested and did not see is affect performance. So I decided to not waste any time on translating the whole thing from macro language. Also thanks for the Distribution page link, is is very useful. As for the R - I decided to go with Shiny app that just allows to download the ImageJ script and run it on the user's computer and then upload the measurements and analyze them with the web app. – Anastasia Oct 11 '17 at 15:21
0

i would suggest maybe trying to write in jython as its a little easier than java. if you post the code or email it could give some advice/i could change the language myself if its not too complicated. Difficult to say how much faster it will run but should be faster (depends what you're trying to do)

mikew
  • 31
  • 7
  • Thanks Patrick! I'll give Jython a try. The macro is not difficult, but it's quite long. I'll translate a part of it and see if it affects performance. – Anastasia Aug 24 '17 at 14:42