How to Remove the baseline wander from ECG?
Mostrar comentarios más antiguos
Hello there! I've noticed a similar question posted in the community, so I kindly request that you refrain from providing a generic response like "Check this." Instead, I'm reaching out for your assistance in effectively eliminating the baseline wander from my signal. Despite my efforts to remove it, the resulting plot remains unchanged, and I haven't observed any improvement. I would greatly appreciate your help with the code to address this issue. Thank you in advance for your support!
load sig_ecg.mat
fs = 300;
t=linspace(0,length(sig)/fs,length(sig));
figure()
plot(t,sig/max(sig));
grid
title('Signal in Time Domain');
xlabel('Time(s)');
ylabel('Amplitude');
figure()
sig=sig-mean(sig); % Per visualizzare meglio lo spettro
f=linspace(-fs/2,fs/2,length(sig));
plot(f,fftshift(abs(fft(sig))));
grid
title('Signal in Frequency Domain');
xlabel('Frequency (Hz)');
ylabel('Amplitude');
Lo spettro del segnale mostra un consistente picco a 42Hz che è probabilmente correlato ad una "power line interference", dovuta ad artefatti da strumentazione. L'approccio più semplice per rimuovere quest'interferenza è di applicare un filtraggio IIR stop-band centrato a 42Hz. Inoltre notiamo la presenza di una baseline wander.
F = sig;
f = gca;
EKG = findobj(f, 'Type','line');
t = EKG.XData; % Recover Data
s = EKG.YData;
L = numel(t); % Signal Length
Ts = mean(diff(t));
St = std(diff(t)); % Test For Uniform Sampling
tr = linspace(min(t), max(t), L); % New, Regularly-Sampled Time Vector
Tsr = mean(diff(tr)) * 1E-3; % Convert To Seconds
sr = resample(s, tr); % Resample To Regularly-Sampled Signal
Fsr = 1/Tsr; % Sampling Frequency (Hz)
Fnr = Fsr/2;
figure
plot(tr, sr)
grid
FTsr = fft(sr-mean(sr))/L; % Fourier Transform Of Mean-Corrected Signal
Fv = linspace(0, 1, fix(L/2)+1)*Fnr;
Iv = 1:numel(Fv);
figure
plot(Fv, abs(FTsr(Iv))*2)
grid
Fs = Fsr; % Sampling Frequency (Hz)
Fn = Fs/2; % Nyquist Frequency (Hz)
Ws = 0.5/Fn; % Passband Frequency Vector (Normalised)
Wp = 1.5/Fn; % Stopband Frequency Vector (Normalised)
Rp = 1; % Passband Ripple (dB)
Rs = 150; % Stopband Attenuation (dB)
[n,Wp] = ellipord(Wp,Ws,Rp,Rs); % Calculate Filter Order
[z,p,k] = ellip(n,Rp,Rs,Wp,'high'); % Default Here Is A Lowpass Filter
[sos,g] = zp2sos(z,p,k); % Use Second-Order-Section Implementation For Stability
sr_filtered = filtfilt(sos,g,sr); % Filter Signal (Here: ‘sr’)
figure
freqz(sos, 2^14, Fs) % Bode Plot Of Filter
set(subplot(2,1,1), 'XLim',[0 Fn]) % Optional, Change Limits As Necessary
set(subplot(2,1,2), 'XLim',[0 Fn]) % Optional, Change Limits As Necessary
figure
plot(tr, sr_filtered)
grid
title('Signal in Frequency Domain with removal of baseline wander');
xlabel('Frequency (Hz)');
ylabel('Amplitude');
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Spectral Measurements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



