Analysis of biological image data typically requires applying multiple algorithms in sequence to many images. Scripting uses a series of simple programming commands (the “script”) to define a sequence of algorithmic operations and then apply them to an image collection.
In Fiji, individual scripting commands can be quickly tested by applying them interactively to opened images using the appropriate Interpreter plugin (for example Jython Interpreter). Beyond interactive execution of commands on current images Fiji also provides a Script Editor that enables writing, debugging, testing and running of arbitrarily complex scripts in all the above languages and additionally Java itself. With the Script Editor users can perform complex tasks with a few lines of code requiring minimal programming knowledge. It becomes relatively simple (16 lines of code) to load a multi-channel 3d image stack, identify all cells in one channel and visualize the results in the 4d Viewer plugin (). Similarly users can implement a simple task such as swapping fluorescent channels in multidimensional images and apply it to a large collection of images in a directory using scripting commands for file manipulation (Supplementary Fig. 3
). The details of the code are unimportant (extensive tutorials are available at http://fiji.sc/wiki/index.php/Category:Scripting
) however it is crucial to note that all the scripting languages enable users to access Fiji’s extensive algorithmic libraries that implement advanced image analysis techniques in Java. Thus researchers do not need to become fluent in Java programming and can use their existing scripting skills to apply complex algorithms to their data. Scripts are seamlessly included in Fiji’s menu structure and can be publicly distributed through the Fiji Updater. These publishing mechanisms ensure validity and long-term viability, and are more convenient for biologists compared with closed scripting environments such as MATLAB.
A key feature of the Fiji project is ImgLib ()26
, a library for type-, dimension-, and storage-independent representation of image data that enables writing generic algorithms in a high-performance manner. In ImgLib, image processing algorithms are implemented just once and can be applied without change to most kinds of images. In other words, ImgLib enables users to apply a complex image processing algorithm to any image regardless of how many dimensions the image has (1d, 2d, 3d, 2d+t, 3d+t, etc.), what the underlying data type is (8-bit, 16-bit, etc.) or how the image is stored (in memory, paged to disc, distributed over the net).
We demonstrate the dimensionality independence of ImgLib when applying segmentation algorithms to confocal scans of C. elegans
larvae expressing fluorescent markers of cell nuclei (). Difference of Gaussian (DoG) and Maximally Stable Extremal Regions (MSER)27
are two examples of blob detection algorithms inspired by computer vision literature that are suitable for detecting cells in biological images. The DoG is computed by subtracting two consecutive Gaussian convolutions of the image. Intensity maxima and minima in the DoG represent bright and dark blob detections, respectively. The MSER tree provides a nested hierarchy of blob segmentation hypotheses, which is particularly relevant in densely packed cellular field. Both algorithms are applicable for processing of 1d curves (), 2d image slices () and 3d image volumes (). With ImgLib a single, simple piece of computer code (Supplementary Fig. 4
) is capable of running the algorithms on images of arbitrary dimensions without any modification (DoG and MSER for 1d, 2d, 3d respectively).
ImgLib is and should be invisible to casual users. It is an “under the hood” advanced software engineering concept that makes programming easier. ImgLib empowers users and computer vision researchers with the abstraction necessary to seamlessly translate mathematical description of an advanced idea or algorithm into concise code that will run efficiently on large bioimages. Similar libraries that separate the algorithm essence from the actual implementation are available on other platforms such as ITK/VTK28
Both examples of scripts mentioned above use ImgLib to do the processing steered by simple scripting commands. Equivalent programs in ImageJ’s macro language or Java would be much more complex or not possible. This is due to the combination of scripting language simplicity and the dimension-, type- and storage-strategy independence of ImgLib. In the next section we showcase how the synergy of Fiji, ImgLib and other libraries results in transformation of abstract algorithms into usable biological image analysis applications.