Use Annotations for read_raw_egi events#12300
Conversation
| annot["onset"].extend(ev[:, 0] / self.info["sfreq"]) | ||
| annot["duration"].extend(np.zeros(ev.shape[0])) | ||
| annot["description"].extend([event_dict[e] for e in ev[:, 2]]) | ||
| self.set_annotations(Annotations(**annot)) |
There was a problem hiding this comment.
I would go a step further and when events_as_annotations=True is used, do not create the synthetic event channel and raw.event_id
There was a problem hiding this comment.
Sure, since those synthetic channels are already created by the time it reaches my code, I can delete them if events_as_annotations is true
There was a problem hiding this comment.
Rather than create then delete, would be better to avoid creation in the first place
There was a problem hiding this comment.
Hmm ok. Then i'll need to take a new approach to this PR! Since now I am just using mne.find_eventsand convert those events to annotations.
As suggested here I can quickly check if simply allowing the initial one-shot event fixes the issue without breaking a bunch of tests. If it ends up being more complicated than that, maybe it will be a better use of time instead to get a PR up that uses mffpy which should solve those issues, as suggested here I can report back. |
|
@scott-huberty we're planning to release in 3ish weeks and it would be great to get this in, let me know if you want help |
I've just moved to a new city and started a postdoc last week, so I'm a bit pressed for time right now 😅. Initially, due to time constraints, I was a little lazy with this PR since it only creates annotations using the generated stim channel. However, it was suggested that if the new parameter This has been a blocker for me because I haven't had the time to really dig into the |
* upstream/main: (252 commits) Disable the "Back to top" button in the documentation (mne-tools#12688) DOC: match_channel_orders works on Epochs and Evoked, too (mne-tools#12699) Scale points and labels in montage plot (mne-tools#12703) Add license header to mne.stats.erp (mne-tools#12712) Update license year to 2024 (mne-tools#12713) Add standardized measurement error (SME) (mne-tools#12707) ENH: Parallel example execution in doc build (mne-tools#12708) MAINT: Update PR template (mne-tools#12692) MAINT: Fix doc build (mne-tools#12706) [pre-commit.ci] pre-commit autoupdate (mne-tools#12702) Improve documentation of ylim argument through Evoked plotting function (mne-tools#12697) [pre-commit.ci] pre-commit autoupdate (mne-tools#12696) BUG: Fix bug with CSP rank="full" (mne-tools#12694) MRG: Add epochs metadata summary to HTML representation (mne-tools#12686) Correct `Epochs.apply_function` docstring (mne-tools#12691) FIX: Gracefully handle missing datetime in Eyelink File (mne-tools#12687) MAINT: Restore SciPy pre (mne-tools#12689) Enh single channel annotation (mne-tools#12669) [pre-commit.ci] pre-commit autoupdate (mne-tools#12682) Bump autofix-ci/action from 1.2 to 1.3 in the actions group (mne-tools#12681) ...
|
Okay this one should be ready for review/merge @drammock ! |
|
Thank you @larsoner ! 🙏 |
|
related CI failures: |
drammock
left a comment
There was a problem hiding this comment.
Reviewed only by eyeballing diff on GH. After these comments are addressed, I can do another review with local testing if requested.
| if events are not mutually exclusive. | ||
|
|
||
| This step will fail if events are not mutually exclusive. | ||
| For these reasons, it is recommended to use ``events_as_annotations=True``. |
There was a problem hiding this comment.
I recommend reorganizing the Notes section, to put the info in this order:
- what happens when
events_as_annotations=True(put this first because it's the recommended way, and easier to explain) - what happens when
events_as_annotations=False- new stim channel STI014 created (w/ crossref to glossary entry for stim chans)...
- ...that contains brief (1-sample?) pulses where the Netstation file had event timestamps.
- An
event_iddictionary is attached (where?) to the Raw object... - ...that will have arbitrary sequential integer IDs for the events...
- ...will fail if any timestamps are duplicated (is that the right way to state the failure mode?)...
- ...and will not survive a save/load roundtrip.
mne/io/egi/egi.py
Outdated
| if events_as_annotations: | ||
| raise NotImplementedError |
There was a problem hiding this comment.
wait, so if I'm reading this right, events_as_annotations=True only works for .mff (not EGI simple binary fmt)? Docstring needs to say that
| egi_pause_w1337_skips = [(21956000.0, 40444000.0), (60936000.0, 89332000.0)] | ||
|
|
||
| # TODO: Remove once complete deprecation / FutureWarning about events_as_annonations | ||
| pytestmark = pytest.mark.filterwarnings("ignore:.*events_as_annotation.*:FutureWarning") |
There was a problem hiding this comment.
I think maybe this got defined but wasn't used to decorate anything (hence the CI errors)?
There was a problem hiding this comment.
Actually it is automagically used in this module
https://docs.pytest.org/en/latest/how-to/skipping.html#skip-all-test-functions-of-a-class-or-module
Just need to add it in test_montage.py (where I'll just decorate the one failing func)
|
Thanks for the quick review, pushed a commit to hopefully fix things @drammock ! |
Closes #12262
Closes #11674
Closes #11672
adds a parameter
events_as_annotations(default False for backward compat), which will create annotations from EGI events.@larsoner what do you think of this design and the new parameter name?