I am classifying data from sleep studies.
I epoch the data into 30s epochs, then run AutoReject
to remove noisy epochs.
I run my classifier on the remaining epochs.
I then need to apply the resulting class labels to the original raw eeg as Annotation
s.
Is there a way to retrieve the time offset into the raw file from Epochs
?
I can probably hack something up with drop_log
, but thought there might be a more elegant way.
Thanks!
1 Like
Epochs.events[:, 0]
contains the sample onsets for each epoch. To convert these into time stamps:
onsets = epochs.events[:, 0] / epochs.info['sfreq'] + raw.first_time
durations = np.repeat(epochs.times[-1] - epochs.times[0], len(onsets))
descriptions = ['trial' for _ in range(len(onsets))] # change this to better descriptions
annotations = mne.Annotations(onsets, durations, descriptions)
4 Likes
Thanks!
I didn’t consider that there would be events since I epoched using a fixed time interval.