Skip to main content

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.

Metadata

Release files for cellsampler 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cellsampler 1.0.0
File Size Uploaded
cellsampler-1.0.0.tar.gz 247.8 kB Details

Release files / cellsampler-1.0.0.tar.gz

Download URL cellsampler-1.0.0.tar.gz
Size 247.8 kB
Tags Source
SHA-256 checksum
How to use checksums
27708bc5ba5a7da75aebf8ae75a205fd5b7ab32488b08f5a60b0c8b62ac905c7
BLAKE2b-256 checksum
How to use checksums
2171e7aa78a29c712eee8586d51ac498bcfdcae790b8bbb5534f2cb7603985aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.22

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 release file

0.1.7

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page