[Mne_analysis] ERP plot issues

Alexandre Gramfort alexandre.gramfort at inria.fr
Tue Jan 29 15:08:05 EST 2019
Search archives:

        External Email - Use Caution        

Dear Lidia,

if you don't share with me the EDF file I cannot replicate to help you.

Alex

On Tue, Jan 29, 2019 at 7:48 PM Lidia Miguel Telega
<lidia.migueltelega at gmail.com> wrote:
>
>         External Email - Use Caution
>
> Hi,
>
> Here is the code (relevant part highlighted. It should work similarly for the sample data set for MNE but with different loading):
>
>
> ##############
>
> import mne
> import numpy
> import matplotlib.pyplot as plt
>
> from os import system
> from read_sleep_markers import REM_em_times
> from mne.preprocessing import ICA
> from mne.preprocessing import create_eog_epochs
>
> system('python read_sleep_markers.py')
>
> # READ DATA #
> raw=mne.io.read_raw_edf('B0939.edf',preload='data_preload')
>
> # REMOVE BAD CHANNELS #
> raw.drop_channels(['EMGchin','ECG','Lage','Licht','Akku','Beweg.','EOGl:M1','EOGl:M2','EOGr:M1','C3:M2','C4:M1','Fz:M1','Oz:M1','EOGr:M2','F4:M1','O2:M1','F3:M2','O1:M2','Fz:M2','Oz:M2','Fp1:M1','Fp2:M1','T3:M1','T4:M1','P3:M1','P4:M1','F3:M1','STI 014'])
>
> # CREATE MONTAGE #
> raw.set_montage('standard_1020')
>
> # SET CHANNEL TYPES
> raw.set_channel_types({'EOGl':'eog','EOGr':'eog','EOGV':'eog','AUX':'stim'})
>
> # CROP RAW DATA #
> raw.crop(tmin=REM_em_times[0], tmax=REM_em_times[0]+125) # or tmin=REM_em_times[1],tmax=REM_em_times[5]...
>
> # STIM INDEX #
> auxindex=[x['ch_name'] for x in raw.info['chs']].index('AUX')
> auxdata,auxtime=raw[auxindex,:]
>
> # STIM EVENTS #
> events=numpy.arange(auxdata.shape[1])[numpy.append(numpy.array([False]),numpy.diff((auxdata>400).astype(int))==1.0)]
> nevents=events.shape[0]
> events=numpy.reshape(events,(-1,1))
> events=numpy.append(events,numpy.zeros((nevents,1),dtype=int),axis=1)
> events=numpy.append(events,numpy.ones((nevents,1),dtype=int),axis=1)
> events
>
> # READ EPOCHS #
> epochs = mne.Epochs(raw, events, tmin= -0.2, tmax=1.0, baseline=(None, 0))
> epochs_array=epochs.get_data()
> erp=epochs.average()
> erp.plot()
>
>
> I have tried to crop the data at different time points and in different ways (directly writing integers or through imported variables,...)
>
> It resulted to work once, when selecting tmin and tmax delimiting a large range of data. But it did not work for other ranges. I do not know why...
>
> Might be something with the data points...
>
> If you could have a fast look to it, would be nice and helpful. I am still struggling since for the ranges I need to analyze does not work.
>
> Thanks!!
>
>
> El mar., 29 ene. 2019 a las 15:38, Alexandre Gramfort (<alexandre.gramfort at inria.fr>) escribió:
>>
>>         External Email - Use Caution
>>
>> hi Lidia,
>>
>> many things could go wrong. I would suggest you provide a few lines of
>> code (as little as possible)
>> using the MNE sample data to replicate the problem so we can investigate.
>>
>> Alex
>>
>>
>> On Tue, Jan 29, 2019 at 1:40 PM Lidia Miguel Telega
>> <lidia.migueltelega at gmail.com> wrote:
>> >
>> >         External Email - Use Caution
>> >
>> > Dear all,
>> >
>> > I am having problems creating an erp plot of a cropped segment of data.
>> > What I am doing is crop the raw at some specific time points, find the stim events at that points using my own code, epoching, averaging the epochs and then plotting) and I always get the error: Some of the values to be plotted are NaN. While when doing the same procedure with whole raw data file it works fine.
>> >
>> > Do you have any idea which might be the cause of that?
>> >
>> > Could it be a problem with some values when epoching the short segment of  data?
>> >
>> > Thank you in advance,
>> >
>> > Lidia
>> >
>> > --
>> > Lidia Miguel Telega
>> > M. Sc. Neuroscience
>> > Albert-Ludwigs-University of Freiburg, Germany
>> > _______________________________________________
>> > 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
>
>
>
> --
> Lidia Miguel Telega
> M. Sc. Neuroscience
> Albert-Ludwigs-University of Freiburg, Germany
> _______________________________________________
> Mne_analysis mailing list
> Mne_analysis at nmr.mgh.harvard.edu
> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis



More information about the Mne_analysis mailing list