ImageJ Macros

ImageJ is a nice, open source, free image analysis program developed by Wayne Rasband and made available by the NIH. It runs on any computer that has Java installed, be it Linux (or other Unix-like OS), MacOS or Windows. You can even run ImageJ as an applet in a webpage!

Part of ImageJ's power is in its ease of extension. You can write your own macros that can do fairly sophisticated stuff, using a very simple language. If you know a bit of Java, you can write even more sophisticated plugins to ImageJ. The other part of ImageJ's power is the community of developers who write macros and plugins (usually for some specific problem), which are then made freely available to everyone.

In the course of my PhD study I have written a couple of macros to streamline data acquisition from confocal and SEM images. Feel free to use them, rip the code to bits, borrow chunks of code or whatever. If you find errors or have improvements then please email me.

Further information on ImageJ and macro writing can be found at the NIH. Try the mailing list archive if you are stuck, or, join the mailing list!

Volume fraction of bone

VolumeFractionOfBone is a macro developed to measure the fraction of an ROI occupied by mineralised bone matrix. It uses thresholded greyscale images, for example quantitative backscattered electron (qBSE) scanning electron micrographs, or microCT stacks. The thresholded area is divided by the total ROI area to gain area fraction. Stacks of images are processed in sequence and results collated to generate volume fraction, useful for MRI, CT, µCT or any other 3D data set. Mean and modal mineralisation density are measured from the total ROI area and the thresholded area. You can set the top and bottom of the sampled volume by pressing [j] and [l] respectively. This macro has been superseded by Volume Fraction, a command in BoneJ.

Volume slicer

3D rendering of bone imaged by microCT
Rendered MicroCT Volume
MPEG (400 kB)
VolumeSlicer is an interface to Kai Uwe Barthel's Volume Viewer 3D rendering plugin. It allows you to create an animated volume rendering of an image stack by entering variables into a GUI dialog. The variables are directly passed to Volume Viewer, which creates a stack of rendered views that you can export as an AVI movie. You can get an idea of the values that you will need to use by opening your data in a Volume Viewer window. Running the job for a small number of frames is helpful while fine-tuning the rotation and slicing variables. The example rendering is of trabecular bone in the distal third metacarpal condyle of an 18-month-old Thoroughbred horse, imaged at 15 micron resolution in the MuCat X-ray microtomography facility by Graham Davis (QMUL Biophysics).

Articular calcified cartilage (ACC)

Cartilage is a macro that opens a contiguous, linear sequence of qBSE images, orders them in a stack, asks which direction the sequence was made in and applies a scale. The user then measures ACC thickness and mineralisation density with the line tool. A spacer ROI is drawn after each measurement to reduce measurement bias. The macro calculates a proportional distance from the starting image and returns all data in a log window.

ACC Dm and LAR

Calcein_Dm is a macro that opens two images, synchronises them with Joachim Walter's very cool Sync Windows plugin, applies the appropriate scale, sets some experimental parameters and initialises a straight line selection ROI. It also draws a circle ROI to guide the even spacing of ROIs along the mineralising front.

The purpose of Calcein_Dm is to allow the simultaneous measurement of mineralisation density (Dm) and linear accretion rate (LAR) from qBSE and confocal images. Vital calcein labels mark two known time points from which LAR can be calculated, and between which Dm can be measured. Thus LAR and Dm can be directly correlated at the mineralising front.

Graph-plotting macros

Rectangular_Scattergraph plots (x,y) coordinates from a comma-separated value (CSV) file on a cartesian grid, then colours the points based on the density of neighbouring points. Radial_Scattergraph Plots (theta,r) data from a CSV file and colours the points based on the neighbourhood density. Radial_Histogram takes the first column of a CSV file and plots the values (0-360o) as a radial histogram.

Umis Array Plotter

Umis Array was designed to retrieve the coordinates of a UMIS nanoindentation array from a CSV layout file and display them on a micrograph of the array. The image can be of any type, however, if a quantitative backscattered electron scanning electron (qBSE) micrograph is used, mineralisation density can easily be measured and correlated to nanoindentation modulus.

