Skip to main content

A plugin to process Imaging Mass Cytometry data with cellpose and steinbock

Project description

napari-steinpose

License BSD-3 PyPI Python Version tests codecov napari hub

This napari plugin allows to segment and extract information from Imaging Mass Cytometry data by combining the cellpose and steinbock tools.

Installation

In order to use this plugin, whe highly recommend to create a specific environment and to install the required software in it. You can create a conda environment using:

conda create -n steinpose python=3.8.5 napari -c conda-forge

Then activate it and install the plugin:

conda activate steinpose
pip install napari-steinpose

Potential issue with PyTorch

Cellpose and therefore the plugin and napari can crash without warning in some cases with torch==1.12.0. This can be fixed by reverting to an earlier version using:

pip install torch==1.11.0

GPU

In order to use a GPU:

  1. Uninstall the PyTorch version that gets installed by default with Cellpose:

     pip uninstall torch
    
  2. Make sure your have up-to-date drivers for your NVIDIA card installed.

  3. Re-install a GPU version of PyTorch via conda using a command that you can find here (this takes care of the cuda toolkit, cudnn etc. so no need to install manually anything more than the driver). The command will look like this:

     conda install pytorch torchvision cudatoolkit=11.3 -c pytorch
    

Plugin Updates

To update the plugin, you only need to activate the existing environment and install the new version:

conda activate steinpose
pip install git+https://github.com/guiwitz/napari-steinpose.git -U

Usage

Here is a short summary on how to proceed to use the plugin. For more detailed information, please visit this page.

Load data

Using the "Select data folder" button, select a folder containing your .mcd files. The contents of the folder will appear in the List of images box. When you select one of the files it is loaded in the viewer. Using the ROI spinpox, you can change the roi (or acquisition) to be visualized.

Segmentation

  1. In the channels tab, choose the combination of channels to use to define images to segment. You can choose what type of projection (mean, min etc.) is used to combine channels. You can either select channels defining both cells and nuclei or just a single channel. Note that if you want to just segment nuclei, you need to select them as "cell channel".

  2. To save the output, select a folder using the "Select output folder" button.

  3. In the segmentation tab, pick a cellpose model to use. If you use one of the built-in models, you can specify the average diameter of objects to detect.

  4. In the Options tab, you can set a few more options:

    • cellpose options: you can adjust the flow threshold and cell probabilities. If cells are missing try to use higher values of flow threshold (close to 1) and lower values for the cell probabilities (around -6)
    • segmentation options: you can decide to remove segmentation touching the image border, and you can also decide to expand the segmented objects by a fixed number of pixels. If a segmentation is displayed in the viewer, adjusting this parameter will live-adjust the mask.
  5. You can first test the segmentation using the "Run on current image" button. Once segmentation is done, the corresponding mask is displayed. You can then run the segmentation over all ROIs of all .mcd files present in the folder by using the "Run on folder" button.

Post-processing

In the Segmentation tab, if you tick the box "Run steinbock post-processing", information will directly be extracted from images and masks at the end of segmentation. Processing is done via steinbock and generates files compatible with further downstream processing.

In the Export tab, you can select what type of information to export: object intensities, geometric properties and object neighbourhood. Note that if you have performed a segmentation without post-processing, you can still run post-processing using the "Run steinbock postproc" button.

Saving settings

To avoid having to re-type the same settings repeatedly, you can export a give configuration using the "Export config" button in the Options tab. This generates a human readable .yml file with:

  • segmentation options
  • channels selected for projections

The file is saved in the output folder. You can just copy the file in a new empty output folder to use it for an other analysis run. Once you select that folder containing a configuration file, you can import it with the "Import config" button. Note that you need to have an image opened so that channels can be selected properly.

Contributing

Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.

License

Distributed under the terms of the BSD-3 license, "napari-steinpose" is free and open source software

Authors

The author of this plugin is Guillaume Witz, Data Science Lab and Microscopy Imaging Center, University of Bern. This plugin is the result of a collaboration with the Imaging Mass Cytometry and Mass Cytometry Platform, University of Bern.

Issues

If you encounter any problems, please file an issue along with a detailed description.

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

napari-steinpose-0.1.0.tar.gz (17.7 MB view details)

Uploaded Source

Built Distribution

napari_steinpose-0.1.0-py3-none-any.whl (1.6 MB view details)

Uploaded Python 3

File details

Details for the file napari-steinpose-0.1.0.tar.gz.

File metadata

  • Download URL: napari-steinpose-0.1.0.tar.gz
  • Upload date:
  • Size: 17.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.0

File hashes

Hashes for napari-steinpose-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a88235cb1c09e5a45d0eef0f6be3c3281cad997f14accc1b2a019fb3f2b9660d
MD5 29871d99ba99c32f028a11da8b444b59
BLAKE2b-256 afcb6f15240efe863ac7db0dcc8c6227a760d028d6da333ffbfac786b1ee4632

See more details on using hashes here.

File details

Details for the file napari_steinpose-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for napari_steinpose-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5d1d96b02ef0def293d7290d5e82d9149e5ca3aa898b2fc09496b2ee67321ff3
MD5 e9b551bfb4e7dfab026d5fc3ba26236a
BLAKE2b-256 898a02cc503b5977b061c9f1f8ff1849e09115b5aae9ff000d3d9c3885cf0b6b

See more details on using hashes here.

Supported by

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