-
Notifications
You must be signed in to change notification settings - Fork 16
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
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.
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.
Alright, I've gone through this now @willGraham01.
The main points that need attention are:
- some formatting errors in docstrings (I've pointed them out in individual comments)
- it's not clear to me what the support plane method will do in the case of a multi-line segment (>2 points). This needs clarification and testing.
- we should consider renaming the
forward_vector
to sth more general, I will tag you and Sofia in the relevant comment.
Good catch as I had completely forgotten that we support cases like this! Right now it's always returning the normal to the first segment of a multi-line geometry, due to how the implementation is implemented. Possible solutions:
Given the extra complexity this could potentially introduce, I'm inclined to go with the "only single-line segments" approach for now. Then we can extend on this in another PR if we want? Right now this PR is doing a lot already 😅 |
I think this makes sense for now. Would a 4th option be: treat multi-segment geometries as polygons? |
|
Because I agree re this PR being already too much, I'd say:
|
Have opened #439 so we don't forget about normals. With that, I think all comments are addressed? So.... please review again guys? 😅 |
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.
Approved by me, with some finishing touches.
Co-authored-by: Niko Sirmpilatze <[email protected]>
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.
fantastic job @willGraham01 !
Some minor comments for consistency but otherwise looks nice and clear
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: