Synthetic Microscope Image Generation (crm_gen)

crm_gen provides tools for generating realistic synthetic microscope images of rod-shaped bacteria. It combines the cr_mech_coli simulation framework with a modular image synthesis pipeline, enabling the creation of labelled training data for cell segmentation models and the validation of imaging workflows against real microscopic data.

The module is available as both a command-line tool and a Python library:

crm_gen run                                           # full simulation + rendering pipeline
crm_gen run --config my_gen.toml                      # custom generation config
crm_gen clone img.tif mask.tif                        # clone a real microscope image
crm_gen clone img.tif mask.tif --config my_gen.toml
crm_gen fit path/to/real/images/                      # fit parameters to real images
crm_gen fit path/to/real/images/ --config my_fit.toml

run and clone use a generation config (imaging and simulation parameters). fit uses a separate fit config (optimization hyperparameters only: maxiter, popsize, etc.). The imaging parameters themselves are the output of the fit.

Module Structure

Submodule

Description

pipeline

Runs the full cell growth simulation and applies synthetic microscope effects to each frame via scene; main programmatic entry point.

scene

Composites a single synthetic frame using background, bacteria, and filters.

background

Generates synthetic phase contrast background textures.

bacteria

Assigns per-cell brightness based on cell age or real image intensities.

filters

Simulates optical effects (Point Spread Function (PSF) blur and phase contrast halos) and sensor noise (Poisson shot noise and Gaussian readout noise).

metrics

Computes SSIM, PSNR, and histogram distance between synthetic and real images.

optimization

Optimizes imaging parameters to match real images via differential evolution.

visualization

Generates diagnostic plots for inspecting optimization results.

configuration

Loads and manages TOML configuration files and default parameter constants.