# Some question about Epochsobjects in mne-python

**URL:** <https://mne.discourse.group/t/some-question-about-epochsobjects-in-mne-python/644>\
**Category:** Mailing List Archive (read-only)\
**Tags:** list-archive\
**Created:** [December 22, 2013, 12:30pm UTC](https://mne.discourse.group/t/some-question-about-epochsobjects-in-mne-python/644 "2013-12-22T12:30:25Z")\
**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:** [December 22, 2013, 12:30pm UTC](https://mne.discourse.group/t/some-question-about-epochsobjects-in-mne-python/644/1 "2013-12-22T12:30:25Z")

</div>

Hello,

I have some epoched data that I created in python (using mne.Epochs) and  
then saved as a .fif file using the save() method of mne.Epochs. After  
saving it, I did some other processing, and now I'd like to load them  
again. But I'm actually not sure how to load these objects?  
mne.fiff.read\_evoked doesn't seem to do it (I get an error 'Could not find  
evoked data'; the full traceback is below).

Also, is it possible to filter an mne.Epochs object? I didn't filter my raw  
data because I wanted to do ICA on the epochs. But now, as far as I can  
tell there is not a built-in filter() method for Epochs like there is for  
Raw, and mne.filter.low\_pass\_filter() seems to be a low-level function so  
I'm not sure if I should be calling it directly or not.

(My epochs are much larger than the time window I'm actually interested in,  
so I think it should be ok to filter; but if that's still not recommended,  
then another solution I could try is to run ICA on the epochs, apply those  
ICA weights back onto the raw data, filter the raw data, and then epoch  
again.)

Thanks,  
Steve

Stephen Politzer-Ahles  
New York University, Abu Dhabi  
Neuroscience of Language Lab  
[http://www.nyu.edu/projects/politzer-ahles/](http://www.nyu.edu/projects/politzer-ahles/)  
-------------- next part --------------  
An HTML attachment was scrubbed...  
URL: [http://mail.nmr.mgh.harvard.edu/pipermail/mne\_analysis/attachments/20131222/234b022f/attachment.html](http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20131222/234b022f/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:** [December 22, 2013, 1:13pm UTC](https://mne.discourse.group/t/some-question-about-epochsobjects-in-mne-python/644/2 "2013-12-22T13:13:37Z")

</div>

Dear Steven,

# epochs IO

for reading epochs use mne.read\_epochs

[http://martinos.org/mne/stable/generated/mne.read\_epochs.html#mne.read\_epochs](http://martinos.org/mne/stable/generated/mne.read_epochs.html#mne.read_epochs)

# filtering epochs

this is not supported by the API because you should know what you do,  
when you do it.  
If you want to do it the way to do it is to access the epochs data (in  
preload mode).

data = epochs.get\_date()  
n\_epochs, n\_channels, n\_samples = data.shape  
data = data.reshape(n\_channels, n\_epochs \* n\_samples)  
# for example  
mne.filter.low\_pass\_filter(data, 1, 45, copy=False)  
epochs.\_data = data.reshape(n\_epochs, n\_channels, n\_samples)

But this will only be valid if your data are sufficiently highpass  
filtered (otherwise artifacts due to epochsing).

# ICA

is there a certain reason why you prefer to do ICA before filtering?  
In my experience ICA will yield better results on filtered data  
(removes e.g high-frequency noise and drifts).  
Also you can speed up estimation time by not passing each sample using  
the decim parameter having filtered the data. For separating signals  
between 1 and 45 Hz you don't need 500 samples per second, which of  
course depends on the total number of samples.  
I often do the decim trick when working with raw data (it internally  
decimates a copy of your data which is passed to ICA, not your  
original data).

also see:  
[http://martinos.org/mne/stable/auto\_examples/preprocessing/plot\_ica\_from\_raw.html](http://martinos.org/mne/stable/auto_examples/preprocessing/plot_ica_from_raw.html)

the line with `ica.decompose_raw`

I hope this helps,  
Denis

---

<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:** [December 22, 2013, 1:20pm UTC](https://mne.discourse.group/t/some-question-about-epochsobjects-in-mne-python/644/3 "2013-12-22T13:20:38Z")

</div>

Thanks, I think that solves all my problems!

Regarding ICA and filtering, I just didn't do filtering because in the past  
I haven't (I have always left off filtering until as late as possible, just  
so I have the option of doing stats on unfiltered data if I want), but  
actually I haven't systematically compared whether ICA works better on  
filtered vs. unfiltered versions of my data, so it's definitely worth  
looking into. As for why I did ICA on epoched data rather than raw, it's  
just because I didn't want to pass in noisy data that's not from the actual  
task (e.g., parts of the recording where the participant was taking a break  
or talking to me, etc.), and the easiest way to do that was just to only  
use the [large] epochs around my critical events. But I took epochs that  
are each several seconds long, so that I can safely low-pass filter them  
and then chop out the actual epoch of interest from the middle later.

Best,  
Steve

Stephen Politzer-Ahles  
New York University, Abu Dhabi  
Neuroscience of Language Lab  
[http://www.nyu.edu/projects/politzer-ahles/](http://www.nyu.edu/projects/politzer-ahles/)

---

<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:** [December 22, 2013, 1:30pm UTC](https://mne.discourse.group/t/some-question-about-epochsobjects-in-mne-python/644/4 "2013-12-22T13:30:43Z")

</div>

Steve,

that's great to hear.

As to ICA, It's perfectly valid to run it on epochs for the reasons  
you mentioned.  
My pitch was that low and highpass filtering should be done before,  
unless you know better.  
The reason is that not doing so you might produce spike like peaks in  
your signals which maybe 'misinterpreted' as e.g. ECG peaks by ICA,  
since ICA is not run on single trials but on the concatenated channels  
by (samples \* epochs) time series.
