基于稀疏辅助信号平滑的心电信号降噪方法(Matlab R2021B)

基于形态成分分析理论(MCA)的稀疏辅助信号分解方法是由信号的形态多样性来分解信号中添加性的混合信号成分,它最早被应用在图像处理领域,后来被引入到一维信号的处理中。

在基于MCA稀疏辅助的信号分析模型中,总变差方法TV是其中一个原型,稀疏辅助平滑方法结合并统一了传统的LTI低通滤波和总变差算法,兼具LTI低通滤波和总变差算法的优势,稀疏辅助平滑降噪的适用性更广泛,降噪的表现更好。已有研究说明,稀疏辅助平滑降噪相比低通滤波器能够有效保留瞬态冲击的幅值。

鉴于此,提出一种基于稀疏辅助信号平滑的心电信号降噪方法,运行环境为Matlab R2021B。

Matlab 复制代码
function [A, B, B1, D, a, b, b1, H1norm, HTH1norm] = Lowpass(deg, fc, N, K)
% [A, B, B1] = ABfilt(d, fc, N, K)
%
% Banded matrices for zero-phase high-pass recursive filter.
% The filter is H = inv(A) * B where the matrices A and B
% are created as 'sparse' matrices.
%
% INPUT
%   d  : degree of filter is 2d
%   fc : cut-off frequency (normalized frequency, 0 < fc < 0.5)
%   N  : length of signal
%   K  : order of difference matrix D (need 1 <= K <= 2*d) (default K = 1)
%
% OUTPUT
%   A, B, B1 : banded filter matrices
%       with B = B1*D where D is the K-th order difference (up to sign)
%
% Use [A, B, B1, D, a, b, b1] = ABfilt(...) to return
% filter coefficient vectors a, b, b1.

if nargin < 4
    K = 1;
end

if K > 2*deg
    error('ABfilt: K > 2*d')
end

omc = 2*pi*fc;
t = ((1-cos(omc))/(1+cos(omc)))^deg;

% Define p such that P(z)P(1/z) = B(z), i.e., P'*P = B
p = 1;
for k = 1:deg
    p = conv(p, [-1 1]);
end
P = spdiags( p(ones(N-deg,1), :), 0:deg, N-deg, N);        % banded matrix

B = P' * P;
% pp = conv(p, p(end:-1:1));

q = sqrt(t);
for i = 1:deg
    q = conv(q, [1 1]);
end
Q = spdiags( q(ones(N-deg,1), :), 0:deg, N-deg, N);    % banded matrix

A = P'*P + Q'*Q;

if K <= deg
    d = 1;
    for i = 1:K
        d = conv(d, [-1 1]);
    end
    D = spdiags(d(ones(N,1), :), 0:K, N-K, N);               % D: banded matrix
    
    p1 = deconv(p, d);
    P1 = spdiags( p1(ones(N-deg,1), :), 0:deg-K, N-deg, N-K);  % banded matrix
    B1 = P' * P1;

    b1 = conv(p1, p(end:-1:1));
else
    % deg < K <= 2*deg
    K2 = 2*deg - K;
    d = 1;
    for i = 1:K2
        d = conv(d, [-1 1]);
    end
    B1 = spdiags(d(ones(N,1), :), 0:K2, N-K2, N)';               % D: banded matrix
    
    p1 = deconv(p, d);
    D1 = spdiags( p1(ones(N-deg,1), :), 0:deg-K2, N-deg, N-K2);  % banded matrix
    D = D1'*P;

    b1 = d;

end

a = conv(p, p(end:-1:1)) + conv(q, q(end:-1:1));
b = conv(p, p(end:-1:1));

% verify that B = B1*D
err = B - B1*D;
mae = max(abs(err(:)));
if mae > 1e-10
    disp('Error in ABfilt (B1*D not equal to B)')
end


% Calculate filter norms

imp = zeros(size(B1,2), 1);
imp(round(N/2)) = 1;                        % imp : impulse signal (located at center to avoid transients)

h1 = A \ (B1 * imp);
H1norm = sqrt( sum( abs( h1 ).^2 ) );       % norm of filter inv(A)*B1

hh = B' * ((A*A') \ (B1 * imp));
%完整代码:https://mbd.pub/o/bread/mbd-ZZaZmJtx

HTH1norm = sqrt( sum( abs( hh ).^2 ) );     % norm of filter B'*inv(A*A')*B1

工学博士,担任《Mechanical System and Signal Processing》《中国电机工程学报》《控制与决策》等期刊审稿专家,擅长领域:现代信号处理,机器学习,深度学习,数字孪生,时间序列分析,设备缺陷检测、设备异常检测、设备智能故障诊断与健康管理PHM等。

相关推荐
软件黑马王子1 小时前
C#初级教程(4)——流程控制:从基础到实践
开发语言·c#
闲猫1 小时前
go orm GORM
开发语言·后端·golang
计算机小白一个2 小时前
蓝桥杯 Java B 组之设计 LRU 缓存
java·算法·蓝桥杯
万事可爱^2 小时前
HDBSCAN:密度自适应的层次聚类算法解析与实践
算法·机器学习·数据挖掘·聚类·hdbscan
李白同学3 小时前
【C语言】结构体内存对齐问题
c语言·开发语言
牧歌悠悠3 小时前
【深度学习】Unet的基础介绍
人工智能·深度学习·u-net
坚毅不拔的柠檬柠檬4 小时前
AI革命下的多元生态:DeepSeek、ChatGPT、XAI、文心一言与通义千问的行业渗透与场景重构
人工智能·chatgpt·文心一言
坚毅不拔的柠檬柠檬4 小时前
2025:人工智能重构人类文明的新纪元
人工智能·重构
jixunwulian4 小时前
DeepSeek赋能AI边缘计算网关,开启智能新时代!
人工智能·边缘计算
Archie_IT4 小时前
DeepSeek R1/V3满血版——在线体验与API调用
人工智能·深度学习·ai·自然语言处理