Giter Club home page Giter Club logo

cytokit's Introduction

Build Status Coverage Status

Cytokit

Cytokit is a collection of tools for quantifying and analyzing properties of individual cells in large fluorescent microscopy datasets with a focus on those generated from multiplexed staining protocols. This includes a GPU-accelerated image processing pipeline (via TensorFlow), CLI tools for batch processing of experimental replicates (often requiring conditional configuration, as things tend go wrong when capturing hundreds of thousands of microscope images over a period of hours or days), and visualization UIs (either Cytokit Explorer or CellProfiler Analyst).

Cytokit runs in a Python 3 environment but also comes (via Docker) with CellProfiler (Python 2) and Ilastik installations.

For more information, see: Cytokit: A single-cell analysis toolkit for high dimensional fluorescent microscopy imaging

Quick Start

Installing and configuring Cytokit currently involves little more than installing nvidia-docker and building or downloading the Cytokit container image, but this inherently limits support to Linux operating systems for GPU-acceleration. Additional limitations include:

  • There is currently no CPU-only docker image
  • Generating and running pipelines requires working knowledge of JupyterLab and a little tolerance for yaml/json files as well as command lines
  • Only tiff files are supported as a raw input image format
  • Deconvolution requires manual configuration of microscope attributes like filter wavelengths, immersion media, and numerical aperture (though support to infer much of this based on the imaging platform may be added in the future)
  • 3 dimensional images are supported but cell segmentation and related outputs are currently 2 dimensional
  • General system requirements include at least 24G RAM and 8G of GPU memory (per GPU)

Once nvidia-docker is installed, the container can be launched and used as follows:

nvidia-docker pull eczech/cytokit:latest

# Set LOCAL_IMAGE_DATA_DIR variable to a host directory for data sharing
# and persistent storage between container runs
export LOCAL_IMAGE_DATA_DIR=/tmp 

# Run the container with an attached volume to contain raw images and results  
nvidia-docker run --rm -ti -p 8888:8888 -p 8787:8787 -p 8050:8050 \
-v $LOCAL_IMAGE_DATA_DIR:/lab/data \
eczech/cytokit

This will launch JupyterLab on port 8888. After navigating to localhost:8888 and entering the access token printed on the command line following nvidia-docker run, you can then run an example notebook like cellular_marker_profiling_example, which can be found at /lab/repos/cytokit/python/notebooks/examples in the JupyterLab file navigator.

Using a Specific Release

To use a release-specific container, the instructions above can be modified as such where the below example shows how to launch the 0.1.1 container:

nvidia-docker pull eczech/cytokit:0.1.1
export LOCAL_IMAGE_DATA_DIR=/tmp   
nvidia-docker run --rm -ti -p 8888:8888 -p 8787:8787 -p 8050:8050 \
-v $LOCAL_IMAGE_DATA_DIR:/lab/data \
eczech/cytokit:0.1.1

Example

One of the goals of Cytokit is to make it as easy as possible to reproduce complicated workflows on big image datasets and to that end, the majority of the logic that drives how Cytokit functions is determined by json/yaml configurations.
Starting from template configurations like this sample Test Experiment and more realistically, this CODEX BALBc1 configuration, pipelines are meant to work as bash scripts executing small variants on these parameterizations for evaluation against one another. Here is a bash script demonstrating how this often works:

EXPERIMENT_DATA_DIR=/lab/data/201801-codex-lung

for REPLICATE in "201801-codex-lung-01" "201801-codex-lung-02"; do
    DATA_DIR=$EXPERIMENT_DATA_DIR/$REPLICATE
    
    # This command will generate 3 processing variants to run:
    # v01 - Cell object determined as fixed radius from nuclei
    # v02 - Cell object determined by membrane stain
    # v03 - 5x5 grid subset with deconvolution applied and before/after channels extracted
    cytokit config editor --base-config-path=template_config.yaml --output-dir=$DATA_DIR/output \
      set processor.cytometry.segmentation_params.nucleus_dilation 10 \
    save_variant v01/config reset \
      set processor.cytometry.membrane_channel_name CD45 \
    save_variant v02/config reset \
      set acquisition.region_height 5 \
      set acquisition.region_width 5 \
      set processor.args.run_deconvolution True \
      add operator '{extract: {name:deconvolution, channels:[raw_DAPI,proc_DAPI]}}' \
    save_variant v03/config exit 
    
    # Run everything for each variant of this experiment
    for VARIANT in v01 v02 v03; do
        OUTPUT_DIR=$DATA_DIR/output/$VARIANT
        CONFIG_DIR=$OUTPUT_DIR/config
        cytokit processor run_all --config-path=$CONFIG_DIR --data-dir=$OUTPUT_DIR --output-dir=$OUTPUT_DIR
        cytokit operator run_all  --config-path=$CONFIG_DIR --data-dir=$OUTPUT_DIR 
        cytokit analysis run_all  --config-path=$CONFIG_DIR --data-dir=$OUTPUT_DIR 
    done
done

The above, when executed, would produce several things:

  1. 5D tiles with processed image data (which can be reused without having to restart from raw data)
  2. 5D tile extracts corresponding to user-defined slices (e.g. raw vs processed DAPI images above) as well as montages of these tiles (e.g. stitchings of 16 2048x2048 images on 4x4 grid into single 8192x8192 images)
  3. CSV/FCS files with single-cell data
  4. Final yaml configuration files representing how each variant was defined

For example, an ad-hoc extraction like this (which could also be defined in the configuration files):

cytokit operator extract --name='primary_markers' --z='best' \
  --channels=['proc_dapi','proc_cd3','proc_cd4','proc_cd8','cyto_cell_boundary','cyto_nucleus_boundary']

Would produce 5D hyperstack images that could be loaded into ImageJ and blended together:

Human T Cells stained for DAPI (gray), CD3 (blue), CD4 (red), CD8 (green) and with nucleus outline (light green), cell outline (light red)

Cytokit Explorer UI

After processing an experiment, the Explorer UI application can be run within the same docker container for fast visualization of the relationship between spatial features of cells and fluorescent signal intensities:

High-Res Version

See the Cytokit Explorer docs for more details.

CellProfiler Analyst

In addition to Cytokit Explorer, exports can also be generated using CellProfiler (CP) directly. This makes it possible to ammend a configuration with a line like this to generate both CP spreadhseets and a SQLite DB compatible with CellProfiler Analyst (see pub/config/codex-spleen/experiment.yaml):

analysis:
  - cellprofiler_quantification: 
    - export_csv: true
    - export_db: true
    - export_db_objects_separately: true

These screenshots from CellProfiler Analyst 2.2.1 show a reconstruction of plots used in the CODEX publication based on data generated by dynamic construction and execution of a CP 3.1.8 pipeline (see pub/analysis/codex-spleen/pipeline_execution.sh):

CellProfiler Integration

CellProfiler is not easy to use programmatically as it is used here. There is no official Python API and direct access to the internals has to be informed largely based on tests and other source code, but for any interested power-users, here are some parts of this project that may be useful resources:

  • Installation: The Dockerfile shows how to bootstrap a minimal Python 2.7 environment compatible with CellProfiler 3.1.8
  • Configuration: The cpcli.py script demonstrates how to build a CP pipeline programmatically (in this case segmented objects are provided to the pipeline that only does quantification and export)
  • Analysis: When exported data from CP in a docker container, the paths in csv files or inserted into a database will all be relative to a container. One simple solution to this problem is to simply create a local /lab/data folder with copies of the information from the container that you would like to analyze.
    A little more information on this can be found at pub/analysis/codex-spleen/README.md.

Custom Segmentation

While the purpose of this pipeline is to perform image preprocessing and segmentation, the semantics of that segmentation often change. Depending on the experimental context, the provided cell nucleus segmentation may not be adequate and if a different segmentation methodology is required then any custom logic can be added to the pipeline as in the mc38-spheroid example. Specifically, a custom segmentation implementation is used here to identify spheroids rather than cells.

Messaging Caveats

Errors in processor logs that can safely be ignored:

  • tornado.iostream.StreamClosedError: Stream is closed: These often follow the completion of successful pipeline runs. These can hopefully be eliminated in the future with a dask upgrade but for now they can simply be ignored.

CODEX Backport

As a small piece of standalone functionality, instructions can be found here for how to run deconvolution on CODEX samples: Standalone Deconvolution Instructions

cytokit's People

Contributors

armish avatar eric-czech avatar hammer avatar nsamusik avatar rs-gh-sa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cytokit's Issues

Error during analysis step

Hello,

I am running Cytokit using the example CODEX BALBc-1 mouse spleen dataset, with the config file set up as in this YAML file, with line 130 uncommented to try to produce the CellProfiler exports. I am using Cytokit via a Singularity container created from the Docker image at docker://eczech/cytokit:latest. I ran the first two steps (with "processor run_all" and "operator run_all") set out in this script, without any problems. But then I ran into problems during the "analysis" step.

First, I got this error:

