mne-tools / mne-python

MNE: Magnetoencephalography (MEG) and Electroencephalography (EEG) in Python
https://mne.tools
BSD 3-Clause "New" or "Revised" License
2.67k stars 1.31k forks source link

Savitzky-Golay filter #347

Closed agramfort closed 9 years ago

agramfort commented 11 years ago

add support of the Savitzky-Golay filter

see : https://github.com/scipy/scipy/pull/304

and :

http://inst.eecs.berkeley.edu/~ee123/fa12/docs/SGFilter.pdf

could be used to filter Evoked and Epochs.

dengemann commented 11 years ago

Sounds very interesting!

On Sun, Jan 6, 2013 at 4:36 PM, Alexandre Gramfort <notifications@github.com

wrote:

add support of the Savitzky-Golay filter

see : scipy/scipy#304 https://github.com/scipy/scipy/issues/304

and :

http://inst.eecs.berkeley.edu/~ee123/fa12/docs/SGFilter.pdf

could be used to filter Evoked and Epochs.

— Reply to this email directly or view it on GitHubhttps://github.com/mne-tools/mne-python/issues/347.

agramfort commented 10 years ago

I'd really like to have this as

epochs.filter evoked.filter

methods.

the motivation is that such filters do not reduce peak amplitudes of ERPs/ERFs

any volunteer?

mainakjas commented 10 years ago

I could give it a shot. Sounds doable.

agramfort commented 10 years ago

I could give it a shot. Sounds doable.

great.

larsoner commented 10 years ago

The upstream scipy function got merged, might have made it to 0.13 or not. Either way, we could implement appropriate version check and throw it in. Should probably go in filter.py. @mainakjas feel free to take a stab when you feel like it, or if you don't want to anymore, would make a good starting project for someone else.

agramfort commented 10 years ago

+1

we should backport it too

mainakjas commented 10 years ago

really sorry about this. At the moment, it doesn't look like I'm going to give this shot till December end. If anyone wants to give it a shot before that, that's cool with me. I'll inform when I start working on this.

dengemann commented 10 years ago

Isn't some one bored? Also here's an implementation in Python https://code.google.com/p/pyeeg/ could put that in externals or find a better implementation.

larsoner commented 9 years ago

I guess we haven't needed this for two years... do you think we still need it @agramfort?

agramfort commented 9 years ago

it's in scipy now.

we need to integrate it.

it can be convenient to smooth the evoked data late in the pipeline

larsoner commented 9 years ago

you want it for 0.9? it seems like it should be pretty straightforward

agramfort commented 9 years ago

let's focus on open PR

conversion between frequency params and sav gol params is maybe not that trivial.

larsoner commented 9 years ago

I wrote a gist suggesting that using a 5th-order polynomial with a window length twice as large as the wavelength of the freq of interest should work okay:

https://gist.github.com/Eric89GXL/bbac101d50176611136b

Plotting the original spectra (yellow) and post-savgol spectra for different filter orders (left labels) and requested "lowpass frequencies" (bottom labels), with the -20 dB point in horizontal dashed line and requested freq in dotted vertical line:

figure_1