1、昆明理工大学信息工程与自动化学院学生实验报告( 2016 20 17 学年第二学期)课程名称:生物医学信号处理 开课实验室: 设备编号:实验日期:2018年5月30日年级、专业、班学号姓名成绩实验项目名称心电信号处理指导教师相艳教师评语教师签名:年月日一、实验目的1、对心电信号的记录、处理、心电信号的特点、心电信号的噪声抑制,工频干扰的抑制与基线纠漂有总体了解。2、能利用MATLAB GUI设计简单的GUI程序。二、实验原理1、心电信号的特点:心电信号具有近场检测的特点,离开人体表微小的距离,就基本上检测不到信号;心电信号通常比较微弱,至多为mV量级,且能量主要在几百赫兹以下;干扰即来自生物体
2、内,如肌电干扰、呼吸干扰等,也来自生物体外,如工频干扰,信号拾取时因不良接地等引入的其他外来干扰等;干扰信号与心电信号本身频带重叠(如工频干扰等)。2、工频干扰抑制:现在使用较多的方法是使用滤波器对工频干扰进行抑制。3、基线漂移:基线漂移是因呼吸、肢体活动或运动心电图测试所引起的,故这样使得ECG信号的基准线呈现上下飘逸的情况。三、实验内容1、对心电信号处理主程序:clear;closeall;clc;load 100_ECG_0_20 /加载心电信号%Eliminate Baseline Drift /消除基线漂移s1=ECG_2; /把心电信号ECG-2赋给s1s2=smooth(s1,1
3、50); /利用移动平均法对s1做平滑处理ecgsmooth=s1-s2; /消除基线漂移%apply Wavelet Transform /应用小波变换C,L=wavedec(ecgsmooth,8,db4); /用db4对ecgsmooth进行8层分解,其中返回的近似和细节都存放在C中,L存放是近似和各阶细节系数对应的长度(阶数为4阶)d1,d2,d3,d4,d5,d6,d7,d8=detcoef(C,L,1,2,3,4,5,6,7,8); /提取小波的细节系数%Denoise /降噪,消除干扰thr,sorh,keepapp=ddencmp(den,wv,ecgsmooth); /返回小
4、波除噪和压缩后的信号cleanecg=wdencmp(gbl,C,L,db4,8,thr,sorh,keepapp);/通过门限阈值处理得到小波系数(执行降噪操作)%thresholding1 /取阈值max_value=max(cleanecg); /最大值(波峰)mean_value=mean(cleanecg); /最小值(波谷)threshold=(max_value-mean_value)/2; /最大值与最小值差的一半作为阈值%R detection algorithm/用R检测算法检测信号a5=appcoef(C,L,db4,5);/取分解后的近似部分,也就是第5层低频系数C1=
5、a5;d5;d4;d3; /L1=length(a5);length(d5);length(d4);length(d3);length(cleanecg);R_detect_signal=waverec(C1,L1,db4); /用二维小波分解的结果C1,L1重建信号R_detect_squared=R_detect_signal.2; /对R检测信号求平方%Beat_Rate_Extraction_Algorithm /计算心率for a=1:length(R_detect_squared)ifR_detect_squared(a)thresholdR_detect_new(a)=R_det
6、ect_squared(a);ElseR_detect_new(a)=0;endendmean_R_detect=5*mean(R_detect_new);for q=1:length( R_detect_new)-1ifR_detect_new(q)thresholdR_detect_new(a)=R_detect_squared(a);elseR_detect_new(a)=0;endendmean_R_detect=5*mean(R_detect_new);for q=1:length( R_detect_new)-1ifR_detect_new(q)mean_R_detectR_det
7、ect_new(q)=0;endendd=0;for b=1:length( R_detect_new)-1if ( R_detect_new(b)=0) & ( R_detect_new(b+1)=0) d=d+1;indext(d)= b+1;endendfs_R_deetect=length(R_detect_new)/20;time=indext.*1/fs_R_deetect;ind=0;for z=1:length(time)-1ind=ind+1;time_diff(ind)=time(z+1)-time(z);endav_time=mean(time_diff);Square_
8、Number=av_time/.2;beat_Rate=300/Square_Number;high=max(R_detect_new);subplot(414);plot(R_detect_new);title(R detected Signal);function pushbutton7_Callback(hObject, eventdata, handles)globalR_detect_newd=0;for b=1:length( R_detect_new)-1if ( R_detect_new(b)=0) & ( R_detect_new(b+1)=0) d=d+1;indext(d
9、)= b+1;endendfs_R_deetect=length(R_detect_new)/20;time=indext.*1/fs_R_deetect;ind=0;for z=1:length(time)-1ind=ind+1;time_diff(ind)=time(z+1)-time(z);endav_time=mean(time_diff);Square_Number=av_time/.2;beat_Rate=300/Square_Number;high=max(R_detect_new);set(handles.edit6,string,num2str(fix(beat_Rate); /文本编辑框中显示心率function edit6_Callback(hObject, eventdata, handles)function edit6_CreateFcn(hObject, eventdata, handles)ifispc&isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor)set(hObject,BackgroundColor,white);end图4 GUI界面运行结果图