ECG Filtering

T-61.181 ² Biomedical Signal Processing Presentation 11.11.2004 Matti Aksela ( (


Very brief introduction to ECG Some common ECG Filtering tasks
Baseline wander filtering  Power line interference filtering  Muscle noise filtering  


A Very brief introduction 

To quote the book:
µHere a general prelude to ECG signal processing and the content of this chapter (3-5 pages) will be included.µ (3- 

Very nice, but let·s take a little more detail for those of us not quite so familiar with the subject...

the ECG (EKG) is a device that measures and records the electrical activity of the heart from electrodes placed on the skin in specific locations .A Brief introduction to ECG   The electrocardiogram (ECG) is a time-varying signal reflecting timethe ionic current flow which causes the cardiac fibers to contract and subsequently relax. The surface ECG is obtained by recording the potential difference between two electrodes placed on the surface of the skin. A single normal cycle of the ECG represents the successive atrial depolarisation/repolarisation and ventricular depolarisation/repolarisation which occurs with every heart beat. Simply put.

valvular and cognitial heart disease Evaluation of ryhthm disorders All in all. monitor progression of the disease Discovery of heart disease. coronal insufficiency as well as myocardial. cardiomyopathies.What the ECG is used for?        Screening test for coronary artery disease. left ventricular hypertrophy Preoperatively to rule out coronary artery disease Can provide information in the precence of metabolic alterations such has hyper/hypo calcemia/kalemia etc. With known heart disease. it is the basic cardiologic test and is widely applied in patients with suspected or known heart disease . infarction.

Measuring ECG  ECG commonly measured via 12 specifically placed leads .

T and U waves .Typical ECG  A typical ECG period consists of P.R.Q.S.

ECG Waves     P wave: the sequential activation (depolarization) of the right and left atria QRS comples: right and left ventricular depolarization T wave: ventricular repolarization U wave: origin not clear. probably µafterdepolarizationsµ in the ventrices .

ECG Example .

to the filter they often pose a large unwanted impulse Possible distortion caused by the filter should be carefully quantified .ECG Filtering  Three common noise sources    Baseline wander Power line interference Muscle noise    When filtering any biomedical signal care should be taken not to alter the desired information in any way A major concern is how the QRS complex influences the output of the filter.

Baseline Wander .

Baseline Wander  Baseline wander. especially when exmining the low-frequency ST-T segment lowSTTwo main approaches used are linear filtering and polynomial fitting . or extragenoeous low-frequency highlowhighbandwidth components. can be caused by:    Perspiration (effects electrode impedance) Respiration Body movements   Can cause problems to analysis.

67 Hz. implying the lowest frequency to be 0. time-invariant filtering time    Basically make a highpass filter to cut of the lower-frequency lowercomponents (the baseline wander) The cut-off frequency should be selected so as to ECG signal cutinformation remains undistorted while as much as possible of the baseline wander is removed. Again as it is not percise.BW ² Linear. hence the lowest-frequency lowestcomponent of the ECG should be saught. This is generally thought to be definded by the slowest heart rate. The heart rate can drop to 40 bpm.5 Hz should be used. a sufficiently lower cutoff frequency of about 0. A filter with linear phase is desirable in order to avoid phase distortion that can alter various temporal realtionships in the cardiac cycle .

however:    not real-time (the backward part. see book for details)  Figure shows leves 400 (dashdot) and 2000 (dashed) and a 5th order forwardforwardbacward filter (solid)  The complexity can be reduced by for example forwardforwardbackward IIR filtering. but the order needed will easily grow very high (approximately 2000. resulting in unstability hard to extend to time-varying cut-offs (will be discussed shortly) timecut- ..) realapplication becomes increasingly difficult at higher sampling rates as poles move closer to the unit circle. This has some drawbacks. Linear phase response can be obtained with finite impulse response..

 Another way of reducing filter complexity is to insert zeroes into a FIR impulse response.  It should be noted. that this resulting multi-stopband filter multican severely distort also diagnostic information in the signal . resulting in a comb filter that attenuates not only the desired baseline wander but also multiples of the original samping rate.

and now a lowpass filter can be used to output an estimate of the baseline wander The estimate is interpolated back to the original sampling rate and subtracted from the original signal .   Yet another way of reducing filter complexity is by first decimating and then again interpolating the signal Decimation removes the high-frequency highcontent.

for example in stress tests. time-variant filtering time  Baseline wander can also be of higher frequency. By noting how the ECG spectrum shifts in frequency when heart rate increases.BW ² Linear. and in such situations using the minimal heart rate for the base can be inefficeient. one may suggest coupling the cutcut-off frequency with the prevailing heart rate instead Schematic example of Baseline noise and the ECG Spectrum at a a) lower heart rate b) higher heart rate .

the RR interval Linear interpolation for interior values  TimeTime-varying cut-off frequency should be inversely proportional cutto the distance between the RR peaks  In practise an upper limit must be set to avoid distortion in very short RR intervals  A single prototype filter can be designed and subjected to simple transformations to yield the other filters . How to represent the µprevailing heart rateµ   A simple but useful way is just to estiamet the length of the interval between R peaks.

often the best choise is the PQ interval A polynomial is fitted so that it passes through every knot in a smooth fashion This type of baseline removal requires the QRS complexes to have been identified and the PQ interval localized .BW ² Polynomial Fitting  One alternative to basline removal is to fit polynomials to representative points in the ECG    Knots selected from a µsilentµ segment.

PQ interval detection is difficult in more noisy conditions  Polynomial fitting can also adapt to the heart rate (as the heart rate increases. a solution can be found Performance is critically dependent on the accuracy of knot detection. but performs poorly when too few knots are available . more knots are available).  HigherHigher-order polynomials can provide a more accurate estimate but at the cost of additional computational complexity A popular approach is the cubic spline estimation technique    thirdthird-order polynomials are fitted to successive sets of triple knots By using the third-order polynomial from the Taylor series thirdand requiring the estimate to pass through the knots and estimating the first derivate linearly.

Baseline Wander Comparsion An comparison of the methods for baseline wander removal at a heart rate of 120 beats per minute a) b) c) d) Original ECG timetime-invariant filtering heart rate dependent filtering cubic spline fitting .

