## Digital Filtering

Digital filters generally come in two flavors: Finite Impulse Response (FIR) and Infinite Impulse Response (IIR) filters. Each one can implement a filter that passes or rejects bands of frequencies, but the mathematics and implementations differ significantly.

### Finite Impulse Response Filters

"Finite Impulse Response" means that the filter´s time-domain response to an impulse (or "spike") is zero after a finite amount of time:

FIR filters have a very useful property: they can (and usually do) exhibit linear phase shift for all frequencies, a feat impossible for an analog or IIR filter. This means that the time-relation between all frequencies of the input signal is undisturbed; only the relative amplitudes are affected. (This is particularly important when processing television signals to keep the color signal aligned with the brightness signal).

When comparing the input and output of FIR-filtered signals, it is usual to shift the input or output in time to reduce linear phase to zero phase as in the graph shown above. When this is done, you can see that the filter´s output is changing *before any input signal has arrived!* This is sometimes referred to as "acausal filtering".

Igor implements FIR digital filtering primarily through time-domain convolution using the Smooth or SmoothCustom commands.

The Smooth operation implements pre-defined low-pass filters whose coefficients are created algorithmically from only a few user-specified parameters. See Smoothing for graphs of the frequency responses of these filters (the phase response is uniformly zero because the filtering is acausal).

In spite of it´s name, SmoothCustom convolves data with user-supplied filter coefficients to implement *any* kind of FIR filter, low-pass, high-pass, band-pass, etc.

Design of the FIR filter coefficients used with SmoothCustom is most easily accomplished using the Igor Filter Design Laboratory (a separate product which also requires Igor Pro).

#### Low-pass to High-pass Conversion

Lacking IFDL, one way to high-pass filter a signal is to subtract a low-passed signal from the input signal. You can do this with Igor's wave assignments.

Another slightly faster way is to create high-pass filter coefficients for SmoothCustom using coefficients formed by subtracting low-pass filter coefficients from an impulse:

Where do you get the low-pass filter coefficents to start with? By smoothing an impulse!

Here are Igor commands which implement and apply a high-pass filter:

Make/O/N=19 impulse=0; impulse[9]=1 // Make an impulse at center (9 zeroes before, 9 after) Duplicate/O impulse, smoothedImpulse // with room for smoothed response. Smooth 5, smoothedImpulse // Form impulse response of Smooth 5. Duplicate/O impulse, coefs // Storage for high-pass coefficients. coefs= impulse - smoothedImpulse // High-pass = Impulse - Low-pass. SmoothCustom coefs, myData // Apply high-pass filter.

### Infinite Impulse Response Filters

The response of an IIR filter continues indefinitely, as it does for analog electronic filters that employ inductors and capacitors:

IIR filters are more like real electronic filters because they are "causal": no output signal is produced until the energizing input signal has arrived.

IIR digital filters are designed *and applied to data* using the Igor Filter Design Laboratory.

### References

- Terrell, Trevor J.,
*Introduction to digital filters*, Halsted Press/John Wiley & Sons, 2nd Ed 1988.