[Eeglablist] linear causal filter
Andreas Widmann
widmann at uni-leipzig.de
Mon Mar 13 05:56:55 PDT 2023
Dear Nasibeh,
ah, ok. Filtering for MVAR or Granger causality is a research topic by itself and I’m not an expert for this. I would recommend to look into the literature and check how other groups approach the problem. Unfortunately the terminology is not always transparent. For example in
https://urldefense.com/v3/__https://doi.org/10.1016/j.neuroimage.2009.12.050__;!!Mih3wA!FV31I8VNFmeubjSihFMu7Et5JXM2CfbLcyBSC1Quwz5NRyHX4xecG6VGPlmHAnr8Yxm5EkXRZgPYOlpyU-vXhkTva12p$
the term "phase neutral filtering“ is used for non-causal/zero-phase/delay corrected filtering (without explicitly referring to the implications of non/causality).
Also a look at similar or related methods might help, for example:
https://urldefense.com/v3/__https://doi.org/10.1016/j.jneumeth.2021.109080__;!!Mih3wA!FV31I8VNFmeubjSihFMu7Et5JXM2CfbLcyBSC1Quwz5NRyHX4xecG6VGPlmHAnr8Yxm5EkXRZgPYOlpyU-vXhkHAI8fp$
https://urldefense.com/v3/__https://doi.org/10.1016/j.jneumeth.2011.08.010__;!!Mih3wA!FV31I8VNFmeubjSihFMu7Et5JXM2CfbLcyBSC1Quwz5NRyHX4xecG6VGPlmHAnr8Yxm5EkXRZgPYOlpyU-vXhoQJULP-$
Also see this FAQ answer, I think contributed by Makoto, on a related issue:
https://urldefense.com/v3/__https://eeglab.org/others/Firfilt_FAQ.html*q-for-granger-causality-analysis-what-filter-should-be-used-11212020-updated__;Iw!!Mih3wA!FV31I8VNFmeubjSihFMu7Et5JXM2CfbLcyBSC1Quwz5NRyHX4xecG6VGPlmHAnr8Yxm5EkXRZgPYOlpyU-vXhl1-6q3w$
Btw., here is also documented how to achieve a linear causal filter on the command line interface:
https://urldefense.com/v3/__https://eeglab.org/others/Firfilt_FAQ.html*q-does-the-firfilt-function-automatically-delay-correct-if-i-choose-to-do-the-non-causal-linear-filter__;Iw!!Mih3wA!FV31I8VNFmeubjSihFMu7Et5JXM2CfbLcyBSC1Quwz5NRyHX4xecG6VGPlmHAnr8Yxm5EkXRZgPYOlpyU-vXhjXqvf0G$
> However, with your explanation, I think that if I ignore the delay correction or I correct the delay for all channels with a constant value, there will be no challenge for the assessment of the causal relationship among them. Am I correct?
Yes, to my understanding, linear filtering should not affect the causal relationship between channels. But see the last paper above that filtering per se might affect the estimation despite theoretical invariance (e.g., numerical instability). Unfortunately, as always there is a trade-off between removal of artifacts possibly introducing spurious results and possible (side-)effects of filtering.
> Is the delay correction value the same for all channels in "eegfiltnew.m" code?
Yes.
> Do you suggest that I continue with "eegfiltnew.m“?
Yes. eegfiltnew.m should be able to perform all operations the old function was providing.
In general, to my understanding only the two combinations make sense:
* Non-causal (zero-phase; delay corrected) linear filters. The output signals of non-causal and causal linear filters are only delayed but otherwise identical. The large delay is hard to ignore and to my experience if not mathematically correcting one will typically still mentally correct for it.
* Causal non-linear filters. Delay correcting them by backward filtering makes them linear (symmetric) and non-causal. Backward filtering introduces various problems.
Both are provided by eegfiltnew.m.
And one correction:
> Non-causal filters may considerably reduce the delay and therefore avoid problems with causality as it may not be necessary to correct.
This was of course a typo. Should have read:
> Non-LINEAR filters may considerably reduce the delay and therefore avoid problems with causality as it may not be necessary to correct.
Best,
Andreas
> Am 13.03.2023 um 09:19 schrieb nasibeh talebi <nasibeh.talebi at gmail.com>:
>
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> Dear Andreas,
>
> Thank you very much for your detailed and complete answer.
> My connectivity study involves a non-linear multivariate autoregressive model:
>
> For M time series (representing samples of cortical signals from M regions of interest x(n)=[x_1 (n),x_2 (n),…,x_M (n)]^T):
> x(n)=f(x_p)+σ(n)
>
> where x_p=[x_1 (n-1),x_2 (n-1),⋯,x_M (n-1),x_1 (n-2),⋯,x_M (n-2),⋯,x_1 (n-p),⋯,x_M (n-p) ]^T is the vector of p past samples of the M time series, and the nonlinear function f(.) quantitatively describes the cortical interaction between the signals, and σ(n)=[σ_1,σ_2,…,σ_M ]^T is a normally distributed real-valued zero-mean white noise.
>
>
> Therefore, to investigate causality, it is necessary that the output at any time (n) is only influenced by delayed samples of itself and other regions. That's why I insisted on using a causal filter.
> However, with your explanation, I think that if I ignore the delay correction or I correct the delay for all channels with a constant value, there will be no challenge for the assessment of the causal relationship among them. Am I correct? Is the delay correction value the same for all channels in "eegfiltnew.m" code? Do you suggest that I continue with "eegfiltnew.m"?
>
> With best regards,
> Nasibeh
>
>
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>
>
> On Fri, Mar 10, 2023 at 6:17 PM Andreas Widmann <widmann at uni-leipzig.de> wrote:
> 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!FV31I8VNFmeubjSihFMu7Et5JXM2CfbLcyBSC1Quwz5NRyHX4xecG6VGPlmHAnr8Yxm5EkXRZgPYOlpyU-vXhlLq3VhY$
> 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!FV31I8VNFmeubjSihFMu7Et5JXM2CfbLcyBSC1Quwz5NRyHX4xecG6VGPlmHAnr8Yxm5EkXRZgPYOlpyU-vXhj8dmpnq$ <https://urldefense.com/v3/__http://home.uni-leipzig.de/biocog/eprints/widmann_a2015jneuroscimeth250_34.pdf__;!!Mih3wA!FV31I8VNFmeubjSihFMu7Et5JXM2CfbLcyBSC1Quwz5NRyHX4xecG6VGPlmHAnr8Yxm5EkXRZgPYOlpyU-vXhvV-jZZr$ >
>
> > 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