Implemented head angle velocity #855
Open
Edu92337 wants to merge 1 commit intoneuroinformatics-unit:mainfrom
Open
Implemented head angle velocity #855Edu92337 wants to merge 1 commit intoneuroinformatics-unit:mainfrom
Edu92337 wants to merge 1 commit intoneuroinformatics-unit:mainfrom
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #855 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 36 36
Lines 2220 2245 +25
=========================================
+ Hits 2220 2245 +25 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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?
There was no built-in way to compute the angular velocity of the head direction over time. The naive approach — computing the polar angle of the head direction vector and differentiating — produces noisy results with large spikes at the ±π boundary due to angle wrapping.
What does this PR do?
Adds
compute_head_angle_velocityto the kinematics module. The function:compute_forward_vector_anglescipy.stats.circmean) over a configurable window to reduce noise while correctly handling the ±π boundaryAlso adds the private helper
_rolling_circmean, which appliesscipy.stats.circmeanin a centred sliding window along a 1D array.References
Closes #367
How has this PR been tested?
Two new test classes in
tests/test_unit/test_kinematics/test_kinematics.py:TestRollingCircmean— tests the private helper in isolation: identity for window=1, constant signal, shape preservation, and correct circular averaging near the ±π boundaryTestComputeHeadAngleVelocity— tests the public function: output name and dimensions, constant angular velocity for a known spinning fixture (π/4 rad/frame), smoke test for larger smoothing windows, and all three validation error paths (TypeErrorfor baddata,TypeError/ValueErrorfor badsmoothing_window)Existing tests were run locally to confirm no regressions.
Is this a breaking change?
No.
Does this PR require an update to the documentation?
Yes.
compute_head_angle_velocityshould be added to the API reference page for the kinematics module.Checklist: