-
Notifications
You must be signed in to change notification settings - Fork 27
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
Reframe polar coordinates example around head direction #426
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #426 +/- ##
==========================================
+ Coverage 99.84% 99.87% +0.03%
==========================================
Files 23 27 +4
Lines 1250 1605 +355
==========================================
+ Hits 1248 1603 +355
Misses 2 2 ☔ View full report in Codecov by Sentry. |
d973c46
to
b7539cc
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.
Looks nice ✨ - a bit more compact than before.
I added some comments, a couple are a bit more substantial but I leave it up to you to assess their importance.
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.
Some comments about the cartesian coordinates diagram:
- can we translate the red and green axes so that their origin is exactly on top of the origin marker? As it is now it can be confusing.
- Similarly, I think it would be clearer if the dotted lines go directly from the axes.
- I think we can also do away with the purple pixel, as the position is not necessarily constrained to be a pixel centre.
- I think I would do away with the "positive angle" inset in the cartesian coordinates and have it in the polar coordinates diagram instead. I realise it mixes a bit both things, but I think it would make the explanation clearer if we put it in the polar coordinates context.
- maybe we can add a small text to the diagram to clarify it exemplifies cartesian coordinates specifically in the image coordinate system.
Re the polar coordinates diagram:
- since we define the positive phi relative to the positive x-axis, I think it would be helpful to plot the image coordinate x and y positive axes in this diagram too. Then you can indicate the sign of the angle by changing the
phi
text tophi > 0
(the rotation arrow already implies a sign) .
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.
Thanks for this very helpful feedback @sfmig.
Have I succeeded in implemented your comments graphically?
Note that I removed the greek spelling for rho and phi (to declutter the polar plot a bit). Besides, I wasn't even using the greek spelling for pi.
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.
Looks great!!
I like the "in the image coordinate system" subtitle - what do you think if we can add it to the polar coordinates too? (not sure tho)
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.
why not, I will add it.
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.
"Top-Down" ---> "Top-down"
(for consistency with "Bottom-up")
I would place the coordinate system origin at the top left corner of the frame (rather than slightly offset and outside of the frame). Or if you want, at the centre of the top-left pixel, but I think simplifying to just the top left corner in the diagrams after the first one should be enough.
Would it be helpful to sketch a mouse's dorsal / ventral view for extra clarity? (and possibly extra cuteness)
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.
yup adding the dorsal/ventral views would be very helpful.
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.
As before I would place the axes with its origin matching the "origin" marker.
I comment on this below, but I think we can use the diagram on the left to introduce the point U vs vector u concept (rather than repeating the other image coordinate system diagram). So maybe instead of a random "position" vector, we plot the U point and the u vector.
Also: I wonder if we can remove the text with "Image/Video frame" - I think that should be clear... Or maybe we can keep it only in the first diagram?
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.
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.
yes, looks great! thanks Niko
head_to_snout_angles = head_to_snout_polar.sel(space_pol="phi") | ||
forward_vector_angles = forward_vector_angle |
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.
head_to_snout_angles = head_to_snout_polar.sel(space_pol="phi") | |
forward_vector_angles = forward_vector_angle | |
head_to_snout_angle = head_to_snout_polar.sel(space_pol="phi") |
Is forward_vector_angles = forward_vector_angle
worth renaming?
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.
Not really, you are right.
# dimension with two coordinates: ``x`` and ``y``. | ||
|
||
head_to_snout_cart = pol2cart(head_to_snout_polar) | ||
print(head_to_snout_cart) |
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.
Maybe instead of printing (which potentially doesn't add much) we can assert that the output is the same as head_to_snout
.
Or if we want to keep the print statement, we can add a line in text to notice that the space coordinates are back to 'x' and 'y'.
Co-authored-by: sfmig <[email protected]>
for more information, see https://pre-commit.ci
|
Description
What is this PR
Why is this PR needed?
Closes #317
What does this PR do?
The updating of this example was was long overdue, as it was written before we had forward vectors and their angles and all the jazz. In the updated example, the primary focus is on head direction, and polar coordinate systems are mentioned in passing as a useful representation (instead of the other way around).
I basically provide two methods for computing head direction vector
At the end I compare the angles derived from both methods using polar histograms. Note that the "old" way is still valuable, in case there are no handy bilaterally symmetric keypoints, but only a posterior and anterior one.
While I was at it, I added several "notes" about coordinate systems and linear algebra concepts. Let me know if they are too much, we could omit them or "collapse" them.
To not have this example balloon out of all proportion (it's already very long) I removed some of the old example's content. I also deliberately chose no to demonstrate forward angle relative to moving reference vectors (e.g. another animal). That usage is better suited for a "social interactions" example.
I also added an exception to the ruff rules, to not enforce import statements being at the top of the file. This exception applies to all examples, where it's often advantageous to have the imports close to where you need them (for teaching purposes).
The best way to review this is by building the example locally, looking at the diff won't help much.
How has this PR been tested?
Local docs build completes without errors.
Is this a breaking change?
No.
Checklist: