基于matlab消除原始心电图信号中的不一致和尖峰和心电信号分离为P波、QRS波、T波

✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。

🍎个人主页:Matlab科研工作室

🍊个人信条:格物致知。

更多Matlab仿真内容点击👇

智能优化算法       神经网络预测       雷达通信       无线传感器        电力系统

信号处理              图像处理               路径规划       元胞自动机        无人机 

⛄ 内容介绍

从原始心电图信号中去除不一致和尖峰,并将心电信号分离为P波、QRS波和T波是心电信号处理的关键步骤。下面是一个基本的处理框架:

  1. 去噪:使用数字滤波技术,例如低通滤波器或中值滤波器,去除原始心电图信号中的高频噪声和不一致成分。这有助于平滑信号并减少突发尖峰。

  2. R波检测:应用R波检测算法来定位QRS波群的峰值。这可以使用峰值检测、阈值检测或相关方法等进行实现。R波处于QRS复合波的最高点。

  3. 分割:基于R波的位置,将QRS复合波从原始心电图信号中分割出来,以获得每个心搏的独立波形。

  4. P波和T波分离:在QRS波形区域之外,使用特定方法(如滑动窗口平均或自适应阈值)识别和提取P波和T波。P波位于QRS波群之前,而T波位于QRS波群之后。

需要注意的是,心电信号处理是一个复杂且具有挑战性的程,可能涉及到信号噪声、基线干扰、不一致理现象等多个方面的问题。因此,为了获得准心电波形分离和去除尖峰,可能需要结合更高级的信号处理技术和机器学习算法。

⛄ 部分代码

function [data_extracted,average_heart_beat_rate] = ECG_Anormaly_Detection_Algorithm(ECG_data,Fs,ECG_distance_threshold_sensivity,ECG_peak_sensivity)if (nargin<3)    %these thresholds are used to choose ECG segments that are most similar to each other.    %the more the value, the more ECG segments'similarity it takes    ECG_distance_threshold_sensivity=5; % threshold for finding ECG signal by the distance difference    ECG_peak_sensivity=35;              % threshold for finding ECG signal by the peak differencesendformat longBL=[1 zeros(1,5) -2 zeros(1,5) 1];AL=[32,-64,32];BH=[-1 zeros(1,15) 32 -32 zeros(1,14) 1];AH=[32 -32];AINT=[8];BINT=[2 1 0 -1 -2 ];BMOV=ones(1,30)./30;AMOV=[1];min_distance=(Fs/2)-round(Fs/6);[preB,preA]=butter(4,[2/Fs 60/Fs]);y=filtfilt(preB,preA,ECG_data);yL=filter(BL,AL,y);yH=filter(BH,AH,yL);yder=filter(BINT,AINT,yH);yder=filter(BINT,AINT,yH);ysqu=yder.^2;yaov=filter(BMOV,AMOV,ysqu);[pks,locs]=findpeaks(yaov,'MinPeakDistance',Fs);ECG_range=median(pks)+median(pks)/ECG_distance_threshold_sensivity;if(max(pks>=ECG_range))    pks= pks(~(pks>=ECG_range));    locs=locs(~(pks>=ECG_range));endThreshold=max(pks)*ECG_peak_sensivity/100;clear pks locs[pks,locs]=findpeaks(yaov,'MinPeakHeight',Threshold,'MinPeakDistance',min_distance);new_locs=zeros([size(locs)]);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%The value 23 is the group delay of Pan-Tompkins filters.%It is used to match the original ECG signals with the R points found by using output of Pan-Tompkins filtersgroup_delay=23;if(locs(1,1)>round(Fs/group_delay))    new_locs=locs-round(Fs/group_delay);else    new_locs=locs(2:end)-round(Fs/group_delay);    pks=pks(2:end);end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%for i=1:length(new_locs)    if(new_locs(i)>(Fs/2) && new_locs(i)+(Fs/2)<length(yaov))        X=yaov(new_locs(i)-(Fs/2):new_locs(i)+(Fs/2));        X=ECG_data(new_locs(i)-(Fs/2):new_locs(i)+(Fs/2));    else        X=0;    end    mu=mean(X);    sigma(i) = std(X)-mu;    clear XendECG_signal_ortalama=median(sigma);Threshold_ECG_Signal=(ECG_signal_ortalama/ECG_distance_threshold_sensivity);%Erase the signal locationslocs_remove=[];j=1;z=1;locs2=0;for i=1:length(sigma)    if((ECG_signal_ortalama+Threshold_ECG_Signal)<sigma(i)||(ECG_signal_ortalama-Threshold_ECG_Signal)>sigma(i))        locs_remove(j)=new_locs(i);        j=j+1;    else        locs2(z)=new_locs(i);        z=z+1;    endendclear zaverage=0;for i=1:length(locs2)-1    average=average+abs(locs2(i)-locs2(i+1));endaverage_heart_beat_rate=(Fs/(average/(length(locs2))))*60;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Double Check  if there is anything unusual between two R pointsstart=1;range=0;data_extracted{1}=0;for i=2:length(locs2)    range=range+abs(locs2(i-1)-locs2(i));endrange=range/length(locs2);Threshols_ayrim_h=range+range/(ECG_distance_threshold_sensivity/2);Threshols_ayrim_l=range-range/(ECG_distance_threshold_sensivity/2);for i=2:length(locs2)    X(i)=std(ECG_data(locs2(i-1):locs2(i)))-mean(ECG_data(locs2(i-1):locs2(i)));endif(length(locs2)==1)    X=0;endThreshols_ayrim_2h=abs(median(X)+median(X)/(ECG_distance_threshold_sensivity/1));Threshols_ayrim_2l=abs(median(X)-median(X)/(ECG_distance_threshold_sensivity/1));k=1;i=2;first_index=1;while i<=length(locs2)    sigma1=std(ECG_data(locs2(i-1):locs2(i)))-mean(ECG_data(locs2(i-1):locs2(i)));    if(((abs(locs2(i-1)-locs2(i))>=Threshols_ayrim_h)||((abs(locs2(i-1)-locs2(i))<=Threshols_ayrim_l)))||((sigma1>=Threshols_ayrim_2h)||(sigma1<=Threshols_ayrim_2l)))        if(start==1)            clear data_extracted            start=0;        end        if(~(abs(locs2(first_index)-locs2(i-1))<=Fs*2))            data_extracted{k}(:)=ECG_data(locs2(first_index):locs2(i-1));            k=k+1;        end        first_index=i;    end    i=i+1;endif((start==1 || (first_index~=1 && start==0))&& (length(locs2)~=1))    if(start==1)        clear data_extracted    end    data_extracted{k}(:)=ECG_data(locs2(first_index):locs2(i-1));end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%figo=figure('WindowState','maximized');plot(0:1/Fs:length(ECG_data)/Fs-1/Fs,ECG_data)hold onif(length(locs2)~=1)    plot(locs2/Fs,(ECG_data(locs2)),'o','MarkerSize',6)endpos = get(figo,'position');set(figo,'position',[pos(1:2)/4 pos(3:4)*1.5]);set(gca,'Fontsize',16)title('Raw ECG Signal','fontsize',32);hold offxlabel('Time in Seconds','fontsize',24);ylabel('12 bits Raw ECG','fontsize',24);end

