Skip to content

support different time formats in Annotations.to_data_frame() #12289

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

Merged
merged 6 commits into from
Dec 12, 2023

Conversation

drammock
Copy link
Member

@drammock drammock commented Dec 11, 2023

it's working, but a bit hackish, so marking as draft while I clean it up.
closes #12274

In [1]: import mne
In [2]: foo = mne.Annotations(onset=[1,5,11], duration=[2, 2, 3], description=list('abc'))
In [3]: foo.to_data_frame(None)
Out[3]: 
   onset  duration description
0    1.0       2.0           a
1    5.0       2.0           b
2   11.0       3.0           c
In [4]: foo.to_data_frame("datetime")
Out[4]: 
                onset  duration description
0 1970-01-01 00:00:01       2.0           a
1 1970-01-01 00:00:05       2.0           b
2 1970-01-01 00:00:11       3.0           c
In [5]: foo.to_data_frame("ms")
Out[5]: 
   onset  duration description
0   1000       2.0           a
1   5000       2.0           b
2  11000       3.0           c
In [6]: foo.to_data_frame("timedelta")
Out[6]: 
            onset  duration description
0 0 days 00:00:01       2.0           a
1 0 days 00:00:05       2.0           b
2 0 days 00:00:11       3.0           c

@drammock drammock marked this pull request as ready for review December 11, 2023 23:16
@drammock
Copy link
Member Author

@dengemann does this meet your needs?

@dengemann
Copy link
Member

Looks awesome! This will facilitate interactive prototyping of analyses of signal windows with irregular duration. LGTM!

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.

❤️

@larsoner
Copy link
Member

Nice, I think it just needs a devel.rst update, feel free to mark for merge-when-green once you push one @drammock !

drammock and others added 2 commits December 12, 2023 12:02
Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
@drammock drammock enabled auto-merge (squash) December 12, 2023 18:14
@drammock drammock merged commit 4e2a600 into mne-tools:main Dec 12, 2023
@drammock drammock deleted the annotation-dataframe branch December 12, 2023 19:16
snwnde pushed a commit to snwnde/mne-python that referenced this pull request Mar 20, 2024
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.

ENH: make use of time-stamps optional in mne.Annotations.to_data_frame()
4 participants