Hi!! I am trying to filter this noisy ECG signal which I have. I tried many of the filtering methods like savitzky golay, FIR(using filter design app). tried with many other types too. But nothing seem to work

15 views (last 30 days)
I have attached the .mat file on which I am trying to filter. For FIR filter I use (LPF, Kaiser window) Fs=128000 Fc=120 N=7
I first design the filter in the Filter design app, then export it in the workspace to perform filtering on the ECG. Tried lot of permutations and combinations but nothing seems to work. Also I used PSD method to determine the Fc and approximated it to be 120Hz Please can anyone help!!
  2 Comments
Image Analyst
Image Analyst on 18 Feb 2018
What is your definition of "work"?
Did sgolayfilt() throw an error or something? Or you just never figured out the parameters to get it to create the output signal that you'd like?
It would also help people if you attach a screenshot of a plot of your signal, and, if possible, what you'd like the output signal to look like.
Vidula Sawant
Vidula Sawant on 19 Feb 2018
Hi!! I put some random parameters for the sgolayfilt. Did not actually figure out. I have attached images of the signal and expected output signal.
Thank you for your reply

Sign in to comment.

Answers (1)

Star Strider
Star Strider on 18 Feb 2018
Your EKG has some sort of broadband noise that a frequency-selective filter cannot completely eliminate, and a wavelet decomposition might not be able to eliminate. There is some sort of 2.2 Hz harmonic (based on analysis of adjacent peaks). You can possibly design a notch comb filter to eliminate all those frequencies.
The best I can do with a frequency-selective filter:
matname = 'tremor.mat';
D = load(matname);
EKG = D.ECG;
t = D.t';
Fs = D.Fs;
Ts = mean(diff(t));
Fsc = 1/Ts;
figure(1)
plot(t, EKG)
grid
Fn = Fs/2;
L = numel(t);
FTEKG = fft(EKG)/L;
Fv = linspace(0, 1, fix(L/2)+1)*Fn;
Iv = 1:numel(Fv);
figure(2)
plot(Fv, abs(FTEKG(Iv))*2)
grid
axis([0 100 ylim])
Wp = [1.5 25.0]/Fn; % Passband Frequency (Normalised)
Ws = [0.5 27.0]/Fn; % Stopband Frequency (Normalised)
Rp = 1; % Passband Ripple (dB)
Rs = 50; % Stopband Ripple (dB)
[n,Ws] = cheb2ord(Wp,Ws,Rp,Rs); % Filter Order
[z,p,k] = cheby2(n,Rs,Ws); % Filter Design, Sepcify Bandpass
[sos,g] = zp2sos(z,p,k); % Convert To Second-Order-Section For Stability
figure(3)
freqz(sos, 2^16, Fs) % Filter Bode Plot
EKG_Filtered = filtfilt(sos, g, EKG); % Filter Signal
figure(4)
plot(t, EKG_Filtered)
grid
It is not possible to reliably identify P, Q, S, T, or U waves. Even the filtered signal is too noisy to allow that.
  3 Comments
Star Strider
Star Strider on 19 Feb 2018
My pleasure.
That is most easily done with a FIR filter. One design that illustrates the idea is in Filtering out a Specific Sound from a Audio File (link). You will have to experiment to get the result you want.
Vidula Sawant
Vidula Sawant on 23 Feb 2018
Thank you Star Strider. I have this another audio file of ECG which I am trying to filter. I have converted it into mat file. PFA. Can you please suggest me some way to filter that. I am not able to figure out what exactly and what frequency the disturbance is? Any help would be appreciated. Thank you.

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!