Skip to content

feat: added from_idtracker to generate bbox annotations from idtracker.ai (#8)#150

Open
GauravSRC wants to merge 3 commits into
neuroinformatics-unit:mainfrom
GauravSRC:feat/idtracker-bbox-annotations
Open

feat: added from_idtracker to generate bbox annotations from idtracker.ai (#8)#150
GauravSRC wants to merge 3 commits into
neuroinformatics-unit:mainfrom
GauravSRC:feat/idtracker-bbox-annotations

Conversation

@GauravSRC
Copy link
Copy Markdown

@GauravSRC GauravSRC commented Mar 30, 2026

Closes #8

Summary

Adds ethology/io/annotations/load_idtracker.py with a public function
from_idtracker that converts idtracker.ai output files into a valid
ethology bounding box annotations xr.Dataset that can be reviewed
by a human and then exported with the existing save_bboxes.to_COCO_file.

New files

File Purpose
ethology/io/annotations/load_idtracker.py from_idtracker + two private helpers
tests\test_unit\test_io_annotations\test_load_idtracker.py 40 unit tests, synthetic data only

How it works

Inputs

Parameter Type Notes
trajectories_path .npy path shape (n_frames, n_animals, 2)
frame_indices list[int] 0-based, duplicates removed silently
bbox_size (width, height) required when blobs_collection_path is None
blobs_collection_path .pkl path optional; uses actual blob bboxes when present
images_dir path stored in attrs, not required for computation

Output -- xr.Dataset validated by ValidBboxAnnotationsDataset:

  • position (image_id, space, id)-- centroid (x, y) in pixels
  • shape (image_id, space, id) -- (width, height) in pixels
  • category (image_id, id) -- 1-based animal identity

Frames where an animal is undetected (NaN centroid in trajectories / no
blob with matching identity) produce NaN in position/shape and
-1 in category, consistent with the NaN-padding convention used
throughout the rest of the codebase.

Testing

All tests use synthetic numpy arrays and unittest.mock.MagicMock
blobs -- no external test-data files or network access are needed.

Checklist

  • New module follows the exact same import / decorator pattern as load_bboxes.py
  • Output is validated by @_check_output(ValidBboxAnnotationsDataset)
  • Full docstring with Parameters, Returns, Raises, Notes, Examples
  • All private helpers have their own docstrings and unit tests
  • No changes to existing files

@GauravSRC GauravSRC force-pushed the feat/idtracker-bbox-annotations branch from ad97a58 to 6813fcf Compare March 30, 2026 21:01
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.

Generate bounding boxes annotations using idtracker

1 participant