Package: baby-seg
BABYBirth Annotation for Budding YeastAn image processing pipeline for accurate single-cell growth estimation of
budding cells from bright-field stacks. The Birth Annotator for Budding Yeast
(BABY) features:segmentation of overlapping cells, e.g., where small buds overlap with their mothers/sisters,automated assignment of buds to mothers, andestimation of the time of birth (cytokinesis) from growth rate.The algorithm is described in:Julian MJ Pietsch, Alán F Muñoz, Diane-Yayra A Adjavon, Iseabail Farquhar,
Ivan BN Clark, Peter S Swain. (2023). Determining growth rates from
bright-field images of budding cells through identifying overlaps. eLife.
12:e79812.InstallationWe recommend installing BABY and all its requirements in a virtual environment
(e.g.,conda createif you are using Anaconda, orpython3 -m venvotherwise).NB: If you want to install with GPU support see below.Otherwise, if you simply wish to use install with the latest compatible versions
of all packages, then simply run the following in your virtual environment:>pipinstallbaby-segNB: You can update by running:pip install -U baby-seg.Python and TensorFlow versionBABY requires Python 3 andTensorFlow.
Different versions of TensorFlow have different Python version requirements.
You can find a table of matching versionshere.Our models were trained with TensorFlow version 2.8, but have been tested up
to version 2.14.By default, BABY will trigger installation of the highest compatible version
of TensorFlow. If you want to use an earlier version, then first install that
version in your virtual environment by running:>pipinstalltensorflow==2.8and then follow the instructions for installing BABY as above.Running with GPUTo make use of a GPU you should follow theTensorFlow set up
instructionsbefore installing BABY.BABY can make use of Metal on M1/M2 Macs by following the instructionshere.For developersYou may prefer to install an editable version by first obtaining this repo and
then pip installing the cloned directory:>gitclonehttps://git.ecdf.ed.ac.uk/swain-lab/baby.git
>cdbaby
>pipinstall-e.Quickstart using the Python APIThe BABY algorithm makes use of several machine learning models that are
defined as a model set. Various model sets are available, and each has been
optimised for a particular species, microfluidics device, pixel size, channel
and number of input Z sections.You can get a list of available model sets and the types of input they were
trained for using themetafunction in themodelsetsmodule:>>>frombabyimportmodelsets>>>modelsets.meta()You then load your favourite model set as aBabyBrainobject, which
coordinates all the models and parameters in the set to produce tracked and
segmented outlines from input images. You can get aBabyBrainfor a given
model set using thegetfunction in themodelsetsmodule:>>>brain=modelsets.get('yeast-alcatras-brightfield-EMCCD-60x-5z')For each time course you want to process, instantiate a newBabyCrawler. The
crawler keeps track of cells between time steps.>>>frombabyimportBabyCrawler>>>crawler=BabyCrawler(brain)Load an image time series (from thetestssubdirectory in this repository).
The image should have shape (x, y, z).>>>frombaby.ioimportload_tiled_image>>>image_series=[load_tiled_image(...'tests/images/evolve_testG_tp{:d}_Brightfield.png'.format(t))...fortinrange(1,6)]Send images to the crawler in time-order (here a batch of size 1). We
additionally request that outlines are optimised to edge predictions, and that
lineage assignments, binary edge-masks and volume estimates (using the conical
method) should be output at each time point.>>>segmented_series=[crawler.step(...img[None,...],refine_outlines=True,assign_mothers=True,...with_edgemasks=True,with_volumes=True)...forimg,_inimage_series]Finally, save the segmentation outlines, labels, volumes and lineage assignments
as an annotated tiled png:>>>frombaby.ioimportsave_tiled_image>>>fort,sinenumerate(segmented_series):...save_tiled_image(255*s[0]['edgemasks'].astype('uint8').transpose((1,2,0)),...'../segout_tp{:d}.png'.format(t+1),...{k:s[0][k]forkin('cell_label','mother_assign','volumes')})Jupyter notebooksMore extensive examples for using BABY can be found in thepython/notebooksfolder. To maintain the repository in a clean state, it's probably best to
copy these to another directory for routine use. If you want to share a
notebook, you can then specifically add it back to the repository at a useful
checkpoint.The notebooks include:acomplete examplefor
reproducing Figure 1e in the associated paper.thebasic training
workflowdemonstrating how
to train the BABY algorithm from scratch. This notebook can be adapted to
train BABY for new cell types or imaging modes.Run via a serverOnce installed, you should be able to start a server to accept segmentation
requests using:>baby-phoneServer runs by default onhttp://0.0.0.0:5101. HTTP requests need to be
sent to the correct URL endpoint, but the HTTP API is currently undocumented.
The primary client implementation is theBABY
GUIavailable for Matlab.