python /lab/repos/cytokit/python/pipeline/cytokit/cli/main.py analysis run_all --config-path=/users/keays/cytokit_testing/Goltsev_mouse_spleen/experiment.yaml --data-dir=/users/keays/cytokit_testing/Goltsev_mouse_spleen/output
2019-12-02 10:26:00,281:INFO:39536:root: Running cytometry statistics aggregation
2019-12-02 10:26:30,798:INFO:39536:cytokit.function.core: Saved cytometry aggregation results to csv at "/users/keays/cytokit_testing/Goltsev_mouse_spleen/output/cytometry/data.csv"
2019-12-02 10:26:31,949:INFO:39536:cytokit.function.core: Saved cytometry aggregation results to fcs at "/users/keays/cytokit_testing/Goltsev_mouse_spleen/output/cytometry/data.fcs"
Traceback (most recent call last):
File "/lab/repos/cytokit/python/pipeline/cytokit/cli/main.py", line 32, in
main()
File "/lab/repos/cytokit/python/pipeline/cytokit/cli/main.py", line 28, in main
fire.Fire(Cytokit)
File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/fire/core.py", line 127, in Fire
component_trace = _Fire(component, args, context, name)
File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/fire/core.py", line 366, in _Fire
component, remaining_args)
File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/fire/core.py", line 542, in _CallCallable
result = fn(*varargs, kwargs)
File "/lab/repos/cytokit/python/pipeline/cytokit/cli/init.py", line 167, in run_all
fn(
{**config[op], **params})
TypeError: cellprofiler_quantification() got an unexpected keyword argument 'export_db_objects_separately'

I removed the export_db_objects_separately: true from line 130, and then I got this error instead:

python /lab/repos/cytokit/python/pipeline/cytokit/cli/main.py analysis run_all --config-path=/users/keays/cytokit_testing/Goltsev_mouse_spleen/experiment.yaml --data-dir=/users/keays/cytokit_testing/Goltsev_mouse_spleen/output
2019-12-02 10:31:37,242:INFO:39625:root: Running cytometry statistics aggregation
2019-12-02 10:32:07,818:INFO:39625:cytokit.function.core: Saved cytometry aggregation results to csv at "/users/keays/cytokit_testing/Goltsev_mouse_spleen/output/cytometry/data.csv"
2019-12-02 10:32:08,988:INFO:39625:cytokit.function.core: Saved cytometry aggregation results to fcs at "/users/keays/cytokit_testing/Goltsev_mouse_spleen/output/cytometry/data.fcs"
2019-12-02 10:32:08,989:INFO:39625:root: Running CellProfiler image quantification pipeline
INFO:main:Loading experiment configuration from file "/users/keays/cytokit_testing/Goltsev_mouse_spleen/experiment.yaml"
INFO:main:Extracting expression channel images
INFO:main:Extracting object images
Traceback (most recent call last):
File "/lab/repos/cytokit/python/external/cellprofiler/cpcli.py", line 450, in
sys.exit(main())
File "/lab/repos/cytokit/python/external/cellprofiler/cpcli.py", line 442, in main
do_extraction=options.do_extraction == 'true'
File "/lab/repos/cytokit/python/external/cellprofiler/cpcli.py", line 307, in run_quantification
run_extraction(output_dir, cp_input_dir, channels)
File "/lab/repos/cytokit/python/external/cellprofiler/cpcli.py", line 275, in run_extraction
for channel_images in extract(filters, cytometry_image_dir):
File "/lab/repos/cytokit/python/external/cellprofiler/cpcli.py", line 229, in extract
raise ValueError('Expecting 5D tile image, got shape {}'.format(img.shape))
ValueError: Expecting 5D tile image, got shape (15, 4, 1008, 1344)
Traceback (most recent call last):
File "/lab/repos/cytokit/python/pipeline/cytokit/cli/main.py", line 32, in
main()
File "/lab/repos/cytokit/python/pipeline/cytokit/cli/main.py", line 28, in main
fire.Fire(Cytokit)
File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/fire/core.py", line 127, in Fire
component_trace = _Fire(component, args, context, name)
File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/fire/core.py", line 366, in _Fire
component, remaining_args)
File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/fire/core.py", line 542, in _CallCallable
result = fn(*varargs, kwargs)
File "/lab/repos/cytokit/python/pipeline/cytokit/cli/init.py", line 167, in run_all
fn(
{**config[op], **params})
File "/lab/repos/cytokit/python/pipeline/cytokit/cli/analysis.py", line 39, in cellprofiler_quantification
log_level=self.py_log_level
File "/lab/repos/cytokit/python/pipeline/cytokit/exec/cellprofiler.py", line 19, in run_quantification
raise ValueError('CellProfiler cli command returned code {}; Command:\n{}'.format(rc.returncode, cmd))
ValueError: CellProfiler cli command returned code 1; Command:
/opt/conda/envs/cellprofiler/bin/python /lab/repos/cytokit/python/external/cellprofiler/cpcli.py --do-extraction=true --export-csv=true --config-path=/users/keays/cytokit_testing/Goltsev_mouse_spleen/experiment.yaml --output-dir=/users/keays/cytokit_testing/Goltsev_mouse_spleen/output --log-level=20 --export-db=true

I looked at the images under output/cytometry/tile, generated during earlier processing steps, and they are indeed 4D, with 4 "channels" and 15 "slices" according to tiffinfo, but no mention of cycles/frames. Is this expected?

Using membrane channel for cell boundary segmentation

Hi @eric-czech,

I am looking to use a membrane stain channel for segmentation the cell boundaries in CODEX data. I see that there is a "processor: cytometry: membrane_channel_name" in the config file for me to specify the membrane channel to use; however, it is unclear to me what the different parameters under "processor: cytometry: segmentation_params" should be set to in this case.

Additionally, I know that Cytokit uses CellProfiler's U-Net for nuclei segmentation, but what is the method of segmentation for the cell membranes?

Thank you,
Monica

Tensorflow DType error

Hi Cytokit team,

Using
Python 3.6
Tensorflow 1.12.0

I was testing out some of the cytokit python pipelines and was testing out the example in the marker_profiling_example

I got to the point where I was going to run the process pipeline on the example datasets in
https://storage.googleapis.com/cytokit/datasets/cellular-marker/{exp}/1_00001_Z{z:03d}_CH{ch}.tif'
when I got this error message:

!cytokit processor run_all --config-path=$variant_dir/config --data-dir=$raw_dir --output-dir=$variant_dir

/Users/ninning/venv/cytokit/lib/python3.6/site-packages/dask/config.py:161: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
data = yaml.load(f.read()) or {}
/Users/ninning/venv/cytokit/lib/python3.6/site-packages/cytokit/config.py:21: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
return yaml.load(fd)
2020-01-31 18:45:57,734:INFO:52737:root: Execution arguments and environment saved to "/var/folders/sq/qy7gh_jj1lgfdyh2wf4vt8p00000gn/T/cytokit-example/cellular-marker/20181116-d40-r1-20x-5by5/output/v00/processor/execution/202001312345.json"
/Users/ninning/venv/cytokit/lib/python3.6/site-packages/bokeh/themes/theme.py:131: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
json = yaml.load(f)
/Users/ninning/venv/cytokit/lib/python3.6/site-packages/dask/config.py:161: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
data = yaml.load(f.read()) or {}
/Users/ninning/venv/cytokit/lib/python3.6/site-packages/bokeh/themes/theme.py:131: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
json = yaml.load(f)
2020-01-31 18:46:07,021:INFO:52737:cytokit.exec.pipeline: Starting Pre-processing pipeline for 1 tasks (1 workers)
distributed.worker - WARNING - Compute Failed
Function: run_preprocess_task
args: ({'region_indexes': array([0]), 'tile_indexes': array([0]), 'data_dir': '/var/folders/sq/qy7gh_jj1lgfdyh2wf4vt8p00000gn/T/cytokit-example/cellular-marker/20181116-d40-r1-20x-5by5/raw', 'output_dir': '/var/folders/sq/qy7gh_jj1lgfdyh2wf4vt8p00000gn/T/cytokit-example/cellular-marker/20181116-d40-r1-20x-5by5/output/v00', 'gpu': 0, 'op_flags': <cytokit.exec.pipeline.OpFlags object at 0x12c4cd898>, 'tile_prefetch_capacity': 1})
kwargs: {}
Exception: Exception('Long error message', <class 'tensorflow.python.framework.errors_impl.OutOfRangeError'>, 'Read less bytes than requested\n\t [[node save/RestoreV2 (defined at /Users/ninning/venv/cytokit/lib/python3.6/site-packages/cytokit/miq/prediction.py:61) = RestoreV2[dtypes=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2/tensor_names, save/RestoreV2/shape_and_slices)]]\n\nCaused by op 'save/RestoreV2', defined at:\n File "/Users/ninning/.pyenv/versions/3.6.10/lib/python3.6/threading.py", line 884, in _bootstrap\n self._bootstrap_inner()\n File "/Users/ninning/.pyenv/versions/3.6.10/lib/python3.6/threading.py", line 916, in _bootstrap_inner\n self.run()\n File "/Users/ninning/.pyenv/versions/3.6.10/lib/python3.6/threading.py", line 864, in run\n self._target(*self._args, **self._kwargs)\n File "/Users/ninning/venv/cytokit/lib/python3.6/site-packages/distributed/threadpoolexecutor.py", line 57, in _worker\n task.run()\n File "/Users/ninning/venv/cytokit/lib/')

