Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

CMM Lab - Collagen Fibril Orientation Analyser for SHG images

CMM Lab website Homepage

CMM Lab GitHub Homepage

ImageJ / FIJI script designed to automate the quantification of pixel orientation of two-photon second harmonic generation images of collagen fibres.

Requires ImageJ/FIJI 1.38m or above.
Tested working on Mac OSX 10.14 and above.
Tested working on Windows 10.

Last updated: 2nd Oct 2020.

This script wraps the B.I.G. OrientationJ plugin into a batch process that applies user-defined pre-processing and iterates through entire directories (including all sub-directories) of images outputting the colour survey overlay and text file of histogram values for each image.

If using multiple sub-directories of images, please ensure that filenames are unique.

### This scripts requires the OrientationJ plugin to run ###

Briefly, the orientation is evaluated for every pixel of the image based on the structure tensor. A histogram of orientations is built taking into account pixels that have a coherency larger than 'min-coherency' and an energy larger than 'min-energy'.

Citation for original OrientationJ plugin:
Rezakhaniha et al. Biomech. Model Mechanobiol. (2012)
Experimental Investigation of Collagen Waviness and Orientation in the Arterial Adventitia
doi: 10.1007/s10237-011-0325-z
PubMed link

Citation for script:
Mayorca-Guiliani AE et al. Nature Medicine (2017)
ISDoT: in situ decellularization of tissues for high-resolution imaging and proteomic analysis of native extracellular matrix
doi: 10.1038/s41467-019-10968-6
Pubmed link

All processed images should be taken using identical acquisition parameters


Ensure you have ImageJ or FIJI (preferred) installed.

  • ImageJ is available from here.
  • FIJI is available from here.

The B.I.G. OrientationJ tools are also required.
These are available from

Copy the CMM_Fibril_Orientation_Analyser.ijm to the ImageJ/FIJI plugins directory.

Restart ImageJ/FIJI.

The script should now appear in the Plugins Dropdown menu.

Basic variables specified by the user include:

Upon launching, the script will ask for the following inputs:

  • File Type - Specify input image file type (.tif .jpg etc.)*
  • Tensor - Minimum structure tensor - Passed to OrientationJ
  • Image pre-processing (Enable/Disable) - Select image pre-processing options.
  • Advanced Options (Enable/Disable) - Opens Advanced Options control panel for user input
  • Enable Batch Mode (Enable/Disable) - Runs the script silently (faster)
  • Launch Memory Monitor (Enable/Disable) - Mainly for debugging

*Output colour overlay files are saved in .png format.
Avoid using input files in the .png format where possible.

Image pre-processing steps (if enabled) include:

  • 8-bit Conversion - Converts each image to 8-bit
  • Brightness Threshold - Minimum brightness threshold
  • Sharpen (Enable/Disable) - Runs the ImageJ/FIJI sharpen command prior to analysis
  • Despeckle (Enable/Disable) - Runs the ImageJ/FIJI despeckle command prior to analysis
  • Auto Enhance Output Image (Enable/Disable) - Enhance Brightness/Contrast of Output images only (does NOT affect analysis - aesthetics only)

Advanced variables specified by the user (if enabled) include:

If enabled in the Basic Parameter window, the script will also launch an input window allowing for customisation of analysis parameters which are passed directly to the OrientationJ plugin:

  • Gradient - Gradient used (0: Cubic Spline, 1: Finite difference, 2: Fourier; 3: Riesz, 4: Gaussian)
  • Min Coherency - Minimum Coherency - The ratio between the difference and the sum of the tensor eigenvalues
  • Min Energy - Minimum Energy value - The energy parameter is the trace of the tensor matrix

Once basic and advanced options have been chosen, you will be asked to specify the top level input directory containing the image files to be analysed.

Output Image files

  1. The script will output colour survey overlays (in .png format) of each of the analysed images, in the originating directory.

  2. It will also output a saved version of the pre-processed image file in .png format in the originating directory.

(The original image always remains unchanged)

Output text files

The analysis will output two text files in the top level directory:

  1. Parameters.txt - Contains a list of all the parameters used in the analysis, along with a list of successfully analysed image files.

  2. Orientation_Results.txt - Results file containing all of the collated orientations for each file analysed.


ImageJ / FIJI script to assess the orientation of collagen fibres in SHG images








No releases published


No packages published