Skip to main content

A toolbox for annotating objects one by one in nD

Project description

napari-nD-annotator

License BSD-3 PyPI Python Version tests codecov napari hub

A toolbox for annotating objects one by one in nD

This plugin contains some tools to make 2D/3D, but basically any dimensional annotation easier. Main features:

  • nD bounding box layer
  • object list from bounding boxes
  • visualizing selected objects from different projections
  • auto-filling labels
  • label slice interpolation (geometric mean, RSPV representation)
  • minimal contour segmentation

This napari plugin was generated with Cookiecutter using @napari's cookiecutter-napari-plugin template.

Installation

You can install napari-nD-annotator via pip:

pip install napari-nD-annotator

The plugin is also available in napari-hub, to install it directly from napari, please refer to plugin installation instructions at the official napari website.

Usage

You can start napari with the plugin's widgets already opened as:

napari -w napari-nD-annotator "Object List" "Annotation Toolbox"

Bounding boxes

The main idea is to create bounding boxes around objects we want to annotate, crop them, and annotate them one by one. This has mainly two advantages when visualizing in 3D:

  1. We don't have to load the whole data into memory
  2. The surrounding objects won't occlude the annotated ones, making it easier to check the annotation.

Bounding boxes can be created from the Object list widget. The dimensionality of the bounding box layer will be determined from the image layer. As bounding boxes are created, a small thumbnail will be displayed.

The proposed pipeline goes as follows:

  1. Create a bounding box layer
  2. Select data parts using the bounding boxes
  3. Select an object from the object list
  4. Annotate the object
  5. Repeat from 3.

Slice interpolation

The Interpolation tab contains tools for estimating missing annotation slices from existing ones. Two methods are implemented:

  • Geometric: the interpolation will be determined by calculating the average of the corresponding contour points.
  • RSPV: A more sophisticated average contour calculation, see the preprint here.

https://user-images.githubusercontent.com/36735863/188876826-1771acee-93ba-4905-982e-bfb459329659.mp4

Minimal contour

This plugin can estimate a minimal contour, which is calculated from a point set on the edges of the object, which are provided by the user. This contour will follow some image feature (pixels with high gradient or high/low intensity). Features:

  • With a single click a new point can be added to the set. This will also extend the contour with the curve shown in red
  • A double click will close the curve by adding both the red and gray curves to the minimal contour
  • When holding Shift, the gray and red highlight will be swapped, so the other curve can be added to the contour
  • With the Ctrl button down a straight line can be added instead of the minimal path
  • If the anchor points were misplaced, the last point can be removed by right-clicking, or the whole point set can be cleared by pressing Esc
  • The Param value at the widget will decide, how strongly should the contour follow edges on the image. Higher value means higher sensitivity to image data, while a lower value will be closer to straight lines.
  • Different features can be used, like image gradient or pixel intensities, and also user-defined features (using Python)
    • the image is accessed as the image variable, and the features should be stored in the features variable in the small code editor widget

This functionality can be used by selecting the Minimal Contour tab in the Annotation Toolbox widget, which will create a new layer called Anchors.

Important note: Do not remove or modify this layer directly!

Note: if any layer is created before opening the Annotation Toolbox widget, some "temporary" layers appear in the layer list. This is not intended, but currently there is no way to hide these. Do not remove or modify these, as this could break the plugin! Whenever possible, open the toolbox first, in order to prevent these from appearing.

Intensity-based:

https://user-images.githubusercontent.com/36735863/191023482-0dfafb5c-003a-47f6-a21b-8582a4e3930f.mp4

Gradient-based:

https://user-images.githubusercontent.com/36735863/191024941-f20f63a0-8281-47d2-be22-d1ec34fe1f5d.mp4

Custom feature:

https://user-images.githubusercontent.com/36735863/191025028-3f807bd2-1f2e-40d2-800b-48af820a7dbe.mp4

License

Distributed under the terms of the BSD-3 license, "napari-nD-annotator" is free and open source software

Issues

Known issues

  • When using the Annotation Toolbox:
    • When deleting a single layer from the layer list, some other layers' names might be overwritten by some "invisible" utility layers. Selecting and unselecting these will restore the original layer.
    • When deleting multiple layers, some strange behavior can happen (layer duplicates appear, only in the layer list; napari breaks etc.). Until fixed, layers should be removed one by one.
    • If any layer is created before opening the Annotation Toolbox widget, some "temporary" layers appear in the layer list. For further information see the Minimal contour section

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-nD-annotator-0.0.8.tar.gz (501.7 kB view hashes)

Uploaded Source

Built Distributions

napari_nD_annotator-0.0.8-cp310-cp310-win_amd64.whl (817.3 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

napari_nD_annotator-0.0.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.8 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

napari_nD_annotator-0.0.8-cp310-cp310-macosx_10_9_x86_64.whl (947.3 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

napari_nD_annotator-0.0.8-cp39-cp39-win_amd64.whl (832.5 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

napari_nD_annotator-0.0.8-cp39-cp39-win32.whl (802.1 kB view hashes)

Uploaded CPython 3.9 Windows x86

napari_nD_annotator-0.0.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.8 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

napari_nD_annotator-0.0.8-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (2.7 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

napari_nD_annotator-0.0.8-cp39-cp39-macosx_10_9_x86_64.whl (964.9 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

napari_nD_annotator-0.0.8-cp38-cp38-win_amd64.whl (836.9 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

napari_nD_annotator-0.0.8-cp38-cp38-win32.whl (805.1 kB view hashes)

Uploaded CPython 3.8 Windows x86

napari_nD_annotator-0.0.8-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.9 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

napari_nD_annotator-0.0.8-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (2.8 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

napari_nD_annotator-0.0.8-cp38-cp38-macosx_10_9_x86_64.whl (955.8 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

Supported by

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