[FieldTrip] 回复: Re: 回复: Re: When to detrend/demean

蔡林 bertram0611 at pku.edu.cn
Mon Jan 7 16:14:16 CET 2013

   Thank you very much.I benefited a lot from your explainations.

----- 原始邮件 -----
发件人: Roemer van der Meij <r.vandermeij at donders.ru.nl>
收件人: FieldTrip discussion list <fieldtrip at science.ru.nl>
已发送邮件: Mon, 07 Jan 2013 20:42:37 +0800 (CST)
主题: Re: [FieldTrip]	回复: Re: When to detrend/demean

Hi Lin,

You are right, up to some extent they are the same. Removing the linear
trend can also be achieved by using a high-pass filter. The 'center
frequency' of the linear trend depends on the length of the trial, a
high-pass filter of a sufficiently high frequency will also remove the
linear trend, and everything below it in terms of frequency as well. What
'sufficiently high' is, depends on which type of filter you are using and
at which order. A butterworth filter of order 4 and with a cutt-off at
(1/trial-length)*2 should in most cases be enough (do note that most
filters become very unstable when the cutt-off frequency is too low).

On frequency-analysis, please see my reply to Vitoria where I explain a
little bit why you should at least demean and detrend your raw-data (the
FAQs I link to are more verbose). Other filtering I would suggest is to
filter out line-noise. This kind of noise is most common at 50 or 60 Hz
depending on which continent you live, but can also occur at other
frequencies. A bandstop butterworth filter of order 4 and a bin of 1 Hz
surrounding it (e.g 49.5 <-> 50.5) will be fine most of the time. You can
also opt not to filter this out and only look at frequencies away from the
line-spectra, but keep in mind that the bleeding will always occur at all
frequencies. Distance will decrease it, but if the noise is sufficiently
strong it will bleed in (whether a channel is any good if it has humongous
line-noise is another thing).

Hope it helps,

On Sun, Jan 6, 2013 at 6:03 AM, 蔡林 <bertram0611 at pku.edu.cn> wrote:

