<p><span style="padding: 3px 10px; border-radius: 5px; color: #ffffff; font-weight: bold; display: inline-block; background-color: #ff0000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;External Email - Use Caution&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></p><p></p><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi,</div><div dir="ltr"><br></div><div dir="ltr">Here is the code (relevant part highlighted. It should work similarly for the sample data set for MNE but with different loading):</div><div dir="ltr"><div><br></div><div><br></div><div>##############</div><div><br></div><div><div>import mne</div><div>import numpy</div><div>import matplotlib.pyplot as plt</div><div> </div><div>from os import system</div><div>from read_sleep_markers import REM_em_times</div><div>from mne.preprocessing import ICA</div><div>from mne.preprocessing import create_eog_epochs</div><div><br></div><div>system(&#39;python read_sleep_markers.py&#39;)</div><div><br></div><div># READ DATA #</div><div>raw=mne.io.read_raw_edf(&#39;B0939.edf&#39;,preload=&#39;data_preload&#39;)</div><div><br></div><div># REMOVE BAD CHANNELS #</div><div>raw.drop_channels([&#39;EMGchin&#39;,&#39;ECG&#39;,&#39;Lage&#39;,&#39;Licht&#39;,&#39;Akku&#39;,&#39;Beweg.&#39;,&#39;EOGl:M1&#39;,&#39;EOGl:M2&#39;,&#39;EOGr:M1&#39;,&#39;C3:M2&#39;,&#39;C4:M1&#39;,&#39;Fz:M1&#39;,&#39;Oz:M1&#39;,&#39;EOGr:M2&#39;,&#39;F4:M1&#39;,&#39;O2:M1&#39;,&#39;F3:M2&#39;,&#39;O1:M2&#39;,&#39;Fz:M2&#39;,&#39;Oz:M2&#39;,&#39;Fp1:M1&#39;,&#39;Fp2:M1&#39;,&#39;T3:M1&#39;,&#39;T4:M1&#39;,&#39;P3:M1&#39;,&#39;P4:M1&#39;,&#39;F3:M1&#39;,&#39;STI 014&#39;]) </div><div><br></div><div># CREATE MONTAGE #</div><div>raw.set_montage(&#39;standard_1020&#39;) </div><div><br></div><div># SET CHANNEL TYPES</div><div>raw.set_channel_types({&#39;EOGl&#39;:&#39;eog&#39;,&#39;EOGr&#39;:&#39;eog&#39;,&#39;EOGV&#39;:&#39;eog&#39;,&#39;AUX&#39;:&#39;stim&#39;}) </div><div><br></div><div><b># CROP RAW DATA #</b></div><div><b>raw.crop(tmin=REM_em_times[0], tmax=REM_em_times[0]+125) # or tmin=REM_em_times[1],tmax=REM_em_times[5]...</b></div><div><b><br></b></div><div><b># STIM INDEX #</b></div><div><b>auxindex=[x[&#39;ch_name&#39;] for x in <a href="http://raw.info" target="_blank">raw.info</a>[&#39;chs&#39;]].index(&#39;AUX&#39;) </b></div><div><b>auxdata,auxtime=raw[auxindex,:]</b></div><div><br></div><div><b># STIM EVENTS #</b></div><div><b>events=numpy.arange(auxdata.shape[1])[numpy.append(numpy.array([False]),numpy.diff((auxdata&gt;400).astype(int))==1.0)]</b></div><div><b>nevents=events.shape[0]</b></div><div><b>events=numpy.reshape(events,(-1,1))</b></div><div><b>events=numpy.append(events,numpy.zeros((nevents,1),dtype=int),axis=1)</b></div><div><b>events=numpy.append(events,numpy.ones((nevents,1),dtype=int),axis=1)</b></div><div><b>events</b></div><div><br></div><div><b># READ EPOCHS #</b></div><div><b>epochs = mne.Epochs(raw, events, tmin= -0.2, tmax=1.0, baseline=(None, 0))</b></div><div><b>epochs_array=epochs.get_data() </b></div><div><b>erp=epochs.average()</b></div><div><b>erp.plot()</b></div></div><div><b><br></b></div><div><b><br></b></div><div>I have tried to crop the data at different time points and in different ways (directly writing integers or through imported variables,...)</div><div><br></div><div>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...</div><div><br></div><div>Might be something with the data points...</div><div><br></div><div>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.</div><div><br></div><div>Thanks!!</div><div><br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail-m_-1751886981227018065gmail_attr">El mar., 29 ene. 2019 a las 15:38, Alexandre Gramfort (&lt;<a href="mailto:alexandre.gramfort@inria.fr" target="_blank">alexandre.gramfort@inria.fr</a>&gt;) escribió:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">        External Email - Use Caution        <br>
<br>
hi Lidia,<br>
<br>
many things could go wrong. I would suggest you provide a few lines of<br>
code (as little as possible)<br>
using the MNE sample data to replicate the problem so we can investigate.<br>
<br>
Alex<br>
<br>
<br>
On Tue, Jan 29, 2019 at 1:40 PM Lidia Miguel Telega<br>
&lt;<a href="mailto:lidia.migueltelega@gmail.com" target="_blank">lidia.migueltelega@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt;         External Email - Use Caution<br>
&gt;<br>
&gt; Dear all,<br>
&gt;<br>
&gt; I am having problems creating an erp plot of a cropped segment of data.<br>
&gt; 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.<br>
&gt;<br>
&gt; Do you have any idea which might be the cause of that?<br>
&gt;<br>
&gt; Could it be a problem with some values when epoching the short segment of  data?<br>
&gt;<br>
&gt; Thank you in advance,<br>
&gt;<br>
&gt; Lidia<br>
&gt;<br>
&gt; --<br>
&gt; Lidia Miguel Telega<br>
&gt; M. Sc. Neuroscience<br>
&gt; Albert-Ludwigs-University of Freiburg, Germany<br>
&gt; _______________________________________________<br>
&gt; Mne_analysis mailing list<br>
&gt; <a href="mailto:Mne_analysis@nmr.mgh.harvard.edu" target="_blank">Mne_analysis@nmr.mgh.harvard.edu</a><br>
&gt; <a href="https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis" rel="noreferrer" target="_blank">https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis</a><br>
<br>
_______________________________________________<br>
Mne_analysis mailing list<br>
<a href="mailto:Mne_analysis@nmr.mgh.harvard.edu" target="_blank">Mne_analysis@nmr.mgh.harvard.edu</a><br>
<a href="https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis" rel="noreferrer" target="_blank">https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail-m_-1751886981227018065gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><em><strong><font color="#666666" face="georgia,serif" size="2">Lidia Miguel Telega</font></strong></em></div><div><em style="font-size:12.8px"><font color="#666666"><font face="georgia,serif" size="2">M. Sc. Neuroscience</font></font></em><br></div><div><font face="georgia, serif"><i><span style="color:rgb(106,106,106);font-size:small">Albert-Ludwigs-</span><span style="color:rgb(84,84,84);font-size:small">University of Freiburg, Germany</span></i></font><em style="font-size:12.8px"><font color="#666666"><font face="georgia,serif" size="2"><br></font></font></em></div></div></div></div></div></div></div></div></div>