Overview
ColonyPy automates the counting and classification of fungal colonies on petri dish images. It uses a trained StarDist deep-learning model to detect individual colonies, measures their size, and classifies each colony as either:
- Tolerance smaller than the control-derived 25th percentile (p25) colony size (grows under drug pressure)
- Heteroresistance same size or larger than the control p25 (potentially resistant sub-population)
The classification threshold is derived automatically from a matching control plate (no drug) of the same strain. A control plate is required for every strain; there is no manual or default threshold. Every image is reviewed in the Manual Editor before its result is saved.
Launching ColonyPy
ColonyPy is distributed as a standalone executable built with PyInstaller. No Python installation, no command line, and no internet connection are required on the user's machine. Everything including the trained StarDist model and all dependencies is bundled inside the executable.
macOS and Linux are strongly recommended. Both are natively compatible with the machine learning libraries ColonyPy uses and analyse a typical plate image in approximately 20 seconds.
Windows is supported but has known compatibility limitations with machine learning frameworks. On Windows, a single image may take 3–5 minutes to analyse. If you are on Windows and need faster performance, the recommended solution is to set up Ubuntu via WSL (Windows Subsystem for Linux) and run the Linux version of ColonyPy, this restores the ~20 second per image speed. Instructions: learn.microsoft.com/en-us/windows/wsl/install.
Double-click ColonyPy.exe
Windows may show a SmartScreen warning on first launch. Click More info → Run anyway.
Double-click ColonyPy.app
On first launch, right-click → Open → Open. You may need to allow it in System Settings → Privacy & Security.
Run ./ColonyPy/ColonyPy from a terminal, or double-click if your file manager supports it.
The executable is entirely self-contained. There is no installation step and no internet connection needed to run ColonyPy.
Imaging Requirements
For reliable colony detection, images must match the conditions used to train the StarDist model. Deviation from these conditions will reduce detection accuracy.
| Parameter | Required Value | Notes |
|---|---|---|
| Background | White transillumination tray | Tray must be clean as residue causes false detections |
| Imager | Bio-Rad ChemiDoc | White transillumination mode |
| Exposure | 0.9 seconds | Standard setting. Use this for all imaging. Only adjust if you observe poor colony contrast with your specific media. See guidance below. |
| Image size | Medium (ChemiDoc setting) | 1830 × 1646 pixels |
| Resolution | 300 DPI | Both axes |
| Bit depth | 24-bit colour | 8-bit per RGB channel |
| Physical size | 15.5 × 12.4 cm | At the Medium image setting |
| Plate size | 90 mm petri dish | Standard round plate |
| Export format | JPEG or PNG or TIFF | Do not resize images before importing |
ChemiDoc Export Settings
When exporting from the ChemiDoc Image Lab software, use these exact settings:
- Select File → Export Image
- Set image size to Medium
- Resolution: 300 DPI
- Format: JPEG (high quality), PNG or TIFF (use JPEG or PNG for control plates; see File Naming)
- Do not apply any post-processing filters before export
Adjusting Exposure for Different Media
0.9 seconds is the standard exposure and should work correctly for the vast majority of plates. Only consider adjusting if you image a plate and observe clearly poor contrast. For example colonies that are nearly invisible, or a background so bright that colonies cannot be distinguished. If adjustment is needed, stay within the 0.8–1.5 second range and use the reference images below as your target.
At 0.9 s, most plates will already look like the reference images below. If yours do not, use these two criteria to judge whether an exposure adjustment is needed:
- Colonies appear as clearly distinct bright spots against a dark agar background
- The agar background is uniformly dark with no large bright patches or blown-out regions
Reference Images, What Good Contrast Looks Like
Use these images as a visual benchmark when setting your exposure. Both were acquired on a Bio-Rad ChemiDoc with Coomassie Blue lighting.
Good contrast: dense uniform colony ring clearly visible against a dark ZOI interior. Individual colonies are distinguishable as separate white dots at the outer edge. The antifungal disk appears as a bright white central circle.
Good contrast: colonies appear as bright, well-separated white spots on a uniformly dark background. Colonies near the rim are fully visible. No blown-out regions or bright background patches.
- Background too bright / colonies hard to distinguish → reduce exposure (try 0.85,0.8 s)
- Colonies very dim or invisible against background → increase exposure (try 0.95,1.0,1.1–1.5 s)
- Colonies appear blown out (pure white, no edge detail) → reduce exposure
- Always capture a test image first and compare it visually to the reference plates above before imaging your full batch
- Once you find the right exposure for a media type, record it and use it consistently across all plates in that experiment
What Bad Contrast Looks Like. Do Not Use
Images like these will produce poor detection results:
Colonies are visible but uneven lighting for example brighter near the rim, lighter patches in the plate, causes inconsistent thresholding and missed or false-positive detections.
Uneven lighting with lighter patches in the ZOI causes false positive detection.
Good Practice Guidelines
Inoculum Preparation
ColonyPy uses StarDist, a convex shape detection model. It is designed to detect convex colonies. It cannot detect colonies within confluent lawns.
Using too high an inoculum in strain control plates will cause:
- Unreliable threshold calibration from control plates
Recommended practice:
- Optimise inoculum concentration so that colonies on the control plate are well-separated
- Control plates should produce distinct, non-overlapping colonies across the whole plate
- Aim for 100–500 countable colonies per plate
- During testing, if the ZOI shows a lawn, dilute the inoculum and repeat
Plate Preparation
- Use standard 90 mm round petri dishes. Disk detection is tuned for 90 mm plates; for other sizes set Plate Diameter in the Setup tab and check every disk and plate boundary in the editor
- Ensure the tray is clean before imaging. Residue on the tray creates bright spots that may be detected as colonies
- Place only one plate per image. ColonyPy analyses one plate per image file
- Remove the plate lid before imaging
- Ensure the plate is upright, resting on its bottom, with the agar surface facing up
- Do not image plates with writing on the bottom or along the sides, as markings interfere with analysis
- Ensure the plate is centred and fully in frame with no shadows cut across it
Critical: Plate Cleanliness
- The agar surface, plate rim and plate bottom must be free of artefacts, bubbles, condensation, or media residue. Any dark marks near the plate edge can disrupt the plate-boundary detection algorithm.
Re-run and Overwrite Policy
ColonyPy writes results into the output directory you specify. If you re-run an analysis with the same output directory, the row for any re-processed image in the results CSV (colony_analysis_results.csv for disk diffusion, agar_dilution_results.csv for agar dilution) is replaced, and its PDF is overwritten.
Best practice: always use a new, separate output directory for each re-run. This preserves your original results and avoids accidental data loss. Use clear naming such as:
results_2025-06-01_run1/results_2025-06-01_run2_adjusted_ZOI/
Installation
System Requirements
macOS and Linux are strongly recommended. Both are natively compatible with the machine learning libraries ColonyPy uses and analyse a typical plate image in approximately 20 seconds.
Windows is supported but has known compatibility limitations with machine learning frameworks. On Windows, a single image may take 3–5 minutes to analyse. If you are on Windows and need faster performance, the recommended solution is to set up Ubuntu via WSL (Windows Subsystem for Linux) and run the Linux version of ColonyPy, this restores the ~20 second per image speed.
- Windows 10/11, macOS 12+, or Linux (Ubuntu 20.04 or newer, or an equivalent recent Linux distribution)
- 4 GB RAM minimum (8 GB recommended for large batches)
- No internet connection needed to run ColonyPy
Step-by-step Setup
- Download the ColonyPy package for your operating system
- Unzip or extract the file to a location of your choice (e.g.
Documents/ColonyPy) - Double-click the executable to launch. See Launching above for platform-specific instructions
ColonyPy is distributed as a fully self-contained executable. The model and all dependencies are bundled inside. You receive only:
ColonyPy.exe ← double-click to launch
USER_MANUAL.html ← open in browser
ColonyPy.app ← double-click to launch
USER_MANUAL.html ← open in browser
ColonyPy/ ← folder containing the binary
ColonyPy ← run this
USER_MANUAL.html
No Python installation, no separate model folder and no launcher scripts. Everything is inside the executable. Keep USER_MANUAL.html next to the executable so Help → User Manual can open it.
Overall Workflow
Prepare Images
ChemiDoc, Coomassie Blue, 0.9 s exposure, Medium size, 300 DPI
Name Files
Follow naming convention; control plates end with _C
Setup Tab
Set input/output directories, analysis method and diameters
Analysis Tab
Click Start Analysis and confirm. Control plates run first
Manual Editor
Review, correct and save every image, controls included
Results
View summary table, open output folder, export CSV
File Naming Convention
Correct file naming is essential for ColonyPy to match control plates to test plates of the same strain and to group replicates for statistics.
| Plate Type | Format | Example |
|---|---|---|
| Control plate | {strain}_C.jpg | KN99_C.jpg |
| Test plate | {strain}_rep{n}_{condition}.jpg | KN99_rep1_FLC.jpg |
- Control plates must end with
_C(case-insensitive) immediately before the file extension. A replicate number is optional:KN99_rep1_C.jpgalso works, butKN99_C.jpgis sufficient. A file without_Cis always treated as a test plate. - Test plates must contain
_rep{n}followed by the condition, e.g.KN99_rep1_FLC.jpg. The replicate number and condition are what group replicates inREPLICATE_STATISTICS_*.csv. A test plate without_rep{n}is either refused (its strain cannot be matched to a control) or analysed without replicate and condition information and left out of the replicate statistics. - How the strain is read: the strain is everything before
_rep. For example, the strain inKN99_rep1_FLC.jpgandKN99_C.jpgisKN99, so the two match. A leading plate number of one or two digits is ignored (3_KN99_C.jpg→KN99). - Avoid strain names that contain the letters
ug(e.g.Bug1), because ColonyPy treats a part containingugas a drug concentration and stops reading the strain name there. - Supported formats:
.jpg,.jpeg,.png,.bmp,.tiff,.tif. For control plates, use.jpg,.jpegor.png: a TIFF or BMP control is not recognised as a control when it is re-detected after a boundary adjustment in the editor.
If a test plate's strain has no control of its own, ColonyPy may match it to another strain's control whose name contains it. For example, KN99_rep1_FLC.jpg can borrow the threshold from KN99a_C.jpg when KN99_C.jpg is missing. Choose strain names where no name is part of another, always include a control for every strain, and check p25_threshold_used_px in the results CSV.
What happens when a control plate is missing?
The behaviour is the same in disk diffusion and agar dilution mode. For each test plate whose strain has no matched control:
- The log shows
❌ No control plate found for strain 'X' … Skipping X - A dialog titled Disk Not Detected appears, asking whether to skip and continue. This dialog is shown for a missing control even in agar dilution mode, and even when the disk was fine. Check the log for the real reason.
- Yes skips that image (nothing is written for it) and continues. No stops the whole run.
If the folder contains no control plates at all, this happens for every test image.
ColonyPy does not use a default threshold. The threshold comes only from control plates that you review and save with Save & Continue in the same run. If you skip a control plate in the editor, every test plate of that strain is refused. Add a control plate for every strain before running a batch.
If a strain has several control plates in one run, ColonyPy averages each new control's threshold (p25), median and CV with the running value, and adds up their colony counts. In agar dilution mode the percentages are calculated against this summed count. For predictable results, use one control plate per strain per batch.
Setup Tab Step by Step
The Setup tab is the first tab you see when ColonyPy opens. Configure everything here before running analysis.
1. Directory Selection
- Click Browse… next to Input Directory (Images) and navigate to the folder containing your plate images
- Click Browse… next to Output Directory (Results) and select or create a folder where results will be saved
2. Analysis Method
Select the method matching your experimental setup:
| Method (as shown in the app) | When to Use | Description |
|---|---|---|
| Zone of Inhibition Analysis (Disk Diffusion) | Antifungal disk present on plate | Detects the plate and disk, fits the ZOI boundary using logistic regression, and classifies colonies inside the ZOI |
| Agar Dilution Assay (Full Plate) | No disk; drug in the agar (agar dilution / population analysis profiling) | Analyses the full plate, excluding a narrow band at the rim, and classifies all colonies on the plate |
Control plates are always analysed as full plates (no disk, no ZOI), whichever method is selected.
3. Parameters
| Parameter | Default | Description |
|---|---|---|
| Disk Diameter (mm) | 6.0 | Physical diameter of the antifungal disk. Used in disk diffusion only: it sets the expected disk size and the pixel-to-mm calibration (mm values are calculated from the detected disk). Standard disks are 6 mm. |
| Plate Diameter (mm) | 90.0 | Physical diameter of the petri dish. Used for the pixel-to-mm calibration of control plates and agar dilution plates. Standard plates are 90 mm. |
ColonyPy does not have a configurable colony threshold. The threshold always comes from a strain-matched control plate's p25 colony size. See File Naming Convention for details.
4. Colour Configuration
Set the colours used in the PDF output for tolerance colonies, heteroresistance colonies, the plate boundary, the ZOI boundary and the antifungal disk. Click any colour button to open the colour picker. Three presets are available: Default Dark Vibrant
These colours do not change the Manual Editor, which always uses the default colours. Control-plate colonies are always drawn in orange.
5. StarDist Status
At the bottom of the directory section you should see ✅ StarDist ready , bundled model loaded automatically. If StarDist cannot be loaded, ColonyPy shows an error when it starts and closes. See Troubleshooting.
Analysis Tab Step by Step
Pre-Analysis Check
The Analysis tab shows four green ticks when everything is ready:
- ✅ Input directory selected
- ✅ Output directory selected
- ✅ Analysis method chosen
- ✅ Images found in directory
If any item shows ✗, go back to Setup and correct it. Click Refresh Check to revalidate after making changes. Start Analysis stays disabled until all four checks pass.
Analysis Options
| Option | Current behaviour |
|---|---|
| Create comparison plots | A PDF is always created for every image you save in the editor, so this option currently has no practical effect. Leave it ticked. |
| Save CSV results | Results are always written to colony_analysis_results.csv or agar_dilution_results.csv, so this option currently has no effect. Leave it ticked. |
| Max replicates per PDF | Reserved for a future feature; it has no effect in this version. |
Enhanced Detection is not on this tab. It is set per plate in the Manual Editor; see Enhanced Detection.
Starting Analysis
If colony_analysis_results.csv or agar_dilution_results.csv is open in Excel (or any spreadsheet program) when a run starts, ColonyPy cannot write to it, Excel holds an exclusive lock on the file while it's open. Close the spreadsheet before starting, and keep it closed for the duration of the run. If you want to check progress partway through, close Excel first, then re-open the file to refresh, don't leave it open across the whole batch.
Similarly, if a particular image's {image}_analysis.pdf is open in a PDF viewer, ColonyPy will not be able to re-process that image, the PDF has to be overwritten on every re-run, and the viewer's lock on the file blocks that. Close the PDF before re-running that image, or before starting a batch that includes it.
- Click Start Analysis
- A confirmation dialog explains that every image will be reviewed manually. Click OK to begin or Cancel to return. Every run uses manual review; there is no fully automated mode.
- If the output folder already has disk diffusion results for some of the images, you are asked whether to resume. See Resuming below.
- Control plates are processed first, then test plates. For each image, the automated analysis runs and then the Manual Editor opens (window title Manual Review {image} (n/N)). Review the result and click Save & Continue to Next Image.
- Watch progress in the log area.
- When the last image is saved, the batch summary and replicate statistics are written and the Results tab opens automatically.
To halt a running analysis, click Stop Analysis. The run stops after the image currently open in the editor is closed. Images you have already saved stay saved, and a batch summary is written for them.
Resuming an Interrupted Analysis
When you start a run, ColonyPy looks in colony_analysis_results.csv in the output folder. If some images already have a row there, it asks Resume Session?: YES skips those images, NO processes everything again.
- Resume only works for disk diffusion. Agar dilution results (
agar_dilution_results.csv) are not checked, so an agar dilution run always starts from the beginning. - Thresholds come only from control plates reviewed in the current run. If you answer YES and the control plates were already saved, they are skipped, and the remaining test plates for those strains are then refused as having no control.
- Test plates you skipped in the editor still have an automated row in the CSV (see Workflow Buttons), so resume treats them as finished.
Recommended: answer NO, or put the remaining test images together with their control plates into a new input folder and run them into a new output folder.
Results Tab
After a run, the Results tab lists every saved image with Total, Tolerance, Heteroresistance, Tol /mm², Het /mm², Tol/Het and ZOI mm (density and ZOI columns apply to disk diffusion only). Buttons:
- Open Results Folder opens the output directory
- Export to CSV saves the table shown to a CSV file of your choice
- Clear Results clears the table (files on disk are not touched)
Menus
| Menu | Items |
|---|---|
| File | Load Settings…, Save Settings…, Open Results Folder, Exit |
| Tools | Load Editing Session, View Results (switches to the Results tab), Group Statistics (opens the output folder if replicate statistics exist) |
| Help | User Manual, About ColonyPy |
Manual Editor, Complete Guide
Opening the Editor
- During analysis: opens automatically after each image has been analysed
- Reviewing a saved image: Tools → Load Editing Session (see Re-opening Sessions)
The editor cannot be opened on a new image outside an analysis run; every image is first analysed through Start Analysis.
Editor Interface
The editor shows the original image on the left and the analysis result on the right, with controls in the left panel: Edit Tools (modes), action buttons, Mode Instructions, Zoom Controls and live Statistics. During a run, an Analysis Results box shows the automated count, the current count and the number of corrections. Use the mouse wheel or Zoom In / Zoom Out / Reset to zoom, and View Mode to drag the image around.
| Overlay colour | Meaning |
|---|---|
| Cyan | Tolerance colony (smaller than the threshold) |
| Magenta | Heteroresistance colony (same size as or larger than the threshold) |
| Orange | Control plate colony (not classified) |
| Green circle | Plate boundary |
| Yellow dashed circle | ZOI boundary (disk diffusion only) |
| Grey disk | Antifungal disk (disk diffusion only) |
Editing Modes
| Mode | What it does |
|---|---|
| View Mode | Click and drag to move around the image |
| Draw Colony | Add a colony by tracing its outline: click and drag around it, then release. Alternatively press Enter, move the mouse around the colony, and press Enter again. The outline is smoothed to a convex shape and the colony is classified automatically by its size. In disk diffusion, colonies can only be drawn between the disk and the ZOI boundary. |
| Delete Colony | Click a colony to remove it, or click and drag across several colonies to remove them all |
| Adjust Disk/ZOI | Move or resize the disk and the ZOI boundary (disk diffusion). See Manual Boundary Adjustments |
| Adjust Plate | Move or resize the plate boundary. See Manual Boundary Adjustments |
| Button / key | What it does |
|---|---|
| Undo or Ctrl+Z | Restores the colony list from before your last change (up to 50 steps). Undo does not move a boundary back; drag it back by hand. |
| Toggle Numbers | Shows or hides colony ID numbers |
| Reset View | Resets zoom and position |
| 🔬 Re-Detect (StarDist) | Runs colony detection again. See Re-detection |
| ⚡ Enhanced detection (tick box) | Makes the next Re-Detect more sensitive. See Enhanced Detection |
| Auto-filter colonies on ZOI change (tick box, on by default) | When you change a boundary, colonies outside it are removed straight away |
Tolerance or heteroresistance is decided only by colony size compared with the control threshold. Every colony is re-classified when you save, so there is no way to override a type manually. To correct a colony, delete it and draw its outline again.
Workflow Buttons (during an analysis run)
| Button | Effect |
|---|---|
| Save & Continue to Next Image | Saves your corrected result (CSV row, PDF, editing session and colony_sizes.csv) and moves to the next image. For a control plate, this is what sets the threshold for that strain. |
| Skip This Image | Moves on without saving your review. See the warning below. |
| Cancel Analysis | After confirmation, stops the whole run. Images already saved are kept, and a batch summary is written for them. |
The automated analysis of a test plate writes a preliminary results row, a PDF and colony_sizes.csv entries before the editor opens. If you skip or cancel on that image, these unreviewed results stay in the output folder. You can recognise the row: its manually_corrected column is N/A instead of Yes or No. Delete such rows before analysing your data, or use a fresh output folder.
Skipping a control plate writes no results row, but no threshold is set for that strain, so all of its test plates will be refused.
Enhanced Detection
Enhanced Detection makes StarDist more sensitive to dim, small or densely packed colonies. It is off by default and is a per-plate decision, available for disk diffusion, agar dilution and control plates.
- In the editor, tick ⚡ Enhanced detection
- Click 🔬 Re-Detect (StarDist); the setting only takes effect when detection is re-run
- Check the result. If colonies are being split or false positives appear, untick the box and re-detect again
| Situation | Recommendation |
|---|---|
| Many colonies missed on a plate | Use Enhanced Detection for that plate, then check the result carefully. |
| Detection already looks good on a plate | Leave Enhanced Detection off. Using it on a well-imaged plate can cause oversegmentation and false positives. |
Manual Boundary Adjustments
Occasionally the automatic boundary detection is imprecise. You correct it directly on the image, then re-detect colonies. The editor has no sliders; boundaries are moved and resized with the mouse (and arrow keys for the disk and ZOI).
Fix boundaries first, then click Re-Detect, then make manual colony edits (draw / delete) last. Re-Detect replaces the whole colony list, so any edits made before it are lost.
Adjusting the ZOI Boundary and Disk (Disk Diffusion)
The ZOI (Zone of Inhibition) boundary is the yellow dashed circle around the disk; colonies are counted between the disk and this circle.
- Select Adjust Disk/ZOI mode. The status bar tells you what is under the cursor.
- Resize the ZOI: click on the yellow circle and drag outwards to expand or inwards to shrink it.
- Resize the disk: click on the edge of the grey disk and drag until it matches the physical disk.
- Move the disk: click near the disk centre and drag; the ZOI moves with it.
- Fine-tune with the arrow keys (in this mode): ↑ / ↓ enlarge or shrink the ZOI, → / ← enlarge or shrink the disk. Each press is 1 pixel; hold Shift for 5 pixels.
- Click 🔬 Re-Detect (StarDist) to count colonies with the new boundaries.
In disk diffusion, millimetre values are calculated from the disk: the Disk Diameter (e.g. 6 mm) divided by the disk's size in pixels. Resizing the disk circle therefore changes every mm value for that plate (ZOI radius, ZOI area, densities). Make the grey disk match the physical disk as closely as possible.
With Auto-filter colonies on ZOI change ticked, colonies outside the new boundary are removed as soon as you release the mouse. If you enlarge the ZOI beyond its original size, the editor re-runs detection on its own and shows a Re-Detection Complete box. This automatic count can differ from a full re-detection, so click 🔬 Re-Detect (StarDist) afterwards to get the full count.
Adjusting the Plate Boundary
The green circle should sit precisely on the inner edge of the petri dish rim. If it is too large (picking up false colonies on the rim) or too small (missing edge colonies):
- Select Adjust Plate mode
- Click on the green circle and drag inwards to shrink it (excludes more rim) or outwards to expand it. Click near the plate centre and drag to move it.
- For agar dilution plates where the rim is thick or falsely bright, shrink the boundary until the green circle sits clearly inside the rim
- Click 🔬 Re-Detect (StarDist)
Colonies within about 10 pixels of the green circle are not counted. In disk diffusion, the plate boundary limits how far the ZOI can be enlarged but does not otherwise affect the count.
In full-plate (agar dilution) analysis, the plate rim often produces bright artefacts that are mistaken for colonies. This is the most common cause of inflated counts in agar dilution mode.
Fix: In Adjust Plate mode, shrink the plate boundary by 5–15 pixels until the false rim colonies are outside it, then click Re-Detect. Apply the same adjustment consistently across all plates in the same batch.
Re-detection
Clicking 🔬 Re-Detect (StarDist) asks for confirmation, then replaces all current colonies with a fresh StarDist detection. Manual edits made before re-detecting are lost (Undo restores them).
- If you changed a boundary, detection runs inside your adjusted boundaries. This uses contrast enhancement only, without the reference standardisation used in the first automated run, so counts can differ slightly from the original analysis.
- If you changed nothing, the complete automatic analysis is repeated, including detecting the plate, disk and ZOI again.
Re-opening Saved Sessions
Every image you save with Save & Continue during a run has its session saved automatically in editing_sessions/ inside your output folder. You can reload any session to review or correct it.
To Load a Saved Session
- Go to Tools → Load Editing Session
- Navigate to your output folder →
editing_sessions/ - Select the
*_session.jsonfile for the image you want to review - The editor opens showing the image with the saved colonies and boundaries
- Make any corrections, then save using the buttons in the left panel (or the editor's File menu):
- Save to CSV/PDF asks for an output folder and replaces that image's row in the results CSV and its PDF. Choose the original output folder to update the existing results.
- Save Session asks where to save the session file. The session in
editing_sessions/is not updated automatically; save over it if you want your changes there. - Export Results saves the colony list as a separate JSON file.
*_session.json) store all colony positions, classifications and boundary parameters from the last save for that image. They do not include the image itself; the original image must be at its original path or in the current input directory, otherwise ColonyPy asks you to locate it.
Correcting a control plate later through a saved session updates that control's own row, but does not update the thresholds of test plates that were already saved. To apply a corrected control, re-run the batch (controls and test plates) into a new output folder.
Re-runs and Result Overwriting
ColonyPy updates colony_analysis_results.csv (disk diffusion) or agar_dilution_results.csv (agar dilution) by replacing the row for any image that is re-processed. If you re-run with the same output directory, your previous results for that image are replaced with no confirmation prompt.
To preserve all versions of your results:
- Create a new output folder before each re-run (e.g.
run2_adjusted_boundary/) - Set this as the output directory in the Setup tab
- Run analysis as normal
Batch summary (BATCH_SUMMARY_*.csv) and replicate statistics (REPLICATE_STATISTICS_*.csv) files are timestamped and never overwritten. A new file is created each time a run finishes with at least one saved image; each file covers only the images saved in that run.
Output Files
| File | Description |
|---|---|
colony_analysis_results.csv | Master results table for disk diffusion runs: one row per image, including the control plates. A preliminary row is written by the automated analysis of each test plate and replaced when you click Save & Continue. |
agar_dilution_results.csv | Master results table for agar dilution runs: one row per image, including the control plates of an agar dilution run. Same row-replacement behaviour as above. |
{image}_analysis.pdf | Per-image annotated visualisation. Disk diffusion includes the ZOI regression plot. Agar dilution shows the full plate with colony overlay and a stats box. Control plates show the colonies and median size/CV. |
BATCH_SUMMARY_{timestamp}.csv | Summary of the images saved in the run: total, tolerance and heteroresistance counts, densities and density ratio (disk diffusion), and whether each was manually corrected. |
REPLICATE_STATISTICS_{timestamp}.csv | Mean, SD, median, min, max and CV per group, with high-variability flags. Groups are formed by strain + condition; at least 2 replicates per group are required. Only written if at least one such group exists. |
colony_sizes.csv | One row per colony (area in px² and mm², category, centroid, image, method). The automated analysis writes rows with source = auto; when you save the image in the editor they are replaced with your reviewed colonies (source = corrected). Use only corrected rows for reviewed data. |
editing_sessions/{image}_session.json | Saved editor state for each image saved during a run. Used by Load Editing Session. |
ColonyPy writes to one of two CSV files depending on the analysis method: disk diffusion results (and their control plates) go to colony_analysis_results.csv, while agar dilution results (and their control plates) go to agar_dilution_results.csv. Agar dilution has no disk or zone-of-inhibition geometry, so those columns are not present in agar_dilution_results.csv. Running disk diffusion and agar dilution batches into the same output directory produces both files, each containing only the rows for its own method.
CSV Column Reference for colony_analysis_results.csv (disk diffusion)
| Column | Description | Applies To |
|---|---|---|
| analysis_method | disk or control_plate | All |
| strain / replicate / condition | Parsed from the filename (see File Naming). Control plates have condition control. | All |
| analysis_timestamp / image_name | When the row was written, and the image file name | All |
| pixel_to_mm | Millimetres per pixel. Disk diffusion: from the disk size; control plates: from the plate size | All |
| total_colonies | All colonies counted (in the ZOI for test plates, on the whole plate for controls) | All |
| tolerance_colonies | Colonies smaller than the threshold. N/A for control plates, which are not classified. | Disk test plates |
| heteroresistance_colonies | Colonies the same size as or larger than the threshold. N/A for control plates. | Disk test plates |
| tolerance_percentage_by_count / heteroresistance_percentage_by_count | Share of the colonies in the ZOI that are tolerance / heteroresistance. The two add up to 100%. | Disk test plates |
| p25_threshold_used_px | For test plates, the classification threshold: the p25 colony area of the matched control (averaged if the strain had several controls). For a control plate's own row, that control's own p25 value. | All |
| control_median_px / control_p75_px / control_cv_percent | Median, 75th percentile and coefficient of variation of colony area on the control. Descriptive only. On a control's own row they are recalculated from its reviewed colonies when the row is saved; on test rows they are the values of the matched control at the time that control was saved. A CV above ~30% may indicate uneven inoculation or imaging artefacts. | All |
| control_colony_count | On test rows, the number of colonies on the matched control (summed if the strain had several controls). Always N/A on the control plate's own row. | All |
| zoi_radius_mm | Distance from the disk edge to the ZOI boundary | Disk test plates; N/A for controls |
| zoi_area_mm2 | Area of the ring between the disk and the ZOI boundary | Disk test plates; N/A for controls |
| disk_radius_mm | Half the Disk Diameter setting. Because mm values are calibrated from the disk, this is the reference value rather than an independent measurement. | Disk test plates; N/A for controls |
| colony_density_per_mm2 / tolerance_density_per_mm2 / heteroresistance_density_per_mm2 / tolerance_heteroresistance_density_ratio | Colony densities relative to the ZOI area, and the tolerance-to-heteroresistance density ratio (text such as "No heteroresistance detected" when one count is zero) | Disk test plates; N/A for controls |
| manually_corrected | Yes if anything was changed in the editor (colonies, boundaries or a re-detection), No if the image was saved unchanged, N/A if the row is a preliminary automated result that was never reviewed | All |
CSV Column Reference for agar_dilution_results.csv (agar dilution / population profiling)
This file uses the same identification and control columns as above, but has no disk, ZOI-area or density columns. zoi_radius_mm is kept only for column-order consistency and is always N/A.
| Column | Description | Applies To |
|---|---|---|
| analysis_method | agar_dilution or control_plate | All |
| strain / replicate / condition, analysis_timestamp, image_name | Same as above | All |
| pixel_to_mm | Millimetres per pixel, from the plate size and the Plate Diameter setting | All |
| total_colonies | All colonies counted on the plate | All |
| tolerance_colonies / heteroresistance_colonies | Colonies smaller than / at least as large as the threshold. N/A on the control plate's own row. | Agar dilution test plates |
| tolerance_percentage_by_count / heteroresistance_percentage_by_count | Count as a percentage of the matched control plate's colony count. These do not normally add up to 100%. | Agar dilution test plates |
| p25_threshold_used_px, control_median_px, control_p75_px, control_cv_percent, control_colony_count | Same meaning as in colony_analysis_results.csv above | All |
| zoi_radius_mm | Always N/A | All |
| manually_corrected | Same as above | All |
Replicate Statistics CV Thresholds
A "HIGH VARIABILITY" flag is added when the CV across replicates exceeds the threshold for that metric:
| Metric | CV threshold |
|---|---|
| Total colonies, colony density | 20% |
| Tolerance colonies, heteroresistance colonies, tolerance density, heteroresistance density | 25% |
| Tolerance %, heteroresistance %, Tol/Het ratio | 30% |
| ZOI radius | 5% |
Trained StarDist Model
The bundled StarDist model was trained specifically on fungal colony images from the Nielsen Laboratory. Understanding the model architecture and training conditions helps you get the best results and interpret detection limitations correctly.
Architecture
| Parameter | Value |
|---|---|
| Architecture | StarDist2D U-Net backbone |
| Input channels | 1 (single-channel grayscale) |
| Ray count | 32 (star-convex polygon approximation) |
| U-Net depth | 3 |
| Base filters | 32 (doubled per depth level) |
| Conv per depth | 2 |
| Activation | ReLU |
| Post-UNet conv | 128 filters |
| Grid downsampling | 2 × 2 |
Training Configuration
| Parameter | Value |
|---|---|
| Training epochs | 100 |
| Best checkpoint | Epoch 99 |
| Steps per epoch | 200 |
| Batch size | 2 |
| Training patch size | 256 × 256 px |
| Learning rate | 0.0003 |
| LR schedule | ReduceLROnPlateau factor 0.5, patience 40 |
| Distance loss | Mean absolute error (MAE) |
| Loss weights | Object probability: 1.0 · Distance: 0.2 |
| Training images | 51 |
| Validation images | 9 |
Performance
The model achieves approximately 80% automated recall. After manual review using the editor (adding missed edge colonies, removing false positives), effective accuracy reaches 95–99% for well-prepared plates. This is why every run includes manual review.
Training Image Conditions
All training images were acquired under these exact conditions:
- Light application: Coomassie Blue
- Imager: Bio-Rad ChemiDoc, white transillumination mode
- Exposure: 0.9 seconds (standard; only adjust if contrast is poor with your specific media, see Imaging Requirements)
- Size: Medium 1830 × 1646 pixels, 300 DPI, 24-bit colour, 15.5 × 12.4 cm
- Plate: Standard 90 mm petri dish
The model is expected to perform best on images that closely match these conditions. Images from different imagers, different exposure times, or different lighting protocols may give reduced accuracy.
Image Processing Pipeline
For each image, ColonyPy runs these steps:
- Grayscale conversion
- CLAHE contrast-limited adaptive histogram equalisation (clip limit 3.0, 8×8 tile grid)
- Plate detection: the plate is found as the largest bright region and fitted with a circle
- Disk and ZOI detection (disk diffusion test plates only): the disk is found as a bright, round object near the plate centre, with a circle-detection fallback. The ZOI boundary is then fitted from the radial intensity profile with logistic regression.
- Reference standardisation (disk diffusion test plates only): the intensity profile is matched to the training dataset's mean and standard deviation
- StarDist detection: intensities are normalised and the model detects colonies. Only colonies inside the ZOI (disk diffusion, excluding the disk) or inside the plate boundary (control and agar dilution) are kept.
- Classification (test plates): each colony's area is compared with the matched control's p25 threshold
Troubleshooting
Disk not detected / disk detection failed
ColonyPy looks for a bright, round object of the expected disk size near the centre of the plate, then falls back to circle detection. This fails if:
- The disk is far from the plate centre, or the plate is not fully in frame
- The tray has smudges or bright spots near the disk
- The Disk Diameter setting does not match the disks you used
- The image is very dark or overexposed, check you are using 0.9 s. If contrast is genuinely poor for your media type, adjust within the 0.8–1.5 s range and compare to the reference images in the Imaging Requirements section
If detection fails, a Disk Not Detected dialog asks whether to skip the image: Yes skips it (nothing is saved for it) and continues, No stops the run. An image whose disk was not detected cannot be opened in the editor, so re-image the plate and run it again.
The same dialog also appears when a test plate has no matched control plate. Check the log: No control plate found for strain … means the control is missing, not the disk.
False colonies detected on the plate rim
The inner surface of the petri dish rim often produces a bright ring of artefacts. To fix:
- In the editor for the affected image, select Adjust Plate mode
- Drag the green boundary circle inwards until it sits inside the rim
- Click 🔬 Re-Detect (StarDist)
- Apply the same adjustment to all plates in the batch for consistency
Fewer colonies detected than expected near the ZOI edge
Colonies at the outer edge of the ZOI are often lower contrast and may be missed by automated detection. This is normal, the model has ~80% automated recall. To recover them:
- If the ZOI is too tight, enlarge it in Adjust Disk/ZOI mode and click 🔬 Re-Detect (StarDist)
- If many colonies are still missed, try Enhanced Detection
- Finally, add any remaining missed colonies in Draw Colony mode by tracing their outlines; they are classified automatically
Test plates refused with "No control plate found"
- Check that a control plate named
{strain}_C.jpgexists for the strain, with exactly the same strain spelling - Make sure you clicked Save & Continue for the control plate in this run (skipping it means no threshold)
- If you resumed a run, the controls may have been skipped. See Resuming
- Check the test plate contains
_rep{n}_; otherwise its strain may be read incorrectly
Lawn in the ZOI
If colonies have grown into a confluent lawn, ColonyPy cannot count individual colonies. The model is designed for convex colonies only. Solutions:
- Repeat the experiment with a lower inoculum concentration
- The lawn colony clusters will be detected as single large heteroresistance colonies, this is not biologically meaningful and should not be included in analysis
Analysis fails partway through, or an image's PDF/CSV row won't update
This is almost always a file-lock issue, another program has the output file open, so ColonyPy cannot write to it:
- Results CSV open in Excel: close
colony_analysis_results.csvoragar_dilution_results.csvin Excel (or any spreadsheet program) before starting a run, and keep it closed for the whole run. Excel holds an exclusive lock on the file while it's open, which blocks ColonyPy from saving results. - A result PDF open in a PDF viewer: if
{image}_analysis.pdfis open when ColonyPy tries to re-process that image, it cannot overwrite the file and that image will fail or be skipped. Close the PDF viewer for that file before re-running.
If you need to check progress mid-run, close the file first, then reopen it afterwards to see the latest version, don't leave it open across the batch.
StarDist not installed / model not found
This should not occur with the PyInstaller executable as StarDist and the model are bundled inside. If ColonyPy shows a StarDist error at start-up and closes, or a "StarDist Model Not Found" error:
- Re-download the ColonyPy executable, the download may have been corrupted
- Ensure you are running the correct executable for your platform (Windows
.exe, macOS.app, Linux binary) - On macOS, make sure you extracted the
.zipfully before launching, do not run directly from inside the zip
Frequently Asked Questions
Can I use images from a different imager?
The StarDist model was trained on images from a Bio-Rad ChemiDoc with Coomassie Blue light application at 0.9 s exposure. Use 0.9 s as your standard. Exposure may be adjusted within 0.8–1.5 s only if you observe poor contrast with a specific media type, compare results to the reference images in the Imaging Requirements section before proceeding. Images from other imagers may have different contrast profiles that reduce detection accuracy. If you use a different system, we recommend validating manually on a representative subset of images before using results for publication.
Do I need a control plate for every strain?
Yes. The classification threshold is the p25 (25th percentile) colony size on the matched control plate, and ColonyPy has no default threshold. Without a matched control, a test image for that strain is refused (the log names the strain and the expected control filename). The control must be reviewed and saved in the same run as its test plates. Include one control plate per strain per batch.
Can I analyse multiple plates per image?
No. ColonyPy expects one plate per image. Use the ChemiDoc imaging software to capture separate images for each plate.
Can I skip the manual review?
No. Every run opens the editor for each image, and results are only finalised when you click Save & Continue. If a plate looks right, you can save it without changes; its manually_corrected value will be No.
What does the CV warning in replicate statistics mean?
CV (coefficient of variation) measures variability across replicates. A "HIGH VARIABILITY" flag appears when CV exceeds the threshold for that metric (e.g. 20% for total colonies; see Output Files for the full list). High CV may indicate: inconsistent inoculum between replicates, variable culturing, imaging artefacts, or biological variability. Investigate flagged groups before reporting.
How do I report ColonyPy in a methods section?
Suggested methods text:
Please cite the ColonyPy publication once it becomes available Atim et al., 2026 (when available). Colony images were acquired using a Bio-Rad ChemiDoc imaging system (white transillumination mode, 0.9 s exposure, Coomassie Blue light application; 1830 × 1646 pixels, 300 DPI, 24-bit colour, 15.5 × 12.4 cm physical size). Colony detection and classification were performed using ColonyPy v1.0 (Nielsen Laboratory), which implements a StarDist deep-learning segmentation model (F1 = 80.5%, precision = 82.9%, recall = 78.2%, trained on 60 images). Colonies were classified as Tolerance or Heteroresistance based on size relative to the p25 (25th percentile) colony area of strain-matched no-drug control plates. Automated detections were reviewed and corrected using the ColonyPy manual editor.
How do I save settings between sessions?
Use File → Save Settings… to save your current settings (directories, method, diameters, colours and options) to a JSON file. File → Load Settings… currently restores only the input and output directories (and the PDF colours, although the colour buttons do not update to show them). After loading, check the analysis method and the disk and plate diameters in the Setup tab before starting a run.