> Hi Ingrid
>    After having seen your explaination, I want to know the relationship
> between highpass filter(eg.0.01 or 0.1Hz)and linear detrending. I think the
> linear detrending can reduce a linear trend due to equipment drift over
> longer time just as you said before. But I think the highpass filter have
> the same function as detrending. Am I right?
>    If I want to do a time-frequency analysis, must I filter my raw data? I
> hope you can give me some advice. I have been puzzled for a long time.
> Thanks!
> Lin
> ----- 原始邮件 -----
> 发件人: Ingrid Nieuwenhuis <inieuwenhuis at berkeley.edu>
> 收件人: fieldtrip at science.ru.nl
> 已发送邮件: Sun, 06 Jan 2013 10:24:56 +0800 (CST)
> 主题: Re: [FieldTrip] When to detrend/demean
> Hi Vitoria,
> The problem with these things is, it depends on what your interested in
> (hypothesis) and which methods you're using to analyze the data (ERP or
> frequanalysis, with our without ICA). All analysis steps have different
> pro and cons, so depending on your hypotheses and effects, what's good
> in one setup can be bad in the next. So you have to think of what the
> measures do, and how that effects your data.
> But now for some answers :) I'm just using a lot of experience and some
> common sense, maybe people can add in some refs and math if they know :)
> Demeaning just subtracts the mean of the specified time window (or
> indeed whole trial) from all samples
> detrending removes linear trend (you can also remove higher order
> trends, just for completeness)
> For ERPs you generally do want to demean using the baseline window, so
> the effect cancels out pre-stim. You don't want to detrend here, since
> often the ERP can have late components, and the signal might not be back
> to baseline yet. If you detrend in such a case, you will decrease the
> value samples late in the trials and increase the values during
> baseline. You will tilt the data (end down thus start up). But if you
> expect a linear trend due to equipment drift over longer time, that can
> muddle the ERP effect, then you might want to detrend. Also when the
> signal is noisy (high amplitude noise) at the end (due to speach
> artifacts), detrending might be dangerous.
> For frequency analysis, demeaning has (as far as I know) no effect,
> since subtracting a constant does not change the frequency info in the
> signal. I know people do tend to detrend before freq analysis (so I also
> tend to do that), but I have to admit, I don't know why really. Maybe to
> get rid of the drift, so it does not end up in the low frequencies. But
> again, the effect of detrending (which freqs it affects) depends how
> long your time window is, and which frequencies your interested in. If
> you are interested in really low frequencies, detrending might change
> your effects.
> Hope this helps somewhat,
> Ingrid
> On 1/5/2013 2:21 AM, Vitória Magalhães Piai wrote:
> > Dear ftrippers,
> >
> > I'm having a discussion with a colleague on something that is still a
> > bit unclear to us. Since I trust the knowledge going around here a
> > lot, I thought it would be my best chance to get a good answer: When
> > should we demean/detrend?
> >
> > As relevant background, our EEG datasets involve speech production on
> > every trial.
> > We read in the data, use ft_databrowser to mark the artefacts and then
> > do complete artefact rejection with ft_rejectartifact. The trials
> > often include speech (onset).
> > I see in the tutorial that the cfg for preprocessing is pretty simple,
> > and ft_preprocessing default has no detrend/demean.
> > But in the FT example 'Reading and pre-processing EEG data', the cfg is
> >
> > cfg.demean           = 'yes';
> > cfg.baselinewindow  = [-0.2 0];
> >
> >
> > In my data, I used cfg.demean = 'yes'; with no cfg for the baseline
> > window because I don't want to correct the signal with a specific
> > interval (and I assume this will take the whole segment then).
> > Our concern is that, given that people speak during part of the trial
> > (always towards the end), using demean here is not a good idea (the
> > signal changes induced by moving the jaws, etc., are included in the
> > calculation). Is this necessarily the case or can it be fixed with
> > subsequent computations (see below)? Do I need to go through artefact
> > rejection again? My guess would be that the damage caused by having
> > demean here doesn't change that much where the eyeblinks are and I
> > always take quite broad windows to mark the artefacts, so at least for
> > the AR I should be safe, but I'd like to check that with you guys.
> >
> > Then, when calculating ERPs, I had both demean and detrend before
> > timelocking.
> > But for the TFRs, I didn't do any of these (dunno why). I'm using the
> > ft_freqanalysis after the 2011 change (removing the first order linear
> > trend from the time domain data).
> > Do I need to redo my TFRs or is it enough if I do sanity checks and
> > everything is in place (like visual alpha and gamma, etc.)?
> >
> > And my last question, for once and for all, so that I get it right
> > next time from the start (assuming that I'll always have EEG speech
> > production data with ERPs and TFRs analysed). Is this the best way to
> > do it?
> > - preprocess with default (so NO detrend and NO demean)
> > - then demean and detrend for ft_timelockanalysis and ft_freqanalysis
> >
> > Thanx a lot, and (keeping to the Dutch tradition) all the best for 2013!
> > Vitoria
> >
> >
> >
> > _______________________________________________
> > fieldtrip mailing list
> > fieldtrip at donders.ru.nl
> > http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> --
> Ingrid Nieuwenhuis PhD
> Postdoctoral Fellow
> Sleep and Neuroimaging Laboratory
> Department of Psychology
> University of California, Berkeley
> California 94720-1650
> Tolman Hall, room 5305
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> --
> Lin Cai
> Department of Psychology, Peking University, Beijing 100871, P.R.China
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip

Roemer van der Meij M.Sc.
PhD Candidate
Donders Institute for Brain, Cognition and Behaviour
Centre for Cognition
P.O. Box 9104
6500 HE Nijmegen
The Netherlands
Tel: +31(0)24 3655932
E-mail: r.vandermeij at donders.ru.nl

Lin Cai
Department of Psychology, Peking University, Beijing 100871, P.R.China

More information about the fieldtrip mailing list