possibly accompanied by some of its harmonics Such noise can cause problems interpreting lowlowamplitude waveforms and spurious waveforms can be introduced.Power Line Interference    Electromagnetic fields from power lines can cause 50/60 Hz sinusoidal interference. but this is not always possible . Naturally precautions should be taken to keep power lines as far as possible or shield and ground them.

but at a radius. The radius then determines the notch bandwith.PLI ² Linear Filtering  A very simple approach to filtering power line interference is to create a filter defined by a complecompleconjugated pair of zeros that lie on the unit circle at the interfering frequency 0    This notch will of course also attenuate ECG waveforms constituted by frequencies close to 0 The filter can be improved by adding a pair of complexcomplexconjugated poles positioned at the same angle as the zeros. Another problem presents. this causes increased transient response time. resulting in a ringing artifact after the transient .

75 and 0. meaning that it is not possible to design a linear time-invariant filter to remove the noise timewithout causing ringing . but with radiuses of 0.95 ‡ ‡ More sophisticated filters can be constructed for. increased frequency resolution is always traded for decreased time resolution.PolePole-zero diagram for two secondsecond-order IIR filters with idential locations of zeros. for example a narrower notch However.

removed by using for example the first difference : e·(n) = e(n) ² e(n-1) e(nNow depending on the sign of e·(n). the value of v(n) is updated by a e·(n). generated by the filter. but that can be x(n).PLI ² Nonlinear Filtering  One possibility is to create a nonlinear filter which buildson the idea of subtracting a sinusoid. negative or positive increment . from the observed signal x(n)    The amplitude of the sinusoid v(n) = sin( 0n) is adapted to the power line interference of the observed signal through the use of an error function e(n) = x(n) ² v(n) The error function is dependent of the DC level of x(n). v*(n) = v(n) + sgn(e·(n)) .

too large a causes extra noise due to the large step alterations Filter convergence: a) pure sinusoid b) output of filter with =1 c) output of filter with =0. the filter poorly tracks changes in the power line interference amplitude. Conversely.2 . y(n) = x(n) ² v*(n) If is too small.  The output signal is obtained by subtracting the interference estimate from the input.

= 10 V .PLI ² Comparison of linear and nonlinear filtering  a) b) c) Comparison of power line interference removal: original signal scondscond-order IIR filter nonlinear filter with transient suppression.

for example to include parts of the P or Q wave. or with some other detection criteria. If the interval is selected poorly. the interference might be overestimated and actually cause an increase in the interference . by the PQ interval.PLI ² Estimation-Subtraction Estimation One can also estimate the amplitude and phase of the interference from an isoelectric sgment. for example. and then subtract the estimated segment from the entire cycle   Bandpass filtering around the interference can be used The location of the segment can be defined.

however at the cost of the increasing oscillatory phenomenon (Gibbs phenomenon)  The estimation-subtraction technique can also work adaptively by estimationcomputing the fitting weights for example using a LMS algorithm and a reference input (possibly from wall outlet)  Weights modified for each time instant to minimize MSE between power line frequency and the observed signal . the stopband becomes increasingly narrow and passband increasingly flat. The sinusoid fitting can be solved by minimizing the mean square error between the observed signal and the sinusoid model  As the fitting interval grows.

but is more difficult since the spectral content of the noise considerably overlaps with that of the PQRST complex However.Muscle Noise Filtering  Muscle noise can cause severe problems as lowlowamplitude waveforms can be obstructed  Especially in recordings during exercise   Muscle noise is not associated with narrow band filtering. ECG is a repetitive signal and thus techniques like ensemle averaging can be used  Successful reduction is restricted to one QRS morphology at a time and requires several beats to become available .

(n)k2 h(k.    Here a width function (n) defined the width of the gaussian. for example Gaussian impulse response. resulting in slowly decaying impulse response. and vice versa. may be used. .MN ² Time-varying lowpass filtering Time A time-varying lowpass filter with variable frequency timeresponse. .n) ~ e The width function is designed to reflect local signal properties such that the smooth segments of the ECG are subjected to considerable filtering whereas the steep slopes (QRS) remains essentially unaltered By making (n) proportional to derivatives of the signal slow changes cause small (n) .

a notable problem is that the methods tend to create artificial waves.   the time-varying lowpass filter examined with baseline timewander the method for power line interference based on trunctated series expansions   However.MN ² Other considerations  Also other already mentioned techniques may be applicable. little or no smoothing in the QRS comples or other serious distortions Muscle noise filtering remains largely an unsolved problem .

is more difficult as it overlaps with actual ECG data For the varying noise types (baseline wander and muscle noise) an adaptive approach seems quite appropriate.  The main problems are the resulting artifacts and how to optimally remove the noise   Muscle noise. the nonlinear approach seems valid as ringing artifacts are almost unavoidable otherwise . on the other hand. For power line interference. if the detection can be done well.Conclusions  Both baseline wander and powerline interference removal are mainly a question of filtering out a narrow band of lower-thanlower-thanECG frequency interference.

in my opinion be. to always take note of why you are doing the filtering.The main thing... The µbestµ way depends on what is most important for the next step of processing ² in many cases preserving the true ECG waveforms can be more important than obtaining a mathematically pleasing µlow errorµ solution. The main idea to take home from this section would. But then again ² doesn·t that apply quite often anyway? .