Traceback (most recent call last):
File "/Users/ninning/venv/cytokit/bin/cytokit", line 8, in
sys.exit(main())
File "/Users/ninning/venv/cytokit/lib/python3.6/site-packages/cytokit/cli/main.py", line 28, in main
fire.Fire(Cytokit)
File "/Users/ninning/venv/cytokit/lib/python3.6/site-packages/fire/core.py", line 138, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
File "/Users/ninning/venv/cytokit/lib/python3.6/site-packages/fire/core.py", line 471, in _Fire
target=component.name)
File "/Users/ninning/venv/cytokit/lib/python3.6/site-packages/fire/core.py", line 675, in _CallAndUpdateTrace
component = fn(*varargs, kwargs)
File "/Users/ninning/venv/cytokit/lib/python3.6/site-packages/cytokit/cli/init.py", line 167, in run_all
fn(
{**config[op], **params})
File "/Users/ninning/venv/cytokit/lib/python3.6/site-packages/cytokit/cli/processor.py", line 131, in run
pipeline.run(pl_config, logging_init_fn=self._logging_init_fn)
File "/Users/ninning/venv/cytokit/lib/python3.6/site-packages/cytokit/exec/pipeline.py", line 458, in run
run_tasks(pl_conf, 'Pre-processing', run_preprocess_task, logging_init_fn)
File "/Users/ninning/venv/cytokit/lib/python3.6/site-packages/cytokit/exec/pipeline.py", line 421, in run_tasks
res = [r.result() for r in res]
File "/Users/ninning/venv/cytokit/lib/python3.6/site-packages/cytokit/exec/pipeline.py", line 421, in
res = [r.result() for r in res]
File "/Users/ninning/venv/cytokit/lib/python3.6/site-packages/distributed/client.py", line 227, in result
six.reraise(*result)
File "/Users/ninning/venv/cytokit/lib/python3.6/site-packages/six.py", line 702, in reraise
raise value.with_traceback(tb)
File "/Users/ninning/venv/cytokit/lib/python3.6/site-packages/cytokit/exec/pipeline.py", line 441, in run_preprocess_task
return run_task(task, ops, preprocess_tile)
File "/Users/ninning/venv/cytokit/lib/python3.6/site-packages/cytokit/exec/pipeline.py", line 355, in run_task
with ops:
File "/Users/ninning/venv/cytokit/lib/python3.6/site-packages/cytokit/ops/op.py", line 200, in enter
v.enter()
File "/Users/ninning/venv/cytokit/lib/python3.6/site-packages/cytokit/ops/op.py", line 152, in enter
self.initialize()
File "/Users/ninning/venv/cytokit/lib/python3.6/site-packages/cytokit/ops/best_focus.py", line 46, in initialize
graph=self.graph, session_config=get_tf_config(self)
File "/Users/ninning/venv/cytokit/lib/python3.6/site-packages/cytokit/miq/prediction.py", line 63, in init
saver.restore(self._sess, model_ckpt)
File "/Users/ninning/venv/cytokit/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1546, in restore
{self.saver_def.filename_tensor_name: save_path})
File "/Users/ninning/venv/cytokit/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 929, in run
run_metadata_ptr)
File "/Users/ninning/venv/cytokit/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1152, in _run
feed_dict_tensor, options, run_metadata)
File "/Users/ninning/venv/cytokit/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1328, in _do_run
run_metadata)
File "/Users/ninning/venv/cytokit/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1348, in _do_call
raise type(e)(node_def, op, message)
Exception: ('Long error message', <class 'tensorflow.python.framework.errors_impl.OutOfRangeError'>, 'Read less bytes than requested\n\t [[node save/RestoreV2 (defined at /Users/ninning/venv/cytokit/lib/python3.6/site-packages/cytokit/miq/prediction.py:61) = RestoreV2[dtypes=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2/tensor_names, save/RestoreV2/shape_and_slices)]]\n\nCaused by op 'save/RestoreV2', defined at:\n File "/Users/ninning/.pyenv/versions/3.6.10/lib/python3.6/threading.py", line 884, in _bootstrap\n self._bootstrap_inner()\n File "/Users/ninning/.pyenv/versions/3.6.10/lib/python3.6/threading.py", line 916, in _bootstrap_inner\n self.run()\n File "/Users/ninning/.pyenv/versions/3.6.10/lib/python3.6/threading.py", line 864, in run\n self._target(*self._args, **self._kwargs)\n File "/Users/ninning/venv/cytokit/lib/python3.6/site-packages/distributed/threadpoolexecutor.py", line 57, in _worker\n task.run()\n File "/Users/ninning/venv/cytokit/lib/')

Appreciate any help and thank you in advance!

MySQL Error - Improve Selection of plane

Hi Eric,

I have started to see the following error with regard the MySQL database

image

Also I have notice that the software is saving the wrong planes to display and probably it is because I am choosing the incorrect parameters at the config files (posted below).

image

pipeline_execution.txt
explorer_config.txt
experiment.txt

Moreover, I would like to run deconvolution. For this I should set the wavelengths to each of the markers, for example: DAPI=488 or the time of exposure 1/10

Model shape error

I run the following command

cytokit processor run_all --data-dir /lab/slices/ --config-path experiment.yaml --output-dir /lab/output/

And get these error messages.

Error message

