ImageJ macros

Disclaimer: all the macros published on this page can be used at your own risk. Although I did my best to ensure that they run as intended, there may be bugs, not expected use or changes to the ImageJ code that results in unexpected behaviour. If you notice a problem with any of the macros please let me know and I can try to solve the problem.

Available macros:

stackHistogramLister2
Creating random dots and measure distance to objects of interest
Plot results
ROI labels
Image annotation macro
Delete ROI from image, ROI manager and Results table
Time space plot (kymograph)
Identify cell area in WGA stained cells
Overlay scalebar macro
Separate Z-stack and position information from large tif files
Convert large tif files to 8 bit
Multi colour line profile plot
Overview heatmap

stackHistogramLister2

Calculates the number of pixels for each intensity in every individual image in a stack or hyperstack. Works also on single images. The macro asks the user for the bin count and histogram min and max and then writes the histogram counts to the Results window. Build from the original StackHistogramlister macro (https://imagej.nih.gov/ij/macros/StackHistogramLister.txt) with some improvements including an easier to handle results table for (hyper)stacks.

Download the macro: stackHistogramLister2.ijm

 

Creating random dots and measure distance to objects of interest

This macro will create random dots in the binary image and measures the shortest distance of dots to objects of interest (value = 255),  records mean distance per simulation off all dots and only the dots outside the objects of interest and prints this in a log file. It also will record how many dots are inside the objects of interest.The macro assumes you have a binary image open.
The user can set the number of repeats and the number of dots randomly placed in the image. The user can also indicate if the dots should be placed over the whole image or only outside the objects of interest.

The name of the results table includes the name of the image, a unique number and the number of dots used in the analysis. 
As starting point I used the code published by Olivier Burri on the ImageJ mailing list on 2 June 2014:
'Generating random points and tallying proportion of points that fall within object'

Download the macro: randomDotsTo_Objects.txt

 

Plot results

This macro allows the user to plot 2 results parameters found in the results table.

Menu sample

Plot sample

Download the macro: Results_graph.txt

 

ROI Labels

A macro to add ROI labels on an overlay to the right or below the ROIs stored in the ROI manager. ImageJ/Fiji will put a label in the centre of the ROI.

Download macro: ROI_Labels.txt

 

Image annotation macro

Overlay menu from annotation macro

Macro to add a Rectangular, Oval, Freehand, Straight Line, Arrow or Text selection to an overlay. The macro allows the user to add more than one selection. The user can select the start and end slice/frame for each of the selections. Very useful to annotate time series.  When an image is "flattened" the overlays are permanently "burned" onto the image and cannot be removed anymore. The macro should be able to handle all image types. Updated 24 August 2020.

Download the macro: Annotation_to_overlay1.5.ijm

 

Delete ROI from image, ROI manager and Results table

This macro allows the user to left mouse-click on a ROI name in the image what will delete the ROI from the image, ROI manager and results table.
For this to work the results table has to be created using the Multi Measure option (deselect "One Row Per Slice") from the ROI Managers menu with "Display label" selected in Set Measurements (Analyze > Set Measurements).

Download macro: DeleteSelected_ROI2.txt

 

Time space plot (kymogram) or a cross section space plot (z-stack)

KymographThis macro will take a line selection (Straight line, Segmented line or Freehand line) and create a time space plot (kymogram) or a cross section space plot (z-stack). When you install the macro a new Tool icon will appear in the Tool bar. Draw a line in your image and click the icon to create the overview plot. The user can change the width of the line by double clicking the icon. The default is 10. Once changed this keeps the new value till the macro is restarted. This value can also be changed in the macro code by changing the value of x.

Above a kymograph of the line selection of the maximum intensity projection from the ImageJ sample image "Mitosis"green channel.

Download macro: MicroTubBleachTool.ijm

 

Identify cell area in WGA stained cells

This macro can be used to calculate cell area in *.tif or *.jpg images of tissue samples stained for cell walls. It was written for WGA stained cells. The user has the choice to analyse the whole image, using a saved ROI, making one ROI to be used for all images or to draw a seperate ROI for each image. The result ROI images will be saved in jpg format and the ROI manager results will be saved as well (as zip file) to allow control over the results.
This macro needs the plugin: Rolling Ball Background.

Download macro: WGA_all.txt.

Download manual in pdf form.

There are three alternative versions of this macro.
- Version 3.1 was optimized for images from Dr Wei Ni, Diabetes Center, University of California, San Francisco.
- Version Histo_2 optimized for images from Malgosia Kepczynska, University of Buckingham, UK using Haematoxylin& eosin Y stained adipose tissue sections.
- Version SEM optimized for SEM image analysis for Chris Fogarty, Helsinki.
Click on the download links below the images.

WGA3.1.txt Histo_6.txt SEM.txt

Publications acknowledging this macro:

Ni W, Watts SW, Ng M, Chen S, Glenn DJ, Gardner DG (2014) Elimination of vitamin D receptor in vascular endothelial cells alters vascular function. Hypertension. 64:1290-1298.

 

Overlay scalebar macro

Original code by Wayne Rasband, improved by Frank Sprenger and deposited on the ImageJ mailing server: (http://imagej.588099.n2.nabble.com/Overlay-Scalebar-Plugins-td6380378.html#a6394996). I added choice of font size, scale bar height, option to choose any position for scale bar and some options that allow to set the image calibration (only for overlay, not in Meta data).

Download macro: scalebar_overlay.txt

 

Separate Z-stack and position information from large tif files

During long multi position time series of Z-stacks using our Nikon microscopes we have had some crashes of the NIS-element software. As a result we end up with a large file containing all images in one stack. We split the different channels in NIS elements and save them as tif files each in there own directory. The Nikon4 macro will read these files and will ask the user for the number of images per Z-stack, the number of positions imaged and after how many time points the file has to be saved (so you will be able to analyse data larger that 2GB). Download the macro and install it in the macro subdirectory of ImageJ.

Download macro: Nikon4.txt

 

Convert large tif files to 8 bit

This macro can take large *.tif data sets, convert them to 8 bit and save the results in a directory chosen by the user. The macro is written for experiments using the Olympus CellR imaging system with a GFP and a BF image at each time point. Each channel and each position is saved as an individual file. However, it can easily be adapted for other channels. If you need help please contact Kees (krs5)

Download macro: cellR.txt

 

Multi colour line profile plot

This macro can plot profiles in up to 7 colours (red, green, blue, cyan, magenta, yellow and grey) and will handle different image types. You can also choose the colour channels you want to plot and the graph is scalled depending on the channels chosen.

Plot_MultiColour

Download macro: Plot_MultiColor4.3.txt

Download Action Tool (will create an icon in the toolbar when the macro is installed): Line Profile Action Tool.

Publications acknowledging this macro:

Jäpel M, Gerth F, Sakaba T, Bacetic J, Yao L, Koo SJ, Maritzen T, Freund C, Haucke V (2020) Intersectin-Mediated Clearance of SNARE Complexes Is Required for Fast Neurotransmission. Cell Rep. 30:409-420.

Vallardi G, Allan LA, Crozier L, Saurin AT (2019) Division of labour between PP2A-B56 isoforms at the centromere and kinetochore. Elife. 8. pii: e42619. doi: 10.7554/eLife.42619.

Gerth F, Jäpel M, Sticht J, Kuropka B, Schmitt XJ, Driller JH, Loll B, Wahl MC, Pagel K, Haucke V, Freund C (2019) Exon Inclusion Modulates Conformational Plasticity and Autoinhibition of the Intersectin 1 SH3A Domain. Structure. 27:977-987.

Brockmann MM, Maglione M, Willmes CG, Stumpf A, Bouazza BA, Velasquez LM, Grauel MK, Beed P, Lehmann M, Gimber N, Schmoranzer J, Sigrist SJ, Rosenmund C, Schmitz D (2019) RIM-BP2 primes synaptic vesicles via recruitment of Munc13-1 at hippocampal mossy fiber synapses. eLife. 8: e43243.

Sabatinos SA, Green MD (2018) A Chromatin Fiber Analysis Pipeline to Model DNA Synthesis and Structures in Fission Yeast. Methods Mol Biol. 1672:509-526.

 

Overview heatmap for screen

This macro will create a well heat map for (ScanR) screens. The macro can handle well plates up to 96 wells including empty wells but does not handle time series at the moment. The directory with image files should not contain any sub-directories and no images should be open in ImageJ when the macro runs.
The format for the images is ??--W00001--P00001--Z00000--T00000--channel where ?? might be empty and order of WPZT is not important. Channel is the name of the channel given within the screening software.
Four images per well are used to represent each well. The user can change the starting image. Default is 2. Background is subtracted is optional.
After finishing the macro the user has to adjust the saved heatmap image for brightness and can use a LUT to visualize the results. We often use 16_colors.

Screen overview

Download macro: screen_heatmap.txt

Share this page: