Petri dish colony segmentation and morphometric analysis for fungal growth experiments
Project description
metrics-petri
Petri dish colony segmentation and morphometric analysis.
metrics-petri measures how a biological sample grows on a petri dish: area, diameter, edge roughness, crack burden, texture entropy, and time-series growth rates — all in physical units calibrated from the dish geometry.
Three entry points, one package
| Entry point | Install | Use |
|---|---|---|
metrics-petri |
pip install metrics-petri |
CLI batch pipeline |
metrics-petri-gui |
pip install "metrics-petri[gui]" |
Gradio browser GUI |
metrics-petri-metadata |
pip install metrics-petri |
Desktop GUI for building image_metadata.csv |
Model checkpoint
The package bundles the SmallUNet checkpoint (best_area_w_0.7.pt, ~23 MB) inside the wheel. No separate download is needed after pip install.
At run time the checkpoint is located in this order:
UNET_MODELenvironment variable or--modelflagmodels/best_area_w_0.7.ptin the current working directory- The installed package location (bundled in the wheel)
- HuggingFace Hub auto-download (
rotsl/grayleafspot-segmentation) as a last resort
CLI batch pipeline
pip install metrics-petri
metrics-petri input_images/
Processes every image in the folder and writes a ZIP containing results, overlays, and charts.
# With metadata for growth rate calculations and day-code charts
metrics-petri input_images/ --metadata input_images/image_metadata.csv
# JSON metadata is also accepted
metrics-petri input_images/ --metadata input_images/image_metadata.json
# Custom output path
metrics-petri input_images/ --output results/run01.zip
# Adjust segmentation threshold (default 0.5)
metrics-petri input_images/ --threshold 0.45
# Custom model checkpoint
metrics-petri input_images/ --model /path/to/checkpoint.pt
Output ZIP
<user_or_experiment_name>.zip
├── analysis_full.csv one row per image, all metrics
├── analysis_full.json same data as a JSON array
├── image_metadata.csv copy of the input metadata (if supplied)
├── image_metadata.json same metadata as JSON
├── overlays/ per-image colony mask composites
└── charts/ growth-rate charts (requires dates in metadata)
Metadata desktop GUI
metrics-petri-metadata is a native tkinter application for creating the image_metadata.csv that drives growth rate calculations and chart labelling.
Requirements: tkinter is part of the Python standard library.
- macOS / Windows: bundled with the official Python installer.
- Linux:
sudo apt install python3-tk(orsudo dnf install python3-tkinter)
metrics-petri-metadata
Four-step flow:
- Select Folder — browse to the image folder; dates are auto-detected from filenames, EXIF data, or file modification time.
- Settings — enter experiment name, experiment start date, user name, and plate count.
- Review & Edit Dates — a table lists every image with its date and day code (
d01,d02, …); click any row to correct a date or set a reminder. - Export — writes
image_metadata.csv,image_metadata.json, and optionallyreminders.icsinto the image folder.
Pass the exported file to the CLI with --metadata or upload it in the Gradio GUI's Step 4.
Gradio browser GUI
pip install "metrics-petri[gui]"
metrics-petri-gui
Opens at http://localhost:7860. Five-step tab flow:
- Upload images — JPEG, PNG, TIFF, BMP, WebP, HEIF, RAW
- Settings — threshold, fast mode, experiment name, user name, plate count
- Review & edit dates — annotate
experiment_date/image_dateper image; day codes are computed automatically - Export metadata — download
image_metadata.csvfor future runs or for the CLI - Run inference — segmentation, dish detection, cracks, hyphal skeletons, growth charts, ZIP download
Options:
metrics-petri-gui --port 8080
metrics-petri-gui --host 127.0.0.1
metrics-petri-gui --no-browser
metrics-petri-gui --model /path/to/checkpoint.pt
Measured metrics
| Metric | Unit | Description |
|---|---|---|
area_mm2 |
mm² | Colony area |
diameter_mm |
mm | Equivalent circle diameter |
perimeter_mm |
mm | Colony perimeter |
eccentricity |
— | Shape elongation (0 = circle, 1 = line) |
edge_roughness |
— | Perimeter / ideal-circle perimeter |
centre_delta_mm |
mm | Colony centroid offset from dish centre |
entropy |
bits | Shannon entropy of pixel intensities |
texture_std |
— | Standard deviation of pixel intensities |
crack_area_mm2 |
mm² | Crack area |
crack_coverage_pct |
% | Crack area as percentage of colony area |
crack_count |
— | Number of discrete crack regions |
hyph_frangi_mm |
mm | Hyphal length (Frangi filter) |
hyph_meijering_mm |
mm | Hyphal length (Meijering filter) |
hyph_hybrid_mm |
mm | Hyphal length (hybrid filter) |
rgr_per_day |
day⁻¹ | Relative growth rate (requires dates) |
relative_growth_per_day |
mm² day⁻¹ | Absolute area growth rate (requires dates) |
Scale is derived from the detected dish circumference (default 90 mm). No calibration target required.
Diagnostics
metrics-petri doctor
metrics-petri-gui doctor
Checks Python, NumPy (warns if 2.x), Torch, accelerator (MPS/CUDA/CPU), model path, and all dependencies. Exits with code 1 on any issue.
Notebook walkthrough
An interactive notebook is available in the GitHub repository at notebooks/example_metrics-petri.ipynb. It traces the full pipeline — mask inference, dish detection, crack analysis, and growth metrics — with inline plots at each step.
The notebook is not distributed with the pip package. Clone the repository to use it.
Requirements
- Python ≥ 3.10
- PyTorch ≥ 2.1 (CPU works; MPS used automatically on Apple Silicon)
- Gradio ≥ 6.0 (GUI only, via
[gui]extra) - tkinter — stdlib, bundled on macOS/Windows;
sudo apt install python3-tkon Linux
License
Apache 2.0 — full text
Citation
Metrics Petri: petri dish colony segmentation and morphometric analysis. Rohan R, 2026.
https://github.com/rotsl/metrics-petri
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file metrics_petri-1.0.0.tar.gz.
File metadata
- Download URL: metrics_petri-1.0.0.tar.gz
- Upload date:
- Size: 22.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6c36e3ee0163df788dfa999a2bc976b923dd7016dd01515094582d2eae21491
|
|
| MD5 |
f2487c6206362c983f6343e0a295d80f
|
|
| BLAKE2b-256 |
1ab3c8a15dec97573caa14183f6d41c318cc78f4162a3e04f04620b0e10f15c8
|
File details
Details for the file metrics_petri-1.0.0-py3-none-any.whl.
File metadata
- Download URL: metrics_petri-1.0.0-py3-none-any.whl
- Upload date:
- Size: 22.0 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
234ff06fec683a1cd74498cdaf862dd6dac5e379931dee12ae7f3a74a9c0e533
|
|
| MD5 |
89d11cd9628360bfa53c0128c7066bef
|
|
| BLAKE2b-256 |
dc9e8c0c742534b95de8a5f10c0f2e4405fcd9dcf97dbac4bd430946f3a6716c
|