Baseline Suppression in ECG-signals Lisette Harting Contents • Introduction to the problem – Problem approach • • • • • ECG analysis Common used solutions & ideas Results Conclusions and recommendations Questions contents - introduction - approach - ECG - literature - results - conclusions Introduction to the problem contents - introduction - approach - ECG - literature - results - conclusions Function of the heart • Distribute oxygen and nutrition contents - introduction - approach - ECG - literature - results - conclusions Electrophysiology Pathology • • • • Bad conductance of signal Second pacer also initiates contraction Needs to be destructed: destructor 2 types of operation: – Open chest – Minimal surgery (catheters, ablation) contents - introduction - approach - ECG - literature - results - conclusions Measuring ECG/EG • Where does the ECG origin? – Chest (only) resistive potentials on the skin ~ potentials on heart * factor • Three deductions of ECG contents - introduction - approach - ECG - literature - results - conclusions Measuring ECG/EG • Extremity leads – Einthoven – Goldberger contents - introduction - approach - ECG - literature - results - conclusions Measuring ECG/EG • Precordial leads contents - introduction - approach - ECG - literature - results - conclusions Application • Diagnostic system – Exercise ECG • Operation room system contents - introduction - approach - ECG - literature - results - conclusions channel I channel II 600 800 400 600 400 200 200 0 Baseline drift 0 -200 -200 -400 -400 • In exercise ECG caused by 15 16 17 18 19 20 15 16 channel III 17 18 19 20 19 20 channel VR 400 400 200 0 – Movements of the patient – Breathing – Changing electrode – skin contact 200 0 -200 -400 -200 -400 15 -600 16 17 18 19 20 -800 15 16 17 18 • In operation room merely caused by channel VL channel VF 300 600 200 400 100 0 -100 -200 – Breathing – Ablation 200 0 -200 -300 15 16 17 18 19 20 -400 15 16 17 18 19 20 contents - introduction - approach - ECG - literature - results - conclusions Assignment • Design of baseline drift filter for operation-room ECG – With test-signals for breathing originated baseline drift • Later to be used in exercise ECG and other applications contents - introduction - approach - ECG - literature - results - conclusions Specifications • Input: – Multiple channels (6 to > 12) – Already first order high pass-filtered with cutoff frequency 0.5 Hz or 0.05 Hz contents - introduction - approach - ECG - literature - results - conclusions • Desired output: – Cutoff frequency 0.5 Hz – 0.5 Hz and lower: minimal 6 dB attenuation – Delay maximal 120 ms – Minimize signal to noise ratio – Minimize distortion of signal – Must work real time on a normal computer contents - introduction - approach - ECG - literature - results - conclusions Problem approach contents - introduction - approach - ECG - literature - results - conclusions Work • • • • • Literature study Oscillation filter on synthetic test signal IIR / FIR Analyzed experimental signals Made for-backward filter with heart rate adaptation • Demonstration program contents - introduction - approach - ECG - literature - results - conclusions • To do: – Write report – Optimize chosen filter further – Work out theoretical problem • No time for: – Adaptive filters contents - introduction - approach - ECG - literature - results - conclusions ECG-signal analysis contents - introduction - approach - ECG - literature - results - conclusions I Time domain 400 200 0 -200 -400 II 500 0 -500 0 1 2 III 3 4 500 500 0 0 0 1 2 aVR 3 4 0 1 2 aVF 3 4 0 1 2 V2 3 4 0 1 2 V4 3 4 0 1 2 V6 3 4 0 1 2 3 4 -500 -500 0 1 2 aVL 3 4 400 200 0 -200 500 0 -500 0 1 2 V1 3 4 500 1000 0 0 -500 0 1 2 V3 3 4 -1000 1500 1000 500 0 -500 500 0 -500 0 1 2 V5 3 4 1500 1000 500 0 -500 1500 1000 500 0 -500 0 1 2 3 4 contents - introduction - approach - ECG - literature - results - conclusions 7 2 PSD channel I x 10 2 1 0 2 2 0x 107 1 2 channel III 3 4 2 2 0x 107 1 2 aVL channel 3 4 2 1 2 aVR channel 3 4 0x 107 1 2 aVF channel 3 4 0x 107 1 2 V2 channel 3 4 0x 107 1 2 V4 channel 3 4 0x 107 1 2 V6 channel 3 4 0 1 2 3 4 1 0x 107 1 2 V1 channel 3 4 0 2 1 0x 107 1 2 V3 channel 3 4 0 2 1 0x 107 1 2 V5 channel 3 4 0 2 1 0 0 2 1 0 0x 107 1 1 0 0 2 1 0 channel II 1 1 0 7 x 10 1 0 1 2 3 4 0 contents - introduction - approach - ECG - literature - results - conclusions SNR • Signal to noise ratio (from PSD) – S/N = 10 * 10log(Ps/Pn) • Signal – Heart rate and higher frequencies • Noise – Rest of signal • Compared qualities of the signals from the 19 experiments contents - introduction - approach - ECG - literature - results - conclusions Heartrate • Varied between 25 and 35 • Was detected correctly 100% by the algorithm (to be discussed later) • Not tested with ill patients contents - introduction - approach - ECG - literature - results - conclusions Common solutions contents - introduction - approach - ECG - literature - results - conclusions Filters • Idea behind hp digital filters: – Out = In(delayed) – In(filtered) delay + low pass filter contents - introduction - approach - ECG - literature - results - conclusions Average based filters • Average based filters – Moving average filters (box) – Triangular FIR-filter • With smart size of window to be able to use shifting instead of division after adding • FIR – May be linear phase – But need large calculation power contents - introduction - approach - ECG - literature - results - conclusions Bidirectional filters • Input hardware filter is reversed in time and sampled • Symmetric filter (zero phase shift) • Problem: fixed cutoff frequency contents - introduction - approach - ECG - literature - results - conclusions Incrementally changing filter • Incrementally changing filter for QRScomplex and rest of ECG-signal contents - introduction - approach - ECG - literature - results - conclusions Slew rate limiter • slew rate limiter – Against fast increase of baseline drift (optimize step response) – Limit rising and falling rate of the signal contents - introduction - approach - ECG - literature - results - conclusions Other solutions contents - introduction - approach - ECG - literature - results - conclusions Heart rate detection • Simple algorithm: – Derivative < minimal value count+1 – Derivative > minimal value reset count – If count > limit QRS-complex detected • reset count • pause detection algorithm 100 ms • adjust cutoff frequency filter – Time between 2 complexes = heart rate contents - introduction - approach - ECG - literature - results - conclusions Envelope method • Baseline drift estimation: – envelope around input signal – Estimation is mean of the envelope • Idea: – Use information about ECG phase – to correct for distortion of ECG – based on (measured) phase dependent distortion of a pure ECG-signal contents - introduction - approach - ECG - literature - results - conclusions Adaptive oscillator • Principle: – Suppress ECG-signal (SLR or lp-filter) – After SLR-interval: average is BLDestimation – Use 2 BLD-estimates to predict 3rd (IIR): • d(n) = a(n) * d(n-w) – d(n-2w) – Update ‘a’ • a(n+1) = a(n) + [d_real(n) – d_meas(n)] / d(n-1) contents - introduction - approach - ECG - literature - results - conclusions Cross-Correlation filter • Principle – Do not adapt filters one by one, but use knowledge about other signals • Why? – There is a high correlation between the signals contents - introduction - approach - ECG - literature - results - conclusions Cross-correlation filter • Why not? – Fast (10 s) and high (90%) changes of the correlation between the signals – Low frequencies need a lot of time & memory to calculate correlation – Non-linear relation between signals – Heart rate would need to be filtered out too contents - introduction - approach - ECG - literature - results - conclusions For-backward filtering • Principle – Minimize calculation time • decimation • IIR-filtering – Linearize and increase steepness IIR-filter by filtering also backward contents - introduction - approach - ECG - literature - results - conclusions For-backward filtering • Working: – Prefilter signal with cutoff freq. 10 Hz. – Decimate signal with 50 to 40 Hz. – Filter signal again with cutoff freq. 0.5 Hz. – Interpolate signal – Filter out high frequency components introduced by interpolated signals contents - introduction - approach - ECG - literature - results - conclusions For-backward filtering • Filtering: – IIR – Continuously forward – Backward over window • window > max. delay filter for all frequencies • last filtered sample is filtered value – Apply together with heart rate adaptation contents - introduction - approach - ECG - literature - results - conclusions Which can be tried • • • • Adaptive oscillator FIR IIR For-backward filter + Heart rate adaptive filter • Envelope (but no time) contents - introduction - approach - ECG - literature - results - conclusions Results contents - introduction - approach - ECG - literature - results - conclusions Adaptive oscillator • The adaptive oscillator was not stable • Step-adaptation of parameters -in order to stabilize- deformed the shape of the ECGsignal • Because of fast changes of sinusoid unstable • Non-linear • Does not work when other noise is present contents - introduction - approach - ECG - literature - results - conclusions FIR • Principle – The ideal response of an analogue filter is truncated – Length: half (180 degrees) cutoff frequency • 0.5 Hz: 1 sec; 0.05 Hz: 10 sec. • It is the standard solution • But delay >= 1 second contents - introduction - approach - ECG - literature - results - conclusions Moving average (2000 points) ECG-signal 600 400 200 0 -200 0 2 4 6 8 moving avarage ECG-signal 10 12 14 0 2 4 6 8 ECG-signal moving avarage filter 10 12 14 0 2 4 10 12 14 100 50 0 -50 -100 600 400 200 0 -200 6 8 contents - introduction - approach - ECG - literature - results - conclusions Chebyshev ECG-signal 600 400 200 0 -200 6 6.5 7 7.5 8.5from ECG-signal 9 reference box-car filtered signal8 substracted 9.5 10 6 6.5chebwin-filtered 7 signal (window 7.5 8 8.5 phase shift 9 correction9.5 1000 samples) without 10 6 6.5 chebwin-filtered 7 8.5 phase shift9correction 9.5 signal 7.5 (window 10008samples) with 10 6 6.5 10 600 400 200 0 -200 600 400 200 0 -200 600 400 200 0 -200 7 7.5 8 8.5 9 9.5 (1000-points; 10dB sidelobe-supression) contents - introduction - approach - ECG - literature - results - conclusions IIR • IIR – Fast (minimal one sample) • But – phase shift causes • Distortion of ECG-signal • The same delay of the signal contents - introduction - approach - ECG - literature - results - conclusions raw ECG-signal Time-domain forward prefiltered ECG-data 400 400 200 200 0 0 15 15.5 16 16.5 17 17.5 18 15 15.5 for- and backward prefiltered and decimated signal 400 400 200 200 0 0 15 15.5 16 16.5 17 17.5 18 15 15.5 for- and backward low-pass filtered signal, interpolated 400 200 200 0 0 15.5 16 16.5 17 17.5 18 15 final low-pass filtered signal 400 200 200 0 0 15.5 16 16.5 17 17 17.5 18 16 16.5 17 17.5 18 15.5 16 16.5 17 17.5 18 filtered signal (raw ECG-signal minus shifted low-pass filtered signal 400 15 16.5 forward interpolation filtered signal 400 15 16 forward low-pass filtered signal 17.5 18 15 15.5 16 16.5 17 17.5 18 contents - introduction - approach - ECG - literature - results - conclusions raw ECG-signal forward prefiltered ECG-data 600 600 400 400 200 200 0 0 -200 -200 -400 15 15.5 16 16.5 17 17.5 18 for- and backward prefiltered and decimated signal 600 -400 15 400 200 200 0 0 -200 -200 -400 15 15.5 16 16.5 17 17.5 18 for- and backward low-pass filtered signal, interpolated 600 -400 15 400 200 200 0 0 -200 -200 18 600 400 200 200 0 0 -200 -200 15.5 16 16.5 17 17.5 18 18 -400 15 15.5 16 16.5 17 17.5 18 filtered signal (raw ECG-signal minus shifted low-pass filtered signal 600 400 -400 15 15.5 16 16.5 17 17.5 forward interpolation filtered signal 600 400 15.5 16 16.5 17 17.5 final low-pass filtered signal 18 600 400 -400 15 15.5 16 16.5 17 17.5 forward low-pass filtered signal -400 15 15.5 16 16.5 17 17.5 18 contents - introduction - approach - ECG - literature - results - conclusions Frequency domain raw ECG-signal forward prefiltered ECG-data 120 120 100 100 80 80 60 60 40 40 20 20 0 2 4 6 8 10 0 2 for- and backward prefiltered and decimated signal 120 120 100 100 80 80 60 60 40 40 20 20 0 2 4 6 8 10 0 2 for- and backward low-pass filtered signal, interpolated 120 100 100 80 80 60 60 40 40 20 20 2 4 6 8 10 0 final low-pass filtered signal 120 100 100 80 80 60 60 40 40 20 20 2 4 6 8 10 4 6 8 10 2 4 6 8 10 filtered signal (raw ECG-signal minus shifted low-pass filtered signal 120 0 6 forward interpolation filtered signal 120 0 4 forward low-pass filtered signal 8 10 0 2 4 6 8 10 contents - introduction - approach - ECG - literature - results - conclusions raw ECG-signal forward prefiltered ECG-data 150 150 100 100 50 50 0 2 4 6 8 10 0 2 for- and backward prefiltered and decimated signal 150 150 100 100 50 50 0 2 4 6 8 10 0 2 for- and backward low-pass filtered signal, interpolated 150 100 100 50 50 2 4 6 8 10 0 final low-pass filtered signal 150 100 100 50 50 2 4 6 8 10 4 6 8 10 2 4 6 8 10 filtered signal (raw ECG-signal minus shifted low-pass filtered signal 150 0 6 forward interpolation filtered signal 150 0 4 forward low-pass filtered signal 8 10 0 2 4 6 8 10 contents - introduction - approach - ECG - literature - results - conclusions 0 Filters Magnitude (dB) -1 -2 -3 -4 -5 0 5 10 15 20 25 30 Frequency (Hz) 35 40 45 50 0 5 10 15 20 25 30 Frequency (Hz) 35 40 45 50 0 Phase (degrees) -10 -20 -30 -40 -50 -60 -70 Prefilter before decimation contents - introduction - approach - ECG - literature - results - conclusions 0 -20 Magnitude (dB) -40 -60 -80 -100 -120 0 5 10 15 20 25 15 20 25 Frequency (Hz) 0 -10 Phase (degrees) -20 -30 -40 -50 -60 -70 -80 -90 0 5 10 Frequency (Hz) Heart rate filter contents - introduction - approach - ECG - literature - results - conclusions SNR • SNR-improvement is quite high • But for signals with little noise, the SNR improvement can be negative Distorsion contents - introduction - approach - ECG - literature - results - conclusions Step response raw ECG-signal forward prefiltered ECG-data 1 1 0.5 0.5 0 0 -0.5 -0.5 0 1 2 3 4 5 6 7 0 1 2 for- and backward prefiltered and decimated signal 3 4 5 6 7 6 7 6 7 forward low-pass filtered signal 1 1 0.5 0.5 0 0 -0.5 -0.5 0 1 2 3 4 5 6 7 0 1 for- and backward low-pass filtered signal, interpolated 2 3 4 5 forward interpolation filtered signal 1 1 0.5 0.5 0 0 -0.5 -0.5 0 1 2 3 4 5 6 7 0 final low-pass filtered signal 1 2 3 4 5 filtered signal (raw ECG-signal minus shifted low-pass filtered signal 1 1 0.5 0.5 0 0 -0.5 -0.5 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 contents - introduction - approach - ECG - literature - results - conclusions Calculation power • Depend on • • • • window width (‘win’) decimation factor (‘dec’) Decimation filter forward: 1 backward: 1 Filter forward: 1/dec backward: win/dec Interpolation forward 1 backward dec TOTAL = 3 + (win + dec + 1)/dec contents - introduction - approach - ECG - literature - results - conclusions Delay (samples) • Decimation filter forward: 1 backward: dec • Filter forward: dec backward: dec*win • Zero order interpolation 0.5 * dec • Interpolation forward 1 backward dec • TOTAL = 2 + (win + 3.5)*dec (samples) contents - introduction - approach - ECG - literature - results - conclusions • TOTAL = 2 + (win + 3.5)*dec (samples) • Optimal: – win = 13 (minimal) – dec = 40 • This makes total: – (2 + 16.5*40) / 2000 = 662 / 2000 = 0.331 sec. contents - introduction - approach - ECG - literature - results - conclusions Demonstration • ..\Program contents - introduction - approach - ECG - literature - results - conclusions Demonstration contents - introduction - approach - ECG - literature - results - conclusions Conclusions and recommendations contents - introduction - approach - ECG - literature - results - conclusions Conclusions • Heart rhythm adaptation works good, in this case • Heart rate filter is working, but needs to be improved contents - introduction - approach - ECG - literature - results - conclusions Recommendations • The heart-rate filter should be tested on more data: • Does the simple heart rate detection system work – in all situations? – on all patients? • It needs to be improved for e.g. systoles en PVC’s contents - introduction - approach - ECG - literature - results - conclusions • Automatically calculate minimal windowwidth • Introduce 2 delay-modes • Optimize parameters • Quantize distortion • Use only analogue low-pass filter • Try other bidirectional filters (same as our filter) contents - introduction - approach - ECG - literature - results - conclusions Questions!