Gilles Carpentier Research Web Site: Computer Image Analysis
Image analysis tools in biology and biochemistry using ImageJ

Home > Sort Selections in Overlay - Application

Sort Selections in Overlay - Application

Thursday 20 January 2022, by Gilles Carpentier

The « Sort Selections in Overlays » macro is an example of handling vectorial objects - named overlays in ImageJ - by using single or composite selection of different nature. This brief page gives examples of use, and an application in cellular neurology.

 Description:

Get overlays elements from any kind of selection (line, freehand etc...) with the options of inclusion, exclusion and intersection (using exclusion removes selected overlays). It allows sorting of the selected overlays elements from their colors. Compatible with composite images and barycenter option in the updated 21/01/2022.

 Installation:

From the code page here (06/02/2013, first version) or code page here (update, 21/02/2022), select all and copy the text. Then open a new macro window on ImageJ (Plugins -> New -> Macro menu), paste the text code and install it ("Macro -> Install Macros" ImageJ text editor menu).

 Demo Image 1 - Barycenter option:

A demo image of human macrophages culture is downloadable from the macro menu. Once the code installed as explained above, open the demo image by the "Plugins -> Macros -> Open Sample Image 1" menu. A four channel composite image is then opened, containing nuclei and cell compartments detected as overlays from different colors and a selections.

Four channel humain macrophage image. Left: fluorescent markers and phase contrast. Center: fluorescent markers. Right: fluorecent with detection of cell compartments and nuclei. In the 3 panels, the cyan selection corresponds to a cell compartment. Cell culture and immunostaining: Fanny De Torres. Image acquisition and analysis: Gilles Carpentier. Fluorescence microscopy, objective 20x, Olympus IX81.
Cyan selections can be removed by clicking in the image and then restored by « Edit ->
Selection -> Restore Selection » ImageJ’s menu. Channels can be selected by « Image -> Color -> Chanels Tools... »

Run the sorting by "Plugin -> Macros -> Sort Selections in Overlays". The "Included" and "Intersection" options lead the selection of two nuclei instead of one for the selected cell (see picture below). Note: "Included" option only would return no nucleus for the left neighbor cell.

Selection sorting with "Included" and "Intersection" options.

The same sorting using the "Barycentre included" option in addition to "Included" and "Intersection" options leads the selection of one nucleus instead of two with the precedent settings. Only objects which barycentre are included in the selection are selected (see bellow).

Selection sorting with "Barycentre included", "Included" and "Intersection" options.

 Demo Image 2 - Multi selections:

A demo image of neuron cells culture is downloadable from the macro menu. Once the code installed as explained above, open the demo image by the "Plugins -> Macros -> Open Sample Image 2" menu. A two channel composite image is then opened, containing detected objects as overlays from different colors and two user selections.

Left: composite image of a portion of a neuronal dendrite. Labeling: psd-95 post-synaptic
elements (red), V-Glut (green) pre-synaptic elements. Image courtesy of Pr.O. Stettler.
Experiment author: Asma Soltani. Image acquisition and processing: Gilles Carpentier,
laser confocal microscope Olympus IX81 FV 1000.
Right, the same with detected objets (overlays) and user selections (yellow).
Yellow selections can be removed by clicking in the image and then restored by « Edit ->
Selection -> Restore Selection » ImageJ’s menu. Overlays can be hidden/showed
by « Image -> Overlay -> Hide/Show » ImageJ’s menus.

 Example of Sorting:

After opening the demo image, select « Sort Selection In Overlays » function in the menu accessible through "Plugins -> Macros". Run the default settings to get the following result:

Left, default settings of the « Sort Selection In Overlays » function. Right, result of the function;
vectorial objects retained are those included and at the intersection of the limits of the polygonal
and free hand selections.

 Applications:

In the demo image, the selections are made by the user. The object sorting can also work automatically by using selections made from activation of overlays by user menu actions or macro code. This can be done through the ROI Manager interface, by the "Combine" option. The next pictures detail how to proceed.

- First, from the demo image the sorting of green objects in and at the intersection with user selections was performed. Resulting overlays were converted into a composite selection by using the ROI Manager:

Above: after sorting green objects in user selections, green overlays were transferred to the
ROI Manager (ImageJ menu : Image-> Overlay -> To Roi Manger).

Above: Green objects were all selected and the "more >> OR (Combine)" operator applied.

- Then sorting of red objects in intersection with previously sorted green objects was performed after restoring the composite selection obtained from the ROI Manager (ImageJ menu : Edit-> Selection -> Restore Selection) in the initial demo image and then "Plugin -> Macros -> Sort Selections in Overlays" menu.

Above: right Image exhibits the composite selection after combining operation in the ROI Manager,
left image shows the result of the sorting using the same composite selection restored in the
initial demo image.

 Publication:

This kind of operation implemented in an original program allowed to put in evidence synaptic alterations in mouse neurone primary culture:

  • Below: example of object sorting used in the paper : The slide show exhibits a confocal image analysis of a neuron synaptic area from a mouse hyppocampal neuron culture in conditioned medium. The first one shows the user selection in the initial image. The second one shows in yellow the intersection between red and green labelling after detection (not shown). It was performed according the same principle than described above.
    Neuron synaptic area detection - user selection Neuron synaptic area detection
    | prev | next |

Soltani A, Lebrun S, Carpentier G, Zunino G, Chantepie S, Maïza A, Bozzi Y, Desnos C, Darchen F, Stettler O. Increased signaling by the autism-related Engrailed-2 protein enhances dendritic branching and spine density, alters synaptic structural matching, and exaggerates protein synthesis. PLoS One. 2017 Aug 15;12(8):e0181350. doi: 10.1371/journal.pone.0181350. Abstact, Paper.

logoij ImageJ (http://rsb.info.nih.gov/ij/) is a public domain Java image processing program inspired by NIH Image for the Macintosh. It runs, either as an online applet or as a downloadable application, on any computer with a Java 1.1 or later virtual machine. Downloadable distributions are available for Windows, Mac OS, Mac OS X and Linux. The author, Wayne Rasband (wayne@codon.nih.gov), is at the Research Services Branch, National Institute of Mental Health, Bethesda, Maryland, USA.
Gilles Carpentier, Faculte des Sciences et Technologie,
Universite Paris Est Creteil Val-de-Marne, France.

Special thanks to Alessandra Albano for the English correction of these sites.
Computer Data Acquisition
for Biochemistry Practice Works

Image.Bio.Methods@free.fr
Image analysis tools in biology
and biochemistry using ImageJ