2020-03-24 08:36:40,229:INFO:7361:root: Execution arguments and environment saved to "/lab/output/processor/execution/202003241236.json"
2020-03-24 08:36:58,448:INFO:7361:cytokit.exec.pipeline: Starting Pre-processing pipeline for 2 tasks (2 workers)
2020-03-24 08:36:59,146:INFO:7493:cytokit.exec.pipeline: Loaded tile 201 for region 1 [shape = (1, 1, 4, 1802, 2633)]
2020-03-24 08:36:59,189:INFO:7492:cytokit.exec.pipeline: Loaded tile 1 for region 1 [shape = (1, 1, 4, 1802, 2633)]
2020-03-24 08:36:59,789:INFO:7493:cytokit.exec.pipeline: Loaded tile 202 for region 1 [shape = (1, 1, 4, 1802, 2633)]
2020-03-24 08:36:59,874:INFO:7492:cytokit.exec.pipeline: Loaded tile 2 for region 1 [shape = (1, 1, 4, 1802, 2633)]
Using TensorFlow backend.
Using TensorFlow backend.
distributed.worker - WARNING -  Compute Failed
Function:  run_preprocess_task
args:      ({'tile_indexes': array([  0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,
        13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,
        26,  27,  28,  29,  30,  31,  32,  33,  34,  35,  36,  37,  38,
        39,  40,  41,  42,  43,  44,  45,  46,  47,  48,  49,  50,  51,
        52,  53,  54,  55,  56,  57,  58,  59,  60,  61,  62,  63,  64,
        65,  66,  67,  68,  69,  70,  71,  72,  73,  74,  75,  76,  77,
        78,  79,  80,  81,  82,  83,  84,  85,  86,  87,  88,  89,  90,
        91,  92,  93,  94,  95,  96,  97,  98,  99, 100, 101, 102, 103,
       104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
       117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129,
       130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142,
       143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155,
       156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168,
       169, 170, 171, 172, 173, 174, 175, 176,
kwargs:    {}
Exception: ValueError('A 'Concatenate' layer requires inputs with matching shapes except for the concat axis. Got inputs shapes: [(None, 462, 668, 512), (None, 462, 669, 256)]',)
distributed.worker - WARNING -  Compute Failed
Function:  run_preprocess_task
args:      ({'tile_indexes': array([200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212,
       213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225,
       226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238,
       239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251,
       252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264,
       265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277,
       278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290,
       291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303,
       304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316,
       317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329,
       330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342,
       343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355,
       356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368,
       369, 370, 371, 372, 373, 374, 375, 376,
kwargs:    {}
Exception: ValueError('A 'Concatenate' layer requires inputs with matching shapes except for the concat axis. Got inputs shapes: [(None, 462, 668, 512), (None, 462, 669, 256)]',)
Traceback (most recent call last):
  File "/usr/local/bin/cytokit", line 32, in <module>
    main()
  File "/usr/local/bin/cytokit", line 28, in main
    fire.Fire(Cytokit)
  File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/fire/core.py", line 127, in Fire
    component_trace = _Fire(component, args, context, name)
  File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/fire/core.py", line 366, in _Fire
    component, remaining_args)
  File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/fire/core.py", line 542, in _CallCallable
    result = fn(*varargs, **kwargs)
  File "/lab/repos/cytokit/python/pipeline/cytokit/cli/__init__.py", line 167, in run_all
    fn(**{**config[op], **params})
  File "/lab/repos/cytokit/python/pipeline/cytokit/cli/processor.py", line 131, in run
    pipeline.run(pl_config, logging_init_fn=self._logging_init_fn)
  File "/lab/repos/cytokit/python/pipeline/cytokit/exec/pipeline.py", line 458, in run
    run_tasks(pl_conf, 'Pre-processing', run_preprocess_task, logging_init_fn)
  File "/lab/repos/cytokit/python/pipeline/cytokit/exec/pipeline.py", line 421, in run_tasks
    res = [r.result() for r in res]
  File "/lab/repos/cytokit/python/pipeline/cytokit/exec/pipeline.py", line 421, in <listcomp>
    res = [r.result() for r in res]
  File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/distributed/client.py", line 227, in result
    six.reraise(*result)
  File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/six.py", line 702, in reraise
    raise value.with_traceback(tb)
  File "/lab/repos/cytokit/python/pipeline/cytokit/exec/pipeline.py", line 441, in run_preprocess_task
    return run_task(task, ops, preprocess_tile)
  File "/lab/repos/cytokit/python/pipeline/cytokit/exec/pipeline.py", line 355, in run_task
    with ops:
  File "/lab/repos/cytokit/python/pipeline/cytokit/ops/op.py", line 200, in __enter__
    v.__enter__()
  File "/lab/repos/cytokit/python/pipeline/cytokit/ops/op.py", line 152, in __enter__
    self.initialize()
  File "/lab/repos/cytokit/python/pipeline/cytokit/ops/cytometry.py", line 136, in initialize
    self.cytometer.initialize()
  File "/lab/repos/cytokit/python/pipeline/cytokit/cytometry/cytometer.py", line 609, in initialize
    self.model = self._get_model(input_shape)
  File "/lab/repos/cytokit/python/pipeline/cytokit/cytometry/cytometer.py", line 885, in _get_model
    return unet_model.get_model(3, input_shape)
  File "/lab/repos/cytokit/python/pipeline/cytokit/cytometry/models/unet_v2.py", line 82, in get_model
    [x, y] = get_model_core(n_class, input_shape, **kwargs)
  File "/lab/repos/cytokit/python/pipeline/cytokit/cytometry/models/unet_v2.py", line 47, in get_model_core
    y = keras.layers.merge.concatenate([d, c])
  File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/keras/layers/merge.py", line 649, in concatenate
    return Concatenate(axis=axis, **kwargs)(inputs)
  File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/keras/engine/base_layer.py", line 431, in __call__
    self.build(unpack_singleton(input_shapes))
  File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/keras/layers/merge.py", line 362, in build
    'Got inputs shapes: %s' % (input_shape))
ValueError: A 'Concatenate' layer requires inputs with matching shapes except for the concat axis. Got inputs shapes: [(None, 462, 668, 512), (None, 462, 669, 256)]

At first I thought that there is problem with image dimensions, but I checked them and they are all same.
So it seems that there is a mismatch in shapes of model layers.

My experiment.yaml file looks like this

experiment.yaml

name: 'VAN0001-RK-1-21'
date: '2020-18-03 00:00:00'
environment:
  path_formats: keyence_single_cycle_v01
acquisition:
  per_cycle_channel_names: [CH1, CH2, CH3, CH4]
  channel_names: [Synaptopodin, Laminin, DAPI, THP]
  emission_wavelengths: [461, 519, 568, 666]
  axial_resolution: 0
  # Placeholder, don't know real value.
  lateral_resolution: 1
  # Don't know if this is correct.
  magnification: 10
  num_cycles: 1
  num_z_planes: 1
  numerical_aperture: 0.45
  objective_type: air
  region_names: [Region1]
  region_height: 20
  region_width: 20
  tile_height: 1802
  tile_overlap_x: 0
  tile_overlap_y: 0
  tile_width: 2633
  tiling_mode: grid
analysis:
  - aggregate_cytometry_statistics: {mode: best_z_plane}
  # Uncomment to produce CP exports by default
  #- cellprofiler_quantification: {export_csv: true, export_db: true, export_db_objects_separately: true}
  #- cellprofiler_quantification: {export_csv: true, export_db: false}
operator:
  - extract:
      name: nucleus_boundaries
      channels: [ cyto_nucleus_boundary ]
      z: best
  - montage: { name: segm, extract_name: segm }
processor:
  args:
    gpus: [ 0, 1 ]
    run_crop: false
    run_tile_generator: true
    run_drift_comp: false
    run_cytometry: true
    run_best_focus: true
  best_focus: {channel: DAPI}
  drift_compensation: {channel: DAPI}
  deconvolution: {n_iter: 25, scale_factor: .5}
  tile_generator: {raw_file_type: keyence_mixed}
  cytometry:
    # target_shape dimensions must be evenly divisble by 8 for the U-Net to
    # work (https://github.com/CellProfiler/CellProfiler-plugins/issues/65).
    target_shape: [1808, 2640]
    nuclei_channel_name: DAPI
    segmentation_params: {memb_min_dist: 8, memb_sigma: 5, memb_gamma: .25, marker_dilation: 3}
    quantification_params: {nucleus_intensity: true, cell_graph: true}

'int' object has no attribute 'auto_restart'

Hi,
I am trying to run the entire cytokit pipeline on my local machine. While executing "!cytokit processor run_all", I get the following error:

File "/home/akashparvatikar/anaconda3/lib/python3.7/site-packages/cytokit-0.1.1-py3.7.egg/cytokit/exec/pipeline.py", line 406, in run_tasks
worker.auto_restart = False
AttributeError: 'int' object has no attribute 'auto_restart'

Any idea, what is the issue? Suggestions would be greatly appreciated. Thank you!

Tensorflow not downloading the NN

Hi Eric,

I am trying to run cytokit on a new pc and got the following error:

image

I have notice that the network is not being download when doing a clean start. I am not sure if that could be the problem.

The new PC has the following configuration:
Memory 128Gb
CPU: Intel Xeon W-2155
GPU: Quadro RTX 5000 12Gb

The image set that I am trying to analyze is 9x7 20 planes 9 cycles

I have try normal configuration and adjusted as suggested in the previous error report, with less number of planes and cycles but I still got the same error,

how to generate a template configuration file?

This tool looks really cool and I'd like to implement it at our organization! However, I'm new to image analysis and cannot for the life of me figure out how to obtain/create a template configuration file for the image I wish to process.

I've managed to extract a utf-16 XML file from the qptiff tags. The XML contained a lot of information about the cameras and channels, but it doesn't have all the information contained in the example yaml config files.

What is the usual way to go about getting the template configuration file? Do you just write it from scratch and hope for the best?

Document how to use cytokit on gcloud

Some preliminary notes:

Cytokit on gcloud

Spin up a machine on gcloud: 2 GPUs Nvidia K80

gcloud beta compute \
	--project=hammerlab-chs \
	instances create \
	cytokit \
	--zone=us-east1-c \
	--machine-type=n1-highmem-16 \
	--subnet=default \
	--network-tier=PREMIUM \
	--maintenance-policy=TERMINATE \
	--service-account=195534064580-compute@developer.gserviceaccount.com \
	--scopes="https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write,https://www.googleapis.com/auth/monitoring.write,https://www.googleapis.com/auth/servicecontrol,https://www.googleapis.com/auth/service.management.readonly,https://www.googleapis.com/auth/trace.append" \
	--accelerator=type=nvidia-tesla-k80,count=2 \
	--tags=http-server,https-server \
	--image=ubuntu-1604-xenial-v20180627 \
	--image-project=ubuntu-os-cloud \
	--boot-disk-size=1000GB \
	--boot-disk-type=pd-standard \
	--boot-disk-device-name=cytokit

gcloud compute ssh --zone us-east1-c cytokit

Inspiration: https://medium.com/google-cloud/jupyter-tensorflow-nvidia-gpu-docker-google-compute-engine-4a146f085f17

# Install all the things as root to work around many issues
sudo su -

#!/bin/bash
echo "Checking for CUDA and installing."
# Check for CUDA and try to install.
if ! dpkg-query -W cuda; then
  # The 16.04 installer works with 16.10.
  curl -O http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
  dpkg -i ./cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
  apt-get update
  apt-get install cuda -y
fi

# Sanity check (should see all GPUs listed here)
nvidia-smi 
#/bin/bash
# install packages to allow apt to use a repository over HTTPS:
apt-get -y install \
apt-transport-https ca-certificates curl software-properties-common
# add Dockerโ€™s official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - 
# set up the Docker stable repository.
add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
# update the apt package index:
apt-get -y update
# finally, install docker
apt-get -y install docker-ce
wget https://github.com/NVIDIA/nvidia-docker/releases/download/v1.0.1/nvidia-docker_1.0.1-1_amd64.deb
dpkg -i nvidia-docker*.deb

# Sanity check (should run without any issues)
nvidia-docker run --rm nvidia/cuda nvidia-smi
exit # from root

# Sudoless docker setup:
sudo usermod -aG docker $USER
sudo systemctl restart docker

exit # logout completely
gcloud compute ssh ... # new login

# Sanity check (should run as a user)
docker run hello-world
nvidia-docker run --rm nvidia/cuda nvidia-smi

Setup is done. Let's pull in relevant programs and scripts:

cd $HOME
mkdir repos
cd repos
git clone https://github.com/hammerlab/cytokit.git && mv cytokit codex
git clone https://github.com/hammerlab/cvutils.git
git clone https://github.com/hammerlab/cell-image-analysis.git

cat << EOF >> ~/cytokit.env
export CODEX_DATA_DIR=$HOME/data
export CODEX_REPO_DIR=$HOME/repos/codex
export CVUTILS_REPO_DIR=$HOME/repos/cvutils
export CODEX_ANALYSIS_REPO_DIR=$HOME/repos/cell-image-analysis
EOF
source ~/cytokit.env

mkdir -p $CODEX_DATA_DIR
cd $CODEX_DATA_DIR
gsutil cp -r gs://musc-codex/models .

cd $CODEX_DATA_DIR
mkdir 20180614_D22_RepA_Tcell_CD4-CD8-DAPI_5by5
cd 20180614_D22_RepA_Tcell_CD4-CD8-DAPI_5by5
gsutil -m cp -r gs://musc-codex/datasets/20180614_D22_RepA_Tcell_CD4-CD8-DAPI_5by5 .
mv 20180614_D22_RepA_Tcell_CD4-CD8-DAPI_5by5 raw

We now have all we need (scripts/data). Let's run the analysis:

cd $CODEX_REPO_DIR/docker
nvidia-docker build -t codex-analysis -f Dockerfile.dev .

nvidia-docker run -ti -p 8888:8888 -p 6006:6006 -p 8787:8787 -p 8050:8050 --rm \
-v $CODEX_DATA_DIR:/lab/data \
-v $CODEX_REPO_DIR:/lab/repos/codex \
-v $CODEX_ANALYSIS_REPO_DIR:/lab/repos/codex-analysis \
-v $CVUTILS_REPO_DIR:/lab/repos/cvutils \
-e CODEX_CYTOMETRY_2D_MODEL_PATH=/lab/data/models/r0.3/nuclei_model.h5 \
-e CODEX_CACHE_DIR=/lab/data/.codex/cache \
codex-analysis

You can now connect to your notebook running on your gcloud instance using its public ID. Once on it, create a new console tab and run the following:

#!/usr/bin/env bash

EXP_NAME="20180614_D22_RepB_Tcell_CD4-CD8-DAPI_5by5"
CODEX_DATA_DIR=/lab/data
EXP_DIR=$CODEX_DATA_DIR/$EXP_NAME
CODEX_ANALYSIS_REPO_DIR=/lab/repos/codex-analysis/
EXP_CONF=$CODEX_ANALYSIS_REPO_DIR/config/experiment/$EXP_NAME/experiment.yaml
EXP_OUT=$EXP_DIR/output/v01

echo "Processing experiment $EXP_NAME"

cytokit processor run \
    --config-path=$EXP_CONF \
    --data-dir=$EXP_DIR/raw \
    --output-dir=$EXP_OUT \
    --run-drift-comp=False \
    --run-best-focus=True \
    --run-deconvolution=True \
    --gpus=[0,1] --py-log-level=info

cytokit operator \
extract \
  --config-path=$EXP_CONF \
  --data-dir=$EXP_OUT \
  --name='best_z_segm' \
  --channels=['proc_dapi','proc_cd4','proc_cd8','cyto_cell_boundary','cyto_nucleus_boundary'] - \
montage \
  --name='best_z_segm' \
  --extract-name='best_z_segm' 

cytokit analysis aggregate_cytometry_statistics \
  --config-path=$EXP_CONF \
  --data-dir=$EXP_OUT \
  --mode='best_z_plane'

Should be done in < 30 minutes. You can gsutil cp it to a bucket and turn your gcloud box off.

Need to clean this up a bit.

cells at tile edges

Hello,

I am trying to understand more about the Cytokit analysis results now, and was wondering -- since cytometry is done for each tile separately, what happens for the cells that overlap the edges of the tiles, so e.g. half of the cell is in one tile and the other half is in another tile? Are these cells just not counted, or only the part of the cell that contains the nucleus is used, or something else?

Thanks!
Maria

Cytokit UI not loading

Hi team,

I was trying to test out the cytokit UI for one of the example datasets shown in the notebook. The process seemed to go through without any errors but no UI popped up at the end.

I should mention that im Not using a framework version of python for my cytokit packages, which I know can sometimes cause issues with GUI related python packages. I was wondering if the Cytokit UI requires something like that or theres something else missing.

Thank you!

(cytokit) Ninnings-MacBook-Pro:~ ninning$ cytokit application run_explorer
2020-02-08 17:46:06,288:INFO:6609:root: Running explorer app
2020-02-08 17:46:06,965:INFO:6609:cytokit_app.explorer.data: Loading montage image for the first time (this may take a bit but is only necessary once)
2020-02-08 17:46:06,979:INFO:6609:cytokit_app.explorer.data: Loaded montage image with shape = (6, 1008, 1344), dtype = uint16, z = 0
2020-02-08 17:46:07,048:INFO:6609:cytokit_app.explorer.data: Loading cytometry data from path "/Users/ninning/Desktop/cytotesting/outputcytotest/v00/cytometry/data.csv"
2020-02-08 17:46:07,302:INFO:6609:cytokit_app.explorer.data: Loaded tile image for tile x = 0, tile y = 0, z = 0, shape = (6, 1008, 1344), dtype = uint16
* Serving Flask app "cytokit" (lazy loading)
* Environment: production WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Debug mode: off 2020-02-08 17:46:08,586:INFO:6609:werkzeug: * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)

CODEX BALBc1 not available

Good Afternoon,

I am trying to run the CODEX BLABc1 example but the dataset is not available. Where can I find this dataset, and is there any better explanation on how to run cytokit on CODEX datasets?

Kind Regards

Add Processing Step Statistics

Each of deconvolution, drift compensation, and best focal plane selection result in some information that should be written into a file for QA. This should include at least:

  • Drift compensation translation vectors
  • Deconvolution mean intensity adjustment ratios
  • Deconvolution before and after SSIM or NRMSE? This may be a good way to get a sense of which tiles/cycles/channels changed the most from applying deconvolution
  • Focal plane classifications for each z-plane as well as the best z plane chosen

Writing them all to a single processor_statistics.json file would probably make sense, as especially the best focal plane information is useful in other parts of the pipeline/analysis.

Ultimately, it would be great to turn anomalies in these numbers into errors, but given that it is a long running operation it may make more sense to simply have a "check_statistics" command or something of the like to point out noteworthy conditions and then let the user decide what to do about them.

Upgrading Python

Hi @eric-czech ,

We noticed that the Cytokit container has Python 3.5, and were wondering whether it's possible/how much work it would be to upgrade to a later version of Python (3.6. or higher)? Is there a specific reason for using 3.5?

Thanks!
Maria

Error during preprocessing

Hello,

I am trying Cytokit with some CODEX data from a collaborator, and have run into the error below and I'm not sure how to overcome it. Would you have any idea what might be causing this?

Thanks,
Maria

2019-11-26 10:52:38,705:INFO:69377:root: Execution arguments and environment saved to "/nfs/cg/hm/cytokit_testing/analysis/dataset2/output/processor/execution/201911261052.json"
2019-11-26 10:52:47,400:INFO:69377:cytokit.exec.pipeline: Starting Pre-processing pipeline for 2 tasks (2 workers)
Using TensorFlow backend.
Using TensorFlow backend.
distributed.worker - WARNING - Compute Failed
Function: run_preprocess_task
args: ({'op_flags': <cytokit.exec.pipeline.OpFlags object at 0x7fcda3353080>, 'tile_prefetch_capacity': 1, 'output_dir': '/nfs/cg/hm/cytokit_testing/analysis/dataset2/output', 'data_dir': '/nfs/cg/hm/cytokit_testing/analysis/dataset2/data', 'region_indexes': array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 'gpu': 2, 'tile_indexes': array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])})
kwargs: {}
Exception: ValueError('A Concatenate layer requires inputs with matching shapes except for the concat axis. Got inputs shapes: [(None, 250, 336, 512), (None, 251, 336, 256)]',)
Traceback (most recent call last):
File "/lab/repos/cytokit/python/pipeline/cytokit/cli/main.py", line 32, in
main()
File "/lab/repos/cytokit/python/pipeline/cytokit/cli/main.py", line 28, in main
fire.Fire(Cytokit)
File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/fire/core.py", line 127, in Fire
component_trace = _Fire(component, args, context, name)
File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/fire/core.py", line 366, in _Fire
component, remaining_args)
File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/fire/core.py", line 542, in _CallCallable
result = fn(*varargs, kwargs)
File "/nfs/cg/hm/cytokit_testing/lab/repos/cytokit/python/pipeline/cytokit/cli/init.py", line 167, in run_all
fn(
{**config[op], **params})
File "/nfs/cg/hm/cytokit_testing/lab/repos/cytokit/python/pipeline/cytokit/cli/processor.py", line 131, in run
pipeline.run(pl_config, logging_init_fn=self._logging_init_fn)
File "/nfs/cg/hm/cytokit_testing/lab/repos/cytokit/python/pipeline/cytokit/exec/pipeline.py", line 458, in run
run_tasks(pl_conf, 'Pre-processing', run_preprocess_task, logging_init_fn)
File "/nfs/cg/hm/cytokit_testing/lab/repos/cytokit/python/pipeline/cytokit/exec/pipeline.py", line 421, in run_tasks
res = [r.result() for r in res]
File "/nfs/cg/hm/cytokit_testing/lab/repos/cytokit/python/pipeline/cytokit/exec/pipeline.py", line 421, in
res = [r.result() for r in res]
File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/distributed/client.py", line 227, in result
six.reraise(*result)
File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/six.py", line 692, in reraise
raise value.with_traceback(tb)
File "/nfs/cg/hm/cytokit_testing/lab/repos/cytokit/python/pipeline/cytokit/exec/pipeline.py", line 441, in run_preprocess_task
return run_task(task, ops, preprocess_tile)
File "/nfs/cg/hm/cytokit_testing/lab/repos/cytokit/python/pipeline/cytokit/exec/pipeline.py", line 355, in run_task
with ops:
File "/nfs/cg/hm/cytokit_testing/lab/repos/cytokit/python/pipeline/cytokit/ops/op.py", line 200, in enter
v.enter()
File "/nfs/cg/hm/cytokit_testing/lab/repos/cytokit/python/pipeline/cytokit/ops/op.py", line 152, in enter
self.initialize()
File "/nfs/cg/hm/cytokit_testing/lab/repos/cytokit/python/pipeline/cytokit/ops/cytometry.py", line 136, in initialize
self.cytometer.initialize()
File "/nfs/cg/hm/cytokit_testing/lab/repos/cytokit/python/pipeline/cytokit/cytometry/cytometer.py", line 609, in initialize
self.model = self._get_model(input_shape)
File "/nfs/cg/hm/cytokit_testing/lab/repos/cytokit/python/pipeline/cytokit/cytometry/cytometer.py", line 885, in _get_model
return unet_model.get_model(3, input_shape)
File "/nfs/cg/hm/cytokit_testing/lab/repos/cytokit/python/pipeline/cytokit/cytometry/models/unet_v2.py", line 82, in get_model
[x, y] = get_model_core(n_class, input_shape, **kwargs)
File "/nfs/cg/hm/cytokit_testing/lab/repos/cytokit/python/pipeline/cytokit/cytometry/models/unet_v2.py", line 47, in get_model_core
y = keras.layers.merge.concatenate([d, c])
File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/keras/layers/merge.py", line 649, in concatenate
return Concatenate(axis=axis, **kwargs)(inputs)
File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/keras/engine/base_layer.py", line 431, in call
self.build(unpack_singleton(input_shapes))
File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/keras/layers/merge.py", line 362, in build
'Got inputs shapes: %s' % (input_shape))
ValueError: A Concatenate layer requires inputs with matching shapes except for the concat axis. Got inputs shapes: [(None, 250, 336, 512), (None, 251, 336, 256)]

CytoKit for other multiplexing methods

Dear cytokit-team,

recently I read your paper and found it really cool toolkit. We are also working with a multiplexing technique which is called "Multi Epitope Ligand Cartography" (MELC). I only would like to ask you, if cytokit could also be configurated in this way, that those images are processed, or at least usable in the cytokit explorer, because image alignment, background subtraction and shading correction is allready done...so at the end we just have to feed these final stack into a readable format for the cytokit explorer, right?

  • Our raw images are registrated by taking a phase contrast image instead of nuclei staining
  • image illumination correction is performed by using bleaching images of the previous and current staining

more information can be found here:
https://onlinelibrary.wiley.com/doi/full/10.1002/cyto.a.23526

At the end we have a stack of every single staining...like multi channel image....most of the time, we only have one field of view, because the method is kind of limited to 4 field of views...so no tile scanning like in CODEX.

With the cytokit explorer I would like to give my colleagues another insight to their data. Handling and interaction in more than 80 stainings in one tissue sample is quite complex, as you maybe know.

Thank you very much in advance

Compute Error due to Memory Error

Good Afternoon,

In the last run I have try with cytokit, I started observing the following error

image
image

I try modifying the parameter target_shape: [504, 672] #1024, 1344 and changing the:

tile_height: 1007
tile_width: 1344
tile_overlap_x: 576
tile_overlap_y: 433

Without any luck

experiment_2.txt

pipeline_execution_2.txt

Thanks in advance for your help,

Kind Regards

Make example data sets public

Here are the ones that we are familiar with and trust the most:

$ gsutil ls gs://musc-codex/datasets/ \
     | grep "20180706\|20180614" \
     | xargs -I@ -P1 bash -c "gsutil du -sh @"

6.65 GiB    gs://musc-codex/datasets/20180614_D22_RepA_Tcell_CD4-CD8-DAPI_5by5
9.88 GiB    gs://musc-codex/datasets/20180614_D22_RepB_Tcell_CD4-CD8-DAPI_5by5
9.4 GiB     gs://musc-codex/datasets/20180614_D23_RepA_Tcell_CD4-CD8-DAPI_5by5
8.81 GiB    gs://musc-codex/datasets/20180614_D23_RepB_Tcell_CD4-CD8-DAPI_5by5
5.55 GiB    gs://musc-codex/datasets/20180706-Donor22-R2-Tcell-CODEX_CD3CD4CD85BY5
5.38 GiB    gs://musc-codex/datasets/20180706-Donor23-R2-Tcell-CODEX_CD3CD4CD85BY5

These would also make testing the framework easier for everybody. The only thing we have to make sure is that making these data sets won't be that costly. We can go with a service like figshare but not sure how their downloading bandwidth scales if we need to download it over and over again.

@hammer: any suggestions?

Outputting ROI polygon info

Hi @eric-czech ,

I've been asked whether it's possible to get Cytokit to output polygon information for the segmented ROIs i.e. nuclei and cell boundaries. The project I'm working on is converging on OME-TIFF as the preferred format for image data, and we'd like to be able to put this information into OME-XML, if it's possible to pull it out from Cytokit somehow?

Thanks,
Maria

IndexError: too many indices for array

Hello,

I'm now trying to run Cytokit to do some processing of a set of tiles I generated (using bfconvert) from a single large fluorescence microscopy image with 4 channels, one z-plane.

I have 400 tiles (20x20), with one cycle, one z-plane, 4 channels, x = 2633, y = 1802. I put the tiles into output/processor/tile and then tried to run cytokit processor run_all --config-path=experiment.yaml --data-dir=output --output-dir=output. The pipeline then fails with the following:

2020-01-20 11:49:42,394:INFO:21480:cytokit.exec.pipeline: Starting Pre-processing pipeline for 2 tasks (2 workers)
Using TensorFlow backend.
Using TensorFlow backend.
/lab/repos/cytokit/python/pipeline/cytokit/io.py:137: UserWarning: ImageJ tags do not contain "axes" property (file = /users/keays/cytokit/all_tiles/output/processor/tile/R001_X001_Y011.tif, tags = {'ImageJ': '', 'slices': 1, 'images': 4, 'hyperstack': True, 'frames': 1, 'channels': 4})
warnings.warn('ImageJ tags do not contain "axes" property (file = {}, tags = {})'.format(file, tags))
/lab/repos/cytokit/python/pipeline/cytokit/io.py:137: UserWarning: ImageJ tags do not contain "axes" property (file = /users/keays/cytokit/all_tiles/output/processor/tile/R001_X001_Y001.tif, tags = {'ImageJ': '', 'slices': 1, 'images': 4, 'hyperstack': True, 'frames': 1, 'channels': 4})
warnings.warn('ImageJ tags do not contain "axes" property (file = {}, tags = {})'.format(file, tags))
Exception in thread Thread-3:
Traceback (most recent call last):
File "/opt/conda/envs/cytokit/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/opt/conda/envs/cytokit/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "/lab/repos/cytokit/python/pipeline/cytokit/exec/pipeline.py", line 169, in load_tiles
q.put((tile, region_index, tile_index), block=True, timeout=TIMEOUT)
File "/lab/repos/cytokit/python/pipeline/cytokit/ops/op.py", line 157, in exit
raise value
File "/lab/repos/cytokit/python/pipeline/cytokit/exec/pipeline.py", line 167, in load_tiles
tile = op.run(None)
File "/lab/repos/cytokit/python/pipeline/cytokit/ops/op.py", line 178, in run
res = self._run(*args, **kwargs)
File "/lab/repos/cytokit/python/pipeline/cytokit/ops/tile_generator.py", line 64, in _run
tile = cytokit_io.read_tile(osp.join(self.data_dir, img_path))
File "/lab/repos/cytokit/python/pipeline/cytokit/io.py", line 152, in read_tile
res = tif.asarray()[tuple(slices)]
IndexError: too many indices for array

Exception in thread Thread-3:
Traceback (most recent call last):
File "/opt/conda/envs/cytokit/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/opt/conda/envs/cytokit/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "/lab/repos/cytokit/python/pipeline/cytokit/exec/pipeline.py", line 169, in load_tiles
q.put((tile, region_index, tile_index), block=True, timeout=TIMEOUT)
File "/lab/repos/cytokit/python/pipeline/cytokit/ops/op.py", line 157, in exit
raise value
File "/lab/repos/cytokit/python/pipeline/cytokit/exec/pipeline.py", line 167, in load_tiles
tile = op.run(None)
File "/lab/repos/cytokit/python/pipeline/cytokit/ops/op.py", line 178, in run
res = self._run(*args, **kwargs)
File "/lab/repos/cytokit/python/pipeline/cytokit/ops/tile_generator.py", line 64, in _run
tile = cytokit_io.read_tile(osp.join(self.data_dir, img_path))
File "/lab/repos/cytokit/python/pipeline/cytokit/io.py", line 152, in read_tile
res = tif.asarray()[tuple(slices)]
IndexError: too many indices for array

I looked a bit more closely at the TIFFs with tifffile and it does look as though they just have three dimensions, rather than five. I suppose this is just because there is only one single z-plane and "cycle", so there are no dimensions in the array for these. Looking at /lab/repos/cytokit/python/pipeline/cytokit/io.py , if I manually run the initial steps of read_tile and remove lines 149 and 150, then line 152 only tries to select three dimensions from the image array and so "works". I'm not sure what knock-on effects that would have though...

Would you recommend trying to add placeholder dimensions to the TIFFs somehow for these, or is there a better way to handle these images?

Imaging mass cytometry

Hello,

I am looking for open source, automation-friendly software to do end-to-end processing for imaging mass cytometry data, and I was wondering if Cytokit would fit the bill? I have data similar to the example dataset here.

Thanks,
Maria

file not found error

I am trying to run "marker_profiling_example" notebook and while trying to visualize the 6-channel image, I get the following error:
No such file or directory: '/tmp/cytokit-example/cellular-marker/20181116-d40-r1-20x-5by5/output/v00/montage/best_z_segm/R001.tif'

I think montage folder is missing within v00. Can you please help me with this?

Fail to download data

Hi, thank you for sharing this useful tool, i'm running the example script and got stuck at downloading raw data.
error

Issue Executing marker_profiling_example.ipynb

I started the docker image, and I am trying to execute the example notebook marker_profiling_example.ipynb. I get an error in the 8th cell. My guess is that the h5 file is not correctly downloaded in the back.

variant_dir = osp.join(out_dir, 'v00')
!cytokit processor run_all --config-path=$variant_dir/config --data-dir=$raw_dir --output-dir=$variant_dir

Error message:

2021-04-20 11:05:20,412:INFO:381:root: Execution arguments and environment saved to "/tmp/cytokit-example/cellular-marker/20181116-d40-r1-20x-5by5/output/v00/processor/execution/202104201105.json"
2021-04-20 11:05:34,536:INFO:381:cytokit.exec.pipeline: Starting Pre-processing pipeline for 1 tasks (1 workers)
Using TensorFlow backend.
distributed.worker - WARNING -  Compute Failed
Function:  run_preprocess_task
args:      ({'output_dir': '/tmp/cytokit-example/cellular-marker/20181116-d40-r1-20x-5by5/output/v00', 'op_flags': <cytokit.exec.pipeline.OpFlags object at 0x7f2202d777b8>, 'data_dir': '/tmp/cytokit-example/cellular-marker/20181116-d40-r1-20x-5by5/raw', 'tile_indexes': array([0]), 'gpu': 0, 'tile_prefetch_capacity': 1, 'region_indexes': array([0])})
kwargs:    {}
Exception: OSError('Unable to open file (file signature not found)',)

Traceback (most recent call last):
  File "/usr/local/bin/cytokit", line 32, in <module>
    main()
  File "/usr/local/bin/cytokit", line 28, in main
    fire.Fire(Cytokit)
  File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/fire/core.py", line 127, in Fire
    component_trace = _Fire(component, args, context, name)
  File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/fire/core.py", line 366, in _Fire
    component, remaining_args)
  File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/fire/core.py", line 542, in _CallCallable
    result = fn(*varargs, **kwargs)
  File "/lab/repos/cytokit/python/pipeline/cytokit/cli/__init__.py", line 167, in run_all
    fn(**{**config[op], **params})
  File "/lab/repos/cytokit/python/pipeline/cytokit/cli/processor.py", line 131, in run
    pipeline.run(pl_config, logging_init_fn=self._logging_init_fn)
  File "/lab/repos/cytokit/python/pipeline/cytokit/exec/pipeline.py", line 458, in run
    run_tasks(pl_conf, 'Pre-processing', run_preprocess_task, logging_init_fn)
  File "/lab/repos/cytokit/python/pipeline/cytokit/exec/pipeline.py", line 421, in run_tasks
    res = [r.result() for r in res]
  File "/lab/repos/cytokit/python/pipeline/cytokit/exec/pipeline.py", line 421, in <listcomp>
    res = [r.result() for r in res]
  File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/distributed/client.py", line 227, in result
    six.reraise(*result)
  File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/six.py", line 702, in reraise
    raise value.with_traceback(tb)
  File "/lab/repos/cytokit/python/pipeline/cytokit/exec/pipeline.py", line 441, in run_preprocess_task
    return run_task(task, ops, preprocess_tile)
  File "/lab/repos/cytokit/python/pipeline/cytokit/exec/pipeline.py", line 355, in run_task
    with ops:
  File "/lab/repos/cytokit/python/pipeline/cytokit/ops/op.py", line 200, in __enter__
    v.__enter__()
  File "/lab/repos/cytokit/python/pipeline/cytokit/ops/op.py", line 152, in __enter__
    self.initialize()
  File "/lab/repos/cytokit/python/pipeline/cytokit/ops/cytometry.py", line 136, in initialize
    self.cytometer.initialize()
  File "/lab/repos/cytokit/python/pipeline/cytokit/cytometry/cytometer.py", line 610, in initialize
    self.model.load_weights(self.weights_path or self._get_weights_path())
  File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/keras/engine/network.py", line 1157, in load_weights
    with h5py.File(filepath, mode='r') as f:
  File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/h5py/_hl/files.py", line 408, in __init__
    swmr=swmr)
  File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/h5py/_hl/files.py", line 173, in make_fid
    fid = h5f.open(name, flags, fapl=fapl)
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py/h5f.pyx", line 88, in h5py.h5f.open
OSError: Unable to open file (file signature not found)

