mne-tools / mne-python

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

add epochs detrending option #349

Closed agramfort closed 11 years ago

agramfort commented 11 years ago

see:

http://mailman.science.ru.nl/pipermail/fieldtrip/2012-January/004666.html

Epochs(..., detrend=None) -> no detrend Epochs(..., detrend=0) -> DC offset Epochs(..., detrend=1) -> order 1 polynomial correction

see scipy.signal.detrend

larsoner commented 11 years ago

This should be pretty straightforward. I can give it a shot soon if nobody else is on it.

larsoner commented 11 years ago

My first thought is to implement this in the epoch reading step, prior to decimation. That way it will work regardless of preloading. I'd probably first make a detrend function in filter (that intelligently wraps to scipy), then call that in epochs.py and evoked.py.

dengemann commented 11 years ago

If this doesn't make things slow, this sounds like a good idea to me.

On Tue, Jan 8, 2013 at 4:23 PM, Eric89GXL notifications@github.com wrote:

My first thought is to implement this in the epoch reading step, prior to decimation. That way it will work regardless of preloading. I'd probably first make a detrend function in filter (that intelligently wraps to scipy), then call that in epochs.py and evoked.py.

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

larsoner commented 11 years ago

IIRC first-order polynomial fits should have a closed-form linear algebra solution (a couple matrix multiplies / inverses), so it should be pretty quick. I guess we'll find out...

larsoner commented 11 years ago

PR coming shortly on this...