Skip to content

Stardist Segmentation

MicheleBortol edited this page Oct 9, 2021 · 3 revisions

Cell segmentation with StarDist

(1) Introduction

Segmentation with StarDist generates single-cell data in.csv format and the cell masks in tiff format. The input data for this process can be derived from:

For more details on segmentation with StarDist please refer to the following pages:

This process can be skipped by setting the skip_sd_segmentation parameter to true.

(2) Input and parameters

2.1) Image metadata

The image metadata used in the segmentation with StarDist are:

  • preprocessed_metadata_file with the tiff image metadata.
  • sd_labels_to_segment = markers to include in the image on which the segmentation is performed, must match the number of dimensions in the model. (comma separated list)

2.2) Model

  • sd_model_name = model to use for the segmentation (name of default model or a pretrained one)
  • sd_model_path = probability threshold to apply
  • sd_prob_thresh = probability threshold used for calling cells: 0 < value < 1 or "default" to use the default valuse saved in the model.
  • sd_nms_thresh = overlap threshold above which Non-Maximum Suppression is performed: 0 < value < 1 or "default" to use the default valuse saved in the model

Default Models

SIMPLI can work with the pretrained models provided with StarDist (table from the StarDist repository README):

key Modality (Staining) Image format Example Image Description
2D_versatile_fluo 2D_paper_dsb2018 Fluorescence (nuclear marker) 2D single channel Versatile (fluorescent nuclei) and DSB 2018 (from StarDist 2D paper) that were both trained on a subset of the DSB 2018 nuclei segmentation challenge dataset.
2D_versatile_he Brightfield (H&E) 2D RGB Versatile (H&E nuclei) that was trained on images from the MoNuSeg 2018 training data and the TNBC dataset from Naylor et al. (2018).

To select one of these models use:

  • sd_model_name = name of default model to use.
  • sd_model_path = "default" (for default models)

Custom trained models

Custom trained models should operate in YXC -> YXC [format] (https://scikit-image.org/docs/dev/user_guide/numpy_images.html#numpy-images-coordinate-conventions), with the first dimension being rows, the second columns and all other dimensions being marker values. The number of C dimensions should match the number of labels given in the sd_labels_to_segment parameter.

Models can be trained with:

For more details on model training see this section of the StarDist repository README.

(3) Output

The output of this process is located at: $output_folder/StarDist_Segmentation/

3.1) Single cell data

  • Single cell data for all samples: $output_folder/StarDist_Segmentation/StarDist-unannotated_cells.csv
  • Single cell data for each sample separately: $output_folder/StarDist_Segmentation/sample_name/sample_name-StarDist-Cells.csv

The single-cell data is a.csv table with a row for each cell and the following annotations:

  • ObjectNumber: Unique identity number from 1 to 216-1, matches the corresponding pixels in the cell masks.
  • Metadata_sample_name: Matching the sample_name values in the preprocessed_metadata_file.
  • Location_Center_X and Location_Center_Y: Location of the cell centroid in the image in pixel, used for both the homotypic and heterotypic spatial analyses.
  • marker intensity measurements: minimum, maximun and mean for all markers in the preprocessed_metadata_file.
  • spatial features computed with skimage.measure.regionprops from the skimage library.
    The following spatial feaures are reported (feature : column_name in the output):
    • area : AreaShape_Area
    • bbox_area : AreaShape_BoundingBoxArea
    • convex_area : AreaShape_ConvexArea
    • eccentricity : AreaShape_Eccentricity
    • equivalent_diameter : AreaShape_EquivalentDiameter
    • euler_number : AreaShape_EulerNumber
    • extent : AreaShape_Extent
    • feret_diameter_max : AreaShape_MaxFeretDiameter
    • filled_area : AreaShape_FilledArea
    • major_axis_length : AreaShape_FilledArea
    • minor_axis_length : AreaShape_MinorAxisLength
    • orientation : AreaShape_Orientation
    • perimeter : AreaShape_Perimeter
    • solidity : AreaShape_Solidity

3.2) Cell masks

Cell masks in uint16 tiff format: $output_folder/StarDist_Segmentation/sample_name/sample_name-StarDist-Cell_Mask.tiff To each cell is associated a unique identity number from 1 to 216-1. All the pixel belonging to a given cell have their value set to its identity number. Pixels not belonging to any cell are set to 0.
These images are compatible with several other tools for downstream analysis including: