Writing plugins for ImageJ

Notes and examples on writing a plugin for ImageJ.

Context

In scientific imaging, ImageJ is a standard software for image analysis and processing. Its architecture allows automation and extensibility through plugins and a macro language. There are many plugins available, but they do not entirely cover all specific tasks. In such cases, we should write our own code.

For simple tasks, a macro can do the job quite well, but when the processing becomes more complex, a macro becomes difficult to debug, modify, and maintain. For these cases, writing a plugin seems a better strategy. When developing plugins, we can utilise IDEs that offer a range of enhanced tools for coding, debugging, versioning, and project management, thereby simplifying the development process.

I do have experience writing macros for ImageJ. For my research, I developed a script for counting the number of nanoparticles taken up by cells. Now, I need to update and improve this script to use it in my current research project. I decided to translate this script into a plugin, so I can also share it easily with my colleagues and community. But I don’t have experience in writing plugins. So, I’m going to learn how to do it here.

Aim

The final goal is to translate an existing macro for ImageJ into a plugin.

Plan

I will start by understanding the plugin’s structure and learning the basics of SciJava and the ImageJ API.

The first landmark will be wrapping the current macro inside a plugin, to provide the functionality while simplifying distribution and access in Fiji’s menu. Then, I will translate each function in the macro to one in SciJava. Finally, I will redesign the workflow and user interface.

The progress is presented as blog articles.

  1. Starting with ImageJ plugins
  2. Wrapping a macro in a plugin
  3. User interaction

Developing framework

There is flexibility regarding the tools used for programming a plugin. First, I’m using ImageJ2 as a target and debugging environment. For coding, I’m using IntelliJ IDEA Community Edition. And for testing the final user experience, I’m installing the plugin in Fiji.