[Mne_analysis] Filtering in MNE python

Jon Houck jhouck at unm.edu
Wed Feb 8 14:56:14 EST 2012
Search archives:

Martin,

This was helpful, thanks.  On the first pass I got a new error message,
"AttributeError: 'module' object has no attribute 'firwin2'.".    Updating
from scipy 0.7.2 to numpy 1.6.1 and scipy 0.10.0 fixed this, and it works
perfectly now.




Regards,

Jon







On Fri, Feb 3, 2012 at 6:29 PM, Martin Luessi
<mluessi at nmr.mgh.harvard.edu>wrote:

>
> On 02/03/12 17:44, Jon Houck wrote:
> > Hi all,
> >
> > I've been trying to filter raw data in MNE python and am getting the
> > error message: AttributeError: 'Raw' object has no attribute 'ndim'.
> >  The tutorial exercises have run perfectly  for me, using both the
> > sample data and my own data, so the most likely cause is user error.
> >  The commands in ipython are:
> >
> >     import numpy as np
> >     from mne import fiff
> >     from mne import filter
> >     data_path =
> >
> '/usr/lib/python2.6/site-packages/mne-0.2.git-py2.6.egg/mne/datasets/sample/MNE-sample-data'
> >     raw_fname = data_path + '/MEG/sample/sample_audvis_raw.fif'
> >     raw = fiff.Raw(raw_fname)
> >     raw = filter.band_pass_filter(raw, 1000, 50, 1, filter_length=2048)
> >
> > What's the correct way to do this?  From the error, I'd guess that I'm
> > either passing the wrong part the array to the filter, or skipping some
> > important step.  I'm using mne-tools-mne-python-v0.2-70-g9a72ede in
> > python 2.6, on a machine running 64-bit CentOS 6.  The complete error
> > message is below.
>
> Jon,
>
> mne-python currently doesn't support direct filtering operations on Raw
> objects; the filtering operations only support 1D ndarrays i.e., a
> single time series, as input.
>
> Using the latest mne-python version from github, you could do what you
> want as follows:
>
> raw = fiff.Raw(raw_fname, preload=True)
> data, times = raw[:, :]
> sfreq = float(raw.info['sfreq'])
> data_filtered = numpy.array([filter.band_pass_filter(x, sfreq, 50, 1,
> filter_length=2048) for x in data])
> raw[:, :] = data_filtered
>
> Note that for band_pass you need Fp1 < Fp2, so the above still won't
> work (I assume it should be 1, 50, 1..50Hz).
>
> Best,
>
> Martin
>
> --
> Martin Luessi, Ph.D.
>
> Research Fellow
>
> Department of Radiology
> Athinoula A. Martinos Center for Biomedical Imaging
> Massachusetts General Hospital
> Harvard Medical School
> 149 13th Street
> Charlestown, MA 02129
>
> Fax: +1 617 726-7422
>
>
> The information in this e-mail is intended only for the person to whom it
> is
> addressed. If you believe this e-mail was sent to you in error and the
> e-mail
> contains patient information, please contact the Partners Compliance
> HelpLine at
> http://www.partners.org/complianceline . If the e-mail was sent to you in
> error
> but does not contain patient information, please contact the sender and
> properly
> dispose of the e-mail.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20120208/2857c7bf/attachment.html 


More information about the Mne_analysis mailing list