# Annotations for Events

**URL:** <https://mne.discourse.group/t/annotations-for-events/2036>\
**Category:** Mailing List Archive (read-only)\
**Tags:** list-archive\
**Created:** [January 3, 2020, 5:06am UTC](https://mne.discourse.group/t/annotations-for-events/2036 "2020-01-03T05:06:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [January 3, 2020, 5:06am UTC](https://mne.discourse.group/t/annotations-for-events/2036/1 "2020-01-03T05:06:51Z")

</div>

External Email - Use Caution

Dear Mailing List,

This is a previously mentioned issue that I?ve been working with Alexandre Gramfort on. This issue involves setting events from annotations. We are reading in NeuroScan continuous files (.cnt) and it would appear that when trying to pass `mne.Annotations()` our descriptions are in string/text format, whereas they need to be in integer format. To accommodate this, we tried passing the `int()` command to convert, however, we got a TypeError specifying that `only size-1 arrays can be converted to Python scalars`. Sending this to the community email in case anyone else is having the same issues or may have some insight.

Attached here is our lab?s google share drive as both the script (.py) and the Neuroscan (.cnt) file are too large to email or upload to a Github repository.  
[https://drive.google.com/open?id=1VZP-V4TM0hsX3dW8WFy0XBKFZ\_tOXrOD](https://drive.google.com/open?id=1VZP-V4TM0hsX3dW8WFy0XBKFZ_tOXrOD)

Very Best,  
Bianca Islas

-------------- next part --------------  
An HTML attachment was scrubbed...  
URL: [http://mail.nmr.mgh.harvard.edu/pipermail/mne\_analysis/attachments/20200102/25cfe2b6/attachment.html](http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20200102/25cfe2b6/attachment.html)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [January 4, 2020, 4:50pm UTC](https://mne.discourse.group/t/annotations-for-events/2036/2 "2020-01-04T16:50:25Z")

</div>

External Email - Use Caution

hi,

I tried

import mne

raw = mne.io.read\_raw\_cnt('st003\_PAMR\_s1079\_20080319.cnt')  
events, event\_id = mne.events\_from\_annotations(raw, event\_id=int)  
print(events)  
print(event\_id)

and it worked fine.

are you doing anything differently?

Alex

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [January 4, 2020, 11:24pm UTC](https://mne.discourse.group/t/annotations-for-events/2036/3 "2020-01-04T23:24:01Z")

</div>

External Email - Use Caution

Yes, entirely different. I first define an event\_dict. My reading in the .cnt file is verbatim:

`raw = mne.io.read\_raw\_cnt(input\_fname=raw\_fname, eog=('VEO', 'HEO',), misc=('SCR', 'SCL',), ecg=('HR',),  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;emg=('PA-L-SCAL', 'PA-L-EAR', 'PA-R-SCAL', 'PA-R-EAR', 'ORB-NOSE', 'ORB-EAR', 'COR-NOSE', 'COR-EAR', 'ZYG-MOUTH', 'ZYG-EAR',),  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data\_format='int32', date\_format='dd/mm/yy', preload=True)  
events = mne.events\_from\_annotations(raw\_corrected, event\_id=event\_dict)  
print(events, raw\_corrected) #corrected raw data after ICA`

Implementing `event_id=int` into `events_from_annotations`, as in your code, was the difference. This is not in the documentation for this function. So I?m glad we were able to cover it here. Thank you for your time and patience in clearing this up!

Bianca Islas

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [January 7, 2020, 6:03pm UTC](https://mne.discourse.group/t/annotations-for-events/2036/4 "2020-01-07T18:03:34Z")

</div>

External Email - Use Caution

Hi Bianca,  
Can you have a look at [https://github.com/mne-tools/mne-python/pull/7183](https://github.com/mne-tools/mne-python/pull/7183) and see if the docstring changes there are clear, and would have prevented your difficulty?

-- dan  
Daniel McCloy  
[http://dan.mccloy.info](http://dan.mccloy.info)  
Research Scientist  
Institute for Learning and Brain Sciences  
University of Washington

??? Original Message ???

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [January 13, 2020, 6:21pm UTC](https://mne.discourse.group/t/annotations-for-events/2036/5 "2020-01-13T18:21:23Z")

</div>

External Email - Use Caution

Mr. McCloy,

My apologies for the late response. I looked at changes made for docstring #7183, notes and crossref implementation for annotations.py. I think that these notes are clear and would have prevented the difficulty. However I did notice that when going to the source code link from the MNE page, it did not show the changes for lines 899-900 and 941. Will this take effect after review? Thank you all for addressing these concerns as related to Neuroscan .cnt file annotations.

Very Best,  
Bianca Islas  
Research Assistant  
Psychophysiology of Emotion and Personality Lab  
University Nevada, Las Vegas

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [January 13, 2020, 6:36pm UTC](https://mne.discourse.group/t/annotations-for-events/2036/6 "2020-01-13T18:36:10Z")

</div>

External Email - Use Caution

Hi Bianca,  
The reason the [source] link still shows the old code is that you were looking at the documentation for the \*stable\* version of MNE-Python (note the URL begins with [https://mne.tools/stable/](https://mne.tools/stable/)). [source] links in the stable documentation don't go to the current master version of the code, they go to a maintenance branch (currently maint/0.19).

If you look at [that page of the documentation for the \*development\* version of MNE-Python]([https://mne.tools/dev/generated/mne.events\_from\_annotations.html](https://mne.tools/dev/generated/mne.events_from_annotations.html)), you'll see in the GitHub URL that the [source] link goes to the current master branch instead of maint/0.19, and the recent changes to the docstring are indeed shown there.

-- dan  
Daniel McCloy  
[https://dan.mccloy.info](https://dan.mccloy.info)  
Research Scientist  
Institute for Learning and Brain Sciences  
University of Washington

??? Original Message ???
