Birth Annotator for Budding Yeast
Project description
Baby
Birth Annotation for Budding Yeast
Neural network code for segmenting buds from brightfield stacks.
Installation
BABY requires Python 3 and TensorFlow. For some versions of TensorFlow, you specifically need Python 3.6.
In any case, it is recommended that you install the package into a virtual
environment (i.e., conda create
if you are using Anaconda, or python3 -m venv
otherwise).
By default, BABY will trigger installation of the latest version of TensorFlow. Our experience, however, is that performance is best with TensorFlow version 1.14. If you want to use this version, first install that in your virtual environment by running:
> pip install tensorflow==1.14
NB: To make use of a GPU you should also follow the set up
instructions for
installing tensorflow-gpu
.
Install BABY by first obtaining this repository (e.g., git clone https://git.ecdf.ed.ac.uk/jpietsch/baby.git
), and then using pip:
> pip install baby/
NB: If you are upgrading, then you may instead need to run: pip install -U baby/
.
Developers: You may prefer to install an editable version:
> pip install -e baby/
Run using the Python API
Create a new BabyBrain
with one of the model sets. The brain
contains
all the models and parameters for segmenting and tracking cells.
>>> from baby import BabyBrain, BabyCrawler, modelsets
>>> modelset = modelsets()['evolve_brightfield_60x_5z']
>>> brain = BabyBrain(**modelset)
For each time course you want to process, instantiate a new BabyCrawler
. The
crawler keeps track of cells between time steps.
>>> crawler = BabyCrawler(brain)
Load an image time series (from the tests
subdirectory in this example). The
image should have shape (x, y, z).
>>> from baby.io import load_tiled_image
>>> image_series = [load_tiled_image(
... 'tests/images/evolve_testG_tp{:d}_Brightfield.png'.format(t))
... for t in range(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)
... for img, _ in image_series]
Finally, save the segmentation outlines, labels, volumes and lineage assignments as an annotated tiled png:
>>> from baby.io import save_tiled_image
>>> for t, s in enumerate(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] for k in ('cell_label', 'mother_assign', 'volumes')})
Run via a server
Once installed, you should be able to start a server to accept segmentation requests using:
> baby-phone
or on windows:
> baby-phone.exe
Server runs by default on http://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 in Matlab.
Jupyter notebooks
Training scripts are saved in Jupyter notebooks in the notebooks
folder. 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.
On how to retrain data
As of mid-2022 we aim to transition to tensorflow 2 (and then to pytorch). This means re-training all networks. We first fetch our data from skye and regenerate the train-val-test pair sets using TrainValTestPairs:
from pathlib import Path
from baby.io import TrainValTestPairs
training_data_path = Path("/home/alan/Documents/dev/training/training-images/")
tvt = TrainValTestPairs()
tvt.add_from(training_data_path / "traps-prime95b-60x")
<!-- tvt.add_from(training_data_path / "traps-evolve-60x") -->
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file aliby_baby-0.1.17.tar.gz
.
File metadata
- Download URL: aliby_baby-0.1.17.tar.gz
- Upload date:
- Size: 16.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.8.14 Linux/5.15.0-46-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e5cac5b9b0c6df95241f29d3c8af49e6b11d5d1298ab05161883ae4fa8a7cf1 |
|
MD5 | 06de17d8f6408ebd209ea4a61b71a9ff |
|
BLAKE2b-256 | 0b105882cc4fcb89d4b7a5ab0c6adffd1921ba563ff487360e9350b6622ae51a |
File details
Details for the file aliby_baby-0.1.17-py3-none-any.whl
.
File metadata
- Download URL: aliby_baby-0.1.17-py3-none-any.whl
- Upload date:
- Size: 17.1 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.8.14 Linux/5.15.0-46-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e84781ff6bdae9ed0ee32329f3a113cb48292e41383ba776628725099b43d0f3 |
|
MD5 | 04e8978afd0ac94bffb8d3b710bf4c2b |
|
BLAKE2b-256 | 74e05df73d178972328c50e2ba6766f7a0a570ac7c96c57491d9d81718676ead |