# Get start time of epoch in original raw file?

**URL:** <https://mne.discourse.group/t/get-start-time-of-epoch-in-original-raw-file/7040>\
**Category:** Support & Discussions\
**Tags:** eeg, epochs\
**Created:** [June 7, 2023, 2:57pm UTC](https://mne.discourse.group/t/get-start-time-of-epoch-in-original-raw-file/7040 "2023-06-07T14:57:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JohnAtl](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/johnatl/32/1223_2.png) [@JohnAtl](https://mne.discourse.group/u/JohnAtl)\
**Post date:** [June 7, 2023, 2:57pm UTC](https://mne.discourse.group/t/get-start-time-of-epoch-in-original-raw-file/7040/1 "2023-06-07T14:57:12Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![wmvanvliet](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/wmvanvliet/32/100_2.png) [@wmvanvliet](https://mne.discourse.group/u/wmvanvliet)\
**Post date:** [June 8, 2023, 9:22am UTC](https://mne.discourse.group/t/get-start-time-of-epoch-in-original-raw-file/7040/2 "2023-06-08T09:22:50Z")

</div>

`Epochs.events[:, 0]` contains the sample onsets for each epoch. To convert these into time stamps:

```python
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)

```

---

<div class="post-metadata">

**Author:** ![JohnAtl](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/johnatl/32/1223_2.png) [@JohnAtl](https://mne.discourse.group/u/JohnAtl)\
**Post date:** [June 12, 2023, 6:10pm UTC](https://mne.discourse.group/t/get-start-time-of-epoch-in-original-raw-file/7040/3 "2023-06-12T18:10:00Z")

</div>

Thanks!  
I didn’t consider that there would be events since I epoched using a fixed time interval.
