Harmonics in ECG signals

3 次查看(过去 30 天)
FSB
FSB 2018-10-27
评论: Star Strider 2018-10-28
Hi, My ECG signals are recorded by an ECG sensor on an arduino primo and sent via bluetooth to another device. Now they appear to have some harmonics in them. My question is can these harmonics be due to bluetooth transmission or power-line interface and how to identify the cause??

回答(1 个)

Star Strider
Star Strider 2018-10-27
Your sampling frequency is about 61.6 Hz, so the line frequency certainly could be aliased into your recording. Without knowing your experimental set-up, it would not be possible to identify the cause. I also do not know if your Arduino has an anti-aliasing filter built into it. If not, I suggest that you design and build a Bessel lowpass filter with a cutoff just below the Nyquist frequency (half the sampling frequency), here about 30 Hz. That will eliminate aliasing, and will also eliminate all power frequencies (that I am aware of).
You can eliminate the baseline wander and some of the high-frequency noise with this:
F = openfig('BaselineWanderBefore.fig','invisible');
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 = [6.0 7.0]/Fn; % Passband Frequency Vector (Normalised)
Wp = [2.0 14.0]/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,'bandpass'); % 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
Feel free to experiment with the filter passbands if you want a different result.
  2 个评论
Star Strider
Star Strider 2018-10-28
The Answer posted by Fatima Sajid Butt is copied here as a Comment:
No, the arduino does not has a built in anti aliasing filter build into it and now it cannot be built due to shortage of time. I would like to analyse the time-frequency domain (scalogram) of ECGs and then use them for training convolutional neural network. But the issue I have is that the readings are distorted(some are missing one or two R peaks etc, some are not making appropriate peaks). Now Can you please suggest why you specifically suggested bessel as it has maximum roll off and we have butter worth doing the same thing (apparently). I am new to signal processing so exuse me if my questions are basic.
Star Strider
Star Strider 2018-10-28
The Bessel filter is a phase-neutral hardware filter, so it has no phase distortion. It is routinely used as an anti-aliasing filter for that reason. Other filter designs exhibit phase distortion, and are therefore not used as anti-aliasing filters.
Higher sampling rates are always better (the practical upper limit for biomedical signals being 1 kHz). You can largely eliminate power mains noise and other extraneous electromagnetic noise by using a reference electrode (in EKG recorders, this is generally called the ‘right leg neutral’ lead, and occasionally — and erroneously — called a ‘ground’ lead).
No worries. We were at one time all asking ‘basic’ questions. I refer you to any good textbook on biomedical instrumentation and signal processing, such as that by John G. Webster, for an extended explanation. It is simply a more extensive discussion than I want to get into here.
Also, after some additional experimentation, these values are better than what I originally posted:
Wp = [3.5 8.0]/Fn; % Passband Frequency Vector (Normalised)
Ws = [2.5 9.0]/Fn; % Stopband Frequency Vector (Normalised)
You can easily build the anti-aliasing filters (identical ones for each ADC), even using a ‘breadboard’ version. Also including a reference electrode and the relevant differential amplifiers to implement it properly. It is much better to design and test the instrumentation first, to be certain it gives you optimal signals, than to spend time later ‘cleaning’ your data.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Spectral Measurements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by