Skip to main content

A Napari plugin to detect and count nuclei on phase contrast images

Project description

napari-nuclephaser

License MIT PyPI Python Version tests napari hub npe2 Copier

A Napari plugin to detect and count nuclei on phase contrast images

napari-nuclephaser utilizes Ultralytics YOLO object detection models and obss/sahi sliced inference methods to detect cell nuclei on phase contrast (and other brightfield) images of any size, including large whole slide ones. Learn more with documentation and paper.

Nuclei detection

We trained a series of YOLOv5 and YOLOv11 models to detect nuclei on phase contrast images. It can be used for counting cells or for individual cell tracking (using nuclei detections as tracking marks). Prominent features of this approach are:

  • Napari-nuclephaser plugin includes obss/sahi functionality, allowing detection on images of arbitrary sizes.

Image didn't load

  • YOLO models are fast, providing reasonable inference speed even with CPU.
  • Ability to predict and automatically count nuclei on stacks of images, making it convenient for cell population growth studies and individual cell tracking.
Image didn't load

Calibration algorithm

Result of object detection model inference is highly dependent on confidence threshold parameter.

Image didn't load

We created several calibration (finding optimal confidence threshold) algorithms that allow adjusting models to specific use cases (cell types, magnifications, illumination settings, cameras etc.):

  • Calibration using known number of objects on an image. Doesn't produce accuracy metrics.
  • Calibration using fluorescent nuclei stain image (for example, DAPI image). Produces accuracy metrics.
  • Calibration using manual annotation of nuclei. Produces accuracy metrics.

Apart from optimal confidence threshold search, these algorithms return accuracy metrics for specific use cases. Given that the calibration image is large, only part of it is used for search of threshold, while the second part is used for evaluation model's accuracy. Accuracy metrics are Mean Absolute Percentage Error (MAPE) and prediction-ground truth scatterplot, which shows how well model performs with different densities of cells.

Learn more about calibration in documentation.

Image didn't load

Models

Currently only YOLOv5n, YOLOv5s, YOLOv11n and YOLOv11s models, as well as fluorescent nuclei detector YOLOv5n are downloaded automatically with pip install napari-nuclephaser. To use larger models, download them with these links:

Fluorescent nuclei detectors

Model Link
Fluorescence_v5n Donwload
Fluorescence_v5s Donwload
Fluorescence_v5m Donwload
Fluorescence_v5l Donwload
Fluorescence_v5x Donwload
Fluorescence_v11n Donwload
Fluorescence_v11s Donwload
Fluorescence_v11m Donwload
Fluorescence_v11l Donwload
Fluorescence_v11x Donwload

Brighfield nuclei detectors

Model Link
Brightfield_v5n Donwload
Brightfield_v5s Donwload
Brightfield_v5m Donwload
Brightfield_v5l Donwload
Brightfield_v5x Donwload
Brightfield_v11n Donwload
Brightfield_v11s Donwload
Brightfield_v11m Donwload
Brightfield_v11l Donwload
Brightfield_v11x Donwload

[!NOTE] Feel free to use the models published here without the plugin!

Plugin functionality

napari-nuclephaser plugin offers following widgets:

  • Widget for inference on single image. Result can be in the form of points or boxes with or without confidence scores. Automatically returns number of cells in the name of result layer.
  • Widget for inference on stack of images. Optionally can create .csv or .xlsx file at given location with counting results.
  • Widget for calibration using known number of cells.
  • Widget for calibration using fluorescent nuclei image (fluorescent nuclei detection model is used as a perfect predictor).
  • Widget for calibration using manual annotations.
  • Widget for transforming Napari Points layer into Labels layer, which allows turning detection in tracking algorithms-digestible form (in particular, btrack).
  • Widget for counting number of points in Points layer.

Learn more about widgets and their functionality at documentation.

Citation

