Skip to main content

computer vision for image-based phenotyping of single cells

Project description

VisCy

Python package index PyPI monthly downloads Total downloads GitHub contributors GitHub Repo stars GitHub forks SPEC 0 — Minimum Supported Dependencies DOI

VisCy (blend of vision and cyto) is a deep learning pipeline for training and deploying computer vision models for image-based phenotyping at single-cell resolution.

This repository provides a pipeline for the following.

  • Image translation
    • Robust virtual staining of landmark organelles with Cytoland
  • Image representation learning
    • Self-supervised learning of the cell state and organelle phenotypes with DynaCLR
  • Semantic segmentation
    • Supervised learning of of cell state (e.g. state of infection)

Note: VisCy is under active development. While we strive to maintain stability, the main branch may occasionally be updated with break-incompatible changes which are subsequently shipped in releases following semantic versioning. Please choose a stable release from PyPI for production use.

Cytoland (robust virtual staining)

Online demo Open in Spaces

Try the 2D virtual staining demo of cell nuclei and membrane from label-free images on Hugging Face.

Virtual Staining App Demo

Virtual Cell Models

Cytoland models are part of the virtual cell models. Notebooks are available as pre-rendered pages or on Colab:

Tutorials

  • Virtual staining exercise: Notebook illustrating how to use VisCy to train, predict and evaluate the VSCyto2D model. This notebook was developed for the DL@MBL2024 course and uses UNeXt2 architecture.

  • Image translation demo: Fluorescence images can be predicted from label-free images. Can we predict label-free image from fluorescence? Find out using this notebook.

  • Training Virtual Staining Models via CLI: Instructions for how to train and run inference on VisCy's virtual staining models (VSCyto3D, VSCyto2D and VSNeuromast).

Gallery

Below are some examples of virtually stained images (click to play videos). See the full gallery here.

VSCyto3D VSNeuromast VSCyto2D
HEK293T Neuromast A549

Reference

The virtual staining models and training protocols are reported in our recent preprint on robust virtual staining.

This package evolved from the TensorFlow version of virtual staining pipeline, which we reported in this paper in 2020.

