mne-python icon indicating copy to clipboard operation
mne-python copied to clipboard

Use pad_start and pad_stop in find_events

Open iraquitan opened this issue 8 years ago • 4 comments

As find_events function uses the _find_stim_steps under the hood: https://github.com/mne-tools/mne-python/blob/06afcc8166f9304d25a72ab159e954542f0cc177/mne/event.py#L447 I believe it should be interesting to use these two arguments as well. I recently started using the EEG Motor Movement/Imagery Dataset and they also have events to rest state, so their events are as follows: eegmmids_events

As you can see, the events already start at a non-zero number, because the event 1 is the rest state. With the current find_events function, this first event will be skipped as the current behavior is to only use pad_stop. I believe setting pad_start=0 as default won't affect much, as in the vast majority of datasets, events start at 0.

My suggestions are:

  • adding these two arguments (pad_start and pad_stop) to the find_events function
  • setting pad_start=0 as default behavior

If this new behavior is ok I can open a PR.

iraquitan avatar Feb 08 '18 14:02 iraquitan

Can you see if #4756 (in latest master) fixes the first sample behavior?

larsoner avatar Feb 08 '18 14:02 larsoner

will check that

iraquitan avatar Feb 08 '18 15:02 iraquitan

>>> raw = mne.io.read_raw_edf(fpath, preload=True)
Extracting edf Parameters from /../eegmmidb/S001/S001R06.edf...
EDF file detected
Setting channel info structure...
Created Raw.info structure...
Reading 0 ... 19999  =      0.000 ...   124.994 secs...
Ready.
>>> events = find_events(raw, initia_event=False)
Trigger channel has a non-zero initial value of 1 (consider using initial_event=True to detect this event)
Removing orphaned offset at the beginning of the file.
29 events found
Event IDs: [1 2 3]
>>> events = find_events(raw, initia_event=True)
30 events found
Event IDs: [1 2 3]
(30, 3)

Works as expected @larsoner . Thanks.

Is this supposed to work in 0.16?

iraquitan avatar Feb 08 '18 19:02 iraquitan

Is this supposed to work in 0.16?

Yes once it is released it should work in 0.16

larsoner avatar Feb 08 '18 19:02 larsoner