@article {Voloshin2025.05.13.653705,
	author = {Voloshin, Nikita and Putlyaev, Egor and Chechekhina, Elizaveta and Usachev, Vladimir and Karagyaur, Maxim and Bozov, Kirill and Grigorieva, Olga and Tyurin-Kuzmin, Pyotr and Kulebyakin, Konstantin},
	title = {NuclePhaser: a YOLO-based framework for cell nuclei detection and counting in phase contrast images of arbitrary size with support of fast calibration and testing on specific use cases},
	year = {2025},
	doi = {10.1101/2025.05.13.653705},
	URL = {https://www.biorxiv.org/content/early/2025/05/16/2025.05.13.653705},
	eprint = {https://www.biorxiv.org/content/early/2025/05/16/2025.05.13.653705.full.pdf},
	journal = {bioRxiv}
}

Installation

Option 1: Using Anaconda (recommended)

We recommend installation using Anaconda Distribution

  1. Install Anaconda with Installation instructions

  2. Open Anaconda Prompt using Search Bar or Anaconda Navigator

  3. Create new environment with default anaconda packages using command

conda create --name napari-env anaconda
  1. Activate new environment using command
conda activate napari-env
  1. Install Napari using command
pip install napari[all]
  1. Verify napari installation using following command. It should open napari GUI.
napari
  1. Install napari-nuclephaser plugin using command
pip install napari-nuclephaser
  1. Plugin is ready to be used! Start napari by typing
napari

Initialize plugin's widgets by opening Plugins window and choosing NuclePhaser.

Installation with GPU

If you have NVIDIA GPU with CUDA, you can significantly increase plugin's speed.

To install GPU-powered version of the plugin, you first need to do all the steps for the installation using Anaconda (above). Then you need to:

  1. Install CUDA using official instructions

[!NOTE] Check which versions of CUDA are supported by current torch installation and consider installing earlier ones

  1. Check CUDA installation with nvidia-smi command in the command line.
nvidia-smi
  1. In the environment with napari and napari-nuclephaser installed, install CUDA-supported torch by typing specific command for your system, which can be found at torch installation page. For example, if you have Windows-based system and CUDA 12.6, your line should look like
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126

[!WARNING] During our tests, torchvision wasn't installed using this line. To avoid that, add -U after install:

pip3 install -U torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126

Option 2: Using standalone napari app (simpler)

  1. Download and install napari as standalone app using installation instructions

  2. Search, download and install napari-nuclephaser plugin by opening the app, navigating to Plugins window and choosing Install/Uninstall plugins...


This napari plugin was generated with copier using the napari-plugin-template.

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 MIT license, "napari-nuclephaser" is free and open source software

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_nuclephaser-0.1.6.tar.gz (42.5 MB view details)

Uploaded Source

Built Distribution

napari_nuclephaser-0.1.6-py3-none-any.whl (42.5 MB view details)

Uploaded Python 3

File details

Details for the file napari_nuclephaser-0.1.6.tar.gz.

File metadata

  • Download URL: napari_nuclephaser-0.1.6.tar.gz
  • Upload date:
  • Size: 42.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for napari_nuclephaser-0.1.6.tar.gz
Algorithm Hash digest
SHA256 01a463d16c25cdae307c64bcbc980c0eca002e5f8e1bca69c07d68946640423e
MD5 d89bf0fb1e02df470f39acf80d1c5ddb
BLAKE2b-256 1fe9352ceabbcc28c192317bf0589e076b2051406945081dc1f275dd8c218971

See more details on using hashes here.

File details

Details for the file napari_nuclephaser-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for napari_nuclephaser-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 bace24cb224f83bc6800eb8043d7d3c23a4936a4ef5024216af45b621c02968c
MD5 3f30ad9d42dc62438f9adb7e389bd4c5
BLAKE2b-256 1660f26321ca2d775fb97c7655c2227f60fb6f4c6349a2d34a1f5e1874bf28db

See more details on using hashes here.

Supported by

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