6
Implementation of Adaptive filtering algorithms for removal of Noise from ECG signal Pramod R. Bokde Nitin K. Choudhari Department of Electronics Engg. Department of Electronics & Communication Engg. Priyadarshini Bhagwati College of Engg. Priyadarshini Bhagwati College of Engg. Nagpur, India Nagpur, India [email protected] [email protected] Abstract : Electrocardiography (ECG) is a non-invasive technique which is used for reading the electrical activity of the heart. It can be detected by several electrodes attached to the body surface and recorded using an external electronic circuit. This real noise free ECG signal can be used to detect different heart diseases, but a recorded ECG signal is not noise free. Noise existing in ECG signals can be removed using analog devices or using digital filters. As computational microprocessor power increases, the need to remove noise has been shifted to the use of digital filters. One of the very effective digital filters to remove the ECG noise is adaptive filtering techniques. In this paper, several adaptive filtering algorithms are proposed for noise cancellation of ECG signals and determining the accuracy of ECG signal features. Different adaptive filter algorithms used in this research work re Least Mean Square (LMS), Normalized Least Mean Squares (NLMS), Kernel Least Mean Squares (KLMS) and Normalized Kernel Least Mean Squares(NKLMS). The main focus of this paper is to compare the performance of the proposed kernel adaptive filter to already existing least mean squares filter and demonstrates usage of different adaptive filtering techniques to cancel noise sources from an ECG signal and to accurately detect its characteristics. Keywords: Artifact, Kernel, Accuracy, Baseline wander, PLI, QRS Complex, Adaptive filters etc. I. INTRODUCTION Electrocardiography (ECG) records the electrical activity of the heart. It can be detected by several electrodes attached to the different positions of the body and recorded by using an external electronic device. It is used as a test to gather information about different heart diseases. A typical ECG signal consists of a P-wave, a QRS complex and a T-wave. Figure 1 below shows the standard noise free ECG signal. Figure 1 : Standard ECG Signal ECG noise is contributed by environmental and biological sources. In this paper, the cause of each noise source along with the methods to eliminate the noise will be discussed. 1.1. Power Line Interference : It is an environmental noise in the ECG that results from poorly grounded ECG recording machine. Because of the alternating feature of the current, this noise appears at 50 Hz and its harmonics. For removal of this type of noise, Type I adaptive filter is used to subtract 50 Hz sinusoidal from ECG signal. 1.2. Baseline Wander : Baseline drift is a biological noise that appears in ECG signal. In this noise, an iso-electric line shifts its position. It can be caused by moving electrodes, patient movement, improper electrode contact etc. during recording of ECG signal. The adaptive filter that is used to remove this noise is a special case of notch filtering, with a notch at zero frequency to remove 0-0.5 Hz frequencies. For removal, type I filter is used with reference noise. 1.3. Motion Artifact :This is most difficult biological noise to cancel. The spectrum of this noise is broad and it completely overlaps the ECG signal spectrum. Linear filtering methods are unable to remove this noise source. Adaptive filter can eliminate this noise source by having the adaptive filter reference input set to an impulse value of 1 that corresponds to the beginning of the P-wave. In this way, adaptive filter only subtracts the P-QRS-T Pramod R Bokde et al, Int.J.Computer Technology & Applications,Vol 6 (1),51-56 IJCTA | Jan-Feb 2015 Available [email protected] 51 ISSN:2229-6093

ISSN:2229-6093 Pramod R Bokde et al, Int.J.Computer ... · Implementation of Adaptive filtering algorithms for removal of Noise from ECG signal. ... (EMG) comes under the ... using

Embed Size (px)

Citation preview

Implementation of Adaptive filtering algorithms for

removal of Noise from ECG signal

Pramod R. Bokde Nitin K. Choudhari

Department of Electronics Engg. Department of Electronics & Communication Engg.

Priyadarshini Bhagwati College of Engg. Priyadarshini Bhagwati College of Engg.

Nagpur, India Nagpur, India

[email protected] [email protected]

Abstract :

Electrocardiography (ECG) is a non-invasive technique which

is used for reading the electrical activity of the heart. It can be

detected by several electrodes attached to the body surface and

recorded using an external electronic circuit. This real noise free

ECG signal can be used to detect different heart diseases, but a

recorded ECG signal is not noise free. Noise existing in ECG

signals can be removed using analog devices or using digital

filters. As computational microprocessor power increases, the

need to remove noise has been shifted to the use of digital filters.

One of the very effective digital filters to remove the ECG noise is

adaptive filtering techniques. In this paper, several adaptive

filtering algorithms are proposed for noise cancellation of ECG

signals and determining the accuracy of ECG signal features.

Different adaptive filter algorithms used in this research work re

Least Mean Square (LMS), Normalized Least Mean Squares

(NLMS), Kernel Least Mean Squares (KLMS) and Normalized

Kernel Least Mean Squares(NKLMS). The main focus of this

paper is to compare the performance of the proposed kernel

adaptive filter to already existing least mean squares filter and

demonstrates usage of different adaptive filtering techniques to

cancel noise sources from an ECG signal and to accurately detect

its characteristics.

Keywords:

Artifact, Kernel, Accuracy, Baseline wander, PLI, QRS Complex, Adaptive filters etc.

I. INTRODUCTION

Electrocardiography (ECG) records the electrical activity

of the heart. It can be detected by several electrodes attached

to the different positions of the body and recorded by using

an external electronic device. It is used as a test to gather

information about different heart diseases. A typical ECG

signal consists of a P-wave, a QRS complex and a T-wave.

Figure 1 below shows the standard noise free ECG signal.

Figure 1 : Standard ECG Signal

ECG noise is contributed by environmental and biological

sources. In this paper, the cause of each noise source along

with the methods to eliminate the noise will be discussed.

1.1. Power Line Interference : It is an environmental

noise in the ECG that results from poorly grounded

ECG recording machine. Because of the alternating

feature of the current, this noise appears at 50 Hz

and its harmonics. For removal of this type of noise,

Type I adaptive filter is used to subtract 50 Hz

sinusoidal from ECG signal.

1.2. Baseline Wander : Baseline drift is a biological

noise that appears in ECG signal. In this noise, an

iso-electric line shifts its position. It can be caused

by moving electrodes, patient movement, improper

electrode contact etc. during recording of ECG

signal. The adaptive filter that is used to remove this

noise is a special case of notch filtering, with a

notch at zero frequency to remove 0-0.5 Hz

frequencies. For removal, type I filter is used with

reference noise.

1.3. Motion Artifact :This is most difficult biological

noise to cancel. The spectrum of this noise is broad

and it completely overlaps the ECG signal

spectrum. Linear filtering methods are unable to

remove this noise source. Adaptive filter can

eliminate this noise source by having the adaptive

filter reference input set to an impulse value of 1

that corresponds to the beginning of the P-wave. In

this way, adaptive filter only subtracts the P-QRS-T

Pramod R Bokde et al, Int.J.Computer Technology & Applications,Vol 6 (1),51-56

IJCTA | Jan-Feb 2015 Available [email protected]

51

ISSN:2229-6093

complex from the signal and the remainder will be

motion artifact. Adaptive filter type- I is used to

subtract this noise from the ECG.

1.4. Muscle Artifact : Muscle artifact or

electromyography (EMG) comes under the

biological noise that appears in the ECG signal.

EMG is an electrical potential generated by muscle

cells when the cells are neurologically or

electrically activated. Muscle artifact can be

produced by unwanted reaction to electrodes. To

reduce this type of noise, typically more than one

ECG lead is used while recording. Type-I adaptive

filter applied for motion artifact will also remove

EMG from signal.

1.5. Instrumentation Noise : This is environmental

noise source which is generated by hardware that is

used for recording of the ECG signal. This noise

can be removed using Low noise Amplifiers , hence

no digital filtering is needed.

A typical noisy ECG signal can include one or more

artifacts described above.

II. ADAPTIVE FILTERS

There are two basic filter structures for adaptive filters :

Type- I and Type- II.

Type-I adaptive filter structure is as shown in figure 2 below:

Figure 2 : Type-I adaptive Filter Structure

In this type-I filter structure, primary input signal S1 with

noise n1 and reference input noise n2, which may be power

line interference, baseline wander etc and it is correlated with

n1. Both noise sources n1 and n2 should not be correlated

with the signal S1. The output of the filter is y and filter error

is e = (S1 + n1) – y . The weight function W is updated every

iteration and the basic structure for the weight function is,

New Weight = Old Weight + adjustments …… (1)

The type-II adaptive filter structure is as shown in figure 3

below :

Figure 3 : Type-II adaptive Filter Structure

Type-II adaptive filter structure, unlike filter structure 1,

has S2 as its reference signal, has primary input is signal S1

with additive noise n1 and reference input is noise S2, which

may be the clean noiseless ECG signal and it is correlated

with S1. As the nature of ECG signal is non-linear, this

adaptive filter structure cannot be used to remove noise

sources from the ECG signal.

III. LEAST MEAN SQUARES (LMS) ALGORITHM

LMS filter working is based on finding the filter

coefficients that leads to minimizing the mean square of the

error which is the difference between the desired signal and

error signal. In order for LMS filter to approach the optimum

filter weights, the algorithm starts by assuming small weights

(zero) and at each step, it finds the gradient of the mean

square error and then updates the weights. If the mean square

error is positive, error is increases positively and if same

error is used, filter weights needs to be reduced accordingly.

And vice versa, if gradient is negative, filter weights need to

be increased. Weight update equation is as below,

w(i) = w(i-1) + μ e(i) x(i) ...............(2)

where e(i), x(i), μ and w(i) are the error, the input, step size

parameter and the weight function respectively.

If the step size parameter μ is significantly small , LMS

algorithm converges in the mean square provided that u

satisfies the condition given below,

0 < u < (1 / λmax )…………. (3)

Where, λmax is the largest eigen value of the correlation

matrix.

The LMS algorithm is summarized as below:

(i) Inputs :

x = input signal

dn = desired signal

M = Filter Length

μ = Step-size factor

(ii) Outputs :

y = output of filter

e = error signal

(iii) Pseudo-code

Initialize :

Filter coefficient w(1) = 0

Loop1:

For every i, do

Pramod R Bokde et al, Int.J.Computer Technology & Applications,Vol 6 (1),51-56

IJCTA | Jan-Feb 2015 Available [email protected]

52

ISSN:2229-6093

Calculate e(i) = d(i) – w(i)T x(i)

Update w(i) = w(i) + μ e(i) x(i)

End

The graphical result of implementation of LMS algorithm

using MATLAB is shown in figure 4 below.

IV. NORMALIZED LEAST MEAN SQUARES

(NLMS) ALGORITHM

Due to sensitivity of the LMS algorithm to scaling of its

input, making it very difficult to choose the correct step size

to ensure stability of the algorithm, NLMS algorithm was

developed. This algorithm works on the basis of normalizing

the power of the input and therefore stabilizing the filter. The

modified weight update equation is shown below,

…………………….(4)

Where, є (epsilon) is very small non-zero number to avoid

division by 0 in denominator.

Figure 4 : Graphical result of implementation of LMS Algorithm

The NLMS algorithm is summarized as below,

(i) Inputs :

x = input signal

dn = desired signal

M = Filter Length

μ = Step-size factor

E = epsilon

(ii) Outputs :

y = output of filter

e = error signal

(iii) Pseudo-code

Initialize :

Filter coefficient w(1) = 0

Loop1:

For every i, do

Calculate e(i) = d(i) – w(i)T x(i)

Update w(i) = w(i) + μ e(i) x(i)/ (E +

||x(i)||2)

End

The graphical result of implementation of LMS algorithm

using MATLAB is shown in figure 5 below.

V. GAUSSIAN REPRODUCING KERNEL

HILBERT SPACE (RKHS)

A kernel k (i, j), is a continuous function which takes two

inputs I and j and maps them to a real value independent of

the order of inputs, i.e. k(I, j) = k (j, i) Є R. The Mercer’s

theorem [18] “is a representation of a symmetric positive-

definite function on a square as a sum of a convergent

sequence of product functions”. Since the noise sources are

Gaussian, Gaussian RKHS is used instead of polynomial

RKHS.

Figure 5 : Graphical result of implementation of NLMS Algorithm

Pramod R Bokde et al, Int.J.Computer Technology & Applications,Vol 6 (1),51-56

IJCTA | Jan-Feb 2015 Available [email protected]

53

ISSN:2229-6093

The algorithm for RKHS is summarized as below,

(i) Inputs :

x(i) = input signal 1

x(j) = input signal 2

α = Kernel Parameter

(ii) Outputs :

k = Gaussian Kernel

(iii) Pseudo-code

Calculate : KernelG (x(i), x(j)) = exp (-α || x(i)

– x(j)|| )

VI. KERNEL LEAST MEAN SQUARES (KLMS)

ALGORITHM

The basic LMS algorithm works properly on linear data,

where mapping between the input signal and the desired

signal is linear. For non-linear data, that mapping between

the desired signal and the input signal is non-linear; the LMS

algorithm will show poor performance. For improvement of

the performance of LMS algorithm, it must be formulated to

be capable of learning non-linear mapping. For non-linear

mapping KLMS algorithm uses RKHS to transform the input

signal x(i) into higher dimension feature space. Since input

signal is in higher dimension, it will provide richer

representation of it and therefore, its stochastic gradient

descent will be more effective for non-linear mapping of the

LMS algorithm for non-linear problems. The weight update

algorithm for KLMS algorithm is same as that of the LMS

weight update algorithm and is as below,

w(i) = w(i) + μ e(i) φ(i) ……….. (5)

where, φ(i) = φ(x(i)) is the higher dimension of input signal.

As the size of the input signal increases, size of the φ will

increase as well. This may cause problem and the need for

alternative way of computation. A kernel trick is a way of

mapping inputs into an inner product space without the

explicit need to compute the mapping. By using the kernel

trick, updated weight equation will be transformed to,

w(i)T φ(i’) = μ ∑e(j) k(x(j), x’) ………. (6)

where i’ is the inner product between transformed inputs.

We notice from the comparison of weight update algorithm

of KLMS algorithm with weight update of LMS algorithm

that KLMS algorithm is calculated weight-less. It uses sum

of all the past errors multiplied by the kernel evaluations on

the previous data.

We denote y(i) as the output of the filter at time i. we

propose the following new algorithm.

F( i – 1) = μ ∑e(j) k(x(j), x(i))…………(7)

This new algorithm which is simply the LMS in RKHS

called KLMS and filtering is done by the kernel evaluation.

Figure 6 below summarizes the new algorithm.

Figure 6 : KLMS topology

The KLMS algorithm has both linear and non-linear step-

size parameters unlike the LMS and NMLS algorithm. This

allowed improved results for the KLMS algorithm on non-

linear signal filtering.

The graphical result of implementation of KLMS algorithm

using MATLAB is shown in figure 7 below.

VII. NORMALIZED KERNEL LEAST MEAN

SQUARES (NKLMS) ALGORITHM

The NKLMS algorithm is derived from the KLMS

algorithm to improve KLMS algorithm performance.

Updated weight function for NKLMS algorithm is shown

below,

.

where, ||φ(i)||2 = k(x(i), x(i)

NKLMS algorithm is also has both linear and non-linear

step size.

Pramod R Bokde et al, Int.J.Computer Technology & Applications,Vol 6 (1),51-56

IJCTA | Jan-Feb 2015 Available [email protected]

54

ISSN:2229-6093

Figure 7 : Graphical result of implementation of KLMS Algorithm

The graphical result of implementation of NKLMS

algorithm using MATLAB is shown in figure 8 below.

Figure 8 : Graphical result of implementation of NKLMS

Algorithm

VIII. MULTISTAGE ADAPTIVE FILTERS

The multistage adaptive filter used in the research is

demonstrated in figure 9 below,

Figure 9 : Multistage Adaptive Filter topology

The actual ECG signal S1 + n1 is the noisy ECG signal. X1

is 50 Hz PLI and X2 is baseline wander artifact. The output

of this stage appears at e1. Signal e1 is used in QRS

detection to generate X3 and used for filter final stage.

Finally clean ECG signal appears at y3. This filter is divided

into two stages. First stage removes 50 Hz PLI and Baseline

wander and second stage removes muscle artifacts and

motion artifacts.

Pramod R Bokde et al, Int.J.Computer Technology & Applications,Vol 6 (1),51-56

IJCTA | Jan-Feb 2015 Available [email protected]

55

ISSN:2229-6093

IX. EXPERIMENTATION

First noisy ECG signals are created by adding artifacts to the

clean signals. The clean ECG signal is 1 minute duration of

the signal record from the MIT-BIH database. The artifacts

are also obtained from the MIT-BIH database. Once the

noisy ECG signals are created, they are fed into MATLAB

program. The performance of LMS, NLMS, KLMS and

NKLMS algorithm on the noisy ECG signals are tested.

For the ECG filtering, first PLI and Baseline Wander are

filtered out and then QRS analysis is applied to determine the

beginning of P-wave value for final filter stage of muscle

artifact and motion artifact removal. This process is done for

each LMS, NLMS, KLMS and NKLMS algorithm. For QRS

detection, a 3rd

party program is used which detects QRS

features using wavelet method.

The most common method of performance analysis is

signal to noise ratio (SNR). However, SNR analysis for an

ECG is meaningless as the medical technicians that work

with ECG signals are not interested in its SNR, but in its

accuracy in detecting its wave parameters.

X. CONCLUSION

Based on the results obtained, it can be seen that the

KLMS and NKLMS algorithms have better performance

than the LMS and NLMS algorithms. As for improving the

results, one can implement variable step-size algorithm

which can help faster convergence algorithm at the start.

Faster adaption allows the signal to be analyzed by smaller

segments, which will help on reducing the Gaussian RKHS.

Reduction in the Gaussian RKHS means fewer algorithm

computations.

It is to be noted that the KLMS and NKLMS algorithms

have linear and non-linear step-size parameters. For the

purpose of this work, both parameters were set to be equal.

By trial and error, it is possible to adjust non-linear

parameters to improve the performance of the KLMS and

NKLMS algorithms.

The comparison based on different parameters are as

shown in table1 below.

LMS NLMS KLMS NKLMS

Data

Modeling

Linear Linear Linear &

Non-

Linear

Linear &

Non-

Linear

Computation Fast Fast Moderate Moderate

Simplicity Simple Simple Moderate Moderate

REFERENCES [1] S. Haykin, Adaptive Filter Theory, Prentice Hall, 2002.

[2] W. Liu, J. Principe and S. Haykin, Kernel Adaptive Filtering: A

Comprehensive Introduction, Wiley, 2010. [3] http://en.wikipedia.org/wiki/Electrocardiography.

[4] http://en.wikipedia.org/wiki/Adaptive_filter.

[5] http://en.wikipedia.org/wiki/Kernel_adaptive_filter.

[6] http://www.cnel.ufl.edu/~weifeng/publication.htm. [7] http://technical.grasshoppernetwork.com/?q=node/156.

[8] N. V. Thakor, J. G. Webster and W. J. Tompkins, "Applications of adaptive filtering to ECG analysis: noise cancellation and

arrhythmia detection," Biomedical Engineering, IEEE Transaction,

vol. 38, no. 8, pp. 785-794, Aug. 1991.

[9] E. R. Ferrara and B. Widrow, "Fetal electrocardiogram enhancement by timesequenced adaptive filtering," Biomedical

Engineering, IEEE Transactions on, Vols. BME-29, no. 6, pp. 458-

460, June 1982.

[10] B. Widrow, J. Glover and J. McCool, "Adaptive noise canceling: principles and applications," Proceedings of the IEEE,

vol. 63, no. 12, pp. 1692-1716, 1975.

[11] M. Yelderman, B. Widrow, J. Ciotfi, E. Hesler and J. Leddy,

"ECG enhancement by adaptive cancellation of electrosurgical interference," lEEE Trans. Biomcd. Eng,Vols. BME-30, no. 7, pp.

392-398, July 1983.

[12] http://www.physionet.org/physiobank/database/mitdb/100.dat.

[13] http://www.physionet.org/physiobank/database/nstdb. [14] http://en.wikipedia.org/wiki/Mercer%27s_theorem.

[15 J . A. Van Alste and T. S. Schilder. “Removal of baseline

wander and power-line interference from the ECG by an efficient

FIR filter with a reduced number of taps,“IEEE Tram. Biomed. Eng.. vol. BME-32. pp. 1052-1062, 1985.

[16] Mercer, J. (1909), "Functions of positive and negative type and

their connection with the theory of integral equations",

Philosophical Transactions of the Royal Society A 209 (441–458): 415–446.

Pramod R Bokde et al, Int.J.Computer Technology & Applications,Vol 6 (1),51-56

IJCTA | Jan-Feb 2015 Available [email protected]

56

ISSN:2229-6093