Skip to content

feat: add compute_polarization() to collective behavior metrics#875

Draft
khan-u wants to merge 1 commit intoneuroinformatics-unit:mainfrom
khan-u:add-collective-behavior-metrics
Draft

feat: add compute_polarization() to collective behavior metrics#875
khan-u wants to merge 1 commit intoneuroinformatics-unit:mainfrom
khan-u:add-collective-behavior-metrics

Conversation

@khan-u
Copy link

@khan-u khan-u commented Mar 7, 2026

Description

What is this PR

  • Bug fix
  • Addition of a new feature
  • Other

Why is this PR needed?

Movement currently lacks collective behavior metrics for analyzing multi-individual tracking data. Polarization is a fundamental metric for measuring group alignment, widely used in collective behavior studies of fish schools, bird flocks, and other animal groups.

What does this PR do?

Adds compute_polarization() function that measures how aligned the heading directions of multiple individuals are. Returns values from 0 (random orientations) to 1 (perfectly aligned).

References

Partial implementation of #873 (adds compute_polarization)

How has this PR been tested?

  • Added 9 unit tests in tests/test_unit/test_kinematics/test_collective.py
  • Tests cover: aligned individuals, opposite directions, keypoint-based heading, NaN handling, value range validation, and input validation errors
  • All 1136 existing tests pass
  • collective.py has 97% test coverage

Is this a breaking change?

No. This adds a new function without modifying existing functionality.

Does this PR require an update to the documentation?

API documentation will be auto-generated from docstrings. No manual documentation update required for this PR.

Checklist:

  • The code has been tested locally
  • Tests have been added to cover all new functionality
  • The documentation has been updated to reflect any changes
  • The code has been formatted with pre-commit

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 7, 2026

@khan-u khan-u mentioned this pull request Mar 7, 2026
9 tasks
@khan-u khan-u changed the title feat: Add compute_polarization for collective behavior analysis feat: add compute_polarization() (#873) Mar 9, 2026
@khan-u khan-u changed the title feat: add compute_polarization() (#873) feat: add compute_polarization() to collective behavior metrics Mar 9, 2026
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.

1 participant