Noise in ECG data

31 ビュー (過去 30 日間)
Talha
Talha 2011 年 7 月 20 日
回答済み: haneen 2014 年 2 月 1 日
hi, I am doing project of ECG acquiring on C5505. I got results successfully on the PC Application. My ECG results are good and their shape matches those available on the real ECG machines.
But the ECGs are still suffering from some humming noise. So when I plot the data on Matlab, I got all forms of zig-zags.
I want to know is it possible that fft of the signal is taken and noise is removed, that is those frequency components can be removed from them in Matlab??
I got the fft spectrum, but the plot does not show the frequency information related to samples...How I will extract the frequency info??
Thanks.
  1 件のコメント
Sean de Wolski
Sean de Wolski 2011 年 7 月 20 日
Can you show us what you've done and supply a small set of sample data?

サインインしてコメントする。

回答 (6 件)

Rick Rosson
Rick Rosson 2011 年 7 月 20 日
Hi Talha,
  1. Do you know the sampling rate of the signal?
  2. Also, what is the size of the time-domain representation (how many rows and columns)?
  3. Can you please show us your MATLAB code?
Thanks.
Rick
  1 件のコメント
Talha
Talha 2011 年 7 月 21 日
Answers to your questions:
1. 500 HZ
2. N x 12(N depends on duration of acquiring of ECG data)
3. I was able to get the frequency spectrum and now I want to remove the noise between 45-55 Hz and then 90-115 Hz. I have applied low pass and band stop filters and All that I have done has made the waveforms with more and more ripples.
The code is written is below:
Fs = 500;
xdft = fft(d);
% below works for even length x
psdest = 1/(length(d)*500).*abs(xdft(1:length(d)/2+1)).^2;
psdest(2:end-1) = 2*psdest(2:end-1);
df = 500/length(d);
freq = 0:df:500/2;
plot(10*log10(psdest),freq);

サインインしてコメントする。


Rick Rosson
Rick Rosson 2011 年 7 月 21 日
Hi Talha,
  1. Why are you using low-pass and band stop filters? Why not use two band-stop filters?
  2. Is the noise you are trying to remove related to 50 Hz electrical power? Is it the fundamental (50 Hz) and the second harmonic (100 Hz) of the electrical power supply? If yes, have you considered using two notch filters, one at 50 Hz and the other at 100 Hz?
  3. How did you design the low-pass and band-stop filters? Did you use the FDATool, MATLAB filter design function calls, or some other method? If you designed by function calls, can you please post your filter design code?
  4. Can you please post the filter coefficients for both filters?
  5. How did you apply the two filters? Can you please post your filter application code?
Thanks!
Rick

Rick Rosson
Rick Rosson 2011 年 7 月 21 日
Hi Talha,
Here is some improved code:
%%Computations:
x = d;
[N,P] = size(x);
Fs = 500;
dt = 1/Fs;
t = dt*(0:N-1)';
dF = Fs/N;
f = (-Fs/2:dF:Fs/2-dF)';
X = fftshift(fft(x))/N;
Xpsd = 20*log10(abs(X));
%%Plotting:
for k = 1:P
figure;
subplot(2,1,1);
plot(t,x(:,k));
subplot(2,1,2);
plot(f,Xpsd(:,k));
title(['Time Domain and PSD for Channel #' num2str(k)]);
end
%%Filtering:
% Specify:
spec(1) = fdesign ...
spec(2) = fdesign ...
% Design:
filt(1) = design(...);
filt(2) = design(...);
% Filter:
y = filter(filt(1),x);
z = filter(filt(2),y);
  1 件のコメント
Talha
Talha 2011 年 7 月 21 日
hi Rick,
Again the answers to your questions:
1. Does not matter, Passing through the filters cause ripples.
2. Two frequencies are not related and I am in a process of implementing a two notch filters but in the DSP stage not after acquiring the data due to the ripples.
3. I used a .m file I made to have the notch filters' coefficients, when I use the fdatool the coefficients were in decimals and rounding them caused distortion.
5. Yes, I have applied the two filters. The code is:
dt=fdesign.bandstop('Fp1,Fst1,Fst2,Fp2,Ap1,Ast,Ap2',40,45,55,56,0.5,80,0.5,500);
de=fdesign.bandstop('Fp1,Fst1,Fst2,Fp2,Ap1,Ast,Ap2',85,86,115,116,0.5,80,0.5,500);
Hd = design(dt,'butter');
Hd1= design(de,'butter');
%view filter magnitude response
fvtool(Hd);
output = filter(Hd,d(:,1));
output1 = filter(Hd1,output);
(I used the code you sent, and yes it has made it much more clear. Thanks for that.)

サインインしてコメントする。


Rick Rosson
Rick Rosson 2011 年 7 月 21 日
Everything that you are doing looks correct, as far as I can tell. When you say that "Passing through the filters causes ripples", what exactly do you mean? Are you seeing "ripples" in the time domain signal, or in the frequency domain representation? Can you please post one or more screen shots showing the signal before and after passing through the two filters?
  7 件のコメント
Rick Rosson
Rick Rosson 2011 年 7 月 25 日
Yes, that could very much affect the results. Please try designing your filters for Fs of 250 samples per second, and then reapplying them to the signal. That might do the trick.
Talha
Talha 2011 年 7 月 26 日
Unfortunately, results were not as expected. Can I use wavelet transform here, cause ultimately I have to extract different locations of peaks. The only problem I am facing is the PQRST waves have random locations i.e. I can't follow simple zero crossings algorithm or findpeaks, on the waveforms.

サインインしてコメントする。


Bjorn Gustavsson
Bjorn Gustavsson 2011 年 7 月 26 日
Talha, what is the noise you're after in your original image? Is it the point-to-point variation? If so you should be fine with a very simple low-pass filter, something you'd need to use only matlab's filtfilt or filter functions. Something like this:
I_filtered = filtfilt([.5,1,.5]/2,1,I_original);
HTH
  2 件のコメント
Talha
Talha 2011 年 7 月 26 日
The noise riding on the signal is due to environment and its over all distributed. The waveforms are also suffering from baseline wandering.
Thank you Bjorn,I tried the code you sent me. It did smooth the waveform further. Now I state again, how can I extract different waves locations? Smoothing of data is been done to satisfaction level.
Bjorn Gustavsson
Bjorn Gustavsson 2011 年 7 月 26 日
I don't know enough about ECG-signals to know what is "true" ECG signal and what constitutes base-line variations. But considering that you only show us ~2 periods it might be completely impossible to determine. I suggest you could do something similar to conditional integration - but here rather "conditional resampling" (I just made that one up.):
Identify the peak of the spikes (the ones at ~2690 and 2950 and so on) then resample/interpolate something like this:
iPeaks = find-local-peaks(ECG);
for i1 = 1:(length(iPeaks)-1),
iCurr = iPeaks(i1):iPeaks(i1+1);
ECGresampled(i1,:) = interp1(t(iCurr),ECG(iCurr),linspace(t(iCurr(1)),t(iCurr(end)),nS);
end
That should give you a 2-D matrix with the individual ECG-periods along the rows and might give you some view of variations in base-line variations that are way slower than one ECG-period. How to determine what is ECG-signal and what is base-line variations in a single period I would not like to tell! Maybe this flutter is a heart condition but not that one over there...

サインインしてコメントする。


haneen
haneen 2014 年 2 月 1 日
hi , i am haneen my broject (removes the baseline wander in ecg signal by using wavelet transform) so, i need code in matlab to do this, thanks

カテゴリ

Help Center および File ExchangeSingle-Rate Filters についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by