Skip to content

AI Stardist Segmentation

The AI Stardist Segmentation command runs instance segmentation using a pretrained StarDist model exported as TorchScript. Unlike threshold-based segmentation, StarDist predicts individual object instances directly - no Connected Components or Watershed step is needed afterward.

Each grid cell predicts object probability plus distances along n rays, which trace out a star-convex polygon

ParameterDescription
Model pathPath to a TorchScript-exported StarDist model (.pt / .pth, via torch.jit.script or torch.jit.trace).
Object classThe segmentation class assigned to every detected object’s pixels.
Probability thresholdProbability above which a grid cell is considered a candidate object centre. Range: 0.0–1.0 (default 0.5).
NMS thresholdPixel-overlap ratio (intersection / union) above which a lower-scoring candidate polygon is suppressed in favour of an overlapping higher-scoring one. Range: 0.0–1.0 (default 0.3).

The model must accept a [1, 1, H, W] single-channel float tensor and return:

  • An object-probability map [1, 1, H', W']
  • A ray-distance map [1, n_rays, H', W'] - the distance to the object boundary along n_rays equally-spaced angles (the StarDist star-convex-polygon representation)

H'/W' may be smaller than the input size if the model predicts on a coarser grid; EVAnalyzer detects this from the output shape and rescales the polygons back to image resolution automatically. Some TorchScript exports concatenate both outputs into a single [1, 1 + n_rays, H', W'] tensor (channel 0 = probability, the rest = distances) - this layout is also supported.

  1. The model runs on the input image, producing per-grid-cell probability and ray-distance predictions.
  2. Grid cells with probability ≥ Probability threshold are converted into star-convex polygon candidates.
  3. Candidates are filtered with greedy non-maximum suppression: lower-scoring polygons overlapping a higher-scoring one by more than NMS threshold are discarded.
  4. Surviving polygons are rasterised directly into the pipeline’s segmentation and instance maps, each with a unique instance ID.

Runs on GPU automatically if CUDA is available in the linked libtorch build, otherwise falls back to CPU.

Uwe Schmidt, Martin Weigert, Coleman Broaddus, and Gene Myers, “Cell Detection with Star-Convex Polygons,” Medical Image Computing and Computer Assisted Intervention (MICCAI), 2018, pp. 265-273. The 3D extension used for volumetric data is described in Martin Weigert, Uwe Schmidt, Robert Haase, Ko Sugawara, and Gene Myers, “Star-Convex Polyhedra for 3D Object Detection and Segmentation in Microscopy,” IEEE Winter Conference on Applications of Computer Vision (WACV), 2020, pp. 3666-3673.