# Should I use ideal or non-ideal filters for offline filtering?

I've got an offline signal that I want to high-pass filter. Should I use a Butterworth filter, or could I use the fact that the whole signal is known and use an ideal (step) filter?

Using a high-degree Butterworth filter is, I think, practically the same thing as using an ideal filter, and a higher degree means a better filter if there's no implementation and processing cost. Could the sharp change in impulse response cause a problem, though?

The signal is a bioelectric signal that is almost periodic, and I've got 100 periods or so.

For most practical applications, filter responses that approach the behavior of the ideal "brick-wall" filter are overkill. I know it's tempting to try to design a really sharp filter when you've got all the time in the world (i.e. for offline applications), but if you really look at the characteristics of your problem, you can most likely get away with something much more reasonable.

Another good reason not to use a brick-wall filter: its impulse response is infinite in length, and it has the form of a $sinc$ function. When you apply such a filter to your signal, you may notice long-duration ringing in the signal at the output of the filter. This comes from the fact that the $sinc$ function in the filter's impulse response is infinitely long and doesn't decay very fast; the resulting effect is most likely not desirable. In general, filters with long frequency responses are not very suitable for analysis of short signals, as the filter output is dominated by the transient behavior of the filter.

The aforementioned effects aren't limited strictly to ideal filter responses; if you design a filter with a really sharp cutoff, it's still possible that you will get time-domain artifacts that you don't want. This intuitively makes sense, because you can view the frequency response of the "not-quite-ideal" filter as the response of the ideal filter convolved with a narrow main lobe that smears the response out a bit. Frequency-domain convolution is equivalent to windowing in the time domain; if you look at the impulse response of a very sharp filter that you've designed, it's likely to look much like a $sinc$ function with a window applied to taper the impulse response off at a faster rate than the $sinc$ does on its own.

I give the same advice as with most filter-design problems: you should really try to tackle the problem as quantitatively as possible. Using intuition on what might seem like a good approach can often steer you down the wrong path. Instead, think about the following:

• Where is my signal of interest in the spectrum?

• What unwanted signals are in the spectrum? Where are they?

• How large are the unwanted signals relative to the signal of interest? In order to accomplish my ultimate goal, how much must it be suppressed?

• How much distortion can I tolerate on my signal of interest (both in amplitude and phase)?

• What computational limitations do I have?

The first four questions will give you filter performance specifications that you can use with any number of design methods to arrive at filters that will achieve your goals. The last question is also important, and can be used to choose between different filter topologies (i.e. FIR versus IIR) to find one that is implementable for your application.

Have you tried to implement a step filter?

Such ideal filters, even in the digital domain, will break. Consider that a 'ideal' step response in the frequency domain required an infinite sized array to adequately represent it in the time domain.

So performing a signal transform to frequency domain, performing a 'perfect' filter, then going back to time domain will give you some erroneous results.

Check out the DSP Guide's chapter on the Windowed Sync Filter and you will get a good understanding of this phenomena