The current version of Umis Array expects a qBSE image, a topographic image registered to the qBSE image and an array file in (x,y,f) comma-separated format. Additionally, a CSV list of elastic moduli can be loaded to produce a scatter plot of E vs qBSE at you measure. The array is set up with [b], you can move forwards [l] and backwards [j] through the array and measure mineralisation density on the qBSE image with [t]. You can print a whole array with [y], and go to any indent in the array with [g]. The macro can handle rotation, skew and reflection of the array in the image, since there is some backlash in the UMIS's x-direction, and because one never quite gets the image perfectly straight! Umis Array allows the user to alter manually the position of each indent position by moving the ROI before moving to the next indent position - the new position is maintained in memory throughout the session on the array.

Umis Array v0.53 allows the direct correlation beween backscatter coefficient and nanoindentation elastic modulus. The qBSE image, topographic image and layout file are loaded with [b] and the refence points identified with [Ctrl]+left click (0,0), [Alt] + left click (xmax, 0) and [Shift] + left click (0,ymax). The elastic modulus map is created by pressing [f], which asks you to choose the CSV list of modulus values in (n, mean E, std dev E) format. It then draws an array of polygons in register with the qBSE image, whose grey levels are proportional to the mean elastic modulus at that point. If you install the Interactive 3D Surface Plot plugin, you can map the elastic modulus on the z-axis, and overlay the qBSE image as a texture.

Both Umis array macros were written for:
Doube M, Firth EC, Boyde A, Bushby AJ (2010) Combined nanoindentation testing and scanning electron microscopy of bone and articular calcified cartilage in an equine fracture predilection site. European Cells and Materials 19: 242-251

Umis Array Designer

Umis Array Designer producing an array layout fileUmis Array Designer helps you generate the layout file that the UMIS nanoindentation program uses to direct a set of indents. Open an image of the region you wish to indent with [b], set the scale, draw a rectangular selection (with rotation if desired), hit [u], enter some parameters and the comma-separated array data are output to the log file, and the array drawn on the image. The macro also draws marker indents at a nominated indentation force, offset from the body of the ROI. You could use the code in this macro to generate a rectangular grid of points for any purpose. The array is designed to start at the lower left of the ROI, and overhangs at the top and right of the array by one row and column, to ensure coverage of the specimen area. You can undo an undesirable array with [z] and continue working on the same image.

DICOM File Batch Rename

Mouse X-rayDCMRenamer processes a directory full of DICOM images, renaming them with the contents of one of the DICOM header tags. This example was written for output from a Faxitron digital microradiography cabinet, which comprised pairs of 11 MB DICOM images and identically-named 256 kB BMP thumbnails. The tag 0010,0010 relates to patient ID fields, into which we had entered specimen details. The macro handles repeated tag information by appending a unique number to filenames that would otherwise be overwritten.

Rotating Callipers

Rotating Calipers calculates the minimum and maximum diameters of an ROI as they would be measured with real, parallel callipers. The method is adapted from this description. Thanks to Gabriel Landini for pointing me in the right direction.

MomentMacroJ_MD

MomentMacroJ_MD is a customised version of the original MomentMacroJ, which is available from JHU. It is designed to run on CT scans of bones in air, and calculates a number of geometric parameters: second moments of area; section moduli; cortical thickness and cross-sectional area are included. MomentMacroJ_MD iterates over every slice in a stack and creates an annotated copy on which the centroid and principal axes are drawn. Density-weighted calculations are provided.

MomentMacroJ_MD was written for a study of felid limb bone scaling.

This macro has been superseded by Slice Geometry, a plugin in BoneJ, which runs 2-3 orders of magnitude faster. It is highly recommended that you use Slice Geometry rather than MomentMacroJ_MD.

Point to ROI

Point to ROI was designed to measure the shortest distance from osteocytes to the osteonal canal surface and to the cement line. It interactively adds ROIs to the ROI manager and logs distances. See: Power J, et al. (2010) Sclerostin and the regulation of bone formation: Effects in hip osteoarthritis and femoral neck fracture. Journal of Bone and Mineral Research. doi:10.1002/jbmr.70

Doube.org's International Visitors

Locations of visitors to this page

This file last modified 0803hrs 28 July 2011 © Michael Doube 2004-2012 :: Designed to be interoperable and standards-compliant. Looks best with Mozilla Firefox.