napari-organoid-counter

napari-organoid-counter

A plugin to automatically count lung organoids

Description

A napari plugin to automatically count lung organoids from microscopy imaging data. A Faster R-CNN model was trained on patches of microscopy data. Model inference is run using a sliding window approach, with a 50% overlap and the option for predictiing on multiple window sizes and scales, the results of which are then merged using NMS.

Alt Text

What's new in v2?

Here is a list of the main changes v2 of napari-organoid-counter offers:

  • Use of Faster R-CNN model for object detection
  • Pyramid model inference with a sliding window approach and tunable parameters for window size and window downsamplign rate
  • Model confidence added as tunable parameter
  • Allow to load and correct existing annotations (note: these must have been saved previously from v2 of this plugin)
  • Object ID along with model confidence displayed in the viewer - this can now be related to box id in csv file of extracted features
  • Fixed: box thickness changing at different donwsampling rates
  • Possibility to work interactively with different shape layers at the same time, go back adjust parameters and switch between shape layers from layer list selection

Technical Extensions:

  • Allows for Python 3.10
  • Extensive testing

Quickstart

The use of the napari-organoid-counter plugin is straightforward. Here is a step-to-step guide of the standard workflow:

  1. You can load the image or images you wish to process into the napari viewer with a simple drag and drop
  2. You can then select the layer you wish to work on by the drop-down box at the top of the input configurations
  3. To improve the way the image is visualised you can pre-process them by clicking the Preprocess button and the image layer will automatically be updated with the result
  4. If you have a Faster R-CNN model you wish to use for the prediction, you can browser and select this by clicking on the Choose button. Otherwise, the default model will be automatically downloaded from here. Note that your own model must follow the specifications described here (TODO).
  5. You can adjust the Window sizes and Downsampling parameters to define the window size in the sliding window inference and the downsampling that is performed on the window. If you have multiple objects with different sizes, it might be good to set multiple window sizes, with corresponding downsampling rates. You can seperate these with a comma in the text box (e.g. 2048, 512). After you have set Window sizes and Downsampling hit Enter for the chanegs to be accepted.
  6. By clicking the Run Organoid Counter button the detection algorithm will run and a new shapes layer will be added to the viewer, with bounding boxes are placed around the detected organoid. You can add, edit or remove boxes using the layer controls window (top left). The Number of detected organoids will show you the number of organoids in the layer in real time. You can switch between viewing the box ids and model confidence for each box by toggling the display text box in the layer controls window. Boxes added by the user will by default have a confidence of 1.
  7. If you feel that your model is over- or under-predicting you can use the Model confidence scroll bar and select the value which best suits your problem. Default confidence is set to 0.8.
  8. If you objects are typically bigger or smaller than those displayed you can use the Minimum Diameter slider to set the minimum diameter of your objects. Default value is 30 um.
  9. After you are happy with the detection results (and your manual corrections if any), you can select which shapes layer results to save via the dropdown box. To save the bounding box coordinates (along with the box id, model confidence for that box, and x and y scale for that image) as a json file click Save boxes and select where to save your file. The features can be saved in a csv file by clicking on the Save features. The saved features will include the organoid id, the two lengths of the boundig box (which corresponds to the min. and max. diameter of the organoid, approximated as an ellipse), the area of the organoid (again approximated as an ellipse).
  10. Additional options: The Take Screenshot button has the same functionality as File -> Save screenshot. The Reset Configs button will reset the image and all parameters to the original settings. To save features of the detected organoids (diameters when approximating organoid as an ellipse and organoid area) in a csv file click Save features.

Getting Help

If you encounter any problems, please [file an issue] along with a detailed description.

Intended Audience & Supported Data

This plugin has been developed and tested with 2D CZI microscopy images of lunch organoids. The images had been previously converted from a 3D stack to 2D using an extended focus algorithm. This plugin may be used as a baseline for developers who wish to extend the plugin to work with other types of input images and/or improve the detection algorithm.

Dependencies

napari-organoid-counter uses the napari-aicsimageio[1] plugin for reading and processing CZI images.

[1] AICSImageIO Contributors (2021). AICSImageIO: Image Reading, Metadata Conversion, and Image Writing for Microscopy Images in Pure Python [Computer software]. GitHub. https://github.com/AllenCellModeling/aicsimageio

How to Cite

If you use this plugin for your work, please cite it using the following:

@software{christina_bukas_2022_6457904,
  author       = {Christina Bukas},
  title        = {{HelmholtzAI-Consultants-Munich/napari-organoid- 
                   counter: first release of napari plugin for lung
                   organoid counting}},
  month        = apr,
  year         = 2022,
  publisher    = {Zenodo},
  version      = {v0.1.0-beta},
  doi          = {10.5281/zenodo.6457904},
  url          = {https://doi.org/10.5281/zenodo.6457904}
}

Version:

  • 0.2.0

Last updated:

  • 24 April 2023

First released:

  • 13 April 2022

License:

  • MIT

Supported data:

  • Information not submitted

Plugin type:

  • Information not submitted

GitHub activity:

  • Stars: 9
  • Forks: 2
  • Issues + PRs: 5

Python versions supported:

Operating system:

Requirements:

  • napari[all] (>=0.4.17)
  • napari-aicsimageio (>=0.7.2)
  • torch (>=1.13.1)
  • torchvision (>=0.14.1)
  • zenodo-get (==1.3.4)

Sign up to receive updates