[Eeglablist] linear causal filter

Andreas Widmann widmann at uni-leipzig.de
Fri Mar 10 09:17:14 PST 2023


Hi Nasibeh,

> I want to pre-process the single-trial EEG signals for a connectivity study
> (So the causality between signals must be preserved).
To help you with this question, could you please elaborate more on your considerations on connectivity and/or/vs. causality?

> 1.      My main question is what linear fitter can preserve causal
> relationships? Which of the codes *eegfilt.m* or *eegfiltnew.m* should I
> use?
Linearity and causality are not directly (but only indirectly) related. A linear filter will (typically) introduce a large delay. It is not the linear filter per se but the correction of this delay which violates causality. In a linear filter the (group) delay is constant at the different frequencies (within the passband). Therefore the easiest way to correct for the delay is to simply shift the output signal backward in time (relative to external reference; event, trigger). The other common way is filtering backwards a second time (see the second paper below for discussion of drawbacks). In both cases, causality with respect to the external reference is violated. This is relevant for example when determining onset latencies.

In a nutshell, if you filter a step signal, in a causal filter the filter output must never deviate from zero before the step appeared in the input. However, in the causal filter output the step is delayed substantially. If you correct for the delay by shifting or backward filtering the step latency is similar in input and output but the output signal may deviate from zero already before the step occurred in the input.

Non-causal filters may considerably reduce the delay and therefore avoid problems with causality as it may not be necessary to correct.

A linear filter will shift all frequencies (and all channels) by the same amount, thus, to my understanding it should not affect connectivity whether you correct for the delay of not (but you may have to account for the delay during interpretation in case not correcting). However, there are so many aspects in connectivity analysis that I might miss something. Therefore my question whether you could elaborate more on your considerations.

> It is suggested
> to use *eegfiltnew.m* code instead. As far as I know, in *eegfiltnew.m*, a
> non-linear filter is used to minimize the phase.
No, by default eegfiltnew.m implements a non-causal (i.e., delay corrected) linear FIR filter. Non-linear minimum phase is just an option (and implemented as a causal filter; i.e. not filtering backwards). Minimum phase means that the introduced delay is minimal (but different) at different frequencies (thus, typically unsuitable for connectivity analysis).

> 2.      If I manually specify the filter order in advance, can I use code
> *eegfilt.m*?
No, besides incorrect filter order the problem is partly also related to usage of MATLAB firls not computing but fitting filters. Fitting is inaccurate and can go wrong. 

> Why is it said to be broken?
See here:
Widmann, A., & Schröger, E. (2012). Filter effects and filter artifacts in the analysis of electrophysiological data. Frontiers in Psychology, 3, 233. doi: 10.3389/fpsyg.2012.00233
https://urldefense.com/v3/__https://www.frontiersin.org/articles/10.3389/fpsyg.2012.00233/full__;!!Mih3wA!G3HiGuuKUBgkLzfZpN263ERttI9ySux4oh89jOK19jomWbyE-3ZIfQgxGSRb8nuUNaE17ttKsFUhYlX1VSuPEL6V2sNC$ 
and here:
Widmann, A., Schröger, E., & Maess, B. (2015). Digital filter design for electrophysiological data–a practical approach. J Neurosci Methods, 250, 34-46.
https://urldefense.com/v3/__https://home.uni-leipzig.de/biocog/eprints/widmann_a2015jneuroscimeth250_34.pdf__;!!Mih3wA!G3HiGuuKUBgkLzfZpN263ERttI9ySux4oh89jOK19jomWbyE-3ZIfQgxGSRb8nuUNaE17ttKsFUhYlX1VSuPEEAL_exH$  <https://urldefense.com/v3/__http://home.uni-leipzig.de/biocog/eprints/widmann_a2015jneuroscimeth250_34.pdf__;!!Mih3wA!G3HiGuuKUBgkLzfZpN263ERttI9ySux4oh89jOK19jomWbyE-3ZIfQgxGSRb8nuUNaE17ttKsFUhYlX1VSuPEIdIFFfr$ >

> 3.      Do you have any other suggestions other than code *eegfilt.m* or
> *eegfiltnew.m*?
A linear causal filter can be achieved on the command line interface. I can assist implementing this in case you really want to still use it after reading the above papers. But note that the output of a causal linear filter is *identical* to the output of an equivalent non-causal linear filter. In the former, the filter output signal is just delayed by the group delay (i.e., half the filter order for FIR; convert to time units by dividing by sampling rate) relative to the latter.

Hope this helps! Best,
Andreas

> Furthermore, for my
> study, the filter should only be linear (so the non-linear minimum phase
> filter is not suitable for me).
> 
> According to my studies, I think one recommendation is to use the linear
> causal filter with *eegfilt.m* code. But on
> https://urldefense.com/v3/__https://eeglab.org/others/Firfilt_FAQ.html*q-should-i-use-a-linear-causal-fir-filter-with-delay-correction-or-a-non-linear-causal-filter-eg-minimum-phase__;Iw!!Mih3wA!FTkqp_XEBN-Ou1XueybEqx94jz9_vW80orzKJHQJ5m8xg2JEsBetYZ9anlSqohf4ElnES8Sc9cX3Nl5l529RX6lwwyX34g$ 
> it is suggested not to use this code because it is broken! It is suggested
> to use *eegfiltnew.m* code instead. As far as I know, in *eegfiltnew.m*, a
> non-linear filter is used to minimize the phase.
> 
> 
> 
> 1.      My main question is what linear fitter can preserve causal
> relationships? Which of the codes *eegfilt.m* or *eegfiltnew.m* should I
> use?
> 
> 
> 
> 2.      If I manually specify the filter order in advance, can I use code
> *eegfilt.m*? Why is it said to be broken?
> 
> 
> 
> 3.      Do you have any other suggestions other than code *eegfilt.m* or
> *eegfiltnew.m*?
> 
> 
> 
> 
> 
> With regards
> 
> 
> 
> Nasibeh
> _______________________________________________
> 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