removing 60 hz from ekg signal william rose, may 2009

15
Removing 60 Hz from EKG signal William Rose, May 2009 •Original EKG signal looked good on paient monitor but had very small amplitude (+- 4 bits) at the A-to-D board, due to partial short in connecting cable (discovered later). •Problem was not recognized at the time because EKG recorded by A-to-D board was not displayed. •Now EKG recorded on computer is displayed in real time, so that in the future a similar problem will likely be noticed and corrected.

Upload: tariq

Post on 06-Feb-2016

52 views

Category:

Documents


0 download

DESCRIPTION

Removing 60 Hz from EKG signal William Rose, May 2009 Original EKG signal looked good on paient monitor but had very small amplitude (+- 4 bits) at the A-to-D board, due to partial short in connecting cable (discovered later). - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Removing 60 Hz from EKG signal William Rose, May 2009

Removing 60 Hz from EKG signal

William Rose, May 2009

•Original EKG signal looked good on paient monitor but had very small amplitude (+- 4 bits) at the A-to-D board, due to partial short in connecting cable (discovered later).

•Problem was not recognized at the time because EKG recorded by A-to-D board was not displayed.

•Now EKG recorded on computer is displayed in real time, so that in the future a similar problem will likely be noticed and corrected.

Page 2: Removing 60 Hz from EKG signal William Rose, May 2009

bandstopfilt.vi, 20081111aecg_10sec.txt

EKG for 10 sec, unfiltered.

Noise is large compared to the R waves, preventing triggering.

EKG for 0.5 sec, unfiltered.

Notice periodic signal and level quantization due to small amplitude.

Page 3: Removing 60 Hz from EKG signal William Rose, May 2009

•Presence of a distinct frequency in the data suggests that a band stop (notch) filter may be useful.

•Band stop filters characterized by

Center frequency (Hz)

Bandwidth (Hz) (half width)

Number of poles

•Labview and Matlab filter functions want high and low frequencies instead of center frequency and half width.

Page 4: Removing 60 Hz from EKG signal William Rose, May 2009

bandstopfilt.vi

Most code inside a while loop.

Before entering loop: Get file name, read in data, get sampling rate.

Inside the loop, program continually re-filters, re-plots, and checks to see if fco, fhalfwidth, or number of poles have changed.

When while loop is done, program writes data to a file if requested.

Filtering

Butterworth Coefficients.viCascade to Direct Coefficients.viZero Phase Filter.vi

Instead of

(Butterworth Filter.vi, Reverse 1D Array.vi) two times

Page 5: Removing 60 Hz from EKG signal William Rose, May 2009

bandstopfilt.viButterworth Coefficients.vi gives filter coefficients in cascade form (2nd order sections for low- and high-pass filters; 4th order sections for band pass and band stop filters). High order filters generally perform better if implemented in cascade form than if implemented in direct form, because they are less sensitive to quantization errors in the coefficients. However, Zero Phase Filter.vi needs direct form. Direct form looks like this:

Yk = b0 Xk + b1 Xk-1 + b2 Xk-2 + b3 Xk-3 + b4 Xk-4 + …

- a1 Yk-1 –a2 Yk-2 –a3 Yk-3 –a4 Yk-4 – …

a’s are the reverse coefficients

b’s are the forward coefficients

Page 6: Removing 60 Hz from EKG signal William Rose, May 2009

Block diagram of bandstopfilt.vi

Page 7: Removing 60 Hz from EKG signal William Rose, May 2009

Front panel of bandstopfilt.vi

20081111aecg_10sec.txt

Top: black dots=original, red line=filtered

Middle: Power spectrum of original signal. Note logarithmic Y-axis scale and power at 60, 120, 180… Hz. (The 60 Hz noise is not a pure sinusoid, so it has power at harmonics of 60.)

Bottom: Power spectrum of filtered signal. Note notch at 60 Hz.

Page 8: Removing 60 Hz from EKG signal William Rose, May 2009

bandstopfilt.vi.

Tests done with input = 20081111aecg_10sec.txt; fcutoff=60 Hz

Change filter width while keeping number of poles fixed: (fhalfwidth, # poles) = (1 Hz, 4); (5 Hz, 4); (10 Hz, 4).

Change number of poles while keeping width fixed: (fhalfwidth, # poles) = (10 Hz, 1); (10 Hz, 4); (10 Hz, 8).

Results: “Signal to noise” (size of QRS /size of background noise) changes little, even though power spectrum notches change.

Tests done with white noise input: uniformrandoms.txt; fco=60 Hz

(fhalfwidth, # poles) = (1Hz, 4); (5 Hz, 4); (10 Hz, 4); (10 Hz, 8).

Results: Some combinations resulted in unstable filters, manifested as an output signal which was orders of magnitude too large: (fhalfwidth, # poles) = (5 Hz, 7); (5 Hz, 8); (10 Hz, 8); (10 Hz, 9).

Page 9: Removing 60 Hz from EKG signal William Rose, May 2009

bandstopfilt+harmonics.vi.

Add filters at the harmonics: multiples of center frequency.

Test with a white noise signal: input=uniformrandoms.txt; fcutoff=60Hz.

(fhalfwidth, # poles) = (3 Hz, 1); (5 Hz, 4); (10 Hz, 8).

Input = 20081111aecg_10sec.txt; fcutoff=60 Hz.

(fhalfwidth, # poles) = (3 Hz, 1); (5 Hz, 4); (10 Hz, 8).

“Signal to noise” (size of QRS /size of background noise) is somewhat better with filtering at 60 Hz and its harmonics than with filtering at 60 Hz only.

Page 10: Removing 60 Hz from EKG signal William Rose, May 2009

Block diagram of bandstopfilt+harmonics.vi

Page 11: Removing 60 Hz from EKG signal William Rose, May 2009

sample_compare.jpg

Comparison of raw signal with output from bandstopfilt.vi and bandstopfilt+harmonics.vi

Top: 20081111aecg.txt unfiltered.

Middle: bandstopfilt, fco=60 Hz, fhw=5 Hz, order=4 (each way).

Bottom: bandstopfilt+harmonics, fco=60 Hz, fhw=5 Hz, order=4 (each way).

Page 12: Removing 60 Hz from EKG signal William Rose, May 2009

bandstopfilt+harmonics+lowpass.vi.

Add an optional 4th order Butterworth lowpass filter (forward plus backward to give zero phase) to the bandpass filters.

Input = 20081111aecg_10sec.txt

fco = 60 Hz, fhw = 20 Hz, order (each way) = 4.

flp = 200 Hz

“Signal to noise” (size of QRS /size of background noise) is somewhat better with than without the lowpass filter at 200 Hz.

Page 13: Removing 60 Hz from EKG signal William Rose, May 2009

Front panel of bandstopfilt+harmonics+lowpass.vi

Page 14: Removing 60 Hz from EKG signal William Rose, May 2009

Block diagram of bandstopfilt+harmonics+lowpass.vi

Page 15: Removing 60 Hz from EKG signal William Rose, May 2009