[Mne_analysis] Mne_analysis Digest, Vol 153, Issue 40

balandongiv at gmail.com balandongiv at gmail.com
Fri Oct 30 03:38:19 EDT 2020
Search archives:

        External Email - Use Caution        

Dear Eric,
Thanks for the link, the tutorial is crystal clear and help resolve the
issue I'm facing.

For the potential future user, the code below shows how to create an event
from an annotation.

events_df = pd.DataFrame ({'Time':  [13.98, 358.71,380.43], # in seconds
        'events_df': [0, 0,0],
         'event_id': [2, 1,2]})

raw = mne.io.read_raw_edf ( path_name, preload=True )

raw.set_annotations ( mne.Annotations ( onset=events_df
['Time'].values.tolist (),
                                        duration=[0] * len ( events_df.index
),
                                        description=events_df
['event_id'].values.tolist () ))
events = mne.events_from_annotations ( raw )[0]




Regards
Rpb

-----Original Message-----
From: mne_analysis-bounces at nmr.mgh.harvard.edu
<mne_analysis-bounces at nmr.mgh.harvard.edu> On Behalf Of
mne_analysis-request at nmr.mgh.harvard.edu
Sent: Thursday, 29 October, 2020 11:59 PM
To: mne_analysis at nmr.mgh.harvard.edu
Subject: Mne_analysis Digest, Vol 153, Issue 40

Send Mne_analysis mailing list submissions to
	mne_analysis at nmr.mgh.harvard.edu

To subscribe or unsubscribe via the World Wide Web, visit
	https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
or, via email, send a message with subject or body 'help' to
	mne_analysis-request at nmr.mgh.harvard.edu

You can reach the person managing the list at
	mne_analysis-owner at nmr.mgh.harvard.edu

When replying, please edit your Subject line so it is more specific than
"Re: Contents of Mne_analysis digest..."


Today's Topics:

   1. Getting Error: events should be a NumPy array of	integers
      (balandongiv at gmail.com)
   2. Re: Getting Error: events should be a NumPy array of integers
      (Phillip Alday)
   3. Re: Getting Error: events should be a NumPy array of	integers
      (Eric Larson)


----------------------------------------------------------------------

Message: 1
Date: Thu, 29 Oct 2020 23:37:07 +0800
From: <balandongiv at gmail.com>
Subject: [Mne_analysis] Getting Error: events should be a NumPy array
	of	integers
To: <mne_analysis at nmr.mgh.harvard.edu>
Message-ID: <004a01d6ae09$5d05d3d0$17117b70$@gmail.com>
Content-Type: text/plain; charset="us-ascii"

        External Email - Use Caution        

Dear All,

 

We are conducting an ERP experiment. In most cases, the precision of the
annotation time is up to two decimal points (e.g., 358.71, 1053.88).

 

When creating an epoch using the module mne.Epochs(), the compiler returns
an error:

 

TypeError: events should be a NumPy array of integers, got <class
'numpy.ndarray'>

 

Is there a way to bypass this type of error?

 

One strategy is by round the time (e.g., 358.71, 1053.88 to 359, 1054).
However, this may reduce the overall accuracy and precision of the
experimentation.

 

Appreciate for any advice.

 

Regards

Rpb

-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20201029/
d78341bf/attachment-0001.html 

------------------------------

Message: 2
Date: Thu, 29 Oct 2020 16:49:37 +0100
From: Phillip Alday <phillip.alday at mpi.nl>
Subject: Re: [Mne_analysis] Getting Error: events should be a NumPy
	array of integers
To: Discussion and support forum for the users of MNE Software
	<mne_analysis at nmr.mgh.harvard.edu>, <balandongiv at gmail.com>
Message-ID: <080b3837-7557-e46c-dccc-3ad74aeb96d1 at mpi.nl>
Content-Type: text/plain; charset="windows-1252"

        External Email - Use Caution        

