TECHNICAL NOTES JOURNAL OF APPLIED BIOMECHANICS, 1994,10, 374-381 Q 1994 by Human Kinetics Publishers, Inc. Construction of a High-Pass Digital Filter From a Low-Pass Digital Filter Stephen D. Murphy and D. Gordon E. Robertson To remove low-frequency noise from data such as DC-bias from electromyograms (EMGs) or drift from force transducers, a high-pass filter was constructed from a low-pass filter of known characteristics. A summary of the necessary steps required to transform the low-pass digital were developed. Contaminated EMG and force platform data were used to test the filter. The high-pass filter successfully removed the low-frequency noise from the EMG signals. The high-pass filter was then cascaded with the low-pass filter to produce a band-pass filter to enable simultaneous high- and low-frequency noise reduction. The smoothing of displacement signals prior to time differentiation is essential to remove high-frequency artifacts. Higher frequencies become amplified during the differentiation process (see Winter, 1990). To remove highfrequency noise, low-pass digital filters are frequently used. A similar situation occurs when low-frequency noise is present in a signal that needs to be integrated. Even a relatively small bias error, upon integration, can become the dominant component of the signal. The solution is a high-pass filter, which removes the low-frequency interference and leaves the higher frequencies unaffected. Digital high-pass filters are rarely used in biomechanics. These filters could be valuable when low-frequency noise, such as amplifier drift, occurs during electromyography (EMG), accelerometry, or dynamometry. The goal of this research was to develop a high-pass digital filter using the same software already developed for performing low-pass digital filtering, since most biomechanics researchers already possess such technology. Pezzack, Norman, and Winter (1977) showed that the process of digitally filtering cinefilm coordinate data to remove high-frequency noise and then applying finite differences was an appropriate solution for obtaining segmental kinematics. More detail on the construction of the low-pass filter used by Pezzack et al. can be found in Rader and Gold (1967) and Winter (1990). Barr and Chan (1986) constructed low-pass, high-pass, band-pass, and band-stop digital filters based on a transformation from an analog low-pass filter. Barr and Chan's approach did not take advantage of the current knowledge that exists regarding the construction of low-pass digital filters to build high-pass digital filters. A high-pass digital filter can be constructed from a low-pass digital Stephen D. Murphy and D. Gordon E. Robertson are with the School of Human Kinetics, University of Ottawa, Ottawa, ON Canada K I N 6N5. High-Pass Digital Filter 375 filter by means of a transformation. A brief presentation of this derivation, as well as applications of the high-pass digital filter follows. For a more detailed description of the theory behind this approach, consult the text by Oppenheim and Schafer (1989), who developed the principles upon which this transformation is made, but who did not provide a specific example with validation of its effects. Theory The general Nth order digital filter is a recursive equation of the form (Hamming, 1977) N N Therefore, a second order (N = 2) digital filter is written Yn = aoxn + alxn-l+ W n - 2 + b,y,-t + b2yn-2. Let the known low-pass digital filter have the following transfer function: To get the corresponding high-pass digital filter let (Oppenheim & Schafer, 1989) where and q,= angular velocity of low-pass filter (radls), wP= angular velocity of highpass filter (radls), and T = sampling interval (seconds). Expanding and regrouping the constants into the same form as (Equation 1) yields the high-pass filter with the following coefficients: Murphy and Robertson 376 Before the coefficients for the low-pass filter can be calculated, a suitable low-pass cutoff frequency must be chosen. Since the high-pass cutoff frequency is given and the low-pass cutoff frequency can be chosen arbitrarily based on a, set a = 0 and solve for a&,. Choosing a = 0 simplifies the calculations of the high-pass filter coefficients (see Equation 3) and Equation 2 implies that q Q T+ Q,~T= a. Solving for wP gives qp= (IT - @,T)/T. Since researchers usually deal with frequencies rather than angular velocities, recall that mQ= 27tfhp-Perform a similar substitution for ol, and simplify to get To summarize, use the following steps to build a high-pass digital filter: 1. After selecting the desired cutoff frequency for the high-pass filter, use Equation 4 to calculate the associated low-pass filter's cutoff frequency, .hQ. 2. Next, compute the low-pass filter's coefficients (Ai and Bj) using the usual equations. We recommend a zero-lag, Butterworth, critically damped filter as presented by Winter (1990) (for suitable equations, see below). 3. Then by letting a = 0 in Equation 3, the new coefficients, a, and bi,for the high-pass digital filter will be 4. Finally, filter the data using the same equation as for the low-pass filter but using the coefficients, ai and bj,instead of Ai and Bi. As an example, the following steps were used to construct a high-pass filter from the critically damped, Butterworth, low-pass zero-lag filter as described by Winter (1990). First, assume that the researcher has sampled the data at a frequency, f,. Using Equation 4, the associated low-pass cutoff frequency is Note that the cutoff frequency,j,, must be less than one half the sampling rate, f,; otherwise, an aliasing error will occur due to violation of the sampling theorem. Second, determine the cutoff frequency of the associated low-pass filter (see Winter, 1990): o,= tan [n(f;&)]. Third, correct for the number of filter passes of the critically damped, zero-lag filter (Robertson, Barden, & Dowling, 1992). The corrected cutoff is where n is the number of filter passes. In the case of a zero-lag filter where the data are passed (cascaded) through the filter twice (once in the forward direction and once in the backwards direction) n will be 2. Fourth, compute the low-pass filter coefficients. Let Kl = 203,* and Then, the low-pass coefficients are as follows: K1= High-Pass Digital Filter Fifth, from Equation 5 above, the high-pass coefficients are a, = A,, a, = -Al, a2 = A,, b, = -B,, and b2 = B2. Finally, filter the data by running them through the filter first in the forwards direction and then in the reverse direction. This will produce a zero-lag filter with a roll-off of fourth order (i.e., -24 db/ + blyi-I + boi-2, octave). The equation of the filter is yi = a,gi+ alxi-~+ a 2 4 - ~ where, 4 are the raw data and yi are the filtered data. Methods Four applications of the high-pass digital filter demonstrate its usefulness in removing low-frequency noise. In the first two applications, a high-pass filter was constructed and applied to two 6-second samples of EMG from a series of flexor digitorurn longus muscle contractions. ~ a c hsignal was collected at approximately 2100 Hz. The first EMG had a DC-bias of 0.13 mV added while the second sample had a drift of 0.42 mV/s added. The third application was a vertical force history that was collected from a piezoelectric force platform (Kistler Model 9865B) with the "time constant" option set (Bioware Version 2.0, Kistler Corp.) to produce drift. This is similar to using the "long" time constant on the older Kistler Model 9261A force platforms. The subject stood on the platform and performed a series of deepknee bends. In the fourth application, a digitally constructed signal containing 0.1, 1.O, and 10.0 Hz sine waves, all with unity amplitude, was constructed. Low-pass and high-pass filters were designed in the same manner as above. The multifrequency signal was both high-pass and low-pass filtered and then was filtered with both the high-pass and low-pass filters providing a band-pass filter. Results and Discussion Figure 1 shows the frequency response of the high-pass filter. Notice that this filter is very flat in the pass band. This is a property of Butterworth filters, which are designed to be optimally flat in the pass band. In Figure 2, a raw EMG signal with a DC-offset is displayed. Below it in the same figure is the signal after applying a high-pass filter with a cutoff frequency of 1.0 Hz. The filter successfully removed the bias from the signal without adversely influencing the amplitudes of the high-frequency components. Note that the closely dotted line in the middle of this and the following figures are the zero voltage levels. Both curves have the same scaling factor, which is displayed to the right beside each curve. The time-axis scaling is displayed in the bottom right-hand side of each figure. Figure 3 shows a similar EMG that had "drift" present. The lower curve was filtered at 1.0 Hz, which completely removed the drift but left the EMG amplitudes unaffected. These results demon- u o s w q o ~pue A y d ~ n ~ High-Pass Digital Filter 3 79 Figure 3 - Effects of a high-pass filter on an EMG signal with "drift." strate the usefulness of a high-pass filter for removing unwanted low-frequency noise from EMG signals. In Figure 4 a vertical force history with drift due to using a piezoelectric force platform (Kistler) with a low time constant is shown. After 12 seconds, the apparent body weight of the subject dropped from 717 N to 633 N. After running the data through a high-pass filter with a 0.5 Hz cutoff the body weight line was reduced to zero. This was expected because a high-pass filter acts like ac-coupling and so the dc-offset produced by the subject's body weight was removed from the signal, as shown by the middle curve in Figure 4. The lower curve shows the force signal after the body weight of 717 N was added back. This signal very closely matches the original signal, except that the drift due to the low time constant has been removed. Notice that there is a slight artifact present in the first second of the filtered signal. This is due to the "warm-up" that is needed before the filter functions correctly. These effects can be reduced by having lead-in data to allow the filter time to settle. Figure 5 shows the results of both high-pass and low-pass filtering a signal containing 0.1, 1.0, and 10.0 Hz sine waves. The top curve is the raw data, the second curve shows the data high-pass filtered with a 0.5 Hz cutoff, and the third curve shows the effects of low-pass filtering at 5.0 Hz. The bottom curve demonstrates the effects of cascading the data through a 0.5 Hz high-pass filter followed by a 5.0 Hz low-pass filter. Examining the second and bottom curves shows that the low frequency 0.1 Hz signal is no longer present. Its signal amplitude has been reduced to 3% of its original amplitude. The higher frequency 10 Hz signal has also been reduced (to 12%) in the third and bottom curves, but is still visible in the filtered signals. Lowering the low-pass filter's cutoff would -leu%!sp3!8!p dauanbaq -!Jlnur e jo %u!Ja~gssed-pueq pue bssed-~olbssed-qS!q jo spa333 - s a~n%!& uosllaqo~pue Ayd~nw 08E High-Pass Digital Filter 381 reduce the 10 Hz signal more, but the amplitude of the 1.0 Hz signal will also be reduced. Again, notice that these filters d o require time to reach their specified operating characteristics. In the case of zero-lag filters, extra leading and trailing data are required (see Smith, 1989). References Barr, R.E., & Chan, E.K.Y. (1986). Design and implementation of digital filters for biomedical signal processing. Journal of Electrophysiological Techniques, 13,7393. Hamming, R.W. (1977). Digitalfilters. Englewood Cliffs, NJ: Prentice Hall. Oppenheim, A.V., & Schafer, R.W. (1989). Discrete-time signal processing. Englewood Cliffs, NJ: Prentice Hall. Pezzack, J.C., Norman, R.W., & Winter, D.A. (1977). An assessment of derivative determining techniques used for motion analysis. Journal of Biomechanics, 10, 377382. Rader, C.M., & Gold, B. (1967). Digital filtering design techniques in the frequency domain. Proceedings of lEEE, 55, 149-171. Robertson, D.G.E., Barden, J., & Dowling, J. (1992). In Proceedings of the Second North American Conference on Biomechanics. Kingston, ON: Canadian Society for Biomechanics, Queen's University. Smith, G. (1989). Padding point extrapolation techniques for the butterworth digital filter. Journal of Biomechanics, 22, 967-972. Winter, D.A. (1990). Biomechanics and motor control of human movement. Toronto, ON: Wiley. Acknowledgment For technical assistance, we wish to thank Dr. Tyseer Aboulnasr of the Department of Electrical Engineering, University of Ottawa.