ColonyPy

Colony Image Analysis Pipeline User Manual

Version 1.0  ·  Nielsen Laboratory  ·  Virginia Tech University

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:

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.

82.9%
Precision
78.2%
Recall
80.5%
F1 Score
99/100
Best Epoch
Bundled Model
The trained StarDist model is bundled inside the ColonyPy application and loads automatically when ColonyPy starts. You do not need to attach or download any model file separately.

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.

Platform Performance

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.

Windows

Double-click ColonyPy.exe

Windows may show a SmartScreen warning on first launch. Click More info → Run anyway.

macOS

Double-click ColonyPy.app

On first launch, right-click → Open → Open. You may need to allow it in System Settings → Privacy & Security.

Linux

Run ./ColonyPy/ColonyPy from a terminal, or double-click if your file manager supports it.

No Setup Required

The executable is entirely self-contained. There is no installation step and no internet connection needed to run ColonyPy.

First Launch Slow Start
On the very first launch, the executable may take 5-10 minutes to start while it unpacks its bundled libraries. Subsequent launches are faster. This is normal behaviour for PyInstaller executables.

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.

ParameterRequired ValueNotes
BackgroundWhite transillumination trayTray must be clean as residue causes false detections
ImagerBio-Rad ChemiDocWhite transillumination mode
Exposure0.9 secondsStandard setting. Use this for all imaging. Only adjust if you observe poor colony contrast with your specific media. See guidance below.
Image sizeMedium (ChemiDoc setting)1830 × 1646 pixels
Resolution300 DPIBoth axes
Bit depth24-bit colour8-bit per RGB channel
Physical size15.5 × 12.4 cmAt the Medium image setting
Plate size90 mm petri dishStandard round plate
Export formatJPEG or PNG or TIFFDo not resize images before importing
Do Not Resize
Never resize or resample images before importing into ColonyPy. The StarDist model was trained on colonies at the original ChemiDoc resolution (1830 × 1646 px, 300 DPI); resized images change the apparent colony size in pixels, which reduces detection accuracy and shifts the pixel-based size threshold. (Millimetre values are calibrated from the detected disk or plate, using the Disk Diameter and Plate Diameter settings.)

ChemiDoc Export Settings

When exporting from the ChemiDoc Image Lab software, use these exact settings:

  1. Select File → Export Image
  2. Set image size to Medium
  3. Resolution: 300 DPI
  4. Format: JPEG (high quality), PNG or TIFF (use JPEG or PNG for control plates; see File Naming)
  5. 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.

Target Contrast Goal

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:

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.

Disk Diffusion Plate
Disk diffusion reference plate showing dense colony ring around ZOI

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.

Agar dilution Plate
Control plate reference showing well-separated bright colonies

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.

If and Only If Contrast Is Poor: Adjustment Tips
Consistency Within a Run
Once you choose an exposure setting, do not change it between a control plate and its matching test plates. Each control plate and its associated test plates must be imaged at the same exposure as the threshold calibration derived from the control applies only to plates imaged under identical conditions. Different plate types within the same run may require different exposure settings, provided each control is matched to its corresponding test plates at the same setting.

What Bad Contrast Looks Like. Do Not Use

Images like these will produce poor detection results:

Uneven Lighting, Agar Dilution Plate
Agar dilution plate with uneven lighting

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.

Confluent Growth, Disk Diffusion Plate
Disk diffusion plate with confluent growth

Uneven lighting with lighter patches in the ZOI causes false positive detection.

Good Practice Guidelines

Inoculum Preparation

Critical: Control Plate Inoculum Concentration

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:

Recommended practice:

Plate Preparation

Critical: Plate Cleanliness

Re-run and Overwrite Policy

Important: Output Directory 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:

Installation

No Installation Required
ColonyPy is a standalone executable. There is nothing to install. Python does not need to be installed on your machine.

System Requirements

Platform Performance

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.

Step-by-step Setup

  1. Download the ColonyPy package for your operating system
  2. Unzip or extract the file to a location of your choice (e.g. Documents/ColonyPy)
  3. Double-click the executable to launch. See Launching above for platform-specific instructions
What You Receive

ColonyPy is distributed as a fully self-contained executable. The model and all dependencies are bundled inside. You receive only:

Windows
ColonyPy.exe          ← double-click to launch
USER_MANUAL.html      ← open in browser
macOS
ColonyPy.app          ← double-click to launch
USER_MANUAL.html      ← open in browser
Linux
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

1

Prepare Images

ChemiDoc, Coomassie Blue, 0.9 s exposure, Medium size, 300 DPI