Any ideas to solve that?

UserWarning: truncating ImageJ file

Hello again! I have another question, this time about montage generation -- I am getting this error (using the BALBc-1 Goltsev et al dataset):

2019-12-11 09:06:55,741:INFO:29559:root: Extraction complete (results saved to /users/keays/cytokit/Stanford/Goltsev_mouse_spleen/output/extract/segm)
2019-12-11 09:06:55,858:INFO:29559:root: Creating montage "segm" from extraction "segm"
2019-12-11 09:06:55,858:INFO:29559:cytokit.function.core: Generating montage for region 1 of 1
2019-12-11 09:07:22,057:INFO:29559:cytokit.function.core: Saving montage to file "/users/keays/cytokit/Stanford/Goltsev_mouse_spleen/output/montage/segm/R001.tif"
/opt/conda/envs/cytokit/lib/python3.5/site-packages/tifffile/tifffile.py:2035: UserWarning: truncating ImageJ file
warnings.warn('truncating ImageJ file')
2019-12-11 09:07:33,966:INFO:29559:cytokit.function.core: Montage generation complete; results saved to "/users/keays/cytokit/Stanford/Goltsev_mouse_spleen/output/montage/segm"

I looked a bit further into the code throwing the error and it looks like it's related to the size of the file, and that it's not generating a BigTIFF? It does look as though some tiles are missing from some planes in the final montage:

