簡體   English   中英

MATLAB:濾除噪聲EKG信號

[英]MATLAB: filter noisy EKG signal

使用matlab從ECG信號中去除噪聲的最佳濾波器是什么?

如果您可以訪問信號處理工具箱 ,那么請查看Savitzky-Golay過濾器 ,即功能sgolay 有一個附帶的演示,只需運行sgolaydemo


以下是一個示例,顯示了可以對信號應用濾波和去噪的各種方法。 請注意,其中一些功能需要存在某些工具箱:

% load ecg: simulate noisy ECG
Fs=500;
x = repmat(ecg(Fs), 1, 8);
x = x + randn(1,length(x)).*0.18;

% plot noisy signal
figure
subplot(911), plot(x), set(gca, 'YLim', [-1 1], 'xtick',[])
title('noisy')

% sgolay filter
frame = 15;
degree = 0;
y = sgolayfilt(x, degree, frame);
subplot(912), plot(y), set(gca, 'YLim', [-1 1], 'xtick',[])
title('sgolayfilt')

% smooth
window = 30;
%y = smooth(x, window, 'moving');
%y = smooth(x, window/length(x), 'sgolay', 2);
y = smooth(x, window/length(x), 'rloess');
subplot(913), plot(y), set(gca, 'YLim', [-1 1], 'xtick',[])
title('smooth')

% moving average filter
window = 15;
h = ones(window,1)/window;
y = filter(h, 1, x);
subplot(914), plot(y), set(gca, 'YLim', [-1 1], 'xtick',[])
title('moving average')

% moving weighted window
window = 7;
h = gausswin(2*window+1)./window;
y = zeros(size(x));
for i=1:length(x)
    for j=-window:window;
        if j>-i && j<(length(x)-i+1) 
            %y(i) = y(i) + x(i+j) * (1-(j/window)^2)/window;
            y(i) = y(i) + x(i+j) * h(j+window+1);
        end
    end
end
subplot(915), plot( y ), set(gca, 'YLim', [-1 1], 'xtick',[])
title('weighted window')

% gaussian
window = 7;
h = normpdf( -window:window, 0, fix((2*window+1)/6) );
y = filter(h, 1, x);
subplot(916), plot( y ), set(gca, 'YLim', [-1 1], 'xtick',[])
title('gaussian')

% median filter
window = 15;
y = medfilt1(x, window);
subplot(917), plot(y), set(gca, 'YLim', [-1 1], 'xtick',[])
title('median')

% filter
order = 15;
h = fir1(order, 0.1, rectwin(order+1));
y = filter(h, 1, x);
subplot(918), plot( y ), set(gca, 'YLim', [-1 1], 'xtick',[])
title('fir1')

% lowpass Butterworth filter
fNorm = 25 / (Fs/2);               % normalized cutoff frequency
[b,a] = butter(10, fNorm, 'low');  % 10th order filter
y = filtfilt(b, a, x);
subplot(919), plot(y), set(gca, 'YLim', [-1 1])
title('butterworth')

截圖

您可能想要查看的兩個過濾器設計工具/演示:

這些應該讓您有機會嘗試不同的濾波器和濾波器參數,以了解它們如何使用EKG / ECG數據。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM