Borrar filtros
Borrar filtros

Correcting for baseline drift and determining the isoelectric line of an ECG

6 visualizaciones (últimos 30 días)
I'll preface this question by saying that I'm a relative novice at Matlab. I'm extracting signal data from ECG PDFs using 'imread', converting the image into the xy coordinate plane, then attempting to determine the integral of the P, QRS, and T waves. However, I'm having trouble with baseline deviation which is also making it difficult to determine the isoelectric line. I should say that I had to artificially increase the sampling frequency / pixel density to an arbitrarily high 10,000 Hz using 'linspace' and 'pchip' so that I could accurately determine the onset and offset points of each wave. Any suggestions would be greatly appreciated.
Note: I can't provide the original ECG PDFs but I've attached the extracted xy coordinate data

Respuesta aceptada

Star Strider
Star Strider el 3 de Feb. de 2020
Try this:
Y = load('sample_data_y.mat');
T = load('sample_data_x.mat');
EKGII = Y.lead2_extended_trace_y;
t = T.lead2_extended_trace_x;
Ts = mean(diff(t)); % Sampling Interval
Fs = 1/Ts; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
L = numel(t); % Signal Length
FT_EKGII = fft(EKGII-mean(EKGII))/L; % Subtract The Mean To See The Other Peaks More Clearly
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector
figure
plot(Fv, abs(FT_EKGII(Iv))*2)
grid
xlim([0 150])
Wp = 3;
Ws = 1;
Rp = 1;
Rs = 50;
[n,Wp] = ellipord(Wp/Fn, Ws/Fn, Rp, Rs);
[z,p,k] = ellip(n, Rp, Rs, Wp,'high');
[sos1,g1] = zp2sos(z,p,k);
figure
freqz(sos1, 2^14, Fs)
set(subplot(2,1,1), 'XLim', [0 150])
set(subplot(2,1,2), 'XLim', [0 150])
sgtitle('Highpass Filter')
Wp = [3 75];
Ws = [1 80];
Rp = 1;
Rs = 50;
[n,Wp] = ellipord(Wp/Fn, Ws/Fn, Rp, Rs);
[z,p,k] = ellip(n, Rp, Rs, Wp);
[sos2,g2] = zp2sos(z,p,k);
figure
freqz(sos2, 2^14, Fs)
set(subplot(2,1,1), 'XLim', [0 150])
set(subplot(2,1,2), 'XLim', [0 150])
sgtitle('Bandpass Filter')
EKGII_filtered = filtfilt(sos2, g2, EKGII); % Change The First Two Arguments To Select The Filter
figure
subplot(2,1,1)
plot(t, EKGII)
grid
subplot(2,1,2)
plot(t, EKGII_filtered)
grid
The baseline drift is relatively easy to eliminate with a highpass filter, and it also elimnates the D-C offset. I added a second optional bandpass filter design for you to experiment with, to elimiinate some of the high-frequency noise (adjust the upper limits of the filter to get the result you want). This is definitely abnormal EKG, with pronounced Q-waves, wide QRS complexes, and a number of artifacts I cannot identify. It appears to be from a very sick heart.
  4 comentarios
Pallavi Bugga
Pallavi Bugga el 4 de Feb. de 2020
That's a good point. Thanks for the feedback!

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by