2
$\begingroup$

Wanted to know the feasibility and usefulness of implementing Zero-Phase Anti-Causal filters such as those mentioned at this link in modern embedded signal processing applications given the advancement of devices on which these applications are now running, resource wise it should not be difficult to implement.

I.e., something like Matlab's filtfilt, as opposed to a typical causal IIR filter (picture from the same page):

enter image description here

The question I want to ask is that if it they are indeed used in practical systems with the advantage of zero-phase distortions or are there other variables in play as well due to which the traditional causal FIR filters are still preferred if non-linear phase distortion is not acceptable?

$\endgroup$
5
  • 1
    $\begingroup$ Your question seems to be mixing the meanings of "anti-causal filter". Traditionally, FIR filters are usually symmetric around the midpoint, and are traditionally designed using a filter that's symmetric around zero that is then just translated until it is causal. In a tradition that makes me want to chew nails, these are often called "non-causal". They have a linear -- not zero phase response when used in real time, but the phase delays in the system can be easily lined up. Is this what you mean when you say "anti-causal"? $\endgroup$
    – TimWescott
    Commented Feb 1, 2023 at 19:24
  • $\begingroup$ @TimWescott, sorry If the question wording caused any confusion. "In a tradition that makes me want to chew nails, these are often called "non-causal"" I believe when the FIR filter has been translated then it is no longer "non-causal". However when I used the term 'anti-causal' in the question I referred to the technique shown here: mathworks.com/help/signal/ug/… $\endgroup$
    – malik12
    Commented Feb 2, 2023 at 7:58
  • $\begingroup$ @TimWescott, I'll edit the question as well, thank you for pointing out the mixup $\endgroup$
    – malik12
    Commented Feb 2, 2023 at 7:59
  • $\begingroup$ If I understand correctly, you want to know if it’s possible to implement 0-delay filters in real time ? In which case, the answer is no $\endgroup$
    – Jdip
    Commented Feb 2, 2023 at 15:32
  • $\begingroup$ The technique in the link you provided is only possible in offline processing (or in a block-based real time scenario, but will introduce a delay equal to at least the size of the input block). $\endgroup$
    – Jdip
    Commented Feb 2, 2023 at 15:37

1 Answer 1

3
$\begingroup$

It depends on your definition of "real time" and how you expect the filter to be used.

Can you implement a two-way, offline IIR filtering scheme like Matlab's filtfilt in an embedded system? Yes, absolutely.

Of necessity, you need to implement it in such a way that once you are done collecting a segment of data you can run it on that data after the fact.

So if you define "real time" as "for every filter input sample I immediately have a filter output sample" -- no, you can't do that. You cannot do that because the filtfilt function runs a perfectly ordinary filter forward through the data from beginning to end, then it runs the same filter backward through the data, from end to beginning. That second step means that you either need a system that sees into the future (that's the "anti-causal" part), or you need to do the filtering retrospectively, on a batch of data that's already been collected (at which point there's a lot of delay and phase shift).

But the definition of "real time" above is not the accepted definition of "real time".

If you define "real time" in the accepted manner -- that all delays are known and guaranteed, and that a system isn't broken if all promises are met -- then yes, you can do offline filtering of chunks of data in a real time system.

$\endgroup$
5
  • $\begingroup$ thank you for the detailed explanation and the last part of you answer is precisely what I had in mind that as long as delays are known and guaranteed, it should not be an issue. However, when such block wise processing is being done using IIR filters will the phase between multiple blocks remain maintained or would there be some offsets which would have to be adjusted to maintain coherency? $\endgroup$
    – malik12
    Commented Feb 3, 2023 at 5:41
  • $\begingroup$ That really should be asked as a separate question. Short answer: if you timestamp things very carefully, the phase between multiple blocks can be maintained, with effort. $\endgroup$
    – TimWescott
    Commented Feb 3, 2023 at 15:11
  • $\begingroup$ Ok, thanks for the response, I'll do some work on it and create a new question if and when I get stuck at that part.. $\endgroup$
    – malik12
    Commented Feb 4, 2023 at 8:46
  • $\begingroup$ @TimWescott so if I have an IIR filter which has a 1 ms group delay at the worst point in the frequency band of interest (let's say LPF 500 Hz), as long as I process fast enough (to prevent buffer overwriting) in "real time" using data chunks bigger than 1 ms of data, on each chunk I could do zero-phase filtering and compensate the group delay? There would be a buffering delay and it would be challenging to reconcile discontinuities at the chunk edges (perhaps overlapping of chunks would help) but in principle this is what you are proposing? $\endgroup$
    – VMMF
    Commented Oct 10 at 23:06
  • $\begingroup$ That's almost worthy of a separate question. Yes, you could. Because filtfilt runs the same filter both ways, the cumulative effect is a filter with an impulse response that's even-symmetric around zero. Such filters have zero phase response. $\endgroup$
    – TimWescott
    Commented Oct 11 at 3:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.