Skip to main content
Glama

Detect nuclei (StarDist)

detect_nuclei
DestructiveIdempotent

Find 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

NameRequiredDescriptionDefault
saveNoSave the outlines as annotations; false only returns the measurements.
image_idYesId of an image in Image Label: the imageId (a UUID string) returned by list_images or an upload.
max_nucleiNoMost nuclei to save, the most confident first.
mark_enlargedNoLabel nuclei over 2.5x the median area 'enlarged nucleus' (in red); the rest are 'nucleus'.
replace_previousNoDelete 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_pixelNoScanner 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

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed6 schema fields changedv0.8.1
    • addedInput schema / properties / image_id / description
      Added value: +"Id of an image in Image Label: the imageId (a UUID string) returned by list_images or an upload."
    • addedInput schema / properties / mark_enlarged / description
      Added value: +"Label nuclei over 2.5x the median area 'enlarged nucleus' (in red); the rest are 'nucleus'."
    • addedInput schema / properties / max_nuclei / description
      Added value: +"Most nuclei to save, the most confident first."
    • addedInput schema / properties / microns_per_pixel / description
      Added value: +"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."
    • addedInput schema / properties / replace_previous / description
      Added value: +"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."
    • addedInput schema / properties / save / description
      Added value: +"Save the outlines as annotations; false only returns the measurements."
  2. Changed1 schema field changedv0.8.0
    • addedInput schema / properties / microns_per_pixel
      Added value: +{
      +  "anyOf": [
      +    {
      +      "maximum": 2,
      +      "minimum": 0.05,
      +      "type": "number"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Microns Per Pixel"
      +}
  3. Addedv0.3.3

TDQS

A4.3/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations only flag a destructive, idempotent write; the description supplies the crucial scope of that destruction: only nuclei from an earlier detect_nuclei run are removed, other annotations are never touched, and replace_previous=false preserves them. It further discloses the up-to-one-minute cold start, the confidence-ordered capping at max_nuclei, and stain-related accuracy limits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The core action and default behavior are front-loaded and no sentence is filler, but the prose is a dense paragraph with several clauses chained by semicolons; splitting the replace_previous and microns_per_pixel behaviors into distinct sentences would scan faster.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 6-parameter, output-schema-backed analysis tool, the description covers input assumptions, default side effects, performance latency, measurement outputs, and the escape hatch for reruns. Nothing an agent needs in order to call it correctly and interpret the result is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds genuine meaning beyond the schema: microns_per_pixel changes how the image is resized (model-optimal resolution vs. nucleus-size heuristic) and unlocks area/density units, and max_nuclei selection is described as most-confident-first. Practical resolution values (0.25 at 40x, 0.5 at 20x) help the agent reason about when to pass it.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

Opens with a specific verb and resource: find and outline every cell nucleus in an H&E-stained histology image using StarDist. It also states the input assumption (H&E, no bounding boxes required), so an agent knows exactly what it produces. It never names the closest sibling (segment_objects), so the differentiation is left implicit rather than stated.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives clear conditions: works on H&E, poor on other stains and non-histology images; use microns_per_pixel when scanner resolution is known, omit it otherwise; warm_up("nuclei") avoids the cold-start wait. It also explains that reruns replace rather than double annotations. It stops short of explicit 'use this instead of segment_objects/classify_cells when...' routing.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.