A Python-based graphical interface for automated cell colony counting and analysis using FIJI/ImageJ. This tool provides a user-friendly GUI for processing images of colonies with advanced image analysis, statistical visualization, and batch processing capabilities.
Originally developed by Beata Brzozowska and published DOI: 10.1007/s00411-018-00772-z.
Count and Plot HIstograms of Colony Size 2 (countPHICS2) is designed to automate the tedious process of counting colonies. It combines the power of FIJI/ImageJ's image processing capabilities with Python's data analysis and visualization tools through an intuitive desktop interactive interface.
- User-friendly GUI - Clean, modern interface built with PySide6
- Automated colony detection - Advanced image processing with customizable parameters
- Batch processing - Process multiple colony images automatically
- Statistical analysis - Weibull distribution fitting, KS tests, and descriptive statistics
- Data visualization - Automatic generation of histograms, boxplots, and distribution plots
- Comprehensive reporting - Detailed summary files with metadata and parameters
- Python 3.12+ - With the following packages:
- PySide6 (Qt6 bindings)
- pandas
- numpy
- matplotlib
- seaborn
- scipy
- natsort
-
FIJI/ImageJ Installation
- The project comes prepackaged with an installation of ImageJ, so no prior installation is necessary.
-
Install Python dependencies (if not using executable)
pip install PySide6 pandas numpy matplotlib seaborn scipy natsort
-
Clone or download this repository
git clone <repository-url> cd countPHICS2
countPHICS2/
├── countPHICS.bat # Windows launcher
├── main_window.py # Main GUI application
├── ImageJ/
│ ├── ImageJ-win64.exe # Bundled Windows FIJI/ImageJ executable
│ └── macros/
│ └── macro_moj.py # FIJI/ImageJ macro (Jython)
├── libraries/
│ ├── grapher.py # Data visualization and analysis
│ └── layout.qss # Qt stylesheet
├── assets/
│ └── countphics2.ico # Application icon
└── README.md # This file
Double click batch file in downloaded directory or run terminal command:
python main_window.py-
Select input directory
- Select directory images 300-1200 dpi with high contrast for best analysis
- Described in further detail in original countPHICS paper
- Example image:

