<div dir="ltr"><div>Hi Jon/ all,<br><br></div><div>It seems to work if I modify the picks line to <br>     picks = mne.pick_types(<a href="http://raw.info">raw.info</a>, meg =False,  ecg = True)<br>and then include picks in my filter statements.<br><br></div><div>Thanks a bunch!<br></div><div>Megan<br></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature">MEG Technician<br>The Mind Research Network<br>1101 Yale Blvd. NE<br>Albuquerque, New Mexico 87106<br>505-272-3304<br><br></div></div>
<br><div class="gmail_quote">On Mon, Apr 25, 2016 at 2:07 PM, Megan Schendel <span dir="ltr">&lt;<a href="mailto:mschendel@mrn.org" target="_blank">mschendel@mrn.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div>Hi Jon!<br></div>Thanks for your help! <br><br></div>I&#39;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.<br><br></div><div>It seems like using picks inside the filter might be redundant with creating a raw object with raw.pick_channels.... ? Or I&#39;m not using something correctly.  I&#39;d very much appreciate a little more help.<br><br></div><div>Thanks again,<br></div><div>Megan<br></div><div><br></div>#<br></div><div># attempt one, set picks prior to if<br></div><div>#<br>In [8]: picks = mne.pick_types(<a href="http://raw.info" target="_blank">raw.info</a>, ecg = True)<br><br>In [9]: if &#39;EEG063&#39; in raw.ch_names:<span class=""><br>   ...:     raw_bits = raw.pick_channels([&#39;EEG063&#39;])<br>   ...:     print (&#39;Found EEG063 &#39;)<br></span>   ...:     <br><br>In [10]: if &#39;ECG063&#39; in raw.ch_names:<span class=""><br>   ....:     raw_bits = raw.pick_channels([&#39;ECG063&#39;])<br>   ....:     print (&#39;Found ECG063 &#39;)<br>   ....:     <br></span>Found ECG063 <br><br>In [11]: raw_bits_orig = raw_bits.copy()<br><br>In [12]: raw_bits.notch_filter(freqs = numpy.arange(60, 241, 60), picks=picks )<br></div><div># Nasty error, which I&#39;ve pasted at the end of my code<br></div><div><br>#<br></div># attempt 2, after I used io.Raw again to make sure I had what I started with<br><div># picks inside if, prior to raw.pick_channels<br></div><div>#<br></div><div class="gmail_extra">In [17]: if &#39;ECG063&#39; in raw.ch_names:<br>   ....:     picks = mne.pick_types(<a href="http://raw.info" target="_blank">raw.info</a>, ecg=True)<span class=""><br>   ....:     raw_bits = raw.pick_channels([&#39;ECG063&#39;])<br>   ....:     print (&#39;Found ECG063 &#39;)<br>   ....:     <br></span>Found ECG063 <br><br>In [18]: raw_bits_orig = raw_bits.copy()<br><br>In [19]: raw_bits.notch_filter(freqs = numpy.arange(60, 241, 60), picks=picks )<br><br>#<br></div><div class="gmail_extra"># In both cases, the error I got:<br></div><div class="gmail_extra">#<br><br>---------------------------------------------------------------------------<br>IndexError                                Traceback (most recent call last)<br>&lt;ipython-input-19-59ffe03b1d2b&gt; in &lt;module&gt;()<br>----&gt; 1 raw_bits.notch_filter(freqs = numpy.arange(60, 241, 60), picks=picks )<span class=""><br><br>/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)<br><br>/export/research/analysis/human/jstephen/shared/programs/python/anaconda3/lib/python3.5/site-packages/mne/utils.py in verbose(function, *args, **kwargs)<br>    549         finally:<br>    550             set_log_level(old_level)<br>--&gt; 551     return function(*args, **kwargs)<br>    552 <br>    553 <br><br>/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)<br></span>    945                                   method=method, iir_params=iir_params,<br>    946                                   mt_bandwidth=mt_bandwidth, p_value=p_value,<br>--&gt; 947                                   picks=picks, n_jobs=n_jobs, copy=False)<br>    948 <br>    949     @verbose<br><br>/export/research/analysis/human/jstephen/shared/programs/python/anaconda3/lib/python3.5/site-packages/mne/filter.py in notch_filter(x, Fs, freqs, filter_length, notch_widths, trans_bandwidth, method, iir_params, mt_bandwidth, p_value, picks, n_jobs, copy, verbose)<span class=""><br><br>/export/research/analysis/human/jstephen/shared/programs/python/anaconda3/lib/python3.5/site-packages/mne/utils.py in verbose(function, *args, **kwargs)<br>    549         finally:<br>    550             set_log_level(old_level)<br>--&gt; 551     return function(*args, **kwargs)<br>    552 <br>    553 <br><br></span>/export/research/analysis/human/jstephen/shared/programs/python/anaconda3/lib/python3.5/site-packages/mne/filter.py in notch_filter(x, Fs, freqs, filter_length, notch_widths, trans_bandwidth, method, iir_params, mt_bandwidth, p_value, picks, n_jobs, copy, verbose)<br>   1105                  for freq, nw in zip(freqs, notch_widths)]<br>   1106         xf = band_stop_filter(x, Fs, lows, highs, filter_length, tb_2, tb_2,<br>-&gt; 1107                               method, iir_params, picks, n_jobs, copy)<br>   1108     elif method == &#39;spectrum_fit&#39;:<br>   1109         xf = _mt_spectrum_proc(x, Fs, freqs, notch_widths, mt_bandwidth,<br><br>/export/research/analysis/human/jstephen/shared/programs/python/anaconda3/lib/python3.5/site-packages/mne/filter.py in band_stop_filter(x, Fs, Fp1, Fp2, filter_length, l_trans_bandwidth, h_trans_bandwidth, method, iir_params, picks, n_jobs, copy, verbose)<span class=""><br><br>/export/research/analysis/human/jstephen/shared/programs/python/anaconda3/lib/python3.5/site-packages/mne/utils.py in verbose(function, *args, **kwargs)<br>    549         finally:<br>    550             set_log_level(old_level)<br>--&gt; 551     return function(*args, **kwargs)<br>    552 <br>    553 <br><br></span>/export/research/analysis/human/jstephen/shared/programs/python/anaconda3/lib/python3.5/site-packages/mne/filter.py in band_stop_filter(x, Fs, Fp1, Fp2, filter_length, l_trans_bandwidth, h_trans_bandwidth, method, iir_params, picks, n_jobs, copy, verbose)<br>    786         if np.any(np.abs(np.diff(gain, 2)) &gt; 1):<br>    787             raise ValueError(&#39;Stop bands are not sufficiently separated.&#39;)<br>--&gt; 788         xf = _filter(x, Fs, freq, gain, filter_length, picks, n_jobs, copy)<br>    789     else:<br>    790         for fp_1, fp_2, fs_1, fs_2 in zip(Fp1, Fp2, Fs1, Fs2):<br><br>/export/research/analysis/human/jstephen/shared/programs/python/anaconda3/lib/python3.5/site-packages/mne/filter.py in _filter(x, Fs, freq, gain, filter_length, picks, n_jobs, copy)<br>    372         h = firwin2(N, freq, gain, window=&#39;hann&#39;)<br>    373         x = _overlap_add_filter(x, h, zero_phase=True, picks=picks,<br>--&gt; 374                                 n_jobs=n_jobs)<br>    375 <br>    376     x.shape = orig_shape<br><br>/export/research/analysis/human/jstephen/shared/programs/python/anaconda3/lib/python3.5/site-packages/mne/filter.py in _overlap_add_filter(x, h, n_fft, zero_phase, picks, n_jobs)<br>    140     if n_jobs == 1:<br>    141         for p in picks:<br>--&gt; 142             x[p] = _1d_overlap_filter(x[p], h_fft, n_h, n_edge, zero_phase,<br>    143                                       cuda_dict)<br>    144     else:<br><br>IndexError: index 1 is out of bounds for axis 0 with size 1<span class=""><br><br><br><br><br clear="all"><div><div>MEG Technician<br>The Mind Research Network<br>1101 Yale Blvd. NE<br>Albuquerque, New Mexico 87106<br><a href="tel:505-272-3304" value="+15052723304" target="_blank">505-272-3304</a><br><br></div></div>
<br></span><div><div class="h5"><div class="gmail_quote">On Fri, Apr 22, 2016 at 2:24 PM, Jon Houck <span dir="ltr">&lt;<a href="mailto:jhouck@mrn.org" target="_blank">jhouck@mrn.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Megan,<div><br></div><div>Notch_filter will only filter the MEG/EEG channels unless you specify some channels using picks.  You could do something like: </div><blockquote style="margin:0px 0px 0px 40px;border:medium none;padding:0px"><div>picks = mne.pick_types(<a href="http://raw.info" target="_blank">raw.info</a>, ecg=True)</div><div>raw.notch_filter(freqs = np.arange(60, 241, 60), picks=picks )</div></blockquote>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&#39;d be good to go.<div><br></div><div>Jon</div><div><br></div><div><br><blockquote style="margin:0px 0px 0px 40px;border:medium none;padding:0px"><div><br></div><div><br></div></blockquote><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Fri, Apr 22, 2016 at 11:49 AM, Megan Schendel <span dir="ltr">&lt;<a href="mailto:mschendel@mrn.org" target="_blank">mschendel@mrn.org</a>&gt;</span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><div dir="ltr"><div>Hello all,<br>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).<br><br>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.<br><br></div><div>I just discovered the raw.set_channel_types method and wonder if that could help, but I&#39;m having trouble getting the syntax right...<br></div><div><br>(also, btw, <a href="http://mne.sys.info" target="_blank">mne.sys.info</a>()
 gives me an error... so I can&#39;t tell what mne version I&#39;m running.  I 
