Adding function: compute_directional_change#912
Open
X-Deng wants to merge 3 commits intoneuroinformatics-unit:mainfrom
Open
Adding function: compute_directional_change#912X-Deng wants to merge 3 commits intoneuroinformatics-unit:mainfrom
X-Deng wants to merge 3 commits intoneuroinformatics-unit:mainfrom
Conversation
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
What is this PR
Why is this PR needed?
Directional change (DC) is a trajectory-based metric that quantifies how rapidly an individual changes direction per unit time. Unlike purely geometric measures such as sinuosity or straightness, DC incorporates temporal information and can distinguish trajectories with identical shapes but different speeds.
This metric is widely used in movement ecology and behavioural analysis (e.g. Kitamura & Imafuku, 2015), and is particularly relevant for high-temporal-resolution pose tracking data.
What does this PR do?
Adds a new function
compute_directional_changetomovement.kinematicsComputes per-time-step directional change:
DC_i = |θ_i| / (t[i+1] - t[i-1])
Uses signed turning angles between consecutive displacement vectors
Handles edge cases:
Supports broadcasting across individuals and optional keypoints
Follows existing kinematics/orientation module conventions
References
Related to #907
How has this PR been tested?
Unit tests have been added to cover:
All tests pass locally using
pytest, and all pre-commit checks pass successfully.Is this a breaking change?
No.
Does this PR require an update to the documentation?
Not yet. This functionality can be documented in a follow-up PR if needed.
Checklist: