An Intelligent Adaptive Filter for Fast Tracking and Elimination of Power ine Interference from ECG Signal Nauman Razzaq, Maryam Butt, Muhammad Salman, Rahat Ali, Ismail Sadiq, Khalid Munawar, Tahir Zaidi College of Electrical and Mechanical Engineering, National University of Sciences and Technology, Islamabad, Pakistan King Abdulaziz University, Jeddah, Saudi Arabia E-mail: nauman.razzaq@ceme.nust.edu.pk, maryambutt0@ceme.nust.edu.pk, salmanmasaud@ceme.nust.edu.pk, rahat.ali@ceme.nust.edu.pk,ismail_sadiq_ee@yahoo.com, kmunawar@kau.edu.sa, tahirzaidi@ceme.nust.edu.pk Abstract The ECG (Electrocardiogram) signal reflects the electrical activity of the heart. Since amplitude of ECG signal is of order of few mv, it is susceptible to many types of noises and amongst which the most disturbing is power line interference (). Variations in frequency of further complicate the problem which can be taken care by implementation of adaptive notch filter (ANF). ANF normally requires a reference input which is not possible in all cases. In this paper, we have proposed an intelligent adaptive filter which does not require a reference input. Proposed method first detects the frequency of noise then adaptively tracks and eliminates from ECG signal.. Introduction Power line interference () is the most devastating noise found in ECG signal. An ECG signal will be characterized as good quality when it does not have noise more than 0.5% of the maimum amplitude of ECG signal []. To remove, one of the simplest solution is to pass mied ECG signal through a notch filter. But this causes long transient time and ringing effects as well as it cannot tackle the drift in the frequency of noise. To handle the problem of frequency drifting, the Adaptive Noise Cancellation (ANC) is useful which tracks the and then subtract it from the corrupted ECG signal to get the pure ECG signal. For the implementation of ANC, we need a reference input which provides the amplitude and phase information of the signal. B. Widrow et al. have proposed an adaptive filter in which an additional reference input has been used []. H.C. So et al proposed an Adaptive Sinusoidal Interference Canceller (ASIC) in which it is assumed that frequency of is known and adaptive filter will estimate amplitude and phase of the interference [3]. Bazhyna et al. have proposed a method which does not require the reference input [4]. They isolate the linear and non linear segments in ECG and then use the linear segments to estimate the but it adds more computational compleity. Also the nonlinear segment (QRS) and linear segment (ST and PQ) are required to be detected first which causes inherent delay making it unworkable for online implementation. This paper proposes a new adaptive method which first estimates the frequency of noise then adaptively tracks present in the ECG signal. In this method, an intelligent Discrete Fourier Transform (DFT) is applied for frequency estimation which require less computational compleity. The estimated frequency is then used as reference for State Space Recursive east Square (SSRS) adaptive filter [5]. SSRS can track the amplitude and phase of noise and provides us estimated. Subtracting the estimated noise from the primary input gives us the pure ECG signal. The rest of the paper is organized as follows. In section, state space model of is derived. In section 3, the proposed method for adaptive noise cancellation is presented. Section 4 includes computer simulations and the discussion on their results. Section 5 gives performance comparison of proposed system with a standard notch filter. Finally conclusion is drawn in section 6.. State Space Model of ECG signal containing is given by y(n) = ECG (n)+ (n) Where y(n) is ECG signal corrupted by, () (n) ECG is the pure ECG signal and (n) is the noise consisting of single sinusoid and can be represented by ( n) = α sin(ωn+φ) () 978--4799-053-3/3/$3.00 c 03 IEEE CBMS 03 5
where n is the discrete time inde, ω is the normalized defined as ω=π f / fs, f is the frequency of the, f s is sampling frequency, α is amplitude of the and φ is the phase of. The proposed adaptive filter is state space based and state space model of is derived as following: et the (n) be the state of a second order state space system and the other state is defined as the (n) with phase shift of π / (n)= α sin(ωn+φ) (3) (n)=α sin(ωn+φ+ π / ) We may rewrite (3) as ( n ) = α sin(ωn+φ) = α( sinωn cosφ+cosωn sinφ) (4) (n)= α cos(ωn+φ) = α(cosωn cosφ-sinωn sinφ) Equation (4) may be rewritten as (n) cosωn sinωn αsinφ = (n) -sinωn cosωn αcosφ (5) Defining initial condition at n =0 (0) =α sinφ (6) (0) =α cosφ From (5) and (6), we get (n) cosωn sinωn (0) = (0) (7) (n) -sinωn cosωn Putting n= in (7) we get () cosω sinω (0) () = (0) (8) -sinω cosω We can compute states at n= () cosω sinω () () = () (9) -sinω cosω cosω sinω Here -sinω cosω is state transition matri and (0) (0) are the initial states. Starting with initial states and applying state transition matri, we can determine the states at any time n> 0. The generalized form of (9) can be written as: (n+) cosω sinω (n) = (n+) -sinω cosω (n) (0) 3. Proposed Implementation ayout of proposed implementation is shown in Figure. Figure. Proposed method consisting of three distinct blocks Proposed method can be grouped into three sections as shown in Figure. The core of the proposed system is the SSRS filter whose role is to track the noise present in the ECG signal. For precise tracking of, the state space model of (derived in section II) must be accurate and ω is the only parameter which defines the accuracy of the model. Therefore we need to estimate the frequency of first. We have employed an intelligent Discrete Fourier Transform (DFT) technique for frequency estimation of. Pure ECG signal is achieved with the subtraction of the estimated component from the noisy ECG in the filtration stage. Workings of these stages are eplained here. 3. SSRS Adaptive Filter The SSRS is a state space model dependent adaptive filter which gives us ecellent signal tracking when the model accuracy is high. The SSRS algorithm is briefly summarized here [5]. et the unforced discrete time state space system be described as following. n [ + ] = Ann [ ] [ ] () yn [ ] = Cnn [ ] [ ] + vn [ ] SSRS filter estimates the states ˆ[ n] on each observation yn [ ]. The estimated state vector is given by n ˆ[ ] = n [ ] + K[ n] ε [ n ] () And estimated output is determined by yn ˆ[ ] = Cn ˆ[ ] (3) Where nis [ ] the predicted state, defined as n [ ] = An ˆ[ -] (4) ε [ n ] is the prediction error, defined as ε [ n] = y[ n]- y[ n ] (5) 5 CBMS 03
ynis [ ] the predicted output state defined as yn [ ] = Cn [ ] = CAn ˆ[ -] (6) K [ n ] in Eq. (), is the observer gain defined as - T K [ n] =Φ [ n] C (7) Φ[ n ] is recursively updated by -T - T Φ [ n] = λ A Φ [ n-] A + C C (8) Where λ is the forgetting factor. The working of SSRS is shown in Figure. Figure. Block diagram of SSRS We choose the noise to be tracked instead of ECG signal because of high modeling accuracy of sinusoid in state space. State space model of has been derived in section whose state transition matri cosω sinω is -sinω cosω which is neutrally stable i.e. all its eigen values lie on unit circle, therefore it eactly replicates with unforced system defined at (). Putting C= [ 0] in (3), ŷ[n] will be estimated i.e. (n). The response of proposed SSRS can be adjusted by the two parameters ω and λ. Hereω is the central frequency of the filter response and it is estimated by intelligent DFT block prior to SSRS filter. λ is forgetting factor and will cause change in bandwidth of the filter. For short bandwidth, value of λ will be selected close to e.g. λ = 0.99 will provide us narrow frequency band selection. In order to start the recursion of SSRS, we need the knowledge of certain quantities at time k=0. This includes initial estimate of states ˆ[0] and initial observer gain K[0]. For initialization, regularization or delayed recursion techniques are the choices. We adopted the later method because of its superior convergence properties [5]. 3. Intelligent DFT Algorithm Frequency estimation of the is performed prior to the SSRS filter and will be used as reference input to the SSRS filter. We have applied the intelligent DFT algorithm proposed by N. Razzaq et al. which provide us fast frequency estimation [6]. This technique provides us high resolution frequency estimation with reduced window size and less computational compleity as compared to Fast Fourier Transform (FFT) making it feasible for online estimation of frequency. The intelligent DFT is improved version of basic DFT algorithm which iteratively narrows down the bandwidth for frequency search of noise thus achieves high frequency resolution with much reduced computations. DFT is defined by N j π Kn/ N X K = n. e (9) n= 0 Where N defines the window size (number of samples) and K defines the number of the frequency bins (number of discrete frequencies), n is the discrete inde and n is discrete data at inde n. The frequency of eists in the frequency band of 45-55 Hz. Assume ECG signal is corrupted by noise of 5.75 Hz with SNR=00. Taking its frequency spectrum, we observe domination of 5.75 Hz in the frequency band of 45-55 Hz (See Figure 3). Figure 3. Domination of frequency in the band of 45-55 Hz (SNR=00) Working principle of intelligent DFT algorithm is briefly eplained here. et the initial selected bandwidth Δ f = 0Hz (45-55 Hz) which is divided into μ frequency bins. The achieved frequency resolution defined as df can be calculated by df =Δ f / μ (0) et s take μ = 0, we will achieve df = in first iteration and we select only one frequency bin with highest magnitude, for net iteration. In second iteration, we have Δ f = Hz and achieve df = 0. Hz. In this way, we enhance frequency resolution by 0 times by just doubling the computation. Working of CBMS 03 53
proposed algorithm for frequency search of 5.75 Hz is illustrated in Figure 4. The results of first four iterations are shown in Figure 6. Number of frequency bins ( μ ) in each iteration is taken as μ = 0 which means we achieve increase in frequency resolution by a factor of 0. In first iteration we achieve frequency resolution df = Hz and after fourth iteration we are able to acquire frequency resolution df = 0.00Hz. Estimated frequency of noise through the proposed method is 5.75 Hz. Figure 4. Frequency search for =5.75 Hz using intelligent DFT Computational compleity of intelligent DFT to search frequency with frequency resolution df = 0.0 Hz with sampling frequency of khz is calculated as 60 3 whereas FFT require 3.30 6 computations to achieve same frequency resolution [6]. 3.3 Filtration At the final stage, the estimated given by SSRS filter is subtracted sample by sample from the primary input to get the pure ECG signal. 4. Results and Discussion Signal simulation and results are discussed in following sub sections. 4. Signal Formulation ECG signal was taken from MIT-BIH database [7] which has sampling frequency of 360 Hz and its amplitude is normalized to have peak-to-peak value of. noise consisting of single sinusoidal frequency at 5.75 Hz was added in the clean ECG in proportion to have SNR=0. Figure 5 illustrate the presence of power line interference in ECG signal. (a) (c) (b) (d) Figure 6. (a) st iteration: f = 0 Hz, df = Hz, (b) nd iteration: f = Hz, df = 0.Hz, (c) 3 rd iteration: f = 0.Hz, df = 0.0 Hz, (d) 4 th iteration: f = 0.0Hz, df = 0.00Hz 4.3 tracking During the initialization of SSRS filter, frequency is taken as 50 Hz and initial states assumed to be zero. Since sinusoidal model has been defined in SSRS filter, it tries to track the sinusoidal frequency of 50 Hz. However due to difference of a frequency from actual, a considerable error will be observed until the frequency estimation is provided by intelligent DFT algorithm. The initialization process is completed after window size of 7 samples and there after SSRS is tuned at correct frequency. The tracking of SSRS during initialization period is presented in Figure 7. Figure 5. ECG signal corrupted with 5.75 Hz having SNR=0 4. Frequency Estimation Window size of 7 samples is selected for frequency search of noise and Hanning function is also applied to reduce the effect of the spectral leakage. Figure 7. Tracking of SSRS during initialization 54 CBMS 03
If we do not tune the SSRS filter with the correct frequency, then tracking error will persist as shown in Figure 8. Whereas intelligent DFT estimates the frequency of after first 7 samples and provides it to SSRS as reference input. Significant reduction in tracking error can be seen after frequency correction in Figure 9. Figure 8. of SSRS Tracking error without correct tuning 5. Performance Comparison Performance of proposed SSRS filter is compared with the standard notch filter in the following section. Transfer function of a nd order notch filter can be written as [8]. b0 + b - - z + bz H( z) = () + az - - + az For designing a notch filter we need to define f notch (notch frequency) and Q (Quality factor). Where f notch is central frequency of the notch filter and Q is defined as fnotch Q = () Δ f Here Δf is bandwidth of the notch filter. For a good quality notch filter, Q must be as high as possible but on the other side higher Q means more transition delay is involved. In our simulation, we have selected Q =40. et us first, assume that f is known to be 5.75 Hz. Having fnotch = 5.75Hz and Q =40, we get the numerator and denominator coefficients of () as b 0 = 0.996, b = -.464, b = 0.996, a = -.464 and a = 0.994. The magnitude response of the specified notch filter is shown in Figure. Figure 9. Reduction in tracking error after correct tuning of SSRS 4.4 Filtration The filtration is achieved by subtracting the estimated from mied ECG signal. The filtered ECG signal is shown in Figure 0. Figure. Magnitude response of 5.75 Hz Notch filter with Q=40 (a) (b) Figure 0. Filtered ECG signal (a) Time domain (b) Frequency domain The ECG filtered from the notch filter is shown in Figure which shows a considerable transient time taken by notch filter before complete elimination of noise. CBMS 03 55
6. Conclusion Figure. ECG filtered output from notch filter In Figure 3, comparison of the filtration errors produced by both notch filter and SSRS have been presented which clearly shows the fast response of SSRS filter as compared to the notch filter. The results of this research shows that when SSRS based on sinusoidal model is applied on ECG signal corrupted with noise, the filter converges to dynamic solution by adaptively updating the states of the filter and in return track the sinusoidal power line interference. SSRS gives us marvelous tracking performance and enable us to suppress without distorting the underlying ECG signal. The proposed combination does not require the eternal reference input rather reference is generated within proposed system by intelligent frequency estimation method. 7. Acknowledgment This work is part of the project undertaken with mutual collaboration of National University of Sciences and Technology (NUST) and National Institute of Heart Diseases (NIHD), Pakistan. 8. References Figure 3. Filtration error comparison between Notch & SSRS - ( f is known) Now let us consider the case where f is not known and initially assumed as 50Hz. In Figure 4, a comparison between a notch filter and proposed algorithm has been presented. In the case of notch filter, we get large filtration error whereas proposed algorithm estimates f and tune the SSRS filter during initialization period of 7 samples and thereafter gives us accurate filtration. Figure 4. Filtration error comparison between Notch & SSRS - ( f is unknown) [] A. C. Van Rijn et al., High quality recording of bioelectric events. part. interference reduction, theory and practice, Med. Biol. Eng. Computing, Vol. 8, Issue 5, 990 pp. 389-397. [] B. Widrow et al., Adaptive Noise Canceling: Principles and Applications, Proc. IEEE, vol. 63, 975, pp 69-76. [3] H.C. So et al., Adaptive Algorithm for Sinusoidal Interference Cancellation, IEE Electron. etters, vol. 33 (), 997, pp.90-9. [4] Bazhyna A et al., Powerline Interference Suppression in High Resolution ECG, Computers in Cardiology; 003, 30:56-564. [5] Mohammad Bilal Malik State-Space Recursive east Squares: part I, Signal Processing, vol. 84/9, 004, pp 709-78. [6] Nauman Razzaq et al., An efficient method for estimation of power line interference in ECG signal, 5th International Conference on Modelling, Identification and Control, Cario, Egypt, 03; (Accepted). [7] A.. Goldberger et al., (000) PhysioBank, PhysioToolkit and Physionet: Components of a new research resource for comple physiologic signals, Circulation. [Online] Available: Circulation Electronic Pages: http://circ.ahajournals.org/cgi/content/full/0/3/e5. [8] P Srisangngam et al., Symmetric IIR notch filter design using pole position displacement, IEEE International Symposium on Intelligent Signal Processing and Communication Systems, Thailand, 008. 56 CBMS 03