-
Notifications
You must be signed in to change notification settings - Fork 5
Stardist Segmentation
- (1) Introduction
- (2) Input
- (2.1) Image metadata
- (2.2) Model
- (3) Output
- (3.1) Cell Data
- (3.2) Cell Masks
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:
- images generated in the image thresholding and masking process.
- images specified by the user with the
preprocessed_metadata_file
file if the image thresholding and masking process is skipped.
For more details on segmentation with StarDist please refer to the following pages:
- Uwe Schmidt, Martin Weigert, Coleman Broaddus, and Gene Myers.
Cell Detection with Star-convex Polygons. (free link) International Conference on Medical Image Computing and Computer-Assisted Intervention (MICCAI), Granada, Spain, September 2018. - StarDist repository
- StarDist FAQ
This process can be skipped by setting the skip_sd_segmentation
parameter to true
.
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)
-
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.
The output of this process is located at: $output_folder/StarDist_Segmentation/
- 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 thesample_name
values in thepreprocessed_metadata_file
. -
Location_Center_X
andLocation_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
-
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:
- CellProfiler4: The cells can be imported as objects from the image.
- Histocat
- cytomapper