Lowpass (LP), Highpass (HP), Bandpass (BP) and Bandreject “Notch” Filters
Analog – A/D Conversion – Digital
Analog and Digital Filters
Butterworth and Bessel Filters
Flat Magnitude Response
Linear Phase or Flat Delay Response
Filtering-induced Distortion – Phase Non-linearity
Z-transform – Prewarping
IIR and FIR Digital Filters
“Ringing” as related to FIR Gibbs phenomena
Lowpass (LP), Highpass (HP), Bandpass (BP) and Bandreject “Notch” Filters
These filters are commonly used in physiological recording. They can be implemented in a variety of ways, either as physical analog filters, switched capacitor filters, digital infinite impulse response (IIR) filters or digital finite impulse response (FIR) filters.
Physical analog filters are typically created using operational amplifiers or transistor-based gain elements with resistors and capacitors. Many different implementation topologies are possible. Efficient analog topologies that lend themselves to physiological filtering requirements include the Sallen and Key implementations. These active filters employ one operational amplifier per biquad filter. These filters can implement the complex transfer function of one quadratic equation divided by another.
If the physical filter only needs unity gain, a simple type of Sallen and Key filter topology can be used, called the pf2 class. The pf2 class filters are associated with simple equations that define the resistor and capacitor values in relation to the filter cut-off frequency (Fo) and quality factor (Q). For each HP or LP, two pole, biquad stage, one operational amplifier, two resistors and two capacitors are required.
If the LP or HP active filter requires gain in excess of unity, there are useful topologies that simply require the addition of two more resistors, to pf2 class designs, to adjust the gain of the filter stage. The design formulas are slightly more complicated, due to the fact that some choices for Q or Gain are non-realizable, but it’s typically easy to work around these problems.
When creating multiple pole filters, it’s best to place the biquad sections with increasingly higher Qs later in the staging. This is because high Q biquad stages will have high gains at the frequency response peaks. These peaks will be more likely to result in operational amplifier saturation, if signals feeding these stages are not well controlled in terms of allowable magnitudes at sensitive frequencies.
Biquad notch filters are the inverse of biquad BP filters. A specific filtering topology reflects this nature. In this case, a notch filter is created by summing the pass-thru and BP- inverted signals together. At the point of the notch, the BP-inverted filter output is is exact opposite of the pass-thru signal so the resulting summed output is exactly zero.
Topology choices become more critical, as the Q of any particular biquad filter increases, because component sensitivities for many topologies (such as Sallen and Key) are proportional to Q squared. As filter Qs increase then other topologies, such as the State Variable Biquad, are often preferable even at the expense of adding additional operational amplifiers to the filter design.
Analog – A/D Conversion – Digital
After filtering, physiological data is usually directed to an analog to digital converter (ADC), for digitization, so the data can be more readily evaluated using application specific software. Given the prevalence of low power, high speed digital signal processors (DSP) and computers, it’s increasing possible to perform needed physiological filtering via digital methods. The primary issues when implementing digital filters are the considerations of processing speed, type of arithmetic and aliasing.
The processing speed of the digital filter is typically only important if the filter is required to be implemented in real-time. The type of arithmetic, such as fixed or floating point, has a bearing on the type of filter topology chosen, as some digital filter types are more sensitive to rounding errors than others. Aliasing is the generation of spurious signals when the data fed to the digital filter has frequency components that are greater than the filter sample rate (Fs) divided by 2. This phenomenon is known as under-sampling. It’s important that no frequencies in excess of Fs/2 are permitted to be sampled by the ADC. If signal frequencies above Fs/2 are permitted to be sampled by the ADC, then these sampled signal frequencies will result in artifacts. Aliasing produces artifact signals that have frequencies defined by the difference between Fs and the sampled signal frequency. Most delta sigma ADCs have a very high sampling rate so it’s usually not a problem to properly constrain the input signal bandwidth, even using just a single pole, passive lowpass filter at the ADC input.
To maximize physiological signal signal to noise ratio (SNR) it’s important to adjust the signal gain so that the maximum signal expected just fits within the maximum range of the ADC. In this manner, the entire digitization potential of the ADC is utilized. With very high resolution ADCs, less and less signal preconditioning is needed because the high dynamic range of the ADC minimizes the requirement for physiological signal gain control or high pass filtering that minimizes baseline wander.
Analog and Digital Filters
Filters can be implemented in a variety of ways. Filters implementation methods can be grouped into two basic classes. One class is analog filters. These filters can be designed to process time varying signals in their raw, real world (analog) form. The other class is digital filters. These filters are mathematical algorithms that operate on a digitized version of the analog signal. To a reasonable degree, analog and digital filters can be designed to mimic each other. However, there are some important differences which can’t easily be masked.
The differences are a consequence of two different phenomenon when a signal is converted from analog to digital form. When an analog signal is converted to digital form, the signal is sampled at a specific rate and converted to a numeric value with a specific resolution. These phenomenon, namely sampling rate and resolution, play a large role in determining the appropriate type of digital filter for a specific application.
Analog filters are typically accommodating in practice. An active filter can operate over a bandwidth spanning six decades with a signal to noise ratio in excess of 100dB. Active filters work very well, but they require mechanical assembly and are subject to performance problems related to component selection and aging. Digital filters sometimes perform less well than analog filters, but digital filters are essentially virtual, require almost no physical space, do not require component selection and do not degrade over time.
Generally, in contemporary analog to digital conversion systems, analog data is amplified and pre-filtered prior to the analog to digital (A/D) conversion process. Amplifying the analog signal is required to match the analog signal range to the A/D conversion range. Pre-filtering the analog data is required to match the analog data bandwidth to the Nyquist requirements established by the ADC sampling rate. The analog signal amplification and pre-filtering processes optimize the A/D conversion for best performance.
Once the analog data is optimally digitized, certain additional filtering steps that may require significant precision can be performed in software. The essential idea here is that analog circuitry is only used to establish the most optimal A/D conversion process possible and all other signal filtering and other processing is performed in software.
Digital filtering algorithms can be derived from the extensive library of analog filter design methods. Analog filters are developed to implement transfer functions defined by a ratio of polynomials. These same polynomial ratios can be implemented using digital filtering methods by employing an intermediate transform, such as the Bilinear Z-transformation. This transformation permits a polynomial ratio established in Laplacian space to operate as a digital filter in the Z-domain. These kinds of digital filters are known as Infinite Impulse Response (IIR) filters.
Butterworth and Bessel Filters
These two types of filters are very important for physiological recording. Butterworth filters are known as maximally-flat magnitude filters. Butterworth filters faithfully reproduce the amplitude relationships between component waves, associated with a physiological signal, over the passband. Bessel filters are known as maximally-flat delay filters. Bessel filters faithfully reproduce the timing relationships between component waves, associated with a physiological signal, over the passband. Unfortunately, Butterworth filters do not have flat delay characteristics nor do Bessel filters have flat magnitude characteristics. Quite often, a compromise is made to choose the best filter, for a given physiological signal, considering all the constraining factors.
For physiological signal recording, it’s typically important to maintain the essential character (waveshape) of the acquired signal. An especially important signal is the Electrocardiogram (ECG). Cardiologists make determinations about a subject’s cardiac health by inspecting their ECG. The ECG consists of a series of component waves (P, Q, R, S and T). Each of these waves have specific amplitude and timing relationships to one another. Preserving the essential character of the ECG requires careful filtering of the ECG. A subject’s ECG can be substantially distorted by running the ECG through the wrong type of filter. For example, a ECG filter with highly non-linear phase in the passband will result in ECG signal ringing and it will appear as though extra waves have appeared in the subject’s ECG. The specified standard for ECG signal processing is a Butterworth filter which runs from 0.05 Hz to 150 Hz. Through the critical part of the pass-band, this filter has sufficiently linear phase and flat magnitude response to not appreciably distort the original ECG signal.
Generally considered, the steeper the transition between pass-band and stop-band for a particular IIR filter, the higher the degree of phase non-linearity will be encountered in the pass-band to stop-band transition.
Flat Magnitude Response
A perfectly flat magnitude response implies that there is zero slope and/or peak to peak variation in the magnitude response of any given filter, in that filter’s pass-band. Butterworth filter topologies approximate this quality.
Linear Phase or Flat Delay Response
A linear phase filter has a flat delay response. A perfectly flat delay response implies that there is zero slope and/or peak to peak variation in the delay response of any given filter, in that filter’s pass-band. Linear phase filters are very useful for faithfully processing signals with minimal frequency-delay distortion added. Bessel filter topologies approximate this quality.
Filtering-induced Distortion – Phase Non-linearity
When a filter has linear phase, this means that all frequencies processed by the filter are delayed by the same amount of time as these frequencies are processed by the filter. If the filter is also maximally flat in the pass-band, then this filter, which is both phase linear and maximally flat, will be as non-distorting to the input signal wave-shape as possible, for the given pass-band of the filter. In some cases, it’s only important that the filter be maximally flat. In other cases, it may be important that the filter only has linear phase. However, to filter a signal with the minimum amount of filter-added distortion, the filter must be as flat as possible in the pass-band and also be linear phase. When designing using analog filters, or their digital IIR implementations, it’s quite involved to optimize a filter for both maximal pass-band flatness and linear phase simultaneously. Although acceptable compromises can usually be found, it’s difficult to create an arbitrary filter to be both very flat and have linear phase. In practice, usually the designer with first create a filter which has the optimal pass-band magnitude characteristics and then follow this filter with an all-pass filter. An all-pass filter can be designed to only affect the phase of an input signal, and not the magnitude of that signal, as a function of frequency.
An excellent digital filter topology, to provide for a flat pass-band and also linear phase, is a Finite Impulse Response (FIR) filter. A FIR filter can be linear phase because an FIR filter has a finite impulse response. This type of filter incorporates no internal feedback and simply consists of a series of staged delay elements, associated multipliers (multiplier values are known as FIR filter coefficients) which multiply the signal at tap points between the delays and a final summing junction to add all the multiplier outputs together. FIR filters are usually designed to be linear-phase. A FIR filter is linear-phase if its coefficients are symmetrical around the center coefficient. Accordingly, a linear phase FIR filter will always have an odd number of coefficients.
Z-transform and Prewarping
To craft an IIR filter, usually the filter will be designed using conventional analog methods to obtain the ratio of polynomials which define the filter’s behavior. This polynomial ratio is called the filter transform function. To convert a filter transform function so it can operate as a digital filter, an additional transformation must be applied to the polynomial ratio to convert it to a digitally-realizable form. A common conversion transform is known as the Bilinear Z-transform. The Bilinear Z-transform is an approximation of the natural logarithm (ln) that defines the frequency mapping between the S-plane and the Z-plane.
S = (1/T) * ln(Z)
The Bilinear Z-transform is defined as:
S = (2/T) * [(Z-1)/(Z+1)]
Where T is the time between samples from one digital value to the next.
Prewarping is used to correct for distortions that occur when transforming analog filters, with poles and zeros on the real and imaginary plane, to the Z domain. The Bilinear Z-transform is adjusted when designing a digital filter that mimics an analog filter at a specific frequency, typically the break point of the analog filter (Wo).
S = (Wo/tan(Wo*T/2)) * [(Z-1)/(Z+1)]
IIR and FIR Digital Filters
IIR stands for Infinite Impulse Response. FIR stands for Finite Impulse Response. IIR filters are topologically more similar to analog filters. This similarity allows for the use of analog filter design methods to be applied to the development of digital IIR filters. This ability is very useful and powerful because many resources have been developed, over decades, to design a very wide range of analog filters suited for a great variety of different tasks. FIR filters can be developed by simply identifying the desired magnitude response in the frequency domain. Then the inverse Fourier transform can be used to determine the coefficients of the FIR filter.
FIR filters can be implemented in hardware, but it can be cumbersome to perform, because of the lack of recursion in these types of filters. FIR filters are generally much less efficient to implement, either in hardware or software, as compared to analog filters or their transformed IIR equivalents in software. IIR filters can achieve a given filtering characteristic using less memory and calculations than a similarly selective FIR filter.
IIR filters are sensitive to the ratio defined by the digital filter cut-off frequency to the ADC sampling rate. The smaller the ratio, the more bits will be required by the DSP to properly implement the filter. IIR filters are prone to problems of finite-length (fixed bits) arithmetic, such as the rounding errors generated by imperfect calculations that are compounded by feedback. However, for 64 bit DSPs, this is rarely a problem.
FIR filters are relatively insensitive to rounding errors, because the lack of internal feedback means that errors do not get compounded. As the ratio defined by the digital filter cut-off frequency to the ADC sampling rate decreases then more coefficients (and delay elements) are required by the FIR filter to effect a specific frequency response.
FIR filters are always stable, because they do not have internal feedback. However, FIR filter order (defined by internal delay elements) is much higher than equivalent IIR filters. Accordingly, an FIR filter will have a longer internal processing signal delay compared to a similarly selective IIR filter.
FIR filters have a helpful advantage in that they can be made to be perfectly phase linear. When a filter is phase linear then all of the frequencies, processed by the filter, are delayed by an equal amount of time. This ability allows the filter to simply affect the magnitude of the processed signal spectra, without affecting the phase relationship of the frequency components in the processed signal. A phase linear FIR filter helps limit the amount of wave-shape distortion, that more typical non-linear phase filters can impart, to the processed signal.
In practice, it’s possible to create IIR filters with high phase linearity, but it can be difficult to do so without unduly impacting the desired magnitude performance. Frequency magnitude and phase response are more tightly linked using IIR filtering methods, so it’s harder to obtain optimal results. Generally considered, to develop IIR filters for both optimal magnitude and phase performance, one filter block is developed to accommodate the desired magnitude response and a subsequent filter block is developed as an all-pass network. The all-pass network can be designed to accommodate for the phase distortions created by the first block.
“Ringing” as related to FIR Gibbs phenomena
A potentially problematic issue associated with FIR filters is the Gibb’s phenomena. The Gibb’s phenomena is a ringing effect which manifests in the FIR filter response. This ringing effect is related to the choice of windowing methodology employed when transforming response curves in the frequency domain, via the inverse Fourier transform, to FIR filter coefficients in the time domain. By employing non-rectangular windowing methods, such as raised cosine or Bartlett, the Gibb’s phenomena can be reduced.
Filter Plots
Magnitude, phase and group delay for the following:
IIR Second Order Filters
Lowpass
Highpass
Bandpass (Low + High)
Bandpass (Single Frequency)
Band reject (Single Frequency)
Comb Notch
Besselworth (includes notch)
FIR filters (optimized for roll off)
Show effects of windows – Bartlett, Raised Cosine, Kaiser-Bessel
Lowpass
Highpass
Bandpass
Show graph of Gibb’s phenomena
-
Switched Capacitor Comb Filters:
-
N-path Filters: