Skip to main content

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.

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 inclues obss/sahi functionality, allowing detection on images of arbitrary sizes.
  • 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.

Inference examples

Calibration algorithm

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

Confidence threshold

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.

Calibration methods

Models

Currently only YOLOv5n, YOLOv5s, YOLOv11n and YOLOv11s models, as well as fluorescent nuclei detector YOLOv5s are available (downloaded automatically with pip install napari-nuclephaser). We are currently working on adding YOLOv5m-x and YOLOv11m-x models.

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.

We are currently working on documentation with full description of widgets and their parameters. For now, if you have questions about widgets and/or parameters, please refer to ultralytics documentation and obss/sahi documentation

Citation

We are currently working on a paper with full description of our approach and how we trained and tested our models.


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

Installation

You can install napari-nuclephaser via pip:

pip install napari-nuclephaser

To install latest development version :

pip install git+https://github.com/nikvo1/napari-nuclephaser.git

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.

Metadata

Release files for napari-nuclephaser 0.0.2

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

Source distribution (sdist)

Source distribution for napari-nuclephaser 0.0.2
File Size Uploaded
napari_nuclephaser-0.0.2.tar.gz 42.5 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for napari-nuclephaser 0.0.2
File Interpreter ABI Platform
napari_nuclephaser-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 84.9 MB

Release files / napari_nuclephaser-0.0.2.tar.gz

Download URL napari_nuclephaser-0.0.2.tar.gz
Size 42.5 MB
Tags Source
SHA-256 checksum
How to use checksums
a7fb572d7f48a53d3ce3fd61e0638b58828d2c120d5ba3b4c92af6cf58e522d9
BLAKE2b-256 checksum
How to use checksums
e6d0e9878f90b911c614b9220c9ff61e37e68586813ac6ded65950128d9b91a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release files / napari_nuclephaser-0.0.2-py3-none-any.whl

Download URL napari_nuclephaser-0.0.2-py3-none-any.whl
Size 42.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
12648f230feeae808419831200817ad83575700435c66b3bef432644faefcf04
BLAKE2b-256 checksum
How to use checksums
1a9505e237b9ff1adcea0908544433b97f488cbdcb24be281c15d08df8cb5a65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release history Release notifications | RSS feed

0.5.0

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

This release

0.0.2 This release

2 release files

0.0.1

2 release files

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