- Click "Browse Input" to select a folder containing your
.tif,.tiff,.png,.jpegor.jpgimages - Images should be RGB.
- Select directory images 300-1200 dpi with high contrast for best analysis
-
Choose output location (optional)
- Click "Browse Output" to specify where results should be saved
- If left blank, results will be saved in a
countPHICS_outputfolder within the input directory
-
Configure analysis settings
General Settings:
- Use same ROI for all images - Define region of interest once, apply to all images
- Split Image - Crop supported composite TIFF scans into separate dish images
- Generate plots after processing - Automatically create visualization plots
Advanced Settings :
- Rolling Ball Radius - Background subtraction parameter
- Min Colony Size - Minimum area to count as colony
- Max Colony Size - Maximum area to count as colony
- Min Circularity - Shape filter (0.0 = any shape, 1.0 = perfect circle)
- Sigma - Gaussian blur strength before detection
- ROI Thickness - Line thickness when selecting plate ROI
-
Launch processing
- Click "▶ LAUNCH FIJI" to start analysis
- Monitor progress in the console window
- FIJI will open and process images automatically
-
Review results
- Results are saved in the user defined output directory with the following structure:
countPHICS_output/ ├── Summary_<cell-line>.txt # Cell-line-specific results table ├── plots/ # Visualization plots │ ├── all_colony_counts_boxplot.png │ ├── all_colony_sizes_violinplot.png │ └── *_area_hist.png ├── size_distribution_files/ # Per-image colony sizes │ └── *_size_distribution.txt └── image_outputs/ # Annotated images └── *_counted.jpg
- Results are saved in the user defined output directory with the following structure:
The summary filename is derived from the Cell line field in the GUI. For
example, entering TP53KO produces Summary_TP53KO.txt. The plotting workflow
loads this same cell-line-specific file after FIJI finishes.
Tab-separated values file containing:
- Metadata - Macro version, run timestamp, parameters
- Per-image results:
- Image name
- Group (assigned in the group-definition dialog)
- Number of colonies
- Min/max counted colony size
- Median colony size
- Geometric mean colony size
Example:
# countPHICS2 v2.3.0 run: 2026-02-11 11:30:22
# Parameters:
# AutoThreshold= False
# SameROI=True
# Image ROI=Roi[Oval, x, y, width, height, pos]
# RollingBall=62
# MinColony=150
# MaxColony=10000
# Circularity=0.75
# Sigma=3.0
# MinThresh=0.0
# MaxThresh=240.0
ImageName\tGroup\tColonies\tMinCountedSize\tMaxCountedSize\tMedianSize\tGeomMeanSize
sampleWT_01.tif\t0\t145\t152\t8234\t1024\t987.42
sampleWT_02.tif\t0\t138\t156\t7891\t1012\t953.18
sampleKO_01.tif\t5\t89\t150\t5621\t894\t915.23
sampleKO_02.tif\t5\t94\t153\t5963\t942\t907.42
Individual .txt files for each image containing:
- Colony count header
- Each colony with its respective area per line (in pixels²)
Example:
Number of colonies: 110
Colony Area
328.0
678.0
175.0
160.0
...
Individual .jpg files for each image containing:
- Thresholded image of colonies.
- Counted colonies surrounded by green outline.
The grapher.py module provides powerful analysis capabilities using matplotlib and seaborn:
-
Boxplot summarizing colony counts among replicates in each assigned group.
-
Violin plot summarizing colony size distributions in each assigned group.
-
Individual histograms for each image summarizing size ditribution:
- histogram() - Distribution with Weibull fit and KS test
- boxplot() - Group comparisons with overlaid strip plots
- scatter() - Correlation analysis
- violin() - Distribution shape visualization
- Weibull distribution fitting - Maximum likelihood estimation for colony size distributions
- Kolmogorov-Smirnov test - Goodness-of-fit assessment with p-value
- Descriptive statistics - Mean, median, quartiles, std deviation
- Metadata annotation - Plots include macro version and runtime information
The FIJI macro (macro_moj.py) performs the following steps:
- Channel selection - Automatically selects RGB channel with highest contrast
- Gaussian blur - Noise reduction (sigma parameter)
- Background subtraction - Rolling ball algorithm
- ROI definition - Region selection on initial image
- Thresholding - Set thresholding based on initial image
- Particle analysis - Size and circularity filtering
- Result compilation - Colony counting and area measurements
- For general troubleshooting, output images and summary files provide a quick way to diagnose errors.
- If errors persist please refer below for common errors and how to solve them.
- Problem: Application can't find FIJI
- Solution: Manually set the FIJI path in the code or parameter file
- On Windows, check:
C:\Program Files\Fiji.app\orC:\Users\<username>\Fiji.app\ - On macOS, check:
/Applications/Fiji.app/
- Problem: All images show 0 colonies
- Solutions:
- Decrease minimum colony size
- Increase sigma value for more blur
- Check that images are RGB format
- Problem: Background noise being counted
- Solutions:
- Increase minimum colony size
- Increase minimum circularity
- Adjust rolling ball radius
- Refine ROI to exclude edges
- Problem: FIJI crashes or freezes
- Solutions:
- Process images in smaller batches
- Increase FIJI's memory allocation in preferences
- Reduce image resolution if appropriate
Advanced settings parameters are automatically calculated based on image dimensions described in the original paper:
- Rolling ball radius:
0.0306 × image_width - Min colony size:
0.01 × image_width - Max colony size:
image_width - Sigma:
0.001 × image_width(if units unknown)- Or:
(1.9e-6) × dpi² + (6.3e-4) × dpi + 1.3(if units known)
- Or:
Colony size distributions often follow Weibull distributions. The grapher fits a two-parameter Weibull distribution using maximum likelihood estimation:
- Shape parameter (k): Controls distribution shape
- Scale parameter (λ): Characteristic size
- KS test p-value: Assesses goodness of fit (p < 0.05 suggests good fit)
If you use countPHICS2 in your research, please cite the original countPHICS paper:
Contributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.
- v2.5.5 (Current GUI)
- Full Python GUI implementation
- Advanced plotting with Weibull fitting
- Enhanced metadata tracking
For questions, issues, or feature requests:
- Open an issue on GitHub
- Contact the authors:
- Dennis Simpson: dennis@unc.edu
- Paolo Guerra: pguerra@unc.edu
- Original countPHICS software by Beata Brzozowska et al. 2019