Liu, Hirata-Miyasaki et al., 2024

  @article {Liu2024.05.31.596901,
          author = {Liu, Ziwen and Hirata-Miyasaki, Eduardo and Pradeep, Soorya and Rahm, Johanna and Foley, Christian and Chandler, Talon and Ivanov, Ivan and Woosley, Hunter and Lao, Tiger and Balasubramanian, Akilandeswari and Liu, Chad and Leonetti, Manu and Arias, Carolina and Jacobo, Adrian and Mehta, Shalin B.},
          title = {Robust virtual staining of landmark organelles},
          elocation-id = {2024.05.31.596901},
          year = {2024},
          doi = {10.1101/2024.05.31.596901},
          publisher = {Cold Spring Harbor Laboratory},
          URL = {https://www.biorxiv.org/content/early/2024/06/03/2024.05.31.596901},
          eprint = {https://www.biorxiv.org/content/early/2024/06/03/2024.05.31.596901.full.pdf},
          journal = {bioRxiv}
      }
Guo, Yeh, Folkesson et al., 2020

  @article {10.7554/eLife.55502,
      article_type = {journal},
      title = {Revealing architectural order with quantitative label-free imaging and deep learning},
      author = {Guo, Syuan-Ming and Yeh, Li-Hao and Folkesson, Jenny and Ivanov, Ivan E and Krishnan, Anitha P and Keefe, Matthew G and Hashemi, Ezzat and Shin, David and Chhun, Bryant B and Cho, Nathan H and Leonetti, Manuel D and Han, May H and Nowakowski, Tomasz J and Mehta, Shalin B},
      editor = {Forstmann, Birte and Malhotra, Vivek and Van Valen, David},
      volume = 9,
      year = 2020,
      month = {jul},
      pub_date = {2020-07-27},
      pages = {e55502},
      citation = {eLife 2020;9:e55502},
      doi = {10.7554/eLife.55502},
      url = {https://doi.org/10.7554/eLife.55502},
      keywords = {label-free imaging, inverse algorithms, deep learning, human tissue, polarization, phase},
      journal = {eLife},
      issn = {2050-084X},
      publisher = {eLife Sciences Publications, Ltd},
      }
    

Library of virtual staining (VS) models

The robust virtual staining models (i.e VSCyto2D, VSCyto3D, VSNeuromast), and fine-tuned models can be found here

Pipeline

A full illustration of the virtual staining pipeline can be found here.

DynaCLR (Contrastive learning of representations of cell dynamics)

We are currently developing self-supervised representation learning to map cell state dynamics in response to perturbations, with focus on cell and organelle remodeling due to viral infection.

See our recent work on temporally regularized contrastive sampling method for representation learning on arXiv.

Pradeep, Imran, Liu et al., 2024

@misc{pradeep_contrastive_2024,
      title={Contrastive learning of cell state dynamics in response to perturbations},
      author={Soorya Pradeep and Alishba Imran and Ziwen Liu and Taylla Milena Theodoro and Eduardo Hirata-Miyasaki and Ivan Ivanov and Madhura Bhave and Sudip Khadka and Hunter Woosley and Carolina Arias and Shalin B. Mehta},
      year={2024},
      eprint={2410.11281},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2410.11281},
}
    

Workflow demo

  • Example test dataset, model checkpoint, and predictions can be found here.

  • See tutorial on exploration of learned embeddings with napari-iohub here.

DynaCLR schematic

Installation

  1. We recommend using a new Conda/virtual environment.

    conda create --name viscy python=3.11
    # OR specify a custom path since the dependencies are large:
    # conda create --prefix /path/to/conda/envs/viscy python=3.11
    
  2. Install a released version of VisCy from PyPI:

    pip install viscy
    

    If evaluating virtually stained images for segmentation tasks, install additional dependencies:

    pip install "viscy[metrics]"
    

    Visualizing the model architecture requires visual dependencies:

    pip install "viscy[visual]"
    
  3. Verify installation by accessing the CLI help message:

    viscy --help
    

For development installation, see the contributing guide.

Additional Notes

The pipeline is built using the PyTorch Lightning framework. The iohub library is used for reading and writing data in OME-Zarr format.

The full functionality is tested on Linux x86_64 with NVIDIA Ampere/Hopper GPUs (CUDA 12.6). Some features (e.g. mixed precision and distributed training) may not be available with other setups, see PyTorch documentation for details.

Project details


Download files

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

Source Distribution

viscy-0.3.4.tar.gz (15.2 MB view details)

Uploaded Source

Built Distribution

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

viscy-0.3.4-py3-none-any.whl (134.1 kB view details)

Uploaded Python 3

File details

Details for the file viscy-0.3.4.tar.gz.

File metadata

  • Download URL: viscy-0.3.4.tar.gz
  • Upload date:
  • Size: 15.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for viscy-0.3.4.tar.gz
Algorithm Hash digest
SHA256 7a26ce2eae96008908cc53e1e6925c3b6166aab11a6bdcb0cfb9298b33c3b722
MD5 7ffb3d2080e56d3f85d5173bef30cb18
BLAKE2b-256 d39a9dd5ba5fae3119d6eec38467ff566cb43def1cb2381536826c7fa15cf060

See more details on using hashes here.

File details

Details for the file viscy-0.3.4-py3-none-any.whl.

File metadata

  • Download URL: viscy-0.3.4-py3-none-any.whl
  • Upload date:
  • Size: 134.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for viscy-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 20043f5a34a9629c3587a9f24ad6c88157b5e8912a9ab35a145d49f77667aefa
MD5 04ad769bece847f0ff6a8f87898fb829
BLAKE2b-256 a54f880e26892328a4b76d5a4581b48dcb234cea05a14e98d4ac6c9da32dc6b3

See more details on using hashes here.

Supported by

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