Cropping raw objects based on no. of events

To whom this may concern,

I’ve got some task-related EEG recordings where my stimulation software crashed after 10 - 20 trials. I’d like to remove the data around these initial events and ensure the data I analyse has the correct amount of events from a single run of the experiment.

Is there any way I could manage to drop all timepoints prior to an event X which is the first event I’d like to consider?

Sure! If you have an events array events and raw data raw, you could determine the time point of the n-th event via

t_event = events[n, 0] /['sfreq']  # samples -> seconds

and then crop the raw data accordingly, e.g.,

raw.crop(tmin=t_event - 0.5)  # 0.5 s prior to the event


1 Like