# trouble filtering ECG channel data

**URL:** <https://mne.discourse.group/t/trouble-filtering-ecg-channel-data/1005>\
**Category:** Mailing List Archive (read-only)\
**Tags:** list-archive\
**Created:** [April 22, 2016, 5:49pm UTC](https://mne.discourse.group/t/trouble-filtering-ecg-channel-data/1005 "2016-04-22T17:49:40Z")\
**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 22, 2016, 5:49pm UTC](https://mne.discourse.group/t/trouble-filtering-ecg-channel-data/1005/1 "2016-04-22T17:49:40Z")

</div>

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()

---

<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 22, 2016, 8:24pm UTC](https://mne.discourse.group/t/trouble-filtering-ecg-channel-data/1005/2 "2016-04-22T20:24:05Z")

</div>

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

---

<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 25, 2016, 8:07pm UTC](https://mne.discourse.group/t/trouble-filtering-ecg-channel-data/1005/3 "2016-04-25T20:07:59Z")

</div>

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

---

<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 25, 2016, 8:19pm UTC](https://mne.discourse.group/t/trouble-filtering-ecg-channel-data/1005/4 "2016-04-25T20:19:28Z")

</div>

Hi Jon/ all,

It seems to work if I modify the picks line to  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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
