Corso di DATI e SEGNALI BIOMEDICI 1 Carmelina Ruggiero Laboratorio MedInfo
Digital Filters
Function of a Filter In signal processing, the functions of a filter are: to remove unwanted parts of the signal, such as random noise; to extract useful parts of the signal, such as the components lying within a certain frequency range. The following block diagram illustrates the basic idea: There are two main kinds of filter: analog and digital.
Analog Filters An analog filter uses analog electronic circuits made up from components such as resistors and capacitors to produce the required filtering effect. Such filter circuits are widely used in such applications as noise reduction, signal enhancement, and many other areas. Advantages: - simple and consolidated methodologies of plan; - fast and simple realization; Disadvantages: - little stable and sensitive to temperature variations; - expensive to realize in large amounts.
Digital Filters A digital filter uses a digital processor to perform numerical calculations on sampled values of the signal. The processor may be a general-purpose computer such as a PC, or a specialised DSP (Digital Signal Processor) chip. Advantages: - A digital filter is programmable, - Digital filters are easily designed, tested and implemented on computer or workstation. -Digital filters are extremely stable with respect both to time and temperature. -Digital filters can handle low frequency signals accurately. -Digital filters are very much versatile.
Diagram of the setup of a digital filter The following diagram shows the basic setup of such a system:
Impulsive Response Filter A digital filter is a stationary linear system (SLS) with sampled time (TS): The output of this system is: + k = y [ n] = x[ k] h[ n k] = x[ n]* h[ n] h[n] is the response of the system to an impulsive input (δ[n])
FIR and IIR Filters There are two types of filters with impulsive response: - FIR (Finite Impulsive Response): it is a nonrecursive filter. Output depends only on present and previous inputs; - IIR(Infinite Impulsive Response): it is a recursive filter. Output depends on one or more previous output values.
Non Recursive Filter (FIR) A Finite Impulse Response (FIR) digital filter is one whose impulse response is of finite duration. The general difference equation for a FIR digital filter is: y[ n] = M k = 0 b k x[ n k] Where: y(n) is the filter output at discrete time instance n b k is the k-th feedforward tap, or filter coefficient x(nk) is the filter input delayed by k samples
Non Recursive Filter (FIR) y[ n] = M k = 0 b k x[ n k] Where: M is the number of feedforward taps in the FIR filter. Note that the FIR filter output depends only on the previous M inputs. This feature is why the impulse response for a FIR filter is finite.
FIR-Simple Moving-Average Filters The moving-average filter is the simples type of FIR. There are three types: 1. Low Pass Filter: they leave to pass the low frequencies and they strongly attenuate the high ones.
2. High Pass Filter: they leave to pass the high frequencies and they strongly attenuate the low ones. 3. A Bandpass Filter: they leave to pass the mean frequencies and they attenuate the high ones and the low ones.
Windowing in the time domain Windows are functions defined across the time record which are periodic in the time record. They start and stop at zero and are smooth functions in between. When the time record is windowed, its points are multiplied by the window function, time-bin by time-bin, and the resulting time record is by definition periodic. It may not be identical from record to record, but it will be periodic (zero at each end) and very steep rolloff on either side.
Windowing in the frequency domain In the frequency domain a window acts like a filter. The amplitude of each frequency bin is determined by centering this filter on each bin and measuring how much of the signal falls within the filter. If the filter is narrow, only frequencies near the bin will contribute to the bin. A narrow filter is called a selective window:it selects a small range of frequencies around each bin. However, since the filter is narrow, it falls off from center rapidly. This means that even frequencies close to the bin may be attenuated somewhat. If the filter is wide, frequencies far from the bin will contribute to the bin amplitude, but those close by will not be attenuated significantly.
Design of FIR Filters by Windowing The truncation window is necessary to transform a non casual filter (as it will have non-zero values for negative time) in a casual one. The truncation window has a length of (M+1) samples, and then it is shifted by M/2 samples in the positive time direction. To troncate an impulse response is equivalent to multiplying the response by a function window. After the windowing operation the impulse response of the FIR filter can be described as: Where: h[ m] = w[ m] hnon casual[ m] h[m] is the time domain response of the filter after windowing; h non-casual [m] is the time domain response of the filter before windowing; w[m] is the time domain response of window. A problem of windowing is the spectrum leakage distortion.
The signal is a non-causal: Windowing Windowing has the effect of multiplying the periodic extension of the sampled signal x[n] by a sequence that represents samples of a filter with duration nt. x[n] is a non periodic sampled and casual signal:
Windowing and Spectrum-Leakage Distortion The periodic extension of the signal is: The product of the periodic extension and the windowing function results in the discrete-time sequence x[n] x[n] represent one period of the periodic extension of the original signal:
Rectangular Window The simplest window is the rectangular window, which involves truncation at sample M: The rectangular window gives an approximation to the desired frequency response containing a number of fluctuations or ripples. It suddenly chops off in the time domain and it tends to spread out in the frequency domain.
Spectrum-Leakage Distortion The spectrum-leakage distortion arises from the spectrum spreading that develps from truncating a signal. This phenomenon can be illustrated by considering the troncated cosine: The cosine signal is producted with a rectangular window:
Spectrum-Leakage Distortion The graphic of rectangular window in the frequency domain is: The result of the product of x[n] and a rectangular window is in the frequency domain is: From this figure, we see that the frequency spectrum of the truncated cosine is spread across all frequency.
Other types of windows Several alternative window shapes, other than the rectangular window, have been developed to alleviate spectrum-leakage distortion. The best known windows are: - Hanning Window; - Hamming Window; - Berlett Window. The net result of windowing is to reduce the amount of smearing in the spectrum from signals not exactly periodic with the time record. The different types of windows trade off selectivity, amplitude accuracy and i fl
Hanning Window It is the simplest non-rectangular window sequence; it is essentially a " raised cosine ":- The effect of the Hanning window is to gradually reduce the amplitude of the ideal impulse-response towards zero at the edges of the window rather than to abruptly truncate the amplitude as does the rectangular window.
Hamming Window The Hamming window is similar to the Hanning window with modifications in weighting.
Barlett Window The Bartlett window reduces the overshoot in the designed filter but spreads the transition region considerably.
These windows are all special cases of the generalized cosine window. By summing the individual terms to form the window, the low-frequency peaks in the frequency domain combine in such a way as to minimize undesired frequency characteristics. These windows have fixed shape. Each window gives a particular trade off between the width of the main spectral lobe.
Advantages of FIR filters FIR filters are simple to design; they are guaranteed to be bounded input-bounded output (BIBO) stable. FIR filter can be guaranteed to have linear phase. This is a desirable property for many applications such as music and video processing. FIR filters also have a low sensitivity to filter coefficient quantization errors.this is an important property to have when implementing a filter on a DSP processor or on an integrated circuit.
Recursive Filter (IIR) The Infinite Impulse Response (IIR) filter has the impulse response of infinite duration. The general difference equation for an IIR digital: Where N y[ n] = ak y[ n k] + b k = 1 M k = 1 k x[ n k] a k is the k-th feedback tap depending on previous outputs. If a k =0 then the filter is a FIR. N is the number of feedback taps in the IIR filter. M is the number of feedforward taps.
Recursive Filter (IIR) Note that, unlike the FIR filter, the output of an IIR filter depends on both the previous M inputs and the previous N outputs. This feedback mechanism is inherent in any IIR structure. It is responsible for the infinete duration of the impulse response.
Filters Derived from Analog Design A digital IIR filters design method is based on the classical analog prototype filters and the bilinear transformation. With use of the bilinear transformation these filters can be used also when designing IIR digital filters.
IIR Filter Design by Impulse Invariance - Given specification in ω domain. - Convert it into specification in Ω domain - Design analog filter meeting the specification - Convert it into digital filter function H(z) by putting H c (s) s k e s k T d
Low Pass Filter: The four standard IIR High Pass Filter: Where: Ω LPc =cut off frequncy Ω LPs =stop band frequency
Band Pass Filter: The four standard IIR Stop Band Pass Filter:
Advantages of IIR filters IIR filters are useful for high-speed designs because they typically require a lower number of multiplies compared to FIR filters. IIR filters can be designed to have a frequency response that is a discrete version of the frequency response of an analog filter. IIR filters also are very sensitive to filter coefficient quantization errors that occur due tousing a finite number of bits to represent the filter coefficients.