Caenorhabditis elegans is a eukaryotic model organism with wide use in the fields of cellular and molecular biology1,2,3. It is a small (~1 mm for wild type adults) soil-living nematode worm with a fast life cycle (~three weeks), and a large number of progeny (typically genetically identical to the self-fertilizing hermaphrodite parent). Despite its relative simplicity, the animal is still a complex multicellular organism with defined and distinct tissues and organs, which, thanks to its small size and transparency, can be studied in vivo without any need for fixing or other invasive treatments4. The capacity of the worm for in vivo study through microscopy can be further amplified through the use of fluorescent reporters, that permit the easy distinguishment of individual cells or even the direct visualization of sub-cellular organelles/components such as mitochondria, lipid droplets, or protein aggregates, and of processes such as signal transduction, gene expression, vesicle fusion, autophagy, neuronal and muscle action potentials, etc.5,6,7,8,9,10,11. In addition, the nematode is also highly amenable to genetic manipulation through mutagenesis12, transgenesis via microinjection or microparticle bombardment13, CRISPR editing14, and, most importantly, when it comes to easy and cost-effective genetic screening, RNAi15. This manipulation permits the extensive study of genes and their role in the nematode itself, while simultaneously, thanks to the significant genetic homology that C. elegans exhibits to other model organisms, making foundational discoveries with relevance all the way to humans16,17. Finally, this homology/conservation also makes the worm an ideal initial testing ground for drugs and chemical agents, allowing the elucidation of the mechanisms of drug activity, the identification of potential activity-modifying genetic variations, and the discovery of potential unwanted interactions and off-target effects18,19,20.
All the above-mentioned advantages have rendered C. elegans an attractive model for cellular and molecular biology studies, particularly for scientists interested in the in vivo and often real-time monitoring of processes via microscopy. Such studies typically involve a significant amount of image analysis through special software, with the most widely used option being ImageJ21,22,23. A common characteristic of the analysis through such software is the need for the user/researcher to specify Regions of Interest (ROIs) for analysis through the use of selection tools. Quite frequently, each individual worm in an image will be selected as its own ROI, with the aim to acquire per-worm information about simple morphological features (such as body dimensions) or more "advanced" experimental readouts such as the expression levels of a gene (measured with a fluorescent reporter), the readout of a ratiometric reporter, the number and size of lipid droplets, the formation of protein aggregates, the morphology of individual organelles and their networks etc.5,8,10,24,25,26,27. These per-worm selections are typically made manually, since automatic selection methods that are based on standard image processing algorithms are usually not capable enough to distinguish the shapes and features of the worm, especially in darkfield images where the outlines of the worms are not clearly visible or in brightfield images with significant numbers of animals that touch and overlap. The manual process is, however, slow (20 s to 1 min per worm depending on the precision needed and the experience of the user), laborious, and subject to user bias and error.
An alternative and much more powerful approach for the generation of individual C. elegans ROIs (a task typically referred to as segmentation in the field of computer vision) is to automate it with the help of deep learning/neural network techniques. Convolutional neural networks based primarily on the Mask R-CNN28 and the U-net architectures29 have produced decent results in segmentation tasks on various biological model systems30,31,32 including in C. elegans33,34,35,36,37,38,39, but none have provided a satisfactory solution to the problem of generating full body segmentations that correctly distinguish individual animals (instance segmentation) in high resolution images with large numbers of touching or outright overlapping worms. In order to meet this need, we developed SegElegans, a deep learning model specifically designed and optimized for this task40.
SegElegans is comprised of two major parts (Figure 1). The first part is a two-headed U-net variant convolutional neural network. It is composed of one encoder block and two decoder blocks. The encoder block is based on the SmaAt AT model41 and uses double convolution blocks for each layer feeding into a Convolutional Block Attention Module (CBAM)42. The two decoder blocks are based on the convolutional long short-term memory (LSTM) network43. One decoder is responsible for categorizing each pixel of the images as a part of the main body of a worm, a part of the edge of a worm, a part of the background, or a part of an area where worms overlap (this is typically referred to as semantic segmentation). The other decoder is responsible for drawing a linear "skeleton" along the length of each worm. The second part is a post-processing algorithm that combines the outputs of the two decoders and uses them to generate accurate instance segmentations. It initially identifies the segments of true overlaps by comparing the semantic segmentation output to the skeleton one. Then it outputs the instance segmentation directly for worms without overlaps or by assembling it from segments for overlapping ones40. These segmentations are saved as binary masks as well as ImageJ compatible ROIs.