2

Name Files

Follow naming convention; control plates end with _C

3

Setup Tab

Set input/output directories, analysis method and diameters

4

Analysis Tab

Click Start Analysis and confirm. Control plates run first

5

Manual Editor

Review, correct and save every image, controls included

6

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 TypeFormatExample
Control plate{strain}_C.jpgKN99_C.jpg
Test plate{strain}_rep{n}_{condition}.jpgKN99_rep1_FLC.jpg
Give every strain a distinct name

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:

If the folder contains no control plates at all, this happens for every test image.

A control plate is required for every strain

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.

More than one control per strain

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

  1. Click Browse… next to Input Directory (Images) and navigate to the folder containing your plate images
  2. Click Browse… next to Output Directory (Results) and select or create a folder where results will be saved
Re-run Warning
Use a new output directory for every re-run. Results from a previous run will be overwritten if you use the same folder. See Re-runs section.

2. Analysis Method

Select the method matching your experimental setup:

Method (as shown in the app)When to UseDescription
Zone of Inhibition Analysis (Disk Diffusion)Antifungal disk present on plateDetects 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

ParameterDefaultDescription
Disk Diameter (mm)6.0Physical 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.0Physical diameter of the petri dish. Used for the pixel-to-mm calibration of control plates and agar dilution plates. Standard plates are 90 mm.
No default colony threshold setting

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:

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

OptionCurrent behaviour
Create comparison plotsA 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 resultsResults 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 PDFReserved 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

Close open results files before you start

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.

  1. Click Start Analysis
  2. 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.
  3. If the output folder already has disk diffusion results for some of the images, you are asked whether to resume. See Resuming below.
  4. 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.
  5. Watch progress in the log area.
  6. 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.

Limitations of resume

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:

Menus

MenuItems
FileLoad Settings…, Save Settings…, Open Results Folder, Exit
ToolsLoad Editing Session, View Results (switches to the Results tab), Group Statistics (opens the output folder if replicate statistics exist)
HelpUser Manual, About ColonyPy

Manual Editor, Complete Guide

Opening the Editor

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 colourMeaning
CyanTolerance colony (smaller than the threshold)
MagentaHeteroresistance colony (same size as or larger than the threshold)
OrangeControl plate colony (not classified)
Green circlePlate boundary
Yellow dashed circleZOI boundary (disk diffusion only)
Grey diskAntifungal disk (disk diffusion only)

Editing Modes

ModeWhat it does
View ModeClick and drag to move around the image
Draw ColonyAdd 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 ColonyClick a colony to remove it, or click and drag across several colonies to remove them all
Adjust Disk/ZOIMove or resize the disk and the ZOI boundary (disk diffusion). See Manual Boundary Adjustments
Adjust PlateMove or resize the plate boundary. See Manual Boundary Adjustments
Button / keyWhat it does
Undo or Ctrl+ZRestores 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 NumbersShows or hides colony ID numbers
Reset ViewResets 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
Colony type cannot be changed by hand

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)

ButtonEffect
Save & Continue to Next ImageSaves 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 ImageMoves on without saving your review. See the warning below.
Cancel AnalysisAfter confirmation, stops the whole run. Images already saved are kept, and a batch summary is written for them.
What Skip and Cancel leave behind

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.

  1. In the editor, tick ⚡ Enhanced detection
  2. Click 🔬 Re-Detect (StarDist); the setting only takes effect when detection is re-run
  3. Check the result. If colonies are being split or false positives appear, untick the box and re-detect again
SituationRecommendation
Many colonies missed on a plateUse Enhanced Detection for that plate, then check the result carefully.
Detection already looks good on a plateLeave 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).

Recommended order

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.

  1. Select Adjust Disk/ZOI mode. The status bar tells you what is under the cursor.
  2. Resize the ZOI: click on the yellow circle and drag outwards to expand or inwards to shrink it.
  3. Resize the disk: click on the edge of the grey disk and drag until it matches the physical disk.
  4. Move the disk: click near the disk centre and drag; the ZOI moves with it.
  5. 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.
  6. Click 🔬 Re-Detect (StarDist) to count colonies with the new boundaries.
Disk size sets the mm calibration

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.

Automatic updates when you drag a boundary

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):

  1. Select Adjust Plate mode
  2. 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.
  3. For agar dilution plates where the rim is thick or falsely bright, shrink the boundary until the green circle sits clearly inside the rim
  4. 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.

Wide Rim / False Edge Colonies in Agar Dilution analysis mode

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).

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

  1. Go to Tools → Load Editing Session
  2. Navigate to your output folder → editing_sessions/
  3. Select the *_session.json file for the image you want to review
  4. The editor opens showing the image with the saved colonies and boundaries
  5. 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 Files
