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.

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.

Hover with a mouse over a parameter to get a tooltip with short description of functionality. 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.

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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for napari_nuclephaser-0.0.3.tar.gz
Algorithm Hash digest
SHA256 f623e0f01c4b315afbde4086a5ca4f371dca5ec4192fac81257ec9263995d5a9
MD5 15a190e2acd6ebd3346adbf3641a6016
BLAKE2b-256 c2053341c5d02df3795e5bd4b55a8bef17c4ae382b474755544bc7a784506ba9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for napari_nuclephaser-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e286a3cda9c59646ba02122ec8991682ed9a779674f25f01ec2a81126f9f8840
MD5 295d34b3af69bca1da008f7ffd59f563
BLAKE2b-256 8a5edf49ed6d4e02408a4ae67e8a236c07aebcac263caef8384282cf701ac4b0

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