-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add functionality for computing ego- and allocentric angles to RoIs #416
base: main
Are you sure you want to change the base?
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
0bf884f
to
df84664
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great job consolidating all this work @willGraham01 !
The vast majority of my comments are about simplifying the function signatures, renaming variables to more intuitive names, and clarifying docstrings.
Re the implementation, I spotted an error with how the normal to a plane is computed. This is currently not captured by the tests because we test with a segment starting at the origin - I explain and provide examples in the comments. For the rest, it mostly looks good and clear to me. I mainly commented on things that may reduce the complexity (for example, removing _vector_from_centroid_of_keypoints
or fixing some conventions to keep the function signatures short).
I have two additional more general comments:
- I think we should review these new ROI additions and make sure we highlight to the users when we assume the camera is top-down/bottom-up - this may be out of the scope of this PR though but something to keep in mind.
- We should think or check with the researchers (e.g. Sepi) what offset in angle with respect to a plane makes more sense in terms of interpretation. For example, if the head vector is at 0 deg wrt a wall or boundary - would that be interpreted as facing the wall? or is the animal's back to the wall? Not a big issue but maybe worth discussing. Right now, the animal is at 0deg when it has its back (of the head) to the wall.
I tagged @niksirbi in a few of the comments to get his view (and any other comments on the rest are more than welcome too). But I think to avoid duplicate effort it would be most useful if he reviews this PR after the suggested changes are reviewed. I also focused much less on the tests, so maybe that is something he can focus on more next.
This comment was marked as resolved.
This comment was marked as resolved.
@sfmig @niksirbi I think I've captured everything caught in the initial review and as discussed in the community call today. Key changes that are more than just renames / reorganisations:
Also, tests are failing due to an internal server error fetching sample data in a place unrelated to this PR. Will re-run in a bit to give the server a chance 😅 |
return angles | ||
|
||
@staticmethod | ||
def _reassign_space_dim( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!! ✨
Sounds great! Thanks both, I will do my own pass over this PR and try to finalise my review by end of Monday. |
Description
What is this PR
Why is this PR needed?
Introduces features necessary for computing ego- and allocentric boundary angles.
What does this PR do?
See the discussion in 370 for disambiguation of terms.
Several related methods are added to the RoI class. Most of these are self-evident from the name.
compute_distance_to
compute_nearest_point_to
compute_approach_vector
compute_allocentric_angle
compute_egocentric_angle
These methods are added to the base region of interest class, so they can be used by all regions of interest.
In addition,
LineOfInterest
has also been given two additional methods;normal
- returns the normal to the segment / linecompute_angle_to_support_plane_of_segment
- this performs the egocentric calculation, but using the normal vectorNOTE: There are a lot of features going in here which are interconnected, but the PR diff is still quite large. It is possible to break the addition of
compute_distance_to
andcompute_nearest_point_to
out into its own PR without too much difficultly, but all the other methods are very much interconnected and need to come in at the same time.References
This functionality should close both #368 and #370.
In particular, we now have the functionality to do any of the calculations discussed in #370. This includes using the normal vector in place of the approach vector when considering a segment (
compute_angle_to_support_plane_of_segment
). Polygonal regions do not have this option, due to this behaviour being ill-defined at corners, but users can access the individual segments that make up the polygon's boundary, which areLineOfInterest
s, and then callcompute_angle_to_support_plane_of_segment
on the segment they deem appropriate.How has this PR been tested?
Addition of tests to the test suite.
Dependence on
shapely
methods has been preferred throughout.Is this a breaking change?
Does this PR require an update to the documentation?
Could potentially give more scope to the examples that are made as part of #415.
Checklist: