Mne_analysis Digest, Vol 55, Issue 16

Greetings,
I am trying to filter raw data before extracting epochs and computing
contrasts.
I am using:
     raw = fiff.Raw(f, preload=True) #Setup for reading the raw data
     events = mne.find_events(raw, stim_channel='STI101')
Up to this point I get 7 events, which is correct.

     raw.filter(None, 40.0, picks=None, filter_length=4096,
h_trans_bandwidth=0.5, verbose=5, n_jobs=8) # filter raw
This command works without error.

     tmin, tmax = -0.1, 0.5
     reject = dict(grad=3000e-13)
     epochs = mne.Epochs(raw, events, 1, tmin, tmax, baseline=(None, 0),
reject=reject) #extract epochs
I get an output with ~300 epochs, also correct.

     evoked = epochs.average() # average epochs and get an Evoked dataset.
If I don't include the mne.filter command I get an unfiltered evoked
dataset which I can visualize with plot_evoked(evoked).
If I include the mne.filter command I get the following error during
averaging:
/usr/local/mne-python/mne/epochs.py:424: RuntimeWarning: invalid value
encountered in divide data /= n_events. And no evoked dataset.
Assuming this procedure is incorrect, how else can I filter raw data on
the fly (i.e., without saving), and average epochs?

Thanks in advance
Kambiz

hi Kambiz,

what you're doing is correct.

filtering param are not independent from rejection values but what you
describe is
weird.

I would plot an epoch after filtering so see what might happen.

data = epochs.get_data()
import pylab as pl
pl.plot(epochs.times, data[0].T)

you might want to share the fif file and the script via dropbox.

Alex