aksela (1).ppt_0

download aksela (1).ppt_0

of 34

Transcript of aksela (1).ppt_0

  • 8/3/2019 aksela (1).ppt_0

    1/34

    ECG FilteringECG Filtering

    T-61.181T-61.181 Biomedical Signal Processing Biomedical Signal Processing

    Presentation 11.11.2004Presentation 11.11.2004

    Matti Aksela (Matti Aksela ([email protected]@hut.fi))

    mailto:[email protected]:[email protected]:[email protected]
  • 8/3/2019 aksela (1).ppt_0

    2/34

    ContentsContents

    Very brief introduction to ECGVery brief introduction to ECG

    Some common ECG Filtering tasksSome common ECG Filtering tasks

    Baseline wander filteringBaseline wander filtering Power line interference filteringPower line interference filtering

    Muscle noise filteringMuscle noise filtering

    SummarySummary

  • 8/3/2019 aksela (1).ppt_0

    3/34

    A Very brief introductionA Very brief introduction

    To quote the book:To quote the book:

    Here a general prelude to ECG signalHere a general prelude to ECG signalprocessing and the content of thisprocessing and the content of this

    chapter (3-5 pages) will be included.chapter (3-5 pages) will be included.

    Very nice, but lets take a little moreVery nice, but lets take a little more

    detail for those of us not quite sodetail for those of us not quite so

    familiar with the subject...familiar with the subject...

  • 8/3/2019 aksela (1).ppt_0

    4/34

    A Brief introduction toA Brief introduction to

    ECGECG The electrocardiogram (ECG) is a time-varyingThe electrocardiogram (ECG) is a time-varying

    signal reflecting the ionic current flow whichsignal reflecting the ionic current flow whichcauses the cardiac fibers to contract andcauses the cardiac fibers to contract andsubsequently relax. The surface ECG is obtainedsubsequently relax. The surface ECG is obtained

    by recording the potential difference between twoby recording the potential difference between twoelectrodes placed on the surface of the skin. Aelectrodes placed on the surface of the skin. Asingle normal cycle of the ECG represents thesingle normal cycle of the ECG represents thesuccessive atrial depolarisation/repolarisation andsuccessive atrial depolarisation/repolarisation andventricular depolarisation/repolarisation whichventricular depolarisation/repolarisation which

    occurs with every heart beat.occurs with every heart beat. Simply put, the ECG (EKG) is a device thatSimply put, the ECG (EKG) is a device that

    measures and records the electrical activity ofmeasures and records the electrical activity ofthe heart from electrodes placed on the skin inthe heart from electrodes placed on the skin inspecific locationsspecific locations

  • 8/3/2019 aksela (1).ppt_0

    5/34

    What the ECG is usedWhat the ECG is used

    for?for? Screening test for coronary artery disease,Screening test for coronary artery disease,

    cardiomyopathies, left ventricular hypertrophycardiomyopathies, left ventricular hypertrophy Preoperatively to rule out coronary artery diseasePreoperatively to rule out coronary artery disease Can provide information in the precence ofCan provide information in the precence of

    metabolic alterations such has hyper/hypometabolic alterations such has hyper/hypocalcemia/kalemia etc.calcemia/kalemia etc.

    With known heart disease, monitor progression ofWith known heart disease, monitor progression ofthe diseasethe disease

    Discovery of heart disease; infarction, coronalDiscovery of heart disease; infarction, coronalinsufficiency as well as myocardial, valvular andinsufficiency as well as myocardial, valvular andcognitial heart diseasecognitial heart disease

    Evaluation of ryhthm disordersEvaluation of ryhthm disorders All in all, it is the basic cardiologic test and isAll in all, it is the basic cardiologic test and is

    widely applied in patients with suspected orwidely applied in patients with suspected or

  • 8/3/2019 aksela (1).ppt_0

    6/34

    Measuring ECGMeasuring ECG

    ECG commonly measured via 12ECG commonly measured via 12

    specifically placed leadsspecifically placed leads

  • 8/3/2019 aksela (1).ppt_0

    7/34

    Typical ECGTypical ECG

    A typical ECG period consists of P,Q,R,S,TA typical ECG period consists of P,Q,R,S,T

    and U wavesand U waves

  • 8/3/2019 aksela (1).ppt_0

    8/34

    ECG WavesECG Waves

    P wave: theP wave: thesequential activationsequential activation(depolarization) of(depolarization) ofthe right and leftthe right and left

    atriaatria QRS comples: rightQRS comples: right

    and left ventricularand left ventriculardepolarizationdepolarization

    T wave: ventricularT wave: ventricularrepolarizationrepolarization

    U wave: origin notU wave: origin notclear, probablyclear, probablyafterdepolarizationsafterdepolarizations

    in the ventrices in the ventrices

  • 8/3/2019 aksela (1).ppt_0

    9/34

    ECG ExampleECG Example

  • 8/3/2019 aksela (1).ppt_0

    10/34

    ECG FilteringECG Filtering

    Three common noise sourcesThree common noise sources Baseline wanderBaseline wander Power line interferencePower line interference Muscle noiseMuscle noise

    When filtering any biomedical signal careWhen filtering any biomedical signal careshould be taken not to alter the desiredshould be taken not to alter the desiredinformation in any wayinformation in any way

    A major concern is how the QRS complexA major concern is how the QRS complex

    influences the output of the filter; to theinfluences the output of the filter; to thefilter they often pose a large unwantedfilter they often pose a large unwantedimpulseimpulse

    Possible distortion caused by the filterPossible distortion caused by the filter

    should be carefully quantifiedshould be carefully quantified

  • 8/3/2019 aksela (1).ppt_0

    11/34

    Baseline WanderBaseline Wander

  • 8/3/2019 aksela (1).ppt_0

    12/34

    Baseline WanderBaseline Wander

    Baseline wander, or extragenoeous low-Baseline wander, or extragenoeous low-

    frequency high-bandwidth components,frequency high-bandwidth components,

    can be caused by:can be caused by:

    Perspiration (effects electrode impedance)Perspiration (effects electrode impedance) RespirationRespiration

    Body movementsBody movements

    Can cause problems to analysis, especiallyCan cause problems to analysis, especially

    when exmining the low-frequency ST-Twhen exmining the low-frequency ST-T

    segmentsegment

    Two main approaches used are linearTwo main approaches used are linear

    filtering and polynomial fittingfiltering and polynomial fitting

  • 8/3/2019 aksela (1).ppt_0

    13/34

    BW Linear, time-invariantBW Linear, time-invariant

    filteringfiltering Basically make a highpass filter to cut of theBasically make a highpass filter to cut of the

    lower-frequency components (the baselinelower-frequency components (the baselinewander)wander)

    The cut-off frequency should be selected so as toThe cut-off frequency should be selected so as to

    ECG signal information remains undistorted whileECG signal information remains undistorted whileas much as possible of the baseline wander isas much as possible of the baseline wander isremoved; hence the lowest-frequency componentremoved; hence the lowest-frequency componentof the ECG should be saught.of the ECG should be saught.

    This is generally thought to be definded by theThis is generally thought to be definded by the

    slowest heart rate. The heart rate can drop to 40slowest heart rate. The heart rate can drop to 40bpm, implying the lowest frequency to be 0.67bpm, implying the lowest frequency to be 0.67Hz. Again as it is not percise, a sufficiently lowerHz. Again as it is not percise, a sufficiently lowercutoff frequency of about 0.5 Hz should be used.cutoff frequency of about 0.5 Hz should be used.

    A filter with linear phase is desirable in order toA filter with linear phase is desirable in order toavoid phase distortion that can alter variousavoid phase distortion that can alter various

  • 8/3/2019 aksela (1).ppt_0

    14/34

    Linear phaseLinear phaseresponse can beresponse can be

    obtained with finiteobtained with finiteimpulse response,impulse response,but the order neededbut the order neededwill easily grow verywill easily grow veryhigh (approximatelyhigh (approximately

    2000, see book for2000, see book fordetails)details) Figure shows levesFigure shows leves

    400 (dashdot) and400 (dashdot) and2000 (dashed) and a2000 (dashed) and a

    5th order forward-5th order forward-bacward filter (solid)bacward filter (solid)

    The complexity can be reduced by for exampleThe complexity can be reduced by for example

    forward-backward IIR filtering. This has someforward-backward IIR filtering. This has somedrawbacks, however:drawbacks, however: not real-time (the backward part...)not real-time (the backward part...) application becomes increasingly difficult at higherapplication becomes increasingly difficult at higher

    sampling rates as poles move closer to the unit circle,sampling rates as poles move closer to the unit circle,

    resulting in unstabilityresulting in unstability hard to extend to time-var in cut-offs will behard to extend to time-var in cut-offs will be

  • 8/3/2019 aksela (1).ppt_0

    15/34

    Another way of reducing filter complexityAnother way of reducing filter complexity

    is to insert zeroes into a FIR impulseis to insert zeroes into a FIR impulse

    response, resulting in a comb filter thatresponse, resulting in a comb filter thatattenuates not only the desired baselineattenuates not only the desired baseline

    wander but also multiples of the originalwander but also multiples of the original

    samping rate.samping rate. It should be noted, that this resulting multi-It should be noted, that this resulting multi-

    stopband filter can severely distort alsostopband filter can severely distort also

    diagnostic information in the signaldiagnostic information in the signal

  • 8/3/2019 aksela (1).ppt_0

    16/34

    Yet another way of reducing filterYet another way of reducing filtercomplexity is by first decimating andcomplexity is by first decimating andthen again interpolating the signalthen again interpolating the signal

    Decimation removes the high-Decimation removes the high-frequency content, and now afrequency content, and now a

    lowpass filter can be used to outputlowpass filter can be used to outputan estimate of the baseline wanderan estimate of the baseline wander

    The estimate is interpolated back toThe estimate is interpolated back tothe original sampling rate andthe original sampling rate andsubtracted from the original signalsubtracted from the original signal

  • 8/3/2019 aksela (1).ppt_0

    17/34

    BW Linear, time-variantBW Linear, time-variant

    filteringfiltering Baseline wander can also be of higherBaseline wander can also be of higher

    frequency, for example in stress tests, andfrequency, for example in stress tests, andin such situations using the minimal heartin such situations using the minimal heartrate for the base can be inefficeient.rate for the base can be inefficeient.

    By noting how the ECG spectrum shifts inBy noting how the ECG spectrum shifts infrequency when heart rate increases, onefrequency when heart rate increases, onemay suggest coupling the cut-offmay suggest coupling the cut-offfrequency with the prevailing heart ratefrequency with the prevailing heart rateinsteadinstead SchematicSchematic

    example ofexample of

    BaselineBaseline

    noise andnoise and

    the ECGthe ECG

  • 8/3/2019 aksela (1).ppt_0

    18/34

    Time-varying cut-off frequency should beTime-varying cut-off frequency should beinversely proportional to the distance betweeninversely proportional to the distance betweenthe RR peaksthe RR peaks In practise an upper limit must be set to avoid distortionIn practise an upper limit must be set to avoid distortion

    in very short RR intervalsin very short RR intervals

    A single prototype filter can be designed andA single prototype filter can be designed andsubjected to simple transformations to yield thesubjected to simple transformations to yield theother filtersother filters

    How to represent theHow to represent theprevailing heart rateprevailing heart rate

    A simple betweenbut usefulA simple betweenbut useful

    way is just to estiamet theway is just to estiamet the

    length of the interval R peaks,length of the interval R peaks,

    the RR intervalthe RR interval Linear interpolation forLinear interpolation for

    interior valuesinterior values

  • 8/3/2019 aksela (1).ppt_0

    19/34

    BW Polynomial FittingBW Polynomial Fitting

    One alternative to basline removal is to fitOne alternative to basline removal is to fit

    polynomials to representative points in the ECGpolynomials to representative points in the ECG

    Knots selected from aKnots selected from a

    silent segment, oftensilent segment, often

    the best choise is thethe best choise is thePQ intervalPQ interval

    A polynomial is fitted soA polynomial is fitted so

    that it passes throughthat it passes through

    every knot in a smoothevery knot in a smooth

    fashionfashion This type of baselineThis type of baseline

    removal requires theremoval requires the

    QRS complexes to haveQRS complexes to have

    been identified and thebeen identified and the

    PQ interval localizedPQ interval localized

  • 8/3/2019 aksela (1).ppt_0

    20/34

    Higher-order polynomials can provide aHigher-order polynomials can provide amore accurate estimate but at the cost ofmore accurate estimate but at the cost ofadditional computational complexityadditional computational complexity

    A popular approach is the cubic splineA popular approach is the cubic splineestimation techniqueestimation technique third-order polynomials are fitted to successivethird-order polynomials are fitted to successive

    sets of triple knotssets of triple knots

    By using the third-order polynomial from theBy using the third-order polynomial from theTaylor series and requiring the estimate to passTaylor series and requiring the estimate to passthrough the knots and estimating the firstthrough the knots and estimating the firstderivate linearly, a solution can be foundderivate linearly, a solution can be found

    Performance is critically dependent on thePerformance is critically dependent on the

    accuracy of knot detection, PQ intervalaccuracy of knot detection, PQ intervaldetection is difficult in more noisy conditionsdetection is difficult in more noisy conditions Polynomial fitting can also adapt to thePolynomial fitting can also adapt to the

    heart rate (as the heart rate increases,heart rate (as the heart rate increases,more knots are available), but performsmore knots are available), but performs

    poorly when too few knots are availablepoorly when too few knots are available

  • 8/3/2019 aksela (1).ppt_0

    21/34

    Baseline WanderBaseline Wander

    ComparsionComparsion

    a)a) Original ECGOriginal ECG

    b)b) time-invarianttime-invariant

    filteringfiltering

    c)c) heart rateheart rate

    dependentdependentfilteringfiltering

    d)d) cubic splinecubic spline

    fittingfitting

    An comparison of the methods forAn comparison of the methods forbaseline wander removal at a heart ratebaseline wander removal at a heart rate

    of 120 beats per minuteof 120 beats per minute

  • 8/3/2019 aksela (1).ppt_0

    22/34

    Power Line InterferencePower Line Interference

    Electromagnetic fields from powerElectromagnetic fields from powerlines can cause 50/60 Hz sinusoidallines can cause 50/60 Hz sinusoidalinterference, possibly accompaniedinterference, possibly accompanied

    by some of its harmonicsby some of its harmonics Such noise can cause problemsSuch noise can cause problems

    interpreting low-amplitudeinterpreting low-amplitudewaveforms and spurious waveformswaveforms and spurious waveformscan be introduced.can be introduced.

    Naturally precautions should beNaturally precautions should betaken to keep power lines as far astaken to keep power lines as far as

    possible or shield and ground them,possible or shield and ground them,

  • 8/3/2019 aksela (1).ppt_0

    23/34

    PLI Linear FilteringPLI Linear Filtering

    A very simple approach to filtering powerA very simple approach to filtering powerline interference is to create a filterline interference is to create a filterdefined by a comple-conjugated pair ofdefined by a comple-conjugated pair ofzeros that lie on the unit circle at thezeros that lie on the unit circle at theinterfering frequencyinterfering frequency 00 This notch will of course also attenuate ECGThis notch will of course also attenuate ECG

    waveforms constituted by frequencies close towaveforms constituted by frequencies close to00

    The filter can be improved by adding a pair ofThe filter can be improved by adding a pair ofcomplex-conjugated poles positioned at thecomplex-conjugated poles positioned at thesame angle as the zeros, but at a radius. Thesame angle as the zeros, but at a radius. Theradius then determines the notch bandwith.radius then determines the notch bandwith.

    Another problem presents; this causesAnother problem presents; this causesincreased transient res onse time, resultin inincreased transient response time, resulting in

  • 8/3/2019 aksela (1).ppt_0

    24/34

    More sophisticated filters can be constructedMore sophisticated filters can be constructed

    for, for example a narrower notchfor, for example a narrower notch

    However, increased frequency resolution isHowever, increased frequency resolution isalways traded for decreased time resolution,always traded for decreased time resolution,

    meaning that it is not possible to design ameaning that it is not possible to design a

    linear time-invariant filter to remove the noiselinear time-invariant filter to remove the noise

    without causing ringingwithout causing ringing

    Pole-zero diagram forPole-zero diagram for

    two second-order IIRtwo second-order IIR

    filters with identialfilters with idential

    locations of zeros, butlocations of zeros, butwith radiuses of 0.75with radiuses of 0.75

    and 0.95and 0.95

  • 8/3/2019 aksela (1).ppt_0

    25/34

    PLI Nonlinear FilteringPLI Nonlinear Filtering

    One possibility is to create a nonlinear filter whichOne possibility is to create a nonlinear filter which

    buildson the idea of subtracting a sinusoid,buildson the idea of subtracting a sinusoid,

    generated by the filter, from the observed signalgenerated by the filter, from the observed signal

    x(n)x(n) The amplitude of the sinusoidThe amplitude of the sinusoid v(n) = sin(v(n) = sin(00n)n) isis

    adapted to the power line interference of the observedadapted to the power line interference of the observed

    signal through the use of an error functionsignal through the use of an error function e(n) = x(n) e(n) = x(n)

    v(n)v(n) The error function is dependent of the DC level ofThe error function is dependent of the DC level ofx(n)x(n),,

    but that can be removed by using for example the firstbut that can be removed by using for example the first

    difference :difference :

    e(n) = e(n) e(n-1)e(n) = e(n) e(n-1)

    Now depending on the sign ofNow depending on the sign ofe(n)e(n), the value of, the value ofv(n)v(n)isis

    updated by a negative or positive incrementupdated by a negative or positive increment ,,

    v*(n) = v(n) +v*(n) = v(n) + sgn(e(n))sgn(e(n))

  • 8/3/2019 aksela (1).ppt_0

    26/34

    The output signal is obtained byThe output signal is obtained by

    subtracting the interference estimate fromsubtracting the interference estimate from

    the input,the input,y(n) = x(n) v*(n)y(n) = x(n) v*(n)

    IfIf is too small, the filter poorly tracksis too small, the filter poorly tracks

    changes in the power line interferencechanges in the power line interference

    amplitude. Conversely, too large aamplitude. Conversely, too large a causes extra noise due to the large stepcauses extra noise due to the large step

    alterationsalterationsFilter

    convergence:

    a)puresinusoid

    b)output of

  • 8/3/2019 aksela (1).ppt_0

    27/34

    PLI Comparison of linearPLI Comparison of linear

    and nonlinear filteringand nonlinear filtering

    Comparison ofComparison of

    power linepower line

    interferenceinterference

    removal:removal:

    a)a) original signaloriginal signal

    b)b) scond-order IIRscond-order IIRfilterfilter

    c)c) nonlinear filternonlinear filter

    with transientwith transient

    su ression,suppression, =

  • 8/3/2019 aksela (1).ppt_0

    28/34

    PLI Estimation-PLI Estimation-

    SubtractionSubtraction One can also estimate the amplitude andOne can also estimate the amplitude and

    phase of the interference from anphase of the interference from anisoelectric sgment, and then subtract theisoelectric sgment, and then subtract theestimated segment from the entire cycleestimated segment from the entire cycle Bandpass filtering around the interference canBandpass filtering around the interference can

    be usedbe used

    The location of the segmentThe location of the segmentcan be defined, forcan be defined, forexample, by the PQexample, by the PQinterval, or with some otherinterval, or with some other

    detection criteria. If thedetection criteria. If theinterval is selected poorly,interval is selected poorly,for example to include partsfor example to include partsof the P or Q wave, theof the P or Q wave, theinterference might beinterference might be

    overestimated and actuallyoverestimated and actuallycause an increase in thecause an increase in the

  • 8/3/2019 aksela (1).ppt_0

    29/34

    The sinusoid fitting can be solved by minimizingThe sinusoid fitting can be solved by minimizing

    the mean square error between the observedthe mean square error between the observed

    signal and the sinusoid modelsignal and the sinusoid model

    The estimation-subtraction technique can alsoThe estimation-subtraction technique can also

    work adaptively by computing the fitting weightswork adaptively by computing the fitting weights

    for example using a LMS algorithm and afor example using a LMS algorithm and a

    reference input (possibly from wall outlet)reference input (possibly from wall outlet)

    As the fittingAs the fittinginterval grows, theinterval grows, the

    stopband becomesstopband becomes

    increasingly narrowincreasingly narrow

    and passbandand passband

    increasingly flat,increasingly flat,

    however at the costhowever at the cost

    of the increasingof the increasing

    oscillatoryoscillatory

    phenomenon (Gibbsphenomenon (Gibbs

    phenomenon)phenomenon)

  • 8/3/2019 aksela (1).ppt_0

    30/34

    Muscle Noise FilteringMuscle Noise Filtering

    Muscle noise can cause severe problemsMuscle noise can cause severe problemsas low-amplitude waveforms can beas low-amplitude waveforms can beobstructedobstructed Especially in recordings during exerciseEspecially in recordings during exercise

    Muscle noise is not associated with narrowMuscle noise is not associated with narrowband filtering, but is more difficult sinceband filtering, but is more difficult sincethe spectral content of the noisethe spectral content of the noiseconsiderably overlaps with that of theconsiderably overlaps with that of thePQRST complexPQRST complex

    However, ECG is a repetitive signal andHowever, ECG is a repetitive signal andthus techniques like ensemle averagingthus techniques like ensemle averagingcan be usedcan be used Successful reduction is restricted to one QRSSuccessful reduction is restricted to one QRS

  • 8/3/2019 aksela (1).ppt_0

    31/34

    MN Time-varying lowpassMN Time-varying lowpass

    filteringfiltering A time-varying lowpass filter with variableA time-varying lowpass filter with variable

    frequency response, for example Gaussianfrequency response, for example Gaussianimpulse response, may be used.impulse response, may be used. Here a width functionHere a width function(n)(n) defined the width ofdefined the width of

    the gaussian,the gaussian,

    h(k,n) ~ eh(k,n) ~ e--(n)k(n)k22

    The width function is designed to reflect localThe width function is designed to reflect localsignal properties such that the smoothsignal properties such that the smooth

    segments of the ECG are subjected tosegments of the ECG are subjected toconsiderable filtering whereas the steep slopesconsiderable filtering whereas the steep slopes(QRS) remains essentially unaltered(QRS) remains essentially unaltered

    By makingBy making(n)(n) proportional to derivatives ofproportional to derivatives ofthe signal slow changes cause smallthe signal slow changes cause small(n)(n) ,,resulting in slowly decaying impulse response,resulting in slowly decaying impulse response,

  • 8/3/2019 aksela (1).ppt_0

    32/34

    MN OtherMN Other

    considerationsconsiderations Also other already mentioned techniquesAlso other already mentioned techniques

    may be applicable;may be applicable; the time-varying lowpass filter examined withthe time-varying lowpass filter examined with

    baseline wanderbaseline wander the method for power line interference basedthe method for power line interference based

    on trunctated series expansionson trunctated series expansions

    However, a notable problem is that theHowever, a notable problem is that themethods tend to create artificial waves,methods tend to create artificial waves,

    little or no smoothing in the QRS compleslittle or no smoothing in the QRS complesor other serious distortionsor other serious distortions

    Muscle noise filtering remains largely anMuscle noise filtering remains largely anunsolved problemunsolved problem

  • 8/3/2019 aksela (1).ppt_0

    33/34

    ConclusionsConclusions

    Both baseline wander and powerline interferenceBoth baseline wander and powerline interferenceremoval are mainly a question of filtering out aremoval are mainly a question of filtering out anarrow band of lower-than-ECG frequencynarrow band of lower-than-ECG frequencyinterference.interference.

    The main problems are the resulting artifacts and how toThe main problems are the resulting artifacts and how tooptimally remove the noiseoptimally remove the noise

    Muscle noise, on the other hand, is more difficultMuscle noise, on the other hand, is more difficultas it overlaps with actual ECG dataas it overlaps with actual ECG data

    For the varying noise types (baseline wander andFor the varying noise types (baseline wander and

    muscle noise) an adaptive approach seems quitemuscle noise) an adaptive approach seems quiteappropriate, if the detection can be done well. Forappropriate, if the detection can be done well. Forpower line interference, the nonlinear approachpower line interference, the nonlinear approachseems valid as ringing artifacts are almostseems valid as ringing artifacts are almostunavoidable otherwiseunavoidable otherwise

  • 8/3/2019 aksela (1).ppt_0

    34/34

    The main thing...The main thing...

    The main idea to take home from thisThe main idea to take home from this

    section would, in my opinion be, tosection would, in my opinion be, to

    always take note of why you arealways take note of why you are

    doing the filtering. The best waydoing the filtering. The best waydepends on what is most importantdepends on what is most important

    for the next step of processing infor the next step of processing in

    many cases preserving the true ECGmany cases preserving the true ECGwaveforms can be more importantwaveforms can be more important

    than obtaining a mathematicallythan obtaining a mathematically

    pleasing lo error solution Butpleasing lo error solution But