Skip to content

Added napari plugin for reviewing and correcting bounding box annotations#144

Open
GauravSRC wants to merge 5 commits into
neuroinformatics-unit:mainfrom
GauravSRC:feature/issue-9-napari-annotation-review
Open

Added napari plugin for reviewing and correcting bounding box annotations#144
GauravSRC wants to merge 5 commits into
neuroinformatics-unit:mainfrom
GauravSRC:feature/issue-9-napari-annotation-review

Conversation

@GauravSRC

Copy link
Copy Markdown

Summary

Closes #9.

Adds a napari plugin to ethology so that automatically generated bounding
box annotations can be loaded into napari, manually reviewed and corrected,
and then exported back to a COCO JSON file.

Changes

New package – ethology/napari/

File Purpose
_reader.py napari reader plugin: detects COCO/VIA JSON files and converts the ethology xr.Dataset to a napari Shapes layer (one rectangle per bounding box, coloured by category_id).
_writer.py napari writer plugin: converts the (corrected) Shapes layer back to an ethology dataset and calls save_bboxes.to_COCO_file. Only rectangle shapes are exported; non-rectangle shapes are silently skipped.
widgets.py make_correction_widget – a magicgui-based container with two panels: Load annotations (file picker + format selector) and Save corrected annotations (output file picker).
napari.yaml Plugin manifest registering the reader, writer, and widget.

pyproject.toml

  • Added [project.entry-points."napari.manifest"] for plugin discovery.
  • Added napari optional-dependency group (napari>=0.4.19, magicgui, qtpy).
  • Added [tool.setuptools.package-data] so napari.yaml is included in the sdist.

Tests

  • tests/test_unit/test_napari/test_reader.py – unit tests for format
    detection, napari_get_reader, _reader_function, and shape geometry
    correctness.
  • tests/test_unit/test_napari/test_writer.py – unit tests for
    _shapes_to_dataset, write_shapes, and two full round-trip tests
    (annotation count + coordinate fidelity).
  • tests/test_unit/test_datasets/test_split.py – placeholder for future
    dataset-splitting tests.

How to test manually

pip install -e ".[napari,dev]"
napari path/to/annotation_file.json   # opens Shapes layer automatically
# or: Plugins → Annotation Correction → load file → correct → save

Notes

  • The reader and writer are pure-Python and tested without a display.
  • The widget tests are not included (they require a running Qt application);
    those will be added in a follow-up using pytest-qt.
  • test_split.py is a placeholder; the split implementation is tracked
    separately.

GauravSRC and others added 2 commits March 22, 2026 19:23
…ns (issue neuroinformatics-unit#9)

- ethology/napari/_reader.py  – napari reader: COCO/VIA file → Shapes layer
- ethology/napari/_writer.py  – napari writer: Shapes layer → COCO file
- ethology/napari/widgets.py  – magicgui widget (load + save panel)
- ethology/napari/napari.yaml – plugin manifest (reader, writer, widget)
- pyproject.toml              – napari entry-point, optional deps, package-data
- tests/test_unit/test_napari/test_reader.py
- tests/test_unit/test_napari/test_writer.py  (incl. round-trip tests)
- tests/test_unit/test_datasets/test_split.py (placeholder)
@codecov

codecov Bot commented Mar 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.36364% with 39 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.85%. Comparing base (33adaa5) to head (dfddb67).

Files with missing lines Patch % Lines
ethology/napari/widgets.py 0.00% 36 Missing ⚠️
ethology/napari/_reader.py 96.20% 3 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (33adaa5) and HEAD (dfddb67). Click for more details.

HEAD has 5 uploads less than BASE
Flag BASE (33adaa5) HEAD (dfddb67)
10 5
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #144       +/-   ##
===========================================
- Coverage   99.45%   78.85%   -20.60%     
===========================================
  Files           8       11        +3     
  Lines         554      719      +165     
===========================================
+ Hits          551      567       +16     
- Misses          3      152      +149     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Review and correct automatically generated annotations

1 participant