[Mne_analysis] trouble filtering ECG channel data

Megan Schendel mschendel at mrn.org
Fri Apr 22 13:49:40 EDT 2016
Search archives:

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()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-aa9bd53b86f1> in <module>()
----> 1 mne.sys.info()

AttributeError: module 'mne' has no attribute 'sys'

#
# Here is my io.Raw command... no trouble there...
#

In [21]: raw = io.Raw(infile, preload=True, verbose=None)
# Cut all the io reporting...

In [22]: if 'EEG063' in raw.ch_names:
   ....:     raw_bits = raw.pick_channels(['EEG063'])
   ....:     print ('Found EEG063 ')
   ....: elif 'ECG063' in raw.ch_names:
   ....:     raw_bits = raw.pick_channels(['ECG063'])
   ....:     print ('Found ECG063 ')
   ....:
Found EEG063

In [23]: raw.notch_filter(freqs = numpy.arange(60, 241, 60) )
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-13-f5e5440dff87> in <module>()
----> 1 raw.notch_filter(freqs = numpy.arange(60, 241, 60) )

/export/research/analysis/human/jstephen/shared/programs/python/anaconda3/lib/python3.5/site-packages/mne/io/base.py
in notch_filter(self, freqs, picks, filter_length, notch_widths,
trans_bandwidth, n_jobs, method, iir_params, mt_bandwidth, p_value, verbose)

/export/research/analysis/human/jstephen/shared/programs/python/anaconda3/lib/python3.5/site-packages/mne/utils.py
in verbose(function, *args, **kwargs)
    549         finally:
    550             set_log_level(old_level)
--> 551     return function(*args, **kwargs)
    552
    553

/export/research/analysis/human/jstephen/shared/programs/python/anaconda3/lib/python3.5/site-packages/mne/io/base.py
in notch_filter(self, freqs, picks, filter_length, notch_widths,
trans_bandwidth, n_jobs, method, iir_params, mt_bandwidth, p_value, verbose)
    932             # let's be safe.
    933             if len(picks) < 1:
--> 934                 raise RuntimeError('Could not find any valid
channels for '
    935                                    'your Raw object. Please contact
the '
    936                                    'MNE-Python developers.')

RuntimeError: Could not find any valid channels for your Raw object. Please
contact the MNE-Python developers.

#
# Try to remap channel to EEG type...
#
In [30]: raw_bits.set_channel_types(mapping = {'ECG063': ‘eeg’})
  File "<ipython-input-30-1c0e7f2a2c6d>", line 1
    raw_bits.set_channel_types(mapping = {'ECG063': ‘eeg’})
                                                        ^
SyntaxError: invalid character in identifier



#
#   If I do the same with data that has channel labeled as EEG ...
#
In [5]: if 'EEG063' in raw.ch_names:
    raw_bits = raw.pick_channels(['EEG063'])
    print ('Found EEG063 ')
elif 'ECG063' in raw.ch_names:
    raw_bits = raw.pick_channels(['ECG063'])
    print ('Found ECG063 ')
   ...:
Found EEG063
In [6]: raw_bits.notch_filter(freqs = numpy.arange(60, 241, 60) )

In [7]: raw_bits.notch_filter(freqs = numpy.arange(60, 241, 60) )
#  no complaints...



MEG Technician
The Mind Research Network
1101 Yale Blvd. NE
Albuquerque, New Mexico 87106
505-272-3304
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20160422/d6319b97/attachment.html 


More information about the Mne_analysis mailing list