[Eeglablist] eeglab causal filtering: impacts and applications?
Cedric Cannard
ccannard at protonmail.com
Fri Feb 5 10:58:27 PST 2021
Hi Andreas,
Thank you so much for all the feedback, advice, and resources.
Still a lot to learn, but the filter world is a little bit clearer.
Kind regards,
Cedric
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Friday, February 5, 2021 9:07 AM, Andreas Widmann <widmann at uni-leipzig.de> wrote:
> Hi Cedric,
>
> > > Indeed blinking can be a serious problem with ERPs. For example, participants tend to blink after giving a response introducing noteworthy amounts of noise. If there are systematic differences in response latency between conditions this may introduce considerable bias between conditions. Personally, I think ICA is very useful for removing blink artifacts.
> >
> > I agree. ICA being applied after filtering, does it remove artifactual activity smeared over the group delay by non-causal filtering?
>
> Linear phase filtering shouldn’t change the independent component topographies. As the output of non-causal vs. causal linear phase filters is identical (just delayed) there shouldn’t be a difference with respect to causality. See e.g., the introduction of
> https://urldefense.com/v3/__https://onlinelibrary.wiley.com/doi/full/10.1111/ejn.14992__;!!Mih3wA!WlVVw6y6WsMIveCkz6Cx0qfOc0soAbgN7fqqfafhhGpsK1K4v6sywYeJkpnraIjK4rrVrw$
> for more detailed considerations on ICA and filtering.
>
> > Last question I promise :)
> > I am now wondering if referencing is affected by the use of a causal non-linear filter. Should I average-reference or is it better to use another referencing method after this type of filter (e.g. REST/infinity, CSD/laplacian transform, no re-referencing)?
>
> Sorry, I cannot comment on this. Just a general note: I’m sometimes lazily writing linear/non-linear filtering. In this context (spectral filters) actually I should consistently use the complete and correct terminology: linear/non-linearphase filtering. "Linear/non-linear phase" here describes that the phase response is a straight line or not. The point is that also non-linear phase spectral filtering is a linear operation (in contrast to true non-linear filtering). This is all straight-forward convolution (https://urldefense.com/v3/__https://en.wikipedia.org/wiki/Convolution*Properties__;Iw!!Mih3wA!WlVVw6y6WsMIveCkz6Cx0qfOc0soAbgN7fqqfafhhGpsK1K4v6sywYeJkpnraIiZ-aC0fQ$ ). For linear operations the order doesn’t matter, and therefore, for regular re-referencing (common/averaged/linked reference) the order (filter -> re-reference or re-reference -> filter) doesn’t matter (except edge effects).
>
> Best,
> Andreas
>
> > I really appreciate you taking the time to respond to all my questions!
> > Cedric
> > Cedric
> > ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> > On Thursday, February 4, 2021 3:34 AM, Andreas Widmann widmann at uni-leipzig.de wrote:
> >
> > > Hi Cedric,
> > >
> > > > That leaves me the minimum-phase causal filter with a reduced but unknown delay as well as unknown signal/phase distortions (which prevents me from doing frequency analyses), which doesn't sound really good either.
> > >
> > > For frequency analysis filtering is not necessarily required. Most time frequency analysis methods are actually filters by itself (and most can indeed be implemented by convolution, that is, also here you may have to watch out for non-causal effects in certain scenarios). Typically DC removal (mean subtraction or possibly detrending in problematic cases) may be sufficient.
> > > For ERPs personally I would try non-linear phase filters. I would try to systematically compare non-linear and linear phase filtered data to try to disentangle what are distortions due to non-linearity or what are potentially non-causal effects. Particularly helpful is to systematically evaluate and compare the signal removed by different filters (unfiltered minus filtered data).
> > >
> > > > Changing the sampling rate would not change anything regarding the delays, right?
> > >
> > > Right.
> > >
> > > > EEG.data = fir_filterdcpadded(b_low, 1, EEG.data, 1);
> > >
> > > From fir_filterdcpadded help:
> > >
> > > > data - raw data (times x chans)
> > >
> > > and
> > >
> > > > fir_filterdcpadded always operates (pads, filters) along first dimension.
> > >
> > > So, with EEG.data (chans x times) it is necessary to transpose (twice):
> > > EEG.data = fir_filterdcpadded(b_low, 1, EEG.data', 1)';
> > >
> > > > Side note 2: These issues must affect standard ERP studies as well I imagine? Even if when using the linear-phase non-causal filters, if participants are blinking after the post-stimulus period of interest for example (as filtering is done on continuous data before cleaning the eye blinks), smearing artifacts must bleed into the ERP just the same, right? If so, that means one would need to systematically have participants blink only after the group delay has passed after the window of interest (e.g. +1.3 s for P300 if delay = 1 s as above with for minimum orders recommended), which is not widespread practice to my knowledge, is it?
> > >
> > > Indeed blinking can be a serious problem with ERPs. For example, participants tend to blink after giving a response introducing noteworthy amounts of noise. If there are systematic differences in response latency between conditions this may introduce considerable bias between conditions. Personally, I think ICA is very useful for removing blink artifacts.
> > > Best,
> > > Andreas
> > >
> > > > Am 03.02.2021 um 20:20 schrieb Cedric Cannard ccannard at protonmail.com:
> > > > Hi Andreas,
> > > > I see, so if I keep it simple with linear causal and non-causal filters (serial application), the minimum transition width I can get (without compromising filter quality,) for the high-pass would be 2 Hz for a cutoff frequency of 1 Hz? Which would give me an order of 826, and therefore a delay of 413 samples (i.e. 0.826 s) for the high-pass.
> > > > The low-pass 50 Hz with a transition width of 12.5 Hz would give me an order of 132, corresponding to a delay of 66 samples (i.e. 0.132 s).
> > > > Together, that's a delay of (827+133-2)/2 = 479 samples (i.e. 0.958 s)... which corresponds to 64% of my window of interest!
> > > > Whether I ignore this period with a non-causal filter, or lose it through the shift with the linear causal filter, it's a huge loss.
> > > > The implementation of a more advanced band-pass method by convolution vs spectral inversion sounds ideal, but above my level of current skills and I don't think I'll have enough time to figure it out unfortunately. And even if I could find a way to implement it somehow, I would still have a delay of 413 samples (i.e. 0.826 s), which is still too big.
> > > > That leaves me the minimum-phase causal filter with a reduced but unknown delay as well as unknown signal/phase distortions (which prevents me from doing frequency analyses), which doesn't sound really good either.
> > > > Is there another option I am missing? :D
> > > > No filters at all at the cost of lower SNR? high-pass at a higher cutoff frequency (e.g. 6.25 Hz for a total delay of 131 samples) and hope the effect is not in lower frequencies? Changing the sampling rate would not change anything regarding the delays, right?
> > > > Side note:
> > > > I tried your fir_filterdcpadded with the following lines:
> > > > fs = 500;
> > > > tansition_low = 12.5;
> > > > order_low = firwsord('hamming', fs, tansition_low)
> > > > b_low = firws(order_low, fcutoff_low/(fs/2), 'low', windows('hamming', order + 1));
> > > > EEG.data = fir_filterdcpadded(b_low, 1, EEG.data, 1);
> > > > And the power spectrum loses 300 dB compared to the other methods (e.g. filter, pop_firws). It can't be due to the coefficients because it doesn't do this when I use the filter function with the same coefficients. Did I miss something? I don't see other options in the fir_filterdcpadded description.
> > > > Side note 2: These issues must affect standard ERP studies as well I imagine? Even if when using the linear-phase non-causal filters, if participants are blinking after the post-stimulus period of interest for example (as filtering is done on continuous data before cleaning the eye blinks), smearing artifacts must bleed into the ERP just the same, right? If so, that means one would need to systematically have participants blink only after the group delay has passed after the window of interest (e.g. +1.3 s for P300 if delay = 1 s as above with for minimum orders recommended), which is not widespread practice to my knowledge, is it?
> > > > Thanks!
> > > > Cedric
> > > > ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> > > > On Wednesday, February 3, 2021 3:11 AM, Andreas Widmann widmann at uni-leipzig.de wrote:
> > > >
> > > > > Hi Cedric,
> > > > >
> > > > > > > > If so, for an order of 1650 (i.e. for a transition bandwidth of 1 Hz as estimated by the pop_firws function; minimum recommended) and a sampling rate of 500 Hz, I get a delay of 1.649 ms.
> > > > > > > > Unit is samples or seconds! Order = 1650 -> N = 1651 samples -> group delay = (N - 1) / 2 samples and sampling rate fs = 500 samples / second -> group delay = (N - 1) / 2 / fs seconds (the equation is the same as from your dspguru webpage, just written differently). Thus, the delay of the order 1650 filter is 1.65 seconds.
> > > > > >
> > > > > > That's what I thought initially but then thought it was too extreme to be correct... My visual inspections of raw data before and after filtering did not show such huge shifts.
> > > > > > So if I want to use a linear non-causal filter, I can use for example an order of 132 (transition bandwidth = 12.5 Hz), as long as I don't interpret any effect located in the -131 ms as that would correspond to the group-delay (or even exclude that period when precomputing ERP and ERSP, e.g. [-1500 -132])?.
> > > > >
> > > > > -132 ms (N is order + 1) but otherwise yes.
> > > > >
> > > > > > But at least there wouldn't be any delay or phase shift in the rest of the 1369 ms period. Then I'd get a shallow roll-off with poorer separation of signal/noise in adjacent frequency bands, but with less temporal smearing and ringing than with a higher order, and therefore losing only a small period of 131 ms before stimulus in this case.
> > > > >
> > > > > For low-pass filters for EEG/ERP 12.5 Hz transition bandwidth is perfectly fine. For high-pass filters for ERPs it is too low. Your high-pass cutoff would be limited to 6.25 Hz (without compromising filter quality).
> > > > >
> > > > > > And this would be the same as using the linear causal filter where that same period is not affected by future activity but shifted to the right by the group delay, so that [-131 0] period would become [0 131] ms?
> > > > >
> > > > > Yes.
> > > > >
> > > > > > If I use linear (causal or non-causal) filters for both high-pass and low-pass, does the group delay double (i.e. 232 ms?)?
> > > > >
> > > > > Depends. This is a somewhat more complex issue as this is different for causal vs. non-causal and also different for serial high-pass and low-pass vs. band-pass and finally also how band-pass is implemented.
> > > > > (1) Non-causal/zero-phase
> > > > > (1a) Serial application: Both filters are delay corrected separately, there is no delay in the final output. The impulse response of the final filter is the convolution of the high-pass and low-pass impulse responses. That is, the time range potentially contaminated by non-causal effects is (Nlow-pass + Nhigh-pass - 2) / 2 (in samples, divide by fs for seconds). This is identical to a band-pass filter implemented by convolution.
> > > > > (1b) You may implement a band-pass filter by clever combinations of spectral inversion and reversal (in a nutshell by adding two low-pass and high-pass kernels). The time range potentially contaminated by non-causal effects can be reduced to (max([Nlow-pass, Nhigh-pass]) - 1) / 2. More details on band-pass by convolution vs. spectral inversion, reversal and adding are explained for example here: https://urldefense.com/v3/http://www.dspguide.com/ch14/5.htm;!!Mih3wA!Sb46ITgIkbnk1HDjcpWA_Qmnuy5lgkQETyg35NJJpiLukRRr5HLB3cYpaJEy4cTx915A6A$ , https://urldefense.com/v3/http://www.dspguide.com/ch14/6.htm;!!Mih3wA!Sb46ITgIkbnk1HDjcpWA_Qmnuy5lgkQETyg35NJJpiLukRRr5HLB3cYpaJEy4cSG3Y03iQ$ pp.
> > > > > (2) Causal
> > > > > (2a) Serial application: Both delays are added (minus 1; see 1a above)
> > > > > (2b) Single stage bandpass. Again the delay can be reduced to (max([Nlow-pass, Nhigh-pass]) - 1) / 2 with clever implementation.
> > > > > Best,
> > > > > Andreas
> > > > >
> > > > > > > > Following your formula to calculate the phase shift when using a causal filter (shift = order-1)/gp_delay), I get 1000 independently of the order (which makes sense as the gd_delay changes as a function of the order). I haven't worked much on phase so I am not sure if that corresponds to a big shift or not.
> > > > > > > > Sorry, not sure whether I understand the question? Which formula do you refer to? Phase shift is frequency dependent. Typically, the question is whether it is linear or not and can therefore be corrected or not.
> > > > > > > > This was from here: https://sccn.ucsd.edu/pipermail/eeglablist/2013/006638.html
> > > > > > > > Sorry, I thought that there were both latency and phase distortions with linear causal filters and that I could calculate both to estimate how it affected the signal and to choose the best order value if I use this filter. But it just corresponds to the same group delay as above for linear, and cannot be corrected for non-linear as you said, so it didn't make sense.
> > > > > >
> > > > > > > > Yes, BUT: pop_firws is the high level wrapper. Unit for fcutoff is Hz! firws is a low-level function. Unit for f is pi rad / sample (i.e. normalized to Nyquist, this is the MATLAB standard for this kind of functions). 0.2 pi rad / sample * fs / 2 with fs = 500 samples / second -> 50 seconds^-1 or Hz.
> > > > > > > > Sorry yes, I used the same values as your example for consistency but used actual frequencies when trying it in the GUI. But thanks, it's good to know how the low-level function works.
> > > > > >
> > > > > > > > Interestingly, they found an effect at 24 ms before stimulus, and filtered with a second-order filter 1–40 Hz bandpass backward–forward. I wonder if that could be a smearing effect from post-stimulus activity.
> > > > > > > > Note, that you cannot delay correct an IIR filter (the impulse response is infinite and the phase response non-linear) and order has a very different meaning. Indeed, backward-forward filtering will result in a non-causal zero-phase filter (actually, the order of backward-forward or forward-backward doesn’t matter). As an IIR filter is used there is no temporal limit for non-causal effects (here post-stimulus on pre-stimulus time ranges) as with FIR filters. I cannot comment whether this affects the conclusions without reading and understanding in detail.
> > > > > >
> > > > > > Sounds good, thank you for the feedback.
> > > > > > I'll check out fir_filterdcpadded and probably use that once I decide which one I'll use. Thanks!
> > > > > > Cedric
> > > > > > ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> > > > > > On Tuesday, February 2, 2021 3:52 AM, Andreas Widmann widmann at uni-leipzig.de wrote:
> > > > > >
> > > > > > > Hi Cedric,
> > > > > > >
> > > > > > > > Do N taps = filter order = filter length?
> > > > > > >
> > > > > > > N taps = filter length = filter order + 1.
> > > > > > >
> > > > > > > > If so, for an order of 1650 (i.e. for a transition bandwidth of 1 Hz as estimated by the pop_firws function; minimum recommended) and a sampling rate of 500 Hz, I get a delay of 1.649 ms.
> > > > > > >
> > > > > > > Unit is samples or seconds! Order = 1650 -> N = 1651 samples -> group delay = (N - 1) / 2 samples and sampling rate fs = 500 samples / second -> group delay = (N - 1) / 2 / fs seconds (the equation is the same as from your dspguru webpage, just written differently). Thus, the delay of the order 1650 filter is 1.65 seconds.
> > > > > > >
> > > > > > > > Following your formula to calculate the phase shift when using a causal filter (shift = order-1)/gp_delay), I get 1000 independently of the order (which makes sense as the gd_delay changes as a function of the order). I haven't worked much on phase so I am not sure if that corresponds to a big shift or not.
> > > > > > >
> > > > > > > Sorry, not sure whether I understand the question? Which formula do you refer to? Phase shift is frequency dependent. Typically, the question is whether it is linear or not and can therefore be corrected or not.
> > > > > > >
> > > > > > > > > b_high = minphaserceps( firws( 10, 1/5, 'high' ) ); % minimum-phase non-linear high-pass
> > > > > > > >
> > > > > > > > Is this the same as using your pop_firws? e.g. [EEG, com, b] = pop_firws(EEG, 'forder', 10, 'fcutoff', 1/5, 'ftype', 'highpass', 'wtype', 'hamming', 'minphase', true);
> > > > > > >
> > > > > > > Yes, BUT: pop_firws is the high level wrapper. Unit for fcutoff is Hz! firws is a low-level function. Unit for f is pi rad / sample (i.e. normalized to Nyquist, this is the MATLAB standard for this kind of functions). 0.2 pi rad / sample * fs / 2 with fs = 500 samples / second -> 50 seconds^-1 or Hz.
> > > > > > >
> > > > > > > > What about your firfilt function that automatically corrects the group-delay if I choose to do the non-causal linear filter? No need to apply correction on EEG.times with this method, right?
> > > > > > >
> > > > > > > Yes, firfilt automatically corrects for the group delay, that is, implements a zero-phase FIR filter. But firfilt is a low-level function and you should know what you are doing when using it. If you want to do this on the command line I would rather recommend using fir_filterdcpadded. There is a 'causal‘ flag and you can do causal and non-causal (linear phase only) filtering. fir_filterdcpadded must be used with continuous segments only. firfilt also works with boundaries. firfilt was designed long time ago when memory was a limited resource and is memory optimized but complex. It will be sooner than later be fully replaced by fir_filterdcpadded (as in Fieldtrip) which is simple and fast but memory consuming.
> > > > > > >
> > > > > > > > Interestingly, they found an effect at 24 ms before stimulus, and filtered with a second-order filter 1–40 Hz bandpass backward–forward. I wonder if that could be a smearing effect from post-stimulus activity.
> > > > > > >
> > > > > > > Note, that you cannot delay correct an IIR filter (the impulse response is infinite and the phase response non-linear) and order has a very different meaning. Indeed, backward-forward filtering will result in a non-causal zero-phase filter (actually, the order of backward-forward or forward-backward doesn’t matter). As an IIR filter is used there is no temporal limit for non-causal effects (here post-stimulus on pre-stimulus time ranges) as with FIR filters. I cannot comment whether this affects the conclusions without reading and understanding in detail.
> > > > > > > Hope this helps! Best,
> > > > > > > Andreas
> > > > > > >
> > > > > > > > Am 02.02.2021 um 02:39 schrieb Cedric Cannard ccannard at protonmail.com:
> > > > > > > > Hi Andreas,
> > > > > > > > Thank you so much for the thorough response and examples, this is very helpful.
> > > > > > > > Because this analysis is exploratory (looking at the whole 1.5 s period before stimulus), I cannot know whether the signal of interest is further away from stimulus onset than the group delay. Other studies on pre-stimulus EEG do not provide much on this topic surprisingly (e.g. https://urldefense.com/v3/https://www.frontiersin.org/articles/10.3389/fnhum.2020.00182/full;!!Mih3wA!XvTZMQW-HAOS-0brWhhQ3MxL38_oEd5FVdHGyNbYHJfz1g5lWxfujc9QDsJT-037KfkNfg$ ). Interestingly, they found an effect at 24 ms before stimulus, and filtered with a second-order filter 1–40 Hz bandpass backward–forward. I wonder if that could be a smearing effect from post-stimulus activity.
> > > > > > > > I tried assessing what the delay would be for a linear-phase filter on my data with: (N – 1)/(2 * sample_freq) from https://urldefense.com/v3/https://dspguru.com/dsp/faqs/fir/properties/::text=has20no20mate.)-,2.1.,1*20kHz)3D1020milliseconds;I34lJSUlJQ!!Mih3wA!XvTZMQW-HAOS-0brWhhQ3MxL38_oEd5FVdHGyNbYHJfz1g5lWxfujc9QDsJT-02fz36Ufw$ .
> > > > > > > > Do N taps = filter order = filter length?
> > > > > > > > If so, for an order of 1650 (i.e. for a transition bandwidth of 1 Hz as estimated by the pop_firws function; minimum recommended) and a sampling rate of 500 Hz, I get a delay of 1.649 ms.
> > > > > > > > For order = 132 (transition bandwidth = 12.5 Hz as with default pop_eegfiltnew), a delay of 0.131 ms.
> > > > > > > > And for order = 3300 (transition bandwidth = 0.5 Hz), a delay of 16.499 ms.
> > > > > > > > Following your formula to calculate the phase shift when using a causal filter (shift = order-1)/gp_delay), I get 1000 independently of the order (which makes sense as the gd_delay changes as a function of the order). I haven't worked much on phase so I am not sure if that corresponds to a big shift or not.
> > > > > > > > If this is correct, then the delay is very small and should not be a problem regarding latency shifts as I am looking at a large window of 1500 ms, right? If there is only a few ms of shift, using a linear-phase non-causal filter would be preferable to preserve spectral/phase information.
> > > > > > > > Visual inspection with vis_artifacts comparing raw data before and after shows very minimal shifts from the linear filtering.
> > > > > > > > Now I understand that I can't correct a causal filter without making it non-causal, thanks!
> > > > > > > > Side note:
> > > > > > > >
> > > > > > > > > b_high = minphaserceps( firws( 10, 1/5, 'high' ) ); % minimum-phase non-linear high-pass
> > > > > > > > > fsig_high = filter( b_high, 1, sig ); % causal filter
> > > > > > > >
> > > > > > > > Is this the same as using your pop_firws? e.g. [EEG, com, b] = pop_firws(EEG, 'forder', 10, 'fcutoff', 1/5, 'ftype', 'highpass', 'wtype', 'hamming', 'minphase', true);
> > > > > > > > What about your firfilt function that automatically corrects the group-delay if I choose to do the non-causal linear filter? No need to apply correction on EEG.times with this method, right?
> > > > > > > > Cedric
> > > > > > > > ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> > > > > > > > On Sunday, January 31, 2021 12:57 PM, Andreas Widmann widmann at uni-leipzig.de wrote:
> > > > > > > >
> > > > > > > > > Hi Cedric,
> > > > > > > > > in general most of your reasoning is correct and reasonable: Non-linear causal filters typically should only be used if the application explicitly requires this, for example is causality matters as in the detection of onset latencies (even if the problem is overestimated as it mainly affects ultra-sharp transients typically not observed in EEG/ERP), the analysis of small fast components before large slow components (e.g. if higher high-pass cutoff frequencies are required), or in the analysis of pre-stimulus activity, that is, your case.
> > > > > > > > > There is, however, one problematic aspect in your reasoning which if resolved might possibly help you finding the right answer for you : You cannot delay correct a causal filter (linear or non-linear). This would make it automatically non-causal and break causality and there is no way around this.
> > > > > > > > > Now you still have to decide whether to apply a linear or a non-linear filter. The difference between a linear causal and linear non-causal filter is exclusively the time axis. The output of the non-causal filter equals the delay corrected output of the causal filter. It is sufficient to change the EEG.times time axis. That is, if your signal of interest is further away from stimulus onset than the group delay you can simply use a linear non-causal filter.
> > > > > > > > > % Example:
> > > > > > > > > sig = [ 0 0 0 0 0 1 0 0 0 0 0 ]; % test signal (impulse)
> > > > > > > > > b = [ 1 1 1 1 1 ] / 5; % some crude boxcar filter for demonstration purposes only, linear-phase, length = 5, order = 4, group delay = 2
> > > > > > > > > fsig = filter( b, 1, sig ); % causal filter
> > > > > > > > > plot( -5:5, [ sig; fsig ]', 'o' ) % the filtered impulse in the output does not start before the impulse in the input
> > > > > > > > > fsig = filter( b, 1, [ sig 0 0 ] ) % padded causal filter
> > > > > > > > > fsig = fsig( 3:end ); % delay correction by group delay, this is what makes the filter non-causal and zero-phase
> > > > > > > > > plot( -5:5, [ sig; fsig ]', 'o' ) % the filtered impulse in the output starts before the impulse in the input BUT everything before x = -2 is unaffected
> > > > > > > > > If the (group) delay is too large for your purpose you must reduce the delay and thus use a non-linear filter, e.g. minimum phase. Non-linear filters delay different frequencies by a different amount (and due to this difference you cannot easily delay correct the output of non-linear filters even if non-causality would be acceptable). Therefore, you must not interpret the shape of the waveform in ERPs as it is distorted to some extent and also not interpret cross-frequency relationships of amplitude or phase in ERSPs. But on the other hand you can be certain that your pre-stimulus data are not contaminated by post-stimulus activity.
> > > > > > > > >
> > > > > > > > > > 2. Can I use the standard linear zero-phase filter for low-pass filtering after a causal filter as the paper showed that low-pass filtering using causal filters introduces large delays?
> > > > > > > > > > My tests did not show any difference on the ERP plots compared to using only the causal filter without low-pass filtering but I haven't run more thorough tests.
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > > No, I do not think that this is a valid strategy. The output of the non-linear high-pass in the first step (if I correctly understand your question) would only introduce a small delay. The non-causal effects of the zero-phase (delay corrected) low-pass will in most cases exceed the delay introduced by the high-pass. Thus, you have a non-linear and non-causal filter output.
> > > > > > > > > % Check:
> > > > > > > > > b_high = minphaserceps( firws( 10, 1/5, 'high' ) ); % minimum-phase non-linear high-pass
> > > > > > > > > fsig_high = filter( b_high, 1, sig ); % causal filter
> > > > > > > > > plot( -5:5, [ sig; fsig_high ]', 'o' ) % Causality preserved :)
> > > > > > > > > fsig_high_low = filter( b, 1, [ fsig_high 0 0 ] ); % the low-pass from above
> > > > > > > > > fsig_high_low = fsig_high_low( 3:13 ); % delay correction/zero-phase
> > > > > > > > > plot( -5:5, [ sig; fsig_high_low ]', 'o' ) % Causality violated :(
> > > > > > > > >
> > > > > > > > > > 3. the minimum-phase filter is called "beta" in eeglab GUI, can I confidently use it for my analysis and publication?
> > > > > > > > >
> > > > > > > > > I didn’t notice or hear of any known errors in the last years. I would consider it safe for productive use.
> > > > > > > > >
> > > > > > > > > > 4. If I need to apply a delay correction (for either causal filter), how can I do it?
> > > > > > > > >
> > > > > > > > > You cannot without making the filter non-causal, see above.
> > > > > > > > > Side note: I recommend not to use the legacy filter. It is broken. It would be relatively simple to use the new filter for causal linear filtering on the command line (just take the filter coefficients and use the regular MATLAB filter command; see above).
> > > > > > > > > Hope this helps! Best,
> > > > > > > > > Andreas
> > > > > > > > >
> > > > > > > > > > Am 29.01.2021 um 22:05 schrieb Cedric Cannard ccannard at protonmail.com:
> > > > > > > > > > Hi all,
> > > > > > > > > > I am analyzing 64-channel EEG data of the pre-stimulus period [-1500 0] ms (3 conditions from 3 types of images being presented) and results will be obtained using LIMO on the ERP and ERSP data. I have been reading Andreas Widmann's papers on filtering (e.g. https://urldefense.com/v3/https://www.frontiersin.org/articles/10.3389/fpsyg.2012.00233/full;!!Mih3wA!VNo4GYqFILb305TK2eZbXRZWcQcgOnHzFo8Zfb510jeSOjaJCydWh45s-vE0funMJm7jiA$ ; https://urldefense.com/v3/https://home.uni-leipzig.de/biocog/eprints/widmann_a2015jneuroscimeth250_34.pdf;!!Mih3wA!VNo4GYqFILb305TK2eZbXRZWcQcgOnHzFo8Zfb510jeSOjaJCydWh45s-vE0fukqNL9gVw$ ), but I am still unsure I fully understand whether I should use the legacy causal FIR filter and apply a delay correction or the new minimum-phase causal filter instead. I also found this eeglablist discussion (https://sccn.ucsd.edu/pipermail/eeglablist/2013/006638.html) but it is from 2013 and there is now a beta minimum-phase causal filter available in EEGLAB, so
> > > > > > > > > > I wonder what the new recommendations would be.
> > > > > > > > > > I am pretty clear about using a non-linear/causal filter and not linear/non-causal filter to avoid "introducing non-causally smeared artificial or artificially enhanced components after high-pass filtering (Fig 7D; see Acunzo et al., 2012 for discussion), or smearing post-stimulus oscillations into the pre-stimulus interval leading to spurious interpretations of pre-stimulus phase (Zoefel and Heil, 2013)."
> > > > > > > > > > However, regarding the causal filtering, I read: "zero-phase (non-causal) filters preserve peak latencies, while causal filters necessarily shift the signal in time. If a causal filter is needed, a non-linear minimum-phase filter should be considered as it introduces only the minimum possible delay at each frequency for a given magnitude response but distorting broadband or complex signals due to non-linearity (see Fig. 2). Causal high-pass minimum-phase (and other non-linear) filters introduce rather small delays (Fig. 2F and G) while causal low-pass (and band-pass and band-stop) filters introduce larger delays even with minimum-phase property (Fig. 2A and B), which is why they are not recommended in electrophysiology (Rousselet, 2012)."
> > > > > > > > > > --> This suggests I should use the minimum-phase for high-pass filtering (1 Hz) but not for low-pass filtering (50 Hz).
> > > > > > > > > > But further in the paper the authors say: "However, as FIR filter coefficients necessarily must be symmetric (or antisymmetric) for the filter to have linear-phase characteristic (Rabiner and Gold, 1975; Ifeachor and Jervis, 2002), this reduction of filter delay comes at the cost of a non-linear phase response and the introduction of a systematic delay in the signal (which can not easily be compensated due to non-linear phase). The recommendation for minimum-phase causal FIR filtering, thus, should be strictly limited to the detection of onset latencies and applications where causality is required for theoretical con
> > > > > > > > > > siderations."
> > > > > > > > > > --> This suggests the minimum-phase filter not only introduces delays that are harder to compensate for compared to the causal FIR filter, but also that it distort complex and broadband signals? Does this mean the minimum-phase filtering might not necessarily be better than the legacy causal FIR filter for ERP/ERSP analyses?? My tests comparing the two during high-pass 1 Hz show extreme differences in the ERP plots for the same subject, obviously.
> > > > > > > > > >
> > > > > > > > > > 1. Which one should I use for ERP and ERSP analyses of the pre-stimulus period?
> > > > > > > > > >
> > > > > > > > > > 2. Can I use the standard linear zero-phase filter for low-pass filtering after a causal filter as the paper showed that low-pass filtering using causal filters introduces large delays?
> > > > > > > > > > My tests did not show any difference on the ERP plots compared to using only the causal filter without low-pass filtering but I haven't run more thorough tests.
> > > > > > > > > >
> > > > > > > > > > 3. the minimum-phase filter is called "beta" in eeglab GUI, can I confidently use it for my analysis and publication?
> > > > > > > > > >
> > > > > > > > > > 4. If I need to apply a delay correction (for either causal filter), how can I do it?
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Thanks in advance to anyone that could bring me more clarity on this topic.
> > > > > > > > > > Cedric
> > > > > > > > > > Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
> > > > > > > > > > To unsubscribe, send an empty email to eeglablist-unsubscribe at sccn.ucsd.edu
> > > > > > > > > > For digest mode, send an email with the subject "set digest mime" to eeglablist-request at sccn.ucsd.edu
> > > > > > > >
> > > > > > > > Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
> > > > > > > > To unsubscribe, send an empty email to eeglablist-unsubscribe at sccn.ucsd.edu
> > > > > > > > For digest mode, send an email with the subject "set digest mime" to eeglablist-request at sccn.ucsd.edu
> > > > > >
> > > > > > Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
> > > > > > To unsubscribe, send an empty email to eeglablist-unsubscribe at sccn.ucsd.edu
> > > > > > For digest mode, send an email with the subject "set digest mime" to eeglablist-request at sccn.ucsd.edu
> > > >
> > > > Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
> > > > To unsubscribe, send an empty email to eeglablist-unsubscribe at sccn.ucsd.edu
> > > > For digest mode, send an email with the subject "set digest mime" to eeglablist-request at sccn.ucsd.edu
More information about the eeglablist
mailing list