How are you creating the events array? The time (first) column is in
*samples*, where are by definition always integers, not in (milli)seconds.
If you annotations that are finer grained than samples, then you need to
round them to your sampling resolution (also because there is no added value
in having annotations that are finer grained than your EEG samples).

Phillip

On 29/10/20 4:37 pm, balandongiv at gmail.com wrote:
> ????????External Email - Use Caution????????
> 
> Dear All,
> 
> ?
> 
> We are conducting an ERP experiment. In most cases, the precision of 
> the annotation time is up to two decimal points (e.g., 358.71,1053.88).
> 
> ?
> 
> When creating an epoch using the module mne.Epochs(), the compiler 
> returns an error:
> 
> ?
> 
> TypeError: events should be a NumPy array of integers, got <class 
> 'numpy.ndarray'>
> 
> ?
> 
> Is there a way to bypass this type of error?
> 
> ?
> 
> One strategy is by round the time (e.g., 358.71,1053.88 to 359,1054).
> However, this may reduce the overall accuracy and precision of the 
> experimentation.
> 
> ?
> 
> Appreciate for any advice.
> 
> ?
> 
> Regards
> 
> Rpb
> 
> 
> _______________________________________________
> Mne_analysis mailing list
> Mne_analysis at nmr.mgh.harvard.edu
> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
> 




------------------------------

Message: 3
Date: Thu, 29 Oct 2020 11:58:16 -0400
From: Eric Larson <larson.eric.d at gmail.com>
Subject: Re: [Mne_analysis] Getting Error: events should be a NumPy
	array of	integers
To: Discussion and support forum for the users of MNE Software
	<mne_analysis at nmr.mgh.harvard.edu>
Message-ID:
	<CAGu2niW8PyEa_5xXqqQuKWVhQi3_PUyh8Wk75bULqKUZH7L7Dw at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

        External Email - Use Caution        

Indeed it sounds like there is a confusion here between time in samples and
time in seconds. Have you read this tutorial? It hopefully makes the
distinction clearer:

https://mne.tools/dev/auto_tutorials/intro/plot_20_events_from_raw.html

Eric


On Thu, Oct 29, 2020 at 11:50 AM Phillip Alday <phillip.alday at mpi.nl> wrote:

>         External Email - Use Caution
>
> How are you creating the events array? The time (first) column is in 
> *samples*, where are by definition always integers, not in 
> (milli)seconds. If you annotations that are finer grained than 
> samples, then you need to round them to your sampling resolution (also 
> because there is no added value in having annotations that are finer 
> grained than your EEG samples).
>
> Phillip
>
> On 29/10/20 4:37 pm, balandongiv at gmail.com wrote:
> >         External Email - Use Caution
> >
> > Dear All,
> >
> >
> >
> > We are conducting an ERP experiment. In most cases, the precision of 
> > the annotation time is up to two decimal points (e.g., 358.71,1053.88).
> >
> >
> >
> > When creating an epoch using the module mne.Epochs(), the compiler 
> > returns an error:
> >
> >
> >
> > TypeError: events should be a NumPy array of integers, got <class 
> > 'numpy.ndarray'>
> >
> >
> >
> > Is there a way to bypass this type of error?
> >
> >
> >
> > One strategy is by round the time (e.g., 358.71,1053.88 to 359,1054).
> > However, this may reduce the overall accuracy and precision of the 
> > experimentation.
> >
> >
> >
> > Appreciate for any advice.
> >
> >
> >
> > Regards
> >
> > Rpb
> >
> >
> > _______________________________________________
> > Mne_analysis mailing list
> > Mne_analysis at nmr.mgh.harvard.edu
> > https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
> >
>
>
> _______________________________________________
> Mne_analysis mailing list
> Mne_analysis at nmr.mgh.harvard.edu
> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20201029/
b0b79355/attachment.html 

------------------------------

_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis

End of Mne_analysis Digest, Vol 153, Issue 40
*********************************************




More information about the Mne_analysis mailing list