Segment and quantify cells in a microscopy image
Hand Claude Code a microscopy image (or a folder of them) and get back per-cell label masks plus a quantitative table — cell count, area, shape, and per-channel intensity for every object — produced by the Cellpose skill and saved as a re-runnable script.
| Problem class | Data analysis |
| Subject areas | Molecular and Cellular Biology |
| Evidence level | Reported |
| Complexity | One skill or MCP |
| Availability | Fully open |
| Compute | Laptop |
Problem
Counting cells and measuring their morphology or marker intensity from microscopy is one of the most common quantitative tasks in cell biology — scoring a knockdown phenotype, quantifying nuclear translocation, measuring cell size across conditions. Manual counting in ImageJ is slow, subjective, and irreproducible across operators. Classic thresholding/watershed breaks down on touching cells, uneven illumination, and the varied staining you get across a real plate. The hard part is robust instance segmentation — separating each cell from its neighbors — without hand-tuning parameters per image or training a model.
“Solved” looks like: point at an image (or directory), get back a label mask per image and one tidy table with one row per cell (image, object id, area, centroid, mean intensity per channel), produced by a committed script you can re-run on the next plate with identical settings — so the count that lands in a figure is auditable, not a number a person eyeballed once.
Recommended approach
-
Install the Cellpose skill. It ships in the SciAgent-Skills collection — clone once and load as a plugin:
git clone https://github.com/jaechang-hits/SciAgent-SkillsThen inside Claude Code run
/plugin install sciagent-skillsand confirm Cellpose appears under/plugin→ Installed. The skill installs thecellposePython package and runs locally — no upload. -
Stage the images and note the channels. Put the images in one folder. Record, for each image: which channel holds the object to segment (the
cytoplasm/membrane stain or thenucleistain) and which channels are the markers you want to quantify. Pick the model up front —nucleifor DAPI/Hoechst,cyto3(the generalist) for whole cells/brightfield. Estimate a typical cell diameter in pixels; Cellpose uses it to set scale. -
Generate a committed segmentation + quantification script. Have Claude write the analysis to a file rather than running it interactively, so the same parameters apply to every plate:
Use the Cellpose skill to segment every image in ./images/. Write a script segment_and_quantify.py that: - runs Cellpose with model=cyto3 (or 'nuclei'), diameter=<D> px, channels=[<seg>, <nuc>], on each image, - saves the integer label mask per image (masks/<name>_masks.tif), - uses scikit-image regionprops to emit one row per cell to cells.csv: image, label, area, eccentricity, centroid_x, centroid_y, and mean intensity for each marker channel, - records cellpose version, model name, diameter, flow/cellprob thresholds, and a sha256 of each input image in provenance.json. Then summarize cells.csv: cells per image and median area per image.Pin the environment (
requirements.txtorenvironment.yml) with the exactcellposeandscikit-imageversions, and commitsegment_and_quantify.py, the pinned env, andprovenance.json. The recorded model name, diameter, and thresholds are what make a cell count reproducible — see the reproducibility guide. -
QC the masks before you trust the numbers. Have Claude overlay a few masks on the source images and check for the two failure modes that quietly corrupt counts: over-merging (two touching cells fused into one label) and over-splitting (one cell broken into fragments). If they appear, adjust
diameter,flow_threshold, orcellprob_thresholdin the script and re-run — never hand-edit the output table. -
Hand off downstream.
cells.csvis the artifact: feed it to your statistics (compare median area or marker intensity across conditions) or to the relevant downstream recipe. The masks are reusable for tracking or co-localization.
Why this assembly
Rung 2 of the simplicity ladder — one cataloged skill does the segmentation, and the same skill’s environment carries scikit-image for the regionprops measurement, so no extra component is needed. Rung 1 (plain Claude Code) can’t segment touching cells robustly: instance segmentation across varied staining is exactly what Cellpose’s pretrained generalist models buy you, and the model can’t reproduce that from prompt instructions alone. Rung 3+ is overkill — there is one input type and one well-bounded task. The only judgement call is model and diameter, which the recipe pins explicitly.
Availability
Fully open. Cellpose is BSD-3-Clause; the SciAgent-Skills wrapper is CC BY 4.0. Pretrained models (cyto3, nuclei, tissuenet) download once and run locally — no account, no API key, no image upload. TIFF/PNG and CSV are open formats.
Compute requirements
Laptop-sufficient. Cellpose runs on CPU; a typical 2D image (~1–4 megapixels) segments in seconds to a couple of minutes per image on a laptop CPU, faster with a CUDA GPU. The pretrained model weights are a one-time download of tens of MB. A plate of a few hundred images is laptop-scale as a loop; very large whole-slide images or 3D z-stacks are the cases where a GPU starts to matter — name that step if you hit it.
Evidence
Reported. Cellpose is the field-standard generalist segmentation method — trained on >70,000 manually segmented objects across highly varied image types, it segments cells, membranes, and nuclei without retraining or per-image parameter tuning (Stringer et al., Nature Methods 2021), with Cellpose3 adding one-click image restoration for noisy/blurry/undersampled inputs (Stringer & Pachitariu, Nature Methods 2025). It is routinely the segmentation step in published quantification pipelines (e.g., single-cell/phagosome tracking via Cellpose + TrackMate, Augenstreich et al., Biol. Open 2024).
No head-to-head benchmark of the agent-driven assembly versus a hand-written Cellpose script is published — the skill buys a local, committed, reproducible run, not a new method. That gap is why this recipe is Reported, not Validated.
Alternatives considered
- scikit-image watershed (rung 1–2, simpler). For well-separated, evenly-lit nuclei on a clean background, classic thresholding + watershed in scikit-image is lighter and fully transparent. Reach for it when cells don’t touch and staining is uniform; reach for Cellpose the moment cells overlap or staining varies across the image.
- Cellpose GUI (no skill). The desktop Cellpose GUI is the simplest path for a one-off interactive segmentation and for human-in-the-loop curation. The skill is worth it when you want the run scripted, batched over many images, and committed with pinned parameters alongside the data.
- nnU-Net (rung 2, different domain). The medical-image segmentation recipe targets 3D radiology volumes (CT/MRI) and requires labeled training data and a GPU. For cell/nucleus microscopy with no training labels, Cellpose’s pretrained generalist models are the right tool.
See also
- Cellpose (Claude Skill) — DL cell/nucleus segmentation.
- scikit-image (Claude Skill) — classical image processing and regionprops.
- Segment an organ or tumor in a medical image with nnU-Net — the radiology-volume counterpart.
- Reproducible, provenance-tracked AI analysis — the committed-artifact pattern this recipe follows.
Sources
- Stringer, Wang, Michaelos & Pachitariu, “Cellpose: a generalist algorithm for cellular segmentation,” Nature Methods 18:100–106 — published 2021; verified 2026-06-27 (this run).
- Stringer & Pachitariu, “Cellpose3: one-click image restoration for improved cellular segmentation,” Nature Methods — published 2025; verified 2026-06-27 (this run).
- Augenstreich et al., “da_Tracker,” Biol. Open 13:bio060555 — Cellpose-based quantification pipeline; published 2024; verified 2026-06-27 (this run).
jaechang-hits/SciAgent-Skills— Cellpose skill source; verified 2026-06-27 (this run).
Tried this recipe?
Share feedback — what worked, what didn’t, what you’d change. The form opens with this recipe pre-selected and a link back to this page.