truncated_montage

Using more than two GPUs

Hi @eric-czech ,

I'm now trying to use Cytokit to process a CODEX dataset with 20 cycles, and I see the following issue, when using two GPUs:

2020-01-29 06:12:55,608:INFO:43129:cytokit.exec.pipeline: Loaded tile 33 for region 1 [shape = (20, 11, 4, 1440, 1920)]
2020-01-29 06:12:55,609:INFO:43129:cytokit.ops.drift_compensation: Calculating drift translations
2020-01-29 06:12:56,185:INFO:43125:cytokit.exec.pipeline: Loaded tile 1 for region 1 [shape = (20, 11, 4, 1440, 1920)]
2020-01-29 06:12:56,186:INFO:43125:cytokit.ops.drift_compensation: Calculating drift translations
2020-01-29 06:13:30,956:INFO:43125:cytokit.ops.drift_compensation: Applying drift translations
2020-01-29 06:13:30,968:INFO:43129:cytokit.ops.drift_compensation: Applying drift translations
distributed.worker - WARNING - Memory use is high but worker has no data to store to disk. Perhaps some other process is leaking memory? Process memory: 33.74 GB -- Worker memory limit: 48.00 GB
distributed.worker - WARNING - Memory use is high but worker has no data to store to disk. Perhaps some other process is leaking memory? Process memory: 33.98 GB -- Worker memory limit: 48.00 GB