did attempt git pull master origin and I&#39;m still having the problem with
 raw.filter.)<br><br></div><div>Thanks much in advance,<br></div><div>Megan<br></div><div><br>[mschendel@XXXX ~]$ ipython<br>Python 3.5.1 |Anaconda 2.5.0 (64-bit)| (default, Dec  7 2015, 11:16:01) <br>In [1]: import mne<br>In [2]: <a href="http://mne.sys.info" target="_blank">mne.sys.info</a>()<br>---------------------------------------------------------------------------<br>AttributeError                            Traceback (most recent call last)<br>&lt;ipython-input-2-aa9bd53b86f1&gt; in &lt;module&gt;()<br>----&gt; 1 <a href="http://mne.sys.info" target="_blank">mne.sys.info</a>()<br><br>AttributeError: module &#39;mne&#39; has no attribute &#39;sys&#39;<br><br>#<br></div><div># Here is my io.Raw command... no trouble there... <br>#<br></div><br>In [21]: raw = io.Raw(infile, preload=True, verbose=None)<br><div># Cut all the io reporting...<br></div><div><br>In [22]: if &#39;EEG063&#39; in raw.ch_names:<br>   ....:     raw_bits = raw.pick_channels([&#39;EEG063&#39;])<br>   ....:     print (&#39;Found EEG063 &#39;)<br>   ....: elif &#39;ECG063&#39; in raw.ch_names:<br>   ....:     raw_bits = raw.pick_channels([&#39;ECG063&#39;])<br>   ....:     print (&#39;Found ECG063 &#39;)<br>   ....:     <br>Found EEG063 <br><br>In [23]: raw.notch_filter(freqs = numpy.arange(60, 241, 60) )<br>---------------------------------------------------------------------------<br>RuntimeError                              Traceback (most recent call last)<br>&lt;ipython-input-13-f5e5440dff87&gt; in &lt;module&gt;()<br>----&gt; 1 raw.notch_filter(freqs = numpy.arange(60, 241, 60) )<br><br>/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)<br><br>/export/research/analysis/human/jstephen/shared/programs/python/anaconda3/lib/python3.5/site-packages/mne/utils.py in verbose(function, *args, **kwargs)<br>    549         finally:<br>    550             set_log_level(old_level)<br>--&gt; 551     return function(*args, **kwargs)<br>    552 <br>    553 <br><br>/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)<br>    932             # let&#39;s be safe.<br>    933             if len(picks) &lt; 1:<br>--&gt; 934                 raise RuntimeError(&#39;Could not find any valid channels for &#39;<br>    935                                    &#39;your Raw object. Please contact the &#39;<br>    936                                    &#39;MNE-Python developers.&#39;)<br><br>RuntimeError: Could not find any valid channels for your Raw object. Please contact the MNE-Python developers.<br><br>#<br></div><div># Try to remap channel to EEG type...<br></div><div>#<br>In [30]: raw_bits.set_channel_types(mapping = {&#39;ECG063&#39;: ‘eeg’})<br>  File &quot;&lt;ipython-input-30-1c0e7f2a2c6d&gt;&quot;, line 1<br>    raw_bits.set_channel_types(mapping = {&#39;ECG063&#39;: ‘eeg’})<br>                                                        ^<br>SyntaxError: invalid character in identifier<br><br><br><br>#<br>#   If I do the same with data that has channel labeled as EEG ... <br>#<br>In [5]: if &#39;EEG063&#39; in raw.ch_names:<br>    raw_bits = raw.pick_channels([&#39;EEG063&#39;])<br>    print (&#39;Found EEG063 &#39;)<br>elif &#39;ECG063&#39; in raw.ch_names:<br>    raw_bits = raw.pick_channels([&#39;ECG063&#39;])<br>    print (&#39;Found ECG063 &#39;)<br>   ...:     <br>Found EEG063 <br>In [6]: raw_bits.notch_filter(freqs = numpy.arange(60, 241, 60) )<br><br>In [7]: raw_bits.notch_filter(freqs = numpy.arange(60, 241, 60) )<br>#  no complaints... <br><br><br><br><div><div>MEG Technician<br>The Mind Research Network<br>1101 Yale Blvd. NE<br>Albuquerque, New Mexico 87106<br><a href="tel:505-272-3304" value="+15052723304" target="_blank">505-272-3304</a><br><br></div></div>
