# Importing events from an array in python

**URL:** <https://mne.discourse.group/t/importing-events-from-an-array-in-python/3921>\
**Category:** Support & Discussions\
**Tags:** data-import, raw\
**Created:** [November 6, 2021, 7:07am UTC](https://mne.discourse.group/t/importing-events-from-an-array-in-python/3921 "2021-11-06T07:07:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gkassis](https://avatars.discourse-cdn.com/v4/letter/g/b9bd4f/32.png) [@gkassis](https://mne.discourse.group/u/gkassis)\
**Post date:** [November 6, 2021, 7:07am UTC](https://mne.discourse.group/t/importing-events-from-an-array-in-python/3921/1 "2021-11-06T07:07:35Z")

</div>

Hi,

I am trying to use an events stream from an xdf file in mne. I was able to import the xdf and create two arrays in python. One array includes lists of markup-language lines describing each event while the second array includes the corresponding timestamps.  
I did edit the timestamps so that they match the timing of the EEG sampling rate already imported into mne. e.g. timestamp of first event is 5.34 seconds (with respect to time zero in mne) and so on.  
I am wondering if there is a way to add these events to the raw file containing the EEG data.

Thank you

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [November 7, 2021, 5:40pm UTC](https://mne.discourse.group/t/importing-events-from-an-array-in-python/3921/2 "2021-11-07T17:40:34Z")

</div>

Hello @gkassis and welcome to the forum!

Can you please share a snippet of the array / data you have created? It’s not really clear to me what exactly you have and what needs to be done.

Best,  
Richard

---

<div class="post-metadata">

**Author:** ![cbrnr](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/cbrnr/32/1409_2.png) [@cbrnr](https://mne.discourse.group/u/cbrnr)\
**Post date:** [November 8, 2021, 6:39am UTC](https://mne.discourse.group/t/importing-events-from-an-array-in-python/3921/3 "2021-11-08T06:39:41Z")

</div>

I assume you use `pyxdf` to load the file. You could try `from mnelab.io.xdf import read_raw_xdf` (using the `mnelab` package) to import your data including annotations. Normally, this should work out of the box, you just have to provide the stream ID (of the EEG data) you want to load.
