Filtering ECG signal with stopband filter using Butterworth filter method
I am trying to filter out an ECG signal using the eighth order butterworth filter method. I am using a bandstop filter. Here is the MATLAB Code:
Data = csvread('ecg_HF_noise.csv',1,0);
signal = Data(:,3)/100000;
N = length(signal);
FreqS = 94.3; % Sampling frequency
nyqFreq = FreqS/2; % Nyquist frequency fft_signal = abs(fft(signal)); figure(1); % Plot single-sided magnitude spectrum (normalized)
x1 = 0:1/(N/2 -1):1;
y1 = fft_signal(1:N/2);
p1 = line(x1,y1);
ax1 = gca; % current axes
axis([0 1 0 1]);
xlabel('Normalised frequency [\pi rads/sample]');
[b a] = butter(8, [0.49 0.55], 'stop');
H = freqz(b,a,N/2);
x2 = linspace(0,nyqFreq,500);
y2 = abs(H);
ax1_pos = ax1.Position;
ax2 = axes('Position',ax1_pos,'XAxisLocation','top','YAxisLocation','right','Color','none');
ax2.XLabel.String = 'Frequency [Hz]';
p2 = line(x2,y2,'Parent',ax2,'Color','r'); % Plot frequency response
title('Magnitude spectrum of signal and frequency response of filter');
axis([0 nyqFreq 0 1]);
legend([p1 p2],'magnitude spectrum','frequency response');
x_filtered = filter(b,a,signal);
This is the resulting frequency response of the filter and the magnitude spectrum of the signal:
An here the filtered signal vs. the noisy signal:
I don’t understand why by rejecting the ca. 24Hz peak, the signal is filtered. What about the noisy part between 0 to 0.4 and the mysterious large peak at the beginning? -When I apply the filter over that region the signal is not filtered. How can that be explained? I had my PC adapter (50Hz) near the sensor during the time of capture of the data.
What might that peak at the beginning with the large amplitude be? The unfiltered signal at the beginning of figure 3 looks normal though.
Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.
Respiratory activity, muscle activity, any number of possibilities. It seems that the EKG was recorded without the benefit of the right-leg reference electrode (erroneously called a ‘ground’), so any activity within the frequency range of the recording equipment could appear.
In addition to the bandstop filter you designed, you probably need to use a bandpass filter with a low-frequency passband of 1 Hz and a high-frequency passband of 50 Hz.
This design works:
SEE COMPLETE ANSWER CLICK THE LINK