Detect nuclei (StarDist)
detect_nucleiFind and outline cell nuclei in H&E-stained histology images without manual boxes, returning counts, density, and nuclear size measurements and optionally saving annotations.
Instructions
Find and outline every cell nucleus in an H&E-stained histology image with StarDist, automatically.
No boxes needed: the model finds the nuclei itself (it is trained on H&E; other stains and non-histology images give poor results). Returns the count, density, median nuclear area and how much nuclear size varies (a rough measure of pleomorphism). With mark_enlarged, nuclei over 2.5x the median area are labelled "enlarged nucleus" (in red), the rest "nucleus". The most confident max_nuclei outlines are saved. By default (replace_previous) nuclei saved by an earlier detect_nuclei run on this image are deleted first, so running it again replaces them rather than doubling them; other annotations are never touched. Pass replace_previous=false to keep the earlier nuclei. With microns_per_pixel (the scanner's resolution: often 0.25 at 40x, 0.5 at 20x) the image is resized to the model's best resolution and sizes are also given in square microns and density per square millimetre; without it, the image is resized by the size of its nuclei. The first run after a quiet spell takes up to a minute while the model starts (warm_up("nuclei") avoids the wait).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| save | No | Save the outlines as annotations; false only returns the measurements. | |
| image_id | Yes | Id of an image in Image Label: the imageId (a UUID string) returned by list_images or an upload. | |
| max_nuclei | No | Most nuclei to save, the most confident first. | |
| mark_enlarged | No | Label nuclei over 2.5x the median area 'enlarged nucleus' (in red); the rest are 'nucleus'. | |
| replace_previous | No | Delete nuclei saved by an earlier detect_nuclei run on this image before saving the new ones (other annotations are kept). False adds to them. | |
| microns_per_pixel | No | Scanner resolution in microns per pixel (often 0.25 at 40x, 0.5 at 20x); adds sizes in square microns and density per square millimetre. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||