Session files (*_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.
Re-editing a control plate

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

Always Use a New Output Directory for Re-runs

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:

  1. Create a new output folder before each re-run (e.g. run2_adjusted_boundary/)
  2. Set this as the output directory in the Setup tab
  3. 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

FileDescription
colony_analysis_results.csvMaster 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.csvMaster 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.pdfPer-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}.csvSummary 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}.csvMean, 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.csvOne 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.jsonSaved editor state for each image saved during a run. Used by Load Editing Session.
Two Separate Results CSVs

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)

ColumnDescriptionApplies To
analysis_methoddisk or control_plateAll
strain / replicate / conditionParsed from the filename (see File Naming). Control plates have condition control.All
analysis_timestamp / image_nameWhen the row was written, and the image file nameAll
pixel_to_mmMillimetres per pixel. Disk diffusion: from the disk size; control plates: from the plate sizeAll
total_coloniesAll colonies counted (in the ZOI for test plates, on the whole plate for controls)All
tolerance_coloniesColonies smaller than the threshold. N/A for control plates, which are not classified.Disk test plates
heteroresistance_coloniesColonies the same size as or larger than the threshold. N/A for control plates.Disk test plates
tolerance_percentage_by_count / heteroresistance_percentage_by_countShare of the colonies in the ZOI that are tolerance / heteroresistance. The two add up to 100%.Disk test plates
p25_threshold_used_pxFor 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_percentMedian, 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_countOn 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_mmDistance from the disk edge to the ZOI boundaryDisk test plates; N/A for controls
zoi_area_mm2Area of the ring between the disk and the ZOI boundaryDisk test plates; N/A for controls
disk_radius_mmHalf 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_ratioColony 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_correctedYes 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 reviewedAll

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.

ColumnDescriptionApplies To
analysis_methodagar_dilution or control_plateAll
strain / replicate / condition, analysis_timestamp, image_nameSame as aboveAll
pixel_to_mmMillimetres per pixel, from the plate size and the Plate Diameter settingAll
total_coloniesAll colonies counted on the plateAll
tolerance_colonies / heteroresistance_coloniesColonies 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_countCount 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_countSame meaning as in colony_analysis_results.csv aboveAll
zoi_radius_mmAlways N/AAll
manually_correctedSame as aboveAll

Replicate Statistics CV Thresholds

A "HIGH VARIABILITY" flag is added when the CV across replicates exceeds the threshold for that metric:

MetricCV threshold
Total colonies, colony density20%
Tolerance colonies, heteroresistance colonies, tolerance density, heteroresistance density25%
Tolerance %, heteroresistance %, Tol/Het ratio30%
ZOI radius5%

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

ParameterValue
ArchitectureStarDist2D U-Net backbone
Input channels1 (single-channel grayscale)
Ray count32 (star-convex polygon approximation)
U-Net depth3
Base filters32 (doubled per depth level)
Conv per depth2
ActivationReLU
Post-UNet conv128 filters
Grid downsampling2 × 2

Training Configuration

ParameterValue
Training epochs100
Best checkpointEpoch 99
Steps per epoch200
Batch size2
Training patch size256 × 256 px
Learning rate0.0003
LR scheduleReduceLROnPlateau factor 0.5, patience 40
Distance lossMean absolute error (MAE)
Loss weightsObject probability: 1.0 · Distance: 0.2
Training images51
Validation images9

Performance

82.9%
Precision
78.2%
Recall
80.5%
F1 Score
99/100
Best Epoch
Two-Stage Accuracy

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:

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:

  1. Grayscale conversion
  2. CLAHE contrast-limited adaptive histogram equalisation (clip limit 3.0, 8×8 tile grid)
  3. Plate detection: the plate is found as the largest bright region and fitted with a circle
  4. 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.
  5. Reference standardisation (disk diffusion test plates only): the intensity profile is matched to the training dataset's mean and standard deviation
  6. 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.
  7. 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:

  1. In the editor for the affected image, select Adjust Plate mode
  2. Drag the green boundary circle inwards until it sits inside the rim
  3. Click 🔬 Re-Detect (StarDist)
  4. 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:

  1. If the ZOI is too tight, enlarge it in Adjust Disk/ZOI mode and click 🔬 Re-Detect (StarDist)
  2. If many colonies are still missed, try Enhanced Detection
  3. 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.jpg exists 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.csv or agar_dilution_results.csv in 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.pdf is 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 .zip fully 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.