Segmentation
I/O
The segmentation module takes a stack of microscopy images as input and produces a stack of instance segmentation masks, delineating each cell in the images. The results are saved frame by frame in a labels_*population* subfolder within each position folder.
Overview
The process of instance segmentation takes an image (multichannel or not) as its input and yields a label image (2D), where each segmented object is attributed a single label.
In Celldetective, you may want to specifically segment up to two cell populations of interest on the images (typically target and effector cells but it could be anything). Segmentation can be carried out using traditional segmentation pipelines (based on filters and thresholds) or using Deep-learning models trained for such task. Celldetective proposes both options and allows a cross-talk between the two. As illustrated below, the output of a traditional segmentation can be corrected and used as an input to a DL model directly in Celldetective. That is only one of many paths to perform segmentation in Celldetective.
Overview of segmentation options in Celldetective. Celldetective provides several entry points (black arrows) to perform segmentation, with the intent of segmenting specifically a cell population (left : effectors, right : targets). The masks output from each segmentation technique can be visualized and manually corrected in napari. Exporting these corrections into a paired image and masks dataset can be used either to fit a generalist model (transfer learning) or train one from scratch. Once the segmentation is satisfactory enough, the user can decide to proceed with the tracking and measurement modules.
Traditional segmentation
In many applications, cell or nucleus segmentation can be achieved through the use of filters and thresholds, without having to resort to a Deep Learning model. Adapting such a model to a new system can be time-consuming and computationally expensive, as it usually requires numerous annotations. To ensure a user-friendly experience with Celldetective, we developed a robust framework for traditional segmentation as a potent alternative to calling a Deep Learning model.
We call this UI the Threshold Configuration Wizard (TCW). This interface allows you to interactively build a segmentation pipeline step-by-step.
The Threshold Configuration Wizard interface showing preprocessing, thresholding, and object detection controls.
The wizard guides you through four stages:
Preprocessing — enhance the image with filters (
gauss,median,std, etc.) to make objects easier to detect.Thresholding — binarize the image to separate foreground from background.
Object Detection — split touching objects using a watershed or label all connected components.
Property Filtering — remove false positives based on morphology or intensity queries (e.g.,
area > 100).
The pipeline can be saved as a .json config file, which can be loaded later via the Upload Model window.
For a complete step-by-step walkthrough, see How to segment with the Threshold Configuration Wizard.
Deep learning segmentation
Models
Celldetective ships with Deep-learning segmentation models trained with the StarDist [1] or Cellpose [2] [3] algorithm. They are split in two families:
Generalist models — models published in the literature that have been trained on thousands of images with one or two channels, on general tasks such as segmenting all nuclei visible on the images. In some cases, more than one modality was passed in the channel slots during training to force the model to generalize and be less sensitive to the modality.
Population-specific models — models that we trained from scratch on brand new multimodal data to achieve more specific tasks such as detecting the nuclei of a population in the presence of another. In this configuration, accurate segmentation often requires to look at multiple channels at once, i.e. performing a multimodal interpretation.
Generalist models. This table lists the different generalist models (Cellpose or StarDist) which can be called natively in Celldetective. The images have been sampled from their respective datasets, cropped to ( 200 × 200 ) px and rescaled homogeneously to fit in the table.
Target models. MCF-7 nuclei segmentation models that we developed for our application. The models have been trained on the db_mcf7_nuclei_w_primary_NK dataset available in Zenodo.
Effector models. Primary NK segmentation models that we developed for our application. The models have been trained on the db_primary_NK_w_mcf7 dataset available in Zenodo.
Importing and applying models
Models are imported via the button in the Segmentation panel. This creates a configuration file that maps your experiment’s channels to the model’s expected inputs, including spatial calibration and normalization.
For a detailed list of all import parameters, see the Segmentation Data Import Reference.
For a complete step-by-step walkthrough (including generalist model configuration), see How to apply a segmentation model.
Mask visualization and correction
Once a position is segmented, the results can be visualized in napari by clicking the button in the segmentation section. This overlays the segmented masks on the original images.
With napari, segmentation mistakes can be corrected using the brush, eraser, and fill tools. Celldetective provides two plugins:
Save the modified labels — overwrite the masks in place.
Export a training sample — create an annotated pair (image + mask) to train a Deep Learning model on your data.
For a step-by-step annotation workflow, see How to annotate for segmentation. To train a model on your annotations, see How to train a segmentation model.
napari. napari provides the basic requirements of image manipulation software, namely a brush, rubber, bucket and pipette, to work on the segmentation layer. In this RICM image of spreading NK cells, two couples of cells have been mistakenly segmented as one object and must be separated. On the right panel, two plugins specific to Celldetective allow 1) the export of the modified masks directly in the position folder, and 2) to create automatically an annotation consisting of the current multichannel frame, the modified mask and a configuration file specifying the modality content of the image and its spatial calibration.