Open talmo opened 1 month ago
Thanks @talmo for such a thorough description. This is indeed a very useful feature and we've been planning to add it from the project's conception.
Your sketched out implementation makes sense to me conceptually, and it could fit in well into the codebase, with a few modifications. The functions would have to accept and return xarray.DataArray
objects (i.e. data variables) instead of numpy
arrays, similar to the existing functions in our kinematics and filtering modules.
The best place for the main function would probably be a new transforms.py
module, as we are likely to add more coordinate transforms in future. I envision something along the lines of from movement.transforms import to_egocentric
. Utilities like signed_angle
can go into utils/vector.py
.
I'm happy for you or someone from your team to have a shot at opening a draft pull request to get this started. If the need arises, I'd be also willing to hop on a call to explain our thoughts on the architecture. If our ongoing API changes get in the way of merging, we can always step in and help with that.
Is your feature request related to a problem? Please describe. For many analyses, it's super nice to have a way to align the animal such that the centroid is at the origin and the head is aligned to the x-axis. This is sometimes referred to as "egocentrization" since it places all the points in the animal-centric coordinate frame.
This is useful for:
Describe the solution you'd like
Here's the nicely vectorized implementation we've used for a while:
Describe alternatives you've considered We've done it ourselves :)
Additional context I know there's been some discussion on APIs and etc., so I don't want to step on your style guide. Given some guidance, happy to shoot a PR or have a student work on it :)