Skip to main content

A package for generating synthetic images of bacteria in phase contrast or fluorescence. Used for creating training data for machine learning segmentation and tracking algorithms.

Project description

SyMBac: Synthetic Micrographs of Bacteria

Update 2025 Please see the SyMBac_2 repo. There is currently a big update coming which will feature lineage tracking ability, full texture generation within cells, spatial fluorescence (membrane, nucleoid, ribosome, etc), and more advanced image simulation models, and BENDY cells! It will also (hopefully) bring about full modularity of SyMBac so you can plug in individual parts of the pipeline to your own workflows.

Read the paper: Synthetic Micrographs of Bacteria (SyMBac) allows accurate segmentation of bacterial cells using deep neural networks , Georgeos Hardo, Maximillian Noka, Somenath Bakshi

Read the docs

[New! Try the Colab version] (please let me know if you run into issues) Open In Colab

What is it?

SyMBac is a tool to generate synthetic phase contrast or fluorescence images of bacteria. Currently the tool only supports bacteria growing in the mother machine, however support for bacteria growing in monolayers (and maybe even biofilms!) is coming.

comparisons

Why would I want to generate synthetic images?

Because you're sick of generating your own training data by hand! Synthetic images provide an instant source of high quality and unlimited training data for machine learning image segmentation algorithms!

The images are tuned to perfectly replicate your experimental setup, no matter what your microscope's objective is (we have tested 20x air all the way to 100x oil), no matter your imaging modality (phase contrast/fluorescence), and no matter the geometry of your microfluidic device.

Additionally,

  • SyMBac is very fast compared to humans:
comparisons
  • The image generation process uses a rigid body physics model to simulate bacterial growth, 3D cell geometry to calculate the light's optical path, and a model of the phase contrast/fluorescence optics (point spread function), with some post-rendering optimisation to match image similarity:
comparisons

How do I use these synthetic images?

That is up to you. SyMBac is not a machine learning tool. It is a tool to generate unlimited free training data which accurately represents your experiment. It is up to you to train a machine learning network on these synthetic images. We do however provide example notebooks for how to train a U-net (as implemented by DeLTA).

comparisons

Prerequisites

Please make sure you have an NVIDIA GPU and a working installation of CUDA and cudNN. If you don't have an NVIDIA GPU then the convolution will default to the CPU, and be very slow.

SyMBac is meant to be run interactively (in a notebook + with a small Qt/GTK intWWerface), so make sure that you are running this on a local machine (you should have access to the machine's display).

Installation

pip install SyMBac

Or to install the development version, run:

pip install git+https://github.com/georgeoshardo/SyMBac

Activate the Jupyter widgets extension. This is needed to interact with slides in the notebooks to optimise images.

jupyter nbextension enable --py widgetsnbextension

If you're using a GPU:

Check the version of CUDA you have installed using nvcc --version and install the appropriate version of cupy. For example, if you have CUDA 11.4 you would install as follows:

pip install cupy-cuda114

If you installed CUDA on Ubuntu 18.04+ using the new Nvidia supplied repositories, it is a real possibility that nvcc won't work. You need to run nvcc from the binary folder of where your cuda installation is.

If you aren't using a GPU:

See FAQs "Do I need to have a GPU?"

Usage

Read the docs

FAQs

  • Do I need to have a GPU?
    • No, although image synthesis will be around 40x slower on the CPU. SyMBac will detect that you do not have CuPy installed and default to using CPU convolution.
    • Interactive image optimisation will be very painful on the CPU. By default I turn off slider interactivity if you are using the CPU, so that you can move a slider without the CPU being maxed out. This means that every time you move a slider you must click the button to update the image (do a convolution).
  • Can I generate fluorescence images as well?
    • Yes, you can do fluorescence image generation, just make sure that in the interactive image generation part of the code, you select fluorescence.
    • Since our fluorescence kernel is defined to be a subset of the phase contrast kernel, you can choose any condenser, and your fluorescence kernel should be correct. Just ensure that the imaging wavelength, numerical aperture, refractive index, and pixel size are set correctly.
  • What format do my images need to be in?
    • The real images you are trying to replicate should be in the format of single-trench timeseries images. If you are unsure what this is, you can call get_sample_images()["E. coli 100x"] from SyMBac.miscfor an example image.
  • I'm getting libGL MESA-LOADER errors
  • I'm getting ContextException: Could not create GL context when trying to visualise my simulation in real time
    • Try conda install -c conda-forge libstdcxx-ng, and if you're on Ubuntu/Debian sudo apt install libgl1-mesa-dri

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

symbac-0.5.0.tar.gz (206.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

symbac-0.5.0-py3-none-any.whl (212.8 kB view details)

Uploaded Python 3

File details

Details for the file symbac-0.5.0.tar.gz.

File metadata

  • Download URL: symbac-0.5.0.tar.gz
  • Upload date:
  • Size: 206.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for symbac-0.5.0.tar.gz
Algorithm Hash digest
SHA256 4623a18a98df54267a4638aaee5d17bd9e47cb302b11c52f425ccdfee8c560e6
MD5 02fd7ad917265ad1e94ba8cf9da31b47
BLAKE2b-256 94d101bff29abd84411138f73da849342808a9e236b0f852c9306b006c14f6eb

See more details on using hashes here.

File details

Details for the file symbac-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: symbac-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 212.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for symbac-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 25714221ac2f3b3c306097275b620ea363f7eae71de5682c170cd97aa099162d
MD5 a9bed5cbeefded29bd247ce36324c8e5
BLAKE2b-256 056fad6d77721bd0e4b5925797346c76752439580211901317029df912c20e72

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page