Skip to content

Annotations extras #13228

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

Open
wants to merge 52 commits into
base: main
Choose a base branch
from
Open

Conversation

PierreGtch
Copy link

@PierreGtch PierreGtch commented Apr 24, 2025

Reference issue (if any)

This PR replaces #13213

What does this implement/fix?

The difference with #13213 is that the additional information is a list[dict[str, str | int | float | None]] instead of a dataframe

@PierreGtch PierreGtch marked this pull request as ready for review April 25, 2025 09:36
@PierreGtch
Copy link
Author

@drammock I implemented here the recommendations in your #13213 (comment)

Copy link
Member

@drammock drammock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a quick first pass with some high-level stuff, LMK when I should take another look @PierreGtch

Copy link
Member

@agramfort agramfort left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am onboard with the change although I am not convinced about the word "details"

Co-authored-by: Alexandre Gramfort <[email protected]>
Co-authored-by: Daniel McCloy <[email protected]>
@PierreGtch PierreGtch changed the title Annotations details Annotations ~details~ extras Apr 26, 2025
@PierreGtch PierreGtch changed the title Annotations ~details~ extras Annotations extras Apr 26, 2025
Copy link
Member

@drammock drammock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is close. I've left several questions below. One thing I want to make sure of (but ran out of time to check) is that users can modify extras in-place (the way they can with onset, duration, etc). In other words:

annotations.onset[3] = 7.1  # this works
annotations.extras[3] = dict(reaction_time=0.7)  # this should be possible
annotations.extras[3].update(dict(button="left"))  # this also should be possible

@PierreGtch
Copy link
Author

@drammock I addressed your comments but left some questions. In particular:

annotations.extras[3].update(dict(button="left"))  # this also should be possible

This is possible and the type of the new extras will be checked

annotations.extras[3] = dict(reaction_time=0.7)  # this should be possible

This is also possible but the type of the new extras will NOT be checked. You think this would be an issue?
To enforce it, a possibility would be to also write a custom list class which would overwrite __setitem__ to replace the input dict with an _AnnotationsExtraDict

Feel free to merge if you are satisfied with the current state :)

@drammock
Copy link
Member

drammock commented May 1, 2025

This is also possible but the type of the new extras will NOT be checked. You think this would be an issue?

I think this may be the more common use case (it more closely mirrors what users currently do with the description field for example). A custom subclass of list is indeed probably the right way to solve it; I'm doing something very similar here:

https://github.com/mne-tools/mne-python/pull/13059/files#diff-8958de0220265a954fac8d4e75521b1917748cdd5e15ce759b5e627b1d401b7cR779-R783

@PierreGtch
Copy link
Author

All good @drammock :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

container for eye tracking related annotation information
4 participants