ClawBio cell-detection
install
source · Clone the upstream repo
git clone https://github.com/ClawBio/ClawBio
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ClawBio/ClawBio "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/cell-detection" ~/.claude/skills/clawbio-clawbio-cell-detection && rm -rf "$T"
manifest:
skills/cell-detection/SKILL.mdsource content
🔬 Cell Segmentation
You are the cell-detection agent, a specialised ClawBio skill for cell segmentation in fluorescence microscopy images. The default backend is
cpsam
(Cellpose 4.0); additional backends (e.g. StarDist) are planned.
Why This Exists
Manual cell counting and segmentation are slow, inconsistent, and hard to reproduce.
- Without it: Users open ImageJ, draw ROIs by hand, export CSVs with no provenance.
- With it: One command segments cells, extracts morphology metrics, saves an overlay figure, and writes a reproducible
.report.md - Why ClawBio: Fully local, no data upload, structured outputs ready for downstream analysis.
Core Capabilities
- Segment: Run
on any TIFF, PNG, or JPG fluorescence imagecpsam - Measure: Extract area, equivalent diameter, centroid, and eccentricity per cell
- Report: Produce
,report.md
, and histogram figures{stem}_measurements.csv
Input Formats
| Format | Extension | Notes |
|---|---|---|
| Greyscale TIFF | , | H×W — passed directly |
| 2-channel TIFF | , | H×W×2 — cytoplasm + nuclear, any order |
| 3-channel TIFF | , | H×W×3 — H&E or fluorescence, any order |
| >3-channel TIFF | , | First 3 channels used; remainder truncated with warning |
| PNG / JPEG | , , | Greyscale or RGB |
Channel handling: cpsam is channel-order invariant — cytoplasm and nuclear channels can be in any order. You do not need to specify which channel is which. If you have more than 3 channels, consider omitting the extra channel or combining it with another before running.
Workflow
- Load image; detect greyscale vs multi-channel
- Prepare — pass 1–3 channels through unchanged; truncate >3 to first 3 with a warning
- Segment with
— noCellposeModel()
argument neededchannels - Metrics via
skimage.measure.regionprops - Figures — overlay + size distribution histogram
- Report —
+report.md
+ reproducibility bundle ({stem}_measurements.csv
,commands.sh
,environment.yml
)checksums.sha256
CLI Reference
# Standard usage — greyscale or multi-channel (cpsam handles channels automatically) python skills/cell-detection/cell_detection.py \ --input <image.tif> --output <report_dir> # Override diameter estimate (pixels) python skills/cell-detection/cell_detection.py \ --input <image.tif> --diameter 30 --output <report_dir> # Demo (synthetic image, no user file needed) python skills/cell-detection/cell_detection.py --demo --output /tmp/cell_detection_demo
Demo
python skills/cell-detection/cell_detection.py --demo --output /tmp/cell_detection_demo
Expected output: report.md with ~67 cells detected from a synthetic 512×512 blob image (67 blobs generated).
Algorithm / Methodology
- Load image with
(TIFF) ortifffile
(PNG/JPG); detect ndimPIL - If >3 channels, truncate to first 3 with a warning
- Instantiate
CellposeModel(gpu=<flag>) - Call
— nomodel.eval(img, diameter=<arg_or_None>)
arg (cpsam is channel-order invariant)channels - Extract per-cell stats from
viamasksskimage.measure.regionprops - Save
, figures,{stem}_measurements.csvreport.md
Key parameters:
- Model:
(Cellpose 4.0 unified model — channel-order invariant)cpsam - Channels: not passed — cpsam uses the first 3 channels of the input in any order
- Diameter:
triggers Cellpose auto-estimationNone
Example Queries
- "Segment the cells in my DAPI image"
- "How many cells are in this microscopy image?"
- "Run cellpose on my TIFF and give me a cell count"
- "Segment my fluorescence image and export morphology metrics"
Output Structure
output_dir/ ├── report.md ├── {stem}_measurements.csv ├── {stem}_cp_masks.tif ├── {stem}_seg.npy ├── figures/ │ ├── {stem}_cp_outlines.png │ └── {stem}_histogram.png └── reproducibility/ ├── checksums.sha256 ├── commands.sh └── environment.yml
Dependencies
— cpsam modelcellpose>=4.0
— TIFF I/Otifffile
— PNG/JPG loadingPillow
— array opsnumpy
— figuresmatplotlib
— regionprops metricsscikit-image
Safety
- Local-first: no image data leaves the machine
- Every report includes the ClawBio medical disclaimer
- Reproducibility bundle (
,commands.sh
,environment.yml
) records the exact invocation, dependencies, and output integritychecksums.sha256
Integration with Bio Orchestrator
Trigger conditions:
- Input is a TIFF/PNG/JPG microscopy image
- User mentions "cellpose", "segment", "cell counting", "microscopy"
Chaining partners:
- Future: export ROI centroids to spatial transcriptomics workflows