trouble filtering ECG channel data

Hello all,
I have written a little script that pulls the ECG channel data out of the
fif file and writes a text file to pass to QRSTool (free external software).

But I have some fif files with the ECG data on channel EEG063 and some on
ECG063. My script works on the channel labeled EEG063, but it fails for
the ECG063. Specifically, I use raw.pick to get the channel I want. I can
plot it fine, it returns type mne.io.fiff.raw.RawFIF, but when I try to
filter using raw.notch_filter, I get a weird error. See below for the
relevant snippets of code and outputs.

I just discovered the raw.set_channel_types method and wonder if that could
help, but I'm having trouble getting the syntax right...

(also, btw, mne.sys.info() gives me an error... so I can't tell what mne
version I'm running. I did attempt git pull master origin and I'm still
having the problem with raw.filter.)

Thanks much in advance,
Megan

[mschendel at XXXX ~]$ ipython
Python 3.5.1 |Anaconda 2.5.0 (64-bit)| (default, Dec 7 2015, 11:16:01)
In [1]: import mne
In [2]: mne.sys.info()

Hi Megan,

Notch_filter will only filter the MEG/EEG channels unless you specify some
channels using picks. You could do something like:

picks = mne.pick_types(raw.info, ecg=True)
raw.notch_filter(freqs = np.arange(60, 241, 60), picks=picks )

which will then find and filter the ECG data. I think if you added that to
your notch_filter and added the picks lines for EEG and ECG in your if
statement, you'd be good to go.

Jon

Hi Jon!
Thanks for your help!

I'm a bit confused on what to do with the picks = line. I tried putting it
before my if statement, and adding picks to my notch statement, but I got a
different error. I also tried adding picks = line inside the if statement,
before I did raw.pick_channels, but I get the same error.

It seems like using picks inside the filter might be redundant with
creating a raw object with raw.pick_channels.... ? Or I'm not using
something correctly. I'd very much appreciate a little more help.

Thanks again,
Megan

Hi Jon/ all,

It seems to work if I modify the picks line to
     picks = mne.pick_types(raw.info, meg =False, ecg = True)
and then include picks in my filter statements.

Thanks a bunch!
Megan

MEG Technician
The Mind Research Network
1101 Yale Blvd. NE
Albuquerque, New Mexico 87106
505-272-3304