Skip to main content

Cell/nuclei counter using cellpose models

Project description

cellpose-counter

License BSD-3 PyPI Python Version tests codecov napari hub

A Napari plugin for cell/nuclei counting from a region or interest using cellpose models.


Installation

Option 1: Install in Napari directly under the plugins tab and select cellpose-counter.

Option 2: via pip (or pip alternatives like uv):

Below is a minimally working example of setting up a new virtual environment and installing the counter module with uv on Unix based systems.

uv venv # create virtual environment in .venv
source .venv/bin/activate

uv pip install "napari[all]" cellpose-counter

Option 3: via Docker/Podman. The provide Dockerfile can be used to install Napari and the counter plugin along with a preconfigured Xpra server using the napari-xpra image. Below is an example of building the image and running the application with GPU support.

podman build -t cellpose-counter .
podman run -it -d \
    -p 9876:9876 \
    -e XPRA_START="python3 -m napari -w cellpose-counter" \
    --device nvidia.com/gpu=all

Then, navigate to http://localhost:9876 to view the application in a virtual machine.

GPU Acceleration

To enable GPU acceleration, you will need a CUDA capable GPU along with the CUDA toolkit and cudNN library.

For instructions on installing cuda toolkit and cudNN, see:

  1. cuda toolkit installation for Linux
  2. cudNN installation for Linux

Once these are installed, update the pytorch package by first uninstalling torch (if already instsalled).

uv pip uninstall torch

Then install a torch version that is compatible with your CUDA version. For example,

uv pip install torch --index-url https://download.pytorch.org/whl/cu118

After installation, you can verify in an interactive python console with:

import torch
torch.cuda.is_available()

Usage

To open Napari with the cellpose counter loaded, run napari -w cellpose-counter.

A dock widget will be open on the right side of the Napari interface. There you can view options for restoring images (using the cellpose denoise module), and counting cells/nuclei in a region of interest (ROI).

A few important notes:

  1. Images in TIFF or CZI file formats may be used.
  2. Images must be grayscale or single channel. RGB images may be loaded, but should be split. You can do this by right clicking on the image and select split rgb or split stack.
  3. ROIs can be drawn using the shape layer tools. Only a single ROI can be drawn per shape layer (otherwise only the first draw ROI will be used).
  4. ROIs should be square or rectangular. You can draw ROIs as polygons or other shapes, but a bounding box will be made from these shapes anyway.
  5. For long running processes such as image restoration or counting, it may seem like Napari is not doing anything. Notifications are shown in the viewer to display import information and a small activity indicator can be seen in the bottom right hand corner. If this indicator is spinning, then work is being done even if it doesn't look like it.

Updating

  1. via Napari plugin manager. Select cellpose-counter plugin and update button.

  2. via pip (or uv, ..., etc.)

uv pip install cellpose-counter --upgrade

Contributing

All contributions are welcome. Please submit an issue for feedback or bugs.

Citations

This plugin is built on top of the Cellpose segmentation and denoising models. If you use this plugin, please cite the following paper:

@article{stringer2021cellpose,
title={Cellpose: a generalist algorithm for cellular segmentation},
author={Stringer, Carsen and Wang, Tim and Michaelos, Michalis and Pachitariu, Marius},
journal={Nature Methods},
volume={18},
number={1},
pages={100--106},
year={2021},
publisher={Nature Publishing Group}
}

License

BSD-3

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

cellpose_counter-0.1.5.tar.gz (2.6 MB view details)

Uploaded Source

Built Distribution

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

cellpose_counter-0.1.5-py3-none-any.whl (2.4 MB view details)

Uploaded Python 3

File details

Details for the file cellpose_counter-0.1.5.tar.gz.

File metadata

  • Download URL: cellpose_counter-0.1.5.tar.gz
  • Upload date:
  • Size: 2.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.15

File hashes

Hashes for cellpose_counter-0.1.5.tar.gz
Algorithm Hash digest
SHA256 daa9a58e60be40f9f2c0887422f7a6fb9d26b31a236d64fb52c45e87ddcffdf3
MD5 c60f6e11b13967ea1e9bbe32b6f1208a
BLAKE2b-256 a9627a2c848edc2c8ff83de744a194e786508f7999e77d4a002e9f24495e04be

See more details on using hashes here.

File details

Details for the file cellpose_counter-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for cellpose_counter-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 9324e7fea715205e519233381dbbb92c6a850d0ff9296b96a7650390f6bcc78c
MD5 befb81e46dfff48a2b75460b2826b9b8
BLAKE2b-256 0d27426111c8c06005ff7bf26d34628bb47861f4b31b15485d53c8f63e5eb85a

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