-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[MRG] Get multiple spaced events from single annotation #5795
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
Conversation
b243063 to
b906d9d
Compare
Codecov Report
@@ Coverage Diff @@
## master #5795 +/- ##
==========================================
- Coverage 88.53% 88.41% -0.12%
==========================================
Files 369 369
Lines 68955 69041 +86
Branches 11614 11623 +9
==========================================
- Hits 61048 61046 -2
- Misses 5048 5131 +83
- Partials 2859 2864 +5 |
mne/annotations.py
Outdated
|
|
||
| logger.info('Used Annotations descriptions: %s' % | ||
| (list(event_id_.keys()),)) | ||
| for onset, duration, description in iterator: |
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.
I would like to add slicing of the annotations so that this can be:
for onset, duration, description in raw.annotations[event_sel]:
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.
but this can be done afterwards
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 a __getitem__ that returns a copy and a __iter__ method (or whatever the correct Py3k one is named) would be good at some point
|
@Slasnista you should be able to get the psg events just by doing the following: raw = mne.io.read_raw_edf(psg_fname, stim_channel=False)
annotations = mne.read_annotations(hyp_fname)
desc2int = {'Sleep stage W': 5,
 'Sleep stage 1': 3,
 'Sleep stage 2': 2,
 'Sleep stage 3': 1,
 'Sleep stage 4': 1,
 'Sleep stage R': 4}
events, event_id = mne.events_from_annotations(raw, event_id=desc2int, chunk_duration=30) |
7f53b9b to
402b990
Compare
|
I've reverted the last commits where I refactored the code to be simpler because it was messing up with EDF and to fix it would complicate the PR. I'll get back to it once EDF #5741 is in and |
|
@massich you have some pep8 errors. |
|
@massich you need to rebase |
a585188 to
a8d8b9f
Compare
|
@larsoner can you merge? |
|
After a talk IRL with @agramfort we decided to set back regexp to I see the value of |
|
Did I forgot to take them out from the signature? I'm AFK. Feel free to
take them out and merge if you want.
Other wise if you think that we should revert the last commit, feel free to
do so.
If not I'll remove the on_missing once I get back
…On Wed, Dec 19, 2018, 19:20 Eric Larson ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In mne/tests/test_annotations.py
<#5795 (comment)>:
> @@ -530,7 +551,7 @@ def test_events_from_annot_in_raw_objects():
assert_array_equal(expected_events5, events5)
with pytest.raises(ValueError, match='not find any of the events'):
- events_from_annotations(raw, regexp='not_there')
+ events_from_annotations(raw, regexp='not_there', on_missing='error')
on_missing is still here
------------------------------
In mne/annotations.py
<#5795 (comment)>:
> @@ -701,9 +701,47 @@ def _ensure_annotation_object(obj):
'mne.Annotations. Got %s.' % obj)
+def _select_annotations_based_on_description(descriptions, event_id=None,
+ regexp=None, on_missing='ignore'):
on_missing is still here
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#5795 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGt-44bbw-0QdHZPHibxayU0sFievb2Oks5u6oNSgaJpZM4ZV5Fb>
.
|
agramfort
left a comment
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.
+1 for MRG when CIs are green
This PR adds a parameter to
events_from_annotationso that if this parameterNone, events correspond to the annotation onsets (as was happening until nos).
But if not, events_from_annotations returns as many events as they fit within
the annotation duration spaced according to this new parameter (right now is
called
chunk_duraitonbut we should discuss it before merging).This PR needs to go in before #5718
Things that are not in this PR (it will be done in subsequent PRs):