⛄ 运行结果

⛄ 参考文献

Guven, Gokhan, et al. “A Novel Biometric Identification System Based on Fingertip Electrocardiogram and Speech Signals.” Digital Signal Processing, vol. 121, Elsevier BV, Mar. 2022, p. 103306, doi:10.1016/j.dsp.2021.103306.

⛳️ 代码获取关注我

❤️部分理论引用网络文献,若有侵权联系博主删除
❤️ 关注我领取海量matlab电子书和数学建模资料

🍅 仿真咨询

1.卷积神经网络(CNN)、LSTM、支持向量机(SVM)、最小二乘支持向量机(LSSVM)、极限学习机(ELM)、核极限学习机(KELM)、BP、RBF、宽度学习、DBN、RF、RBF、DELM实现风电预测、光伏预测、电池寿命预测、辐射源识别、交通流预测、负荷预测、股价预测、PM2.5浓度预测、电池健康状态预测、水体光学参数反演、NLOS信号识别、地铁停车精准预测、变压器故障诊断
2.图像识别、图像分割、图像检测、图像隐藏、图像配准、图像拼接、图像融合、图像增强、图像压缩感知
3.旅行商问题(TSP)、车辆路径问题(VRP、MVRP、CVRP、VRPTW等)、无人机三维路径规划、无人机协同、无人机编队、机器人路径规划、栅格地图路径规划、多式联运运输问题、车辆协同无人机路径规划
4.无人机路径规划、无人机控制、无人机编队、无人机协同、无人机任务分配
5.传感器部署优化、通信协议优化、路由优化、目标定位
6.信号识别、信号加密、信号去噪、信号增强、雷达信号处理、信号水印嵌入提取、肌电信号、脑电信号
7.生产调度、经济调度、装配线调度、充电优化、车间调度、发车优化、水库调度、三维装箱、物流选址、货位优化
8.微电网优化、无功优化、配电网重构、储能配置
9.元胞自动机交通流 人群疏散 病毒扩散 晶体生长

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

matlab科研助手

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值