I tried processing a subset of the data with 10 cycles, and this began to work as expected.

I then tried to process the full 20-cycle dataset using a node with more GPUs in case this would help (setting gpus: [0, 1, 2, 3, 4, 5, 6, 7]). However for some reason, although 8 workers were set up, Cytokit still only appeared to use two of them (note the "Loaded tile 1" and "Loaded tile 33", out of 63 tiles total):

2020-01-29 06:11:41,623:INFO:42970:root: Execution arguments and environment saved to "output/processor/execution/202001291111.json"
2020-01-29 06:11:50,772:INFO:42970:cytokit.exec.pipeline: Starting Pre-processing pipeline for 8 tasks (8 workers)
Using TensorFlow backend.
Using TensorFlow backend.
Using TensorFlow backend.
Using TensorFlow backend.
Using TensorFlow backend.
Using TensorFlow backend.
Using TensorFlow backend.
Using TensorFlow backend.
2020-01-29 06:12:55,608:INFO:43129:cytokit.exec.pipeline: Loaded tile 33 for region 1 [shape = (20, 11, 4, 1440, 1920)]
2020-01-29 06:12:55,609:INFO:43129:cytokit.ops.drift_compensation: Calculating drift translations
2020-01-29 06:12:56,185:INFO:43125:cytokit.exec.pipeline: Loaded tile 1 for region 1 [shape = (20, 11, 4, 1440, 1920)]
2020-01-29 06:12:56,186:INFO:43125:cytokit.ops.drift_compensation: Calculating drift translations
2020-01-29 06:13:30,956:INFO:43125:cytokit.ops.drift_compensation: Applying drift translations
2020-01-29 06:13:30,968:INFO:43129:cytokit.ops.drift_compensation: Applying drift translations
distributed.worker - WARNING - Memory use is high but worker has no data to store to disk. Perhaps some other process is leaking memory? Process memory: 33.74 GB -- Worker memory limit: 48.00 GB

How can I get it to use all of the GPUs? Do you think it would help with the memory issue even if it does use them?

Thanks,
Maria

thoughts on adding cellpose based segmentation

First, this is a great project and we think it's very powerful.
We have had really bad poor segmenation with our own data using cytokit. We have however seen seen fantastic results with cellpose. Is there a way that incorporate a way that a user could specify what segmentation approach is used, and provide an option to add others as they become available?

running marker_profiling_example

Greetings and thank you for sharing this fantastic tool, i'm running the example script and got stuck at the last processing step, any comment is appreciated!
Untitled

Is there a way to change threshold for nucleus segmentation?

I've noticed that Cytokit segmentation performs poorly on some CODEX datasets. Is there a way to change a threshold that tells which nuclei are allowed to pass. Or maybe there are some other parameters that can influence the quality of nucleus segmentation? I could only find some options that influence size of the nuclei masks.

Example file didn't work well

When I tried to run the example, it reported the following errors.

2022-09-07 21:04:53,032:INFO:91:root: Execution arguments and environment saved to "/tmp/cytokit-example/cellular-marker/20181116-d40-r1-20x-5by5/output/v00/processor/execution/202209072104.json"
2022-09-07 21:05:00,776:INFO:91:cytokit.exec.pipeline: Starting Pre-processing pipeline for 1 tasks (1 workers)
2022-09-07 21:05:00,794:INFO:107:cytokit.data: Downloading url "https://storage.googleapis.com/microscope-image-quality/static/model/model.ckpt-1000042.index" to local path "/lab/data/.cytokit/cache/best_focus/model/model.ckpt-1000042.index"
2022-09-07 21:05:02,492:INFO:107:cytokit.exec.pipeline: Loaded tile 1 for region 1 [shape = (1, 7, 4, 1440, 1920)]
2022-09-07 21:05:05,007:INFO:107:cytokit.data: Downloading url "https://storage.googleapis.com/microscope-image-quality/static/model/model.ckpt-1000042.meta" to local path "/lab/data/.cytokit/cache/best_focus/model/model.ckpt-1000042.meta"
2022-09-07 21:05:06,764:INFO:107:cytokit.data: Downloading url "https://storage.googleapis.com/microscope-image-quality/static/model/model.ckpt-1000042.data-00000-of-00001" to local path "/lab/data/.cytokit/cache/best_focus/model/model.ckpt-1000042.data-00000-of-00001"
Using TensorFlow backend.
distributed.worker - WARNING - Compute Failed
Function: run_preprocess_task
args: ({'tile_prefetch_capacity': 1, 'op_flags': <cytokit.exec.pipeline.OpFlags object at 0x7f334cab47b8>, 'output_dir': '/tmp/cytokit-example/cellular-marker/20181116-d40-r1-20x-5by5/output/v00', 'gpu': 0, 'tile_indexes': array([0]), 'region_indexes': array([0]), 'data_dir': '/tmp/cytokit-example/cellular-marker/20181116-d40-r1-20x-5by5/raw'})
kwargs: {}
Exception: OSError('Unable to open file (file signature not found)',)

