Skip to content

CovertLab/CellTK

 
 

Repository files navigation

CellTK

Live-cell analysis toolkit.

For the active development version, please visit here.

v0.4 is used in Nature Protocols paper.

Image processing is simply an image conversion/transformation process. CellTK has the following five major processes which all implement conversion between img and labels.

  1. preprocessing: img -> img
  2. segmentation: img -> labels
  3. subdetection: labels (and img) -> labels
  4. tracking: labels -> labels*
  5. postprocessing: labels -> labels*

where

  • img: np.ndarray[np.float32] (e.g. a raw image from a microscope)
  • labels: np.ndarray[np.int16] (e.g. nuclear objects) * tracked objects have consistent values over frames

For each processes, you can find a module named *_operation.py. (e.g. celltk/preprocess_operations.py).

These files are the "repositories" of functions. They simply contain a list of functions which takes an input and convert images. If you need a new function, simply add it to here.

When you input a raw image, it should take TIFF or PNG files with various datatypes as well.

Command line Example:

The simplest way to apply a function is to use command.py. This option is convenient to play with functions and parameters.

python celltk/command.py -i data/testimages0/CFP/img* -f constant_thres -p THRES=2000 -o output/c1
python celltk/command.py -i data/testimages0/CFP/img* -l output/c1/img* -f run_lap track_neck_cut -o output/nuc

-i for images path, -l for labels path, -o for an output directory, -f for a function name from *operation.py modules, -p for arguments to the function.

Note that, time-lapse files need to have file names in a sorted order.

Caller Example:

You can run a pipeline of operations using celltk/caller.py.

python celltk/caller.py input_files/input_tests1.yml

This configuration file contains operations defined like this:

- function: constant_thres
  images: /example/img_00*.tif
  output: output_0
  params:
    THRES: 500

You can find how to set up a configuration file here.

Apply to extract single-cell properties

After segmenting and tracking cells, we want to extract single-cell properties as a table.

Unlike other five major processes, celltk/apply.py produces csv and npz file as an output.

python celltk/apply.py -i data/testimages0/CFP/img* -l output/nuc/img* -o output/array.npz

By default, it will use a folder name as a table key. To specify table keys, use -p and -s in a command line.

python celltk/apply.py -i data/testimages0/YFP/img* -l output/nuc/img* -o output/array.npz -p nuc -s YFP

Or use obj_names and ch_names in a caller.

# Sample YML
- function: apply
  images:
    - DAPI/img*
    - TRITC/img*
  labels:
    - op001
    - op002
  ch_names:
    - DAPI
    - JNKKTR
  obj_names:
    - nuc
    - cyto

The output can be loaded with LabeledArray class. e.g.

python -c "from celltk.labeledarray import LabeledArray;arr = LabeledArray().load('output/array.npz');print arr.labels;print arr['CFP', 'nuc', 'x']"

For visualization and manipulation of these arrays, I recommend to take a loot at covertrace.

Install dependencies

If you do not need a dev version, simply

pip install celltk

This will register celltk command, where you can pass input file like celltk input_file/input_tests1.yml.


It is compatible with poetry.

git clone https://github.com/braysia/CellTK.git & cd CellTK
pip install poetry
poetry install

Install the additional package may speed up computation.

pip install git+https://github.com/jfrelinger/cython-munkres-wrapper

The other option is to use Docker container.

docker pull braysia/celltk
docker run -it -v /$FOLDER_TO_MOUNT:/home/ braysia/celltk

Please modify $FOLDER_TO_MOUNT, like docker run -it -v /Users/kudo/example:/home/ braysia/celltk.

You can add "-p 8888:8888" for running jupyter notebook from the docker image.

Covert lab specific details

About

Live-cell image analysis toolkit

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.5%
  • Dockerfile 0.5%