baseline correction using media filter

Hi
I have used median filter (medifilt1)to correct the baseline , is this method is correct ? or there is other methods that can give better results ?
close all
% plot default annotated peaks
subplot(2,1,1);
order =4 ;
framelen =13;
lx = 20;
% generate sinal
x = 1:1:1274;
y = (AV)';
y = sgolayfilt(y,order,framelen);
% get derivatives
dy = diff(y);
findpeaks(y -medfilt1(y,50) ,x,'Annotate','extents','MinPeakProminence',0.008);
[pks,locs,peakWidth1,p] = findpeaks(y -medfilt1(y,50),x,'MinPeakProminence',0.008);
subplot(212);
plot(x,y);
hold on
plot(locs,pks,'*m')
Thanks

Answers (1)

Your medfilt approach seems to be giving appropriate results, but is not the approach I would use.
For initial EKG signal processing, I usually use a Chebyshev Type II filter with a low-frequency cutoff of 1 Hz and a high-frequency of 100 Hz, since that eliminates the low-frequency baseline variations and d-c (constant) offset, and high-frequency noise. (Even abnormal EKGs — for example atrial flutter and fibrillation — have a bandwidth of 0+ to 100 Hz. Everything greater than 100 Hz is noise.)
Your original EKG appears to have atrial fibrillation, possibly contaminated with EMG noise. I would be reluctant to use a Savitzky-Golay filter on an EKG, since it has the tendency to obscure potentially clinically-relevant details.

8 Comments

My goal is to reduce the atrial fibrillation between the peaks and detect peaks only . is medfilt is ok for my requirements ? would Chebyshev Type II give more accurate reults ?
The atrial waves should not be of sufficient amplitude to interfere with R-wave detection. (That record actually looks like flutter waves, since atrial fibrillation just looks like noise.)
I would use the Chebyshev Type II filter. It gives more predictable results, since you know exactly what it is doing.
Thanks , should I use Chebyshev Type II filte instead of SG filter or medifilt ?
I would use the Chebyshev Type II filter. The sgolayfilt approach can be difficult with physiological signals because it may not give the result you need, and the same is true for medfilt1. Both are essentially lowpass filters.
I always use specificallly-designed filters for physiological signals because I know exactly what the filters are doing.
could you please show me an example of how can I use Chebyshev Type II filter and medfilt1 on this data ?
Your data do not contain any time information, so I cannot calculate a sampling frequency from them. Filtering a signal without knowing the sampling frequency is pointless. The sampling frequency must be at least 250 Hz for this filter to work.
Here is the design for the Chebyshev Type II filter:
Fs = ...; % Sampling Frequency (Hz)
Fn = Fs/2; % Nyquist Frequency (Hz)
Wp = [1.0 100]/Fn; % Passband Frequencies (Normalised)
Ws = [0.5 101]/Fn; % Stopband Frequencies (Normalised)
Rp = 10; % 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
[sosbp,gbp] = zp2sos(z,p,k); % Convert To Second-Order-Section For Stability
figure(1)
freqz(sosbp, 2^17, Fs)
(I tested this filter with a sampling frequency of 250 Hz, and it gave acceptable results with the freqz plot.)
Use the filtfilt function to do the actual filtering.
EKG_filt = filtfilt(sosbp, gbp, EKG_original); % Filter EKG Signal
I do not use medfilt1 for physiological signals (and I do not recommend it), so I will leave that to you to perform and compare with the Chebyshev filter results.
My data is from video file with 30 FPS and each video file generates different data . These peaks represents eye blinks .So , for each video file there is different number of peaks (blinks ). I used SG filter with median filter to correct baseline then findpeaks which gave me good baseline correction .
is Chebyshev filter is applicable in my case ?
The Chebyshev filter would still be applicable. Do a fft (link) on your signal to determine the signal frequencies and the noise frequencies. Then, design the filter passband to include the signal and eliminate as much of the noise as possible, as well as eliminate baseline variation.
Experiment with both approaches to see what the best and most efficient is.
The plot looks like an EKG with atrial flutter. EKG signal processing questions are frequent here.

Sign in to comment.

Categories

Tags

Asked:

on 12 May 2017

Commented:

on 17 May 2017

Community Treasure Hunt

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

Start Hunting!