# Causal and Non-causal filtering. Strange behavior

I'm trying to understand the behavior of a causal filtering exemplified by figure below.

This behavior is making LDA (Linear Discriminant Analysis) misclassify our data, by clearly reverse the signal pattern at the highlighted box. We need to alter the filtering method from non-causal (MATLAB filfilt function) to a causal (MATLAB filter function), but we face off this strange behavior.

Can someone give us an idea for what is really happening?

EDIT:

• Motivation: Real-time processing. -Note: Delays are expected, but the output causal filtered signal inside the red box seems to be very uncorrelated with the zero-phase filtered signal.
• Band-pass cut-off frequency: $[0.16 - 1]\textrm{ Hz}$.
• Signal: Electroencephalography @ $128\textrm{ Hz}$
• Welcome to DSP.SE! Your question isn't clear to me: filter and filtfilt will give different results. filter will include phase delays but filtfilt won't (because the reverse filtering operation will remove any phase delay effects). Can you explain a bit more about what you are expecting to see? – Peter K. Jun 7 '16 at 12:13
• Could you add an explanation why you can't use 'filtfilt' (maybe because you need to do real-time processing ...)? You could instead use a linear-phase FIR filter and take the delay into account. This should give you something comparable with what you get from 'filtfilt' (if you account for the delay). – Matt L. Jun 7 '16 at 13:44
• Thanks for the welcome. Yes, I expected different results, but like in the other signal parts, after half (with visible delays and same signal shape), not the confused output that appear in the red box. It seems to have no correlation with the near zero-phase filtered signal. – Alexandre Gomes Jun 7 '16 at 13:44

So let's look at this statement. Suppose the original, unfiltered signal is $x[n]$. Filtering this using filtfilt with a filter with impulse response $h[n]$ gives: $$y_{ff}[n] = h[-n] \star h[n] \star x[n]$$ and filtering with just filter is: $$y_f[n] = h[n] \star x[n]$$ so $$y_{ff}[n] = h[-n] \star y_f[n]$$ Regardless of what $x[n]$ is, the 'correlation' between $y_f$ and $y_{ff}$ will look like the anticausal (perhaps anticausal + constant term) $h[-n]$.