</div></div>
<br></div></div>_______________________________________________<br>
Mne_analysis mailing list<br>
<a href="mailto:Mne_analysis@nmr.mgh.harvard.edu" target="_blank">Mne_analysis@nmr.mgh.harvard.edu</a><br>
<a href="https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis" rel="noreferrer" target="_blank">https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis</a><br>
<br>
<br>
The information in this e-mail is intended only for the person to whom it is<br>
addressed. If you believe this e-mail was sent to you in error and the e-mail<br>
contains patient information, please contact the Partners Compliance HelpLine at<br>
<a href="http://www.partners.org/complianceline" rel="noreferrer" target="_blank">http://www.partners.org/complianceline</a> . If the e-mail was sent to you in error<br>
but does not contain patient information, please contact the sender and properly<br>
dispose of the e-mail.<br>
<br></blockquote></div><span><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div><div dir="ltr">Jon M. Houck, Ph.D.<br>Assistant Professor of Translational Neuroscience<br>Mind Research Network<div>1101 Yale Blvd. NE<br>Albuquerque, NM 87106<br><br></div></div></div>
</font></span></div>
<br>_______________________________________________<br>
Mne_analysis mailing list<br>
<a href="mailto:Mne_analysis@nmr.mgh.harvard.edu" target="_blank">Mne_analysis@nmr.mgh.harvard.edu</a><br>
<a href="https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis" rel="noreferrer" target="_blank">https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis</a><br>
<br>
<br>
The information in this e-mail is intended only for the person to whom it is<br>
addressed. If you believe this e-mail was sent to you in error and the e-mail<br>
contains patient information, please contact the Partners Compliance HelpLine at<br>
<a href="http://www.partners.org/complianceline" rel="noreferrer" target="_blank">http://www.partners.org/complianceline</a> . If the e-mail was sent to you in error<br>
but does not contain patient information, please contact the sender and properly<br>
dispose of the e-mail.<br>
<br></blockquote></div><br></div></div></div></div>
</blockquote></div><br></div>