Epoching based on timing of events

  • MNE-Python version: 0.23.0
  • operating system: MacOS

For epoching my data based on events, I have a list that shows start time of my events like this:
event_lines_float = [64.698, 65.165, 65.632, 68.654, 69.121, 69.588, 72.61, 73.077, 73.545, 76.566]
and another arrays that shows the duration of each of these events:
duration_lines_float=[0.45, 0.45, 3.0, 0.45, 0.45, 3.0, 0.45, 0.45, 3.0, 0.45]
(So the duration of my events can be different)

Is this the correct way of epoching data?

stim_annotations = mne.Annotations(onset=event_lines_float,

(stim_events, stim_event_dict) = mne.events_from_annotations(raw)

epochs = mne.Epochs(filt_raw, stim_events, event_id=stim_event_dict, tmin=-0.1, tmax=0.45, preload=True)

The reason I am asking this, is because my stim_events are the onset time (not ID) and also the duration of epochs could be different. So I think the method above won’t work correctly.

I appreciate if you can help me regarding this.

MNE Epochs have fixed durations by design.
Maybe what you want is a list of cropped Raw instances. See raw.crop method.


1 Like