# many epochs dropped due to 'NO\_DATA'

**URL:** <https://mne.discourse.group/t/many-epochs-dropped-due-to-no-data/989>\
**Category:** Mailing List Archive (read-only)\
**Tags:** list-archive\
**Created:** [April 7, 2016, 10:24am UTC](https://mne.discourse.group/t/many-epochs-dropped-due-to-no-data/989 "2016-04-07T10:24:41Z")\
**Posts on this page:** 4\
**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:** [April 7, 2016, 10:24am UTC](https://mne.discourse.group/t/many-epochs-dropped-due-to-no-data/989/1 "2016-04-07T10:24:41Z")

</div>

Hi,

Thanks for the hint; It must have something to do with it.

I must be overlooking something here, but I can't get it right:  
Somehow it looks as if the epochs method looks for timestamps from  
before the cropping of the data from somewhere (?), although I'm not  
sure how that is possible

I first crop my data with raw.crop, save that data, and load it again  
from file.  
I previously crop the file at 232 seconds - it loses the first 44 epochs.  
Other files I don't crop don't have this problem.

I can't figure out what's wrong about the time indices:

the resulting raw structure has the correct raw.time (from 0 to 618, at  
sfreq=1000) and time indices:  
raw[0][1] goes from 0 to 618;  
len(raw[0][1]): 618001

My events array goes like this:  
In [37]: events  
Out[37]:  
array([[9279, 0, 1],  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[18677, 0, 2],  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[28475, 0, 3],  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[38491, 0, 3],  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[49491, 0, 1],  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[58705, 0, 3],  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[69505, 0, 1],  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[79905, 0, 1],  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[89736, 0, 1],  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[99134, 0, 2],  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[108933, 0, 1],  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[118948, 0, 1],  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[128146, 0, 2],  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[138361, 0, 3],  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[147759, 0, 2],  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[157558, 0, 3],  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[167774, 0, 1],  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;......  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[595400, 0, 1]])

Notably, I lose the first epochs, not the last epochs:

epochs = mne.Epochs(raw,events, event\_id, tmin=tmin, tmax=tmax,  
proj=True, picks=picks\_plan2,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;baseline=None, preload=True,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reject=None)

In [35]: 60 matching events found  
Applying baseline correction (mode: mean)  
0 projection items activated  
Loading data for 60 events and 1001 original time points ...  
44 bad epochs dropped

In [36]: epochs.drop\_log  
Out[36]:  
[['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
['NO\_DATA'],  
[],  
[],  
[],  
[],  
[],  
[],  
[],  
[],  
[],  
[],  
[],  
[],  
[],  
[],  
[],  
[]]

Any Ideas?  
Many Thanks,

cheers Tristan

---

<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:** [April 7, 2016, 10:36am UTC](https://mne.discourse.group/t/many-epochs-dropped-due-to-no-data/989/2 "2016-04-07T10:36:54Z")

</div>

have a look at raw.first\_samp

it can interfere. It is basically an offset in samples

A

---

<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:** [April 8, 2016, 12:56am UTC](https://mne.discourse.group/t/many-epochs-dropped-due-to-no-data/989/3 "2016-04-08T00:56:36Z")

</div>

That was it; when adding raw.first\_samp to all my events I lose no epochs.  
I guess a cleaner way is to reset the first\_samp property.

For others with this problem, instead of:  
raw.first\_samp=0

do this (found by asking ipython for the definition with:  
raw.first\_samp?? ):  
raw.\_first\_samps[0]=0

May I suggest a switch in the crop method (e.g.: keep\_offset=True)?  
Thanks for the help!

Tristan

---

<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:** [April 8, 2016, 5:50am UTC](https://mne.discourse.group/t/many-epochs-dropped-due-to-no-data/989/4 "2016-04-08T05:50:41Z")

</div>

I'm not sure if it is a good idea to set the first\_samp property by hand.  
It could have some side effects elsewhere. In general, you shouldn't have  
to change the private attributes yourself. I don't know your analysis pipe  
line, but the events should line up properly if you do mne.find\_events to  
the cropped data. This way the events outside the cropping window will be  
excluded.