Traceback (most recent call last):
File "/usr/local/bin/cytokit", line 32, in
main()
File "/usr/local/bin/cytokit", line 28, in main
fire.Fire(Cytokit)
File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/fire/core.py", line 127, in Fire
component_trace = _Fire(component, args, context, name)
File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/fire/core.py", line 366, in _Fire
component, remaining_args)
File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/fire/core.py", line 542, in _CallCallable
result = fn(*varargs, kwargs)
File "/lab/repos/cytokit/python/pipeline/cytokit/cli/init.py", line 167, in run_all
fn(
{**config[op], **params})
File "/lab/repos/cytokit/python/pipeline/cytokit/cli/processor.py", line 131, in run
pipeline.run(pl_config, logging_init_fn=self._logging_init_fn)
File "/lab/repos/cytokit/python/pipeline/cytokit/exec/pipeline.py", line 458, in run
run_tasks(pl_conf, 'Pre-processing', run_preprocess_task, logging_init_fn)
File "/lab/repos/cytokit/python/pipeline/cytokit/exec/pipeline.py", line 421, in run_tasks
res = [r.result() for r in res]
File "/lab/repos/cytokit/python/pipeline/cytokit/exec/pipeline.py", line 421, in
res = [r.result() for r in res]
File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/distributed/client.py", line 227, in result
six.reraise(*result)
File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/six.py", line 702, in reraise
raise value.with_traceback(tb)
File "/lab/repos/cytokit/python/pipeline/cytokit/exec/pipeline.py", line 441, in run_preprocess_task
return run_task(task, ops, preprocess_tile)
File "/lab/repos/cytokit/python/pipeline/cytokit/exec/pipeline.py", line 355, in run_task
with ops:
File "/lab/repos/cytokit/python/pipeline/cytokit/ops/op.py", line 200, in enter
v.enter()
File "/lab/repos/cytokit/python/pipeline/cytokit/ops/op.py", line 152, in enter
self.initialize()
File "/lab/repos/cytokit/python/pipeline/cytokit/ops/cytometry.py", line 136, in initialize
self.cytometer.initialize()
File "/lab/repos/cytokit/python/pipeline/cytokit/cytometry/cytometer.py", line 610, in initialize
self.model.load_weights(self.weights_path or self._get_weights_path())
File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/keras/engine/network.py", line 1157, in load_weights
with h5py.File(filepath, mode='r') as f:
File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/h5py/_hl/files.py", line 408, in init
swmr=swmr)
File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/h5py/_hl/files.py", line 173, in make_fid
fid = h5f.open(name, flags, fapl=fapl)
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "h5py/h5f.pyx", line 88, in h5py.h5f.open
OSError: Unable to open file (file signature not found)
Traceback (most recent call last):
File "/usr/local/bin/cytokit", line 32, in
main()
File "/usr/local/bin/cytokit", line 28, in main
fire.Fire(Cytokit)
File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/fire/core.py", line 127, in Fire
component_trace = _Fire(component, args, context, name)
File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/fire/core.py", line 366, in _Fire
component, remaining_args)
File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/fire/core.py", line 542, in _CallCallable
result = fn(*varargs, kwargs)
File "/lab/repos/cytokit/python/pipeline/cytokit/cli/init.py", line 167, in run_all
fn(
{**config[op], **params})
File "/lab/repos/cytokit/python/pipeline/cytokit/cli/operator.py", line 135, in extract
z_slice_fn = _get_z_slice_fn(z, self.data_dir)
File "/lab/repos/cytokit/python/pipeline/cytokit/cli/operator.py", line 78, in _get_z_slice_fn
map = function_data.get_best_focus_coord_map(data_dir)
File "/lab/repos/cytokit/python/pipeline/cytokit/function/data.py", line 45, in get_best_focus_coord_map
return get_best_focus_data(output_dir).set_index(['region_index', 'tile_x', 'tile_y'])['best_z'].to_dict()
File "/lab/repos/cytokit/python/pipeline/cytokit/function/data.py", line 31, in get_best_focus_data
processor_data, path = get_processor_data(output_dir, return_path=True)
File "/lab/repos/cytokit/python/pipeline/cytokit/function/data.py", line 19, in get_processor_data
proc_data = exec.read_processor_data(path)
File "/lab/repos/cytokit/python/pipeline/cytokit/exec/init.py", line 34, in read_processor_data
with open(path, 'r') as fd:
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/cytokit-example/cellular-marker/20181116-d40-r1-20x-5by5/output/v00/processor/data.json'
2022-09-07 21:07:19,050:INFO:189:root: Running cytometry statistics aggregation
2022-09-07 21:07:19,051:WARNING:189:cytokit.cytometry.data: Expected cytometry data file at "/tmp/cytokit-example/cellular-marker/20181116-d40-r1-20x-5by5/output/v00/cytometry/statistics/R001_X001_Y001.csv" does not exist. It will be ignored but this may be worth investigating
Traceback (most recent call last):
File "/usr/local/bin/cytokit", line 32, in
main()
File "/usr/local/bin/cytokit", line 28, in main
fire.Fire(Cytokit)
File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/fire/core.py", line 127, in Fire
component_trace = _Fire(component, args, context, name)
File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/fire/core.py", line 366, in _Fire
component, remaining_args)
File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/fire/core.py", line 542, in _CallCallable
result = fn(*varargs, kwargs)
File "/lab/repos/cytokit/python/pipeline/cytokit/cli/init.py", line 167, in run_all
fn(
{**config[op], **params})
File "/lab/repos/cytokit/python/pipeline/cytokit/cli/analysis.py", line 28, in aggregate_cytometry_statistics
self.data_dir, self.config, mode=mode, export_csv=export_csv, export_fcs=export_fcs, variant=variant)
File "/lab/repos/cytokit/python/pipeline/cytokit/function/core.py", line 19, in aggregate_cytometry_statistics
res = function_data.get_cytometry_data(output_dir, config, mode=mode)
File "/lab/repos/cytokit/python/pipeline/cytokit/function/data.py", line 59, in get_cytometry_data
cyto_data = cytometry_data.aggregate(config, output_dir)
File "/lab/repos/cytokit/python/pipeline/cytokit/cytometry/data.py", line 32, in aggregate
df = pd.concat(df)
File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/pandas/core/reshape/concat.py", line 212, in concat
copy=copy)
File "/opt/conda/envs/cytokit/lib/python3.5/site-packages/pandas/core/reshape/concat.py", line 245, in init
raise ValueError('No objects to concatenate')
ValueError: No objects to concatenate

Do you have any ideas to figure out the issue?
Thanks a lot.

Segmentation Methodology

Relevant section from the CODEX preprint:

A 3D segmentation algorithm was therefore created to combine information from the nuclear staining and a ubiquitous membrane marker (in this case CD45) to define single-cell boundaries in crowded images such as lymphoid tissues. For each segmented object (i.e., cell) a marker expression profile, as well as the identities of the nearby neighbors were recorded (using Delaunay triangulation)

Software

Expanding on that list a bit:

Models Specific to Medical Imaging

  • U-Net (Example TF-based implementation) - This appears to be a real workhorse architecture in medical image segmentation (there are dozens of implementations in TensorFlow and Caffe)
  • V-Net - A TensorFlow implementation of 3d extensions to the U-Net
  • NiftyNet (Site) - "NiftyNet is a TensorFlow-based open-source convolutional neural networks (CNN) platform for research in medical image analysis and image-guided therapy."
    • If we have to retrain an architecture for segmentation I have to imagine this would be a top choice.
    • Supports 2-D, 2.5-D, 3-D, 4-D inputs
    • It has a Model Zoo but nothing in there for our modality yet, or anything even close
    • (Original Publication](https://arxiv.org/abs/1709.03485)

Generic Architectures

  • DeepLab (Google Research Post) - Google research project in the vein of Detectron
    • My gut says we'd never have enough data to train these big general kinds of models but who knows
  • SegNet - Another generic architecture for semantic segmentation which I only mention because it was brought up along with U-Nets in this webinar on advances in medical image analysis

Comments from @nsamusik on some things to keep in mind:

My main thought at this point is that the segmentation itself is just the first step, there also has to be a second step, where cell boundaries are optimized concomitantly with estimating the single-cell expression vectors. This way both the optimized cell boundaries and the expression data will likely look more accurate.

As for the benchmarking, I am happy to share a hand-labelled dataset that I have generated for the CODEX paper revisions. Here, each TIFF is matched with a TXT file that contains the coordinates of hand-labeled cell centers (X, Y, Z). There are no cell outlines labelled here, just the centers. In order to assess the segmentation quality, I computed several measures: R = Recall (% of hand-labelled centeres that ended up within a segmented cell region), S= Singlets (of those, what % how many ended up in a cell region with exactly 1 hand-labelled center), FPR = False positive rate (% cell regions without a hand-labelled center). Then I combined the three in a harmonic mean 3/(1/R + 1/S + 1/(1-FPR))

here's the link
https://drive.google.com/open?id=1wUNaZ5dv2mDn_wwcSXlnfof6SwoQmlsq

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.