# Is it possible to compute delay with an IIR filter between peaks?

I am developing a project which receives accelerometer signals as input, which must then be analysed via peak-detection algorithms (among other techniques).

In order to do so more effectively, I first filter the signal with a low-pass Butterworth digital filter (an IIR filter) with order 20.

By plotting the signal to a graph, I can then see a delay between the peaks to be detected, which wouldn't matter much if I just needed to detect the peaks themselves.

But since I need to compare the output of this filter with the input and then some other filtered outputs, I need to be able to match these peaks between themselves.

I know this can be done (approximately) with FIR filters by calculating their delay (which is n/2), so I ask: is this possible with an IIR filter?

Filter coefficients:

A = [ 1; -5,98758963; 16,67219332; -28,2587879; 32,15975649; -25,6017496; 14,40568743; -5,647074344; 1,473727937; -0,230919346; 0,016479631 ]

B = [ 1,68E-06; 1,68E-05; 7,58E-05; 2,02E-04; 3,54E-04; 4,24E-04; 3,54E-04; 2,02E-04; 7,58E-05; 1,68E-05; 1,68E-06 ]

It is possible with an IIR filter, but not accurately with a plain Butterworth filter. As far as I can recall, the only IIR filter with flat group delay is the Bessel, whose stopband attenuation is inferior to the Butterworth.

The problem with the Butterworth is that the group delay is a function of frequency, therefore the different frequency components of your peaks are delayed by different times.

One solution is to follow the Butterworth filter with a "group delay equaliser" consisting of approximately as many "all pass" stages as the filter itself. This will give you a good approximation to a constant group delay. I wouldn't presume to advise you on actually designing the equaliser.

All in all, I think the FIR filter is a far simpler approach, as well as more accurate : I don't know why you regard its delay as "approximate".

• I am not the most experienced person in the area, for sure, so I refered to the delay expression as approximate in reference to where I saw it originally. In any case, thanks for the Bessel suggestion: I thought trying that one would be overkill but maybe that's not the case. Also: you mention using FIR filters as a better approach, but from what I have seen, these warp the signal too much to be recognizable (using a moving average with n=25), so is there a good reference to a FIR filter that would be better in this aspect? Commented Mar 19, 2013 at 14:27
• A 20th order IIR filter should be compared to an FIR of about 100 taps or more in terms of computational complexity. FIR filter design tools should be easy to find.
– user16324
Commented Mar 19, 2013 at 14:40
• "warp" usually refers to phase distortion, which is not an issue with a symmetric FIR filter. Commented Mar 19, 2013 at 15:00