Scripting with ImageJ

An introduction to ImageJ Ops

Curtis Rueden, UW-Madison LOCI

Tweets to #neubias


  1. Everyone installed Beaker, right? Great! 👍

  2. Now clone the ImageJ tutorials repository:
    git clone git://

  3. Finally, start Beaker and open this notebook:
    ImageJ Tutorials and Demo.bkr
    It will take a few minutes (!) to initialize.


  • Notebook fails to initialize?
    1. Borrow a thumb drive.
    2. Copy to your home folder.
    3. Unzip it.
    4. Check for ~/.groovy/grapes and ~/data.
    5. Copy the .bkr notebooks too if you like.
    6. Give back the thumb drive. 😉


  • Beaker launches, but nothing happens?
    1. Try this link to open a local Beaker web page.

  • Beaker cannot install, or crashes?
    1. Try restarting Beaker.
    2. Use the online static version.

Working state to working state

A software engineer, a hardware engineer and a department manager were on their way to a meeting in Switzerland. They were driving down a steep mountain road when suddenly the brakes on their car failed. The car careened almost out of control down the road, bouncing off the crash barriers, until it miraculously ground to a halt scraping along the mountainside.

The car's occupants, shaken but unhurt, now had a problem: they were stuck halfway down a mountain in a car with no brakes. What were they to do?

What should they do?

Department manager
Have a meeting, propose a Vision, formulate a Mission Statement, define some Goals and by a process of Continuous Improvement find a solution to the Critical Problems.

Hardware engineer
Strip down the car's braking system, isolate the fault, and fix it.

Software engineer
Push the car back up the road and see if it happens again.


  • Compare working to non-working: what changed?
  • Needed for effective bug reports.
  • Works great with the scientific method, too.


Why should you care about ImageJ?
Why not use Imaris and MATLAB for everything?

  • Pragmatic: You can fix bugs, add features
  • Scientific: See and understand how it works
  • Frugal: ImageJ is free and cross-platform
  • Ethical: Fully reproducible, better science

How to be effective

  • VCS – Version Control System
  • IDE – Integrated Development Environment
  • CLI – Command Line Tools
  • Build systems and dependency management
  • Debuggers

Further reading

Get involved

  • Edit and improve the ImageJ wiki
  • Make your science open and reproducible
  • Add your favorite/new algorithms as Ops
  • Help others to avoid repeating your pain
  • Discuss ideas publicly to help all of us
  • You are custodians of the OSS ecosystem!

Workshop caveats

  • I cannot show you real workflows.

  • Ops is still not stable.

Data science observations

  • Tools are always changing, improving
  • Different tools have different strengths
  • No one language is poised to dominate

Conclusion: use polyglot tools!

Which tools are "polyglot"?

Look forward to Martin's KNIME workshop tomorrow!

We will use Beaker Notebook to explore ImageJ today.

More will emerge. Always keep looking!

Beaker vs. Jupyter Notebook

  • Jupyter has only one language kernel at a time.
  • Beaker is (IMHO) easier to install.
  • Beaker works better for Java code.
  • Jupyter works better (?) for Python code.
  • GitHub renders Jupyter notebooks, but not Beaker ones.
  • Jupyter has a much larger community.

Strengths of Beaker

  • Groovy, Python, R
  • Charts (Groovy and Python APIs)
  • Language switching

Beaker Examples and Help

Script tools inside ImageJ

Beaker Time!

Our first ImageJ plugin

Further reading about ImageJ

Rueden, C. T., et al. "ImageJ2: ImageJ for the next generation of scientific image data." arXiv preprint (2017).