Skip to main content

""

Project description

Cellsampler - Robust consensus image segmentation

cellsampler

Cellsampler is a Python package for generating masks and catalogues of cells in images using multiple segmentation methods and using consensus in order to select the best segmentation for each image region. It has been designed to work with IMC (Imaging Mass Cytometry) datasets stored in Zarr format but can be adapted for other imaging modalities. The package is built on top of the Cellpose, Stardist, and Watershed segmentation methods, providing a unified interface to apply these methods to your datasets.

It supports by default following segmentation methods:

The interface to these methods is described in the Segmentation document. The package also provides a set of image preprocessing methods that can be used to enhance the quality of the input images before segmentation. These methods are described in the Preprocessing document.

See Extending Cellsampler for more information on how to add your own image preprocessing and segmentation methods.

Installation

To install the software use pip a below

pip install cellsampler

The above does not install the segmentation methods from other repositories. To do this you can use:

pip install cellsampler[cellpose,stardist]

or install the segmentation software independently.

For development of for extending the code clone the repository and install in editable mode:

git clone https://gitlab.developers.cam.ac.uk/astronomy/camcead/imaxt/public-code/cellsampler.git
cd cellsampler
pip install -e .

Configuration

The package uses a YAML configuration file to specify the parameters for each segmentation method. The configuration file allows you to customize the parameters for each method, including the model type, threshold, and other settings.

For more details please refer to the default configuration file config.yaml in the root directory of the repository.

Usage

IMC Datasets

To generate masks and catalogues alter the yaml file as appropriate and run from the command line:

cellsampler -c config.yaml 

The explanation of the config.yaml file is given inside the file.

The input dataset is a IMC dataset in Zarr format. The output is a copy of the input IMC dataset with added masks for each method in Zarr format and a catalogue of the cells in the dataset.

Example output Zarr with masks for each method:

<xarray.Dataset> Size: 2GB
Dimensions:        (channel: 53, y: 3054, x: 3551)
Coordinates:
  * channel        (channel) int64 424B 0 1 2 3 4 5 6 7 ... 46 47 48 49 50 51 52
  * x              (x) int64 28kB 0 1 2 3 4 5 ... 3545 3546 3547 3548 3549 3550
  * y              (y) int64 24kB 0 1 2 3 4 5 ... 3048 3049 3050 3051 3052 3053
Data variables:
    Q001           (channel, y, x) float32 2GB dask.array<chunksize=(4, 382, 444), meta=np.ndarray>
    mask_cellpose  (y, x) uint16 22MB dask.array<chunksize=(382, 888), meta=np.ndarray>
    mask_stardist  (y, x) int32 43MB dask.array<chunksize=(382, 444), meta=np.ndarray>

Generic Datasets

To generate masks and catalogues for generic datasets in other formats, you can use the cellsampler module directly. The module provides a unified interface to apply the segmentation methods to your datasets.

Examples of how to use the package with different datasets are provided in the notebooks directory. The examples include:

  • Using Cellsampler with multi-channel TIFF files
  • ...

Roadmap

License

This project is licensed under the Apache License - see the LICENSE file for details.

Acknowledgements

Citation

Changelog

For a list of changes to the package, please refer to the CHANGELOG file.

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

cellsampler-1.0.0.tar.gz (247.8 kB view details)

Uploaded Source

File details

Details for the file cellsampler-1.0.0.tar.gz.

File metadata

  • Download URL: cellsampler-1.0.0.tar.gz
  • Upload date:
  • Size: 247.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for cellsampler-1.0.0.tar.gz
Algorithm Hash digest
SHA256 27708bc5ba5a7da75aebf8ae75a205fd5b7ab32488b08f5a60b0c8b62ac905c7
MD5 ed7e984f7e14184f0e4397c886b617fc
BLAKE2b-256 2171e7aa78a29c712eee8586d51ac498bcfdcae790b8bbb5534f2cb7603985aa

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