当前位置:文档之家› 心电信号

心电信号

昆明理工大学信息工程与自动化学院学生实验报告( 2016 —2017 学年第二学期)课程名称:生物医学信号处理开课实验室:信自445 设备编号:实验日期:2017.6.13一、实验目的1、对心电信号的记录、处理,心电信号的特点、心电信号的噪声抑制,工频干扰的抑制与基线纠漂有总体了解。

2、能利用MATLAB GUI设计简单GUI程序。

二、实验原理1、心电信号属生物医学信号,具有如下特点:信号具有近场检测的特点,离开人体表微小的距离,就基本上检测不到信号;心电信号通常比较微弱,至多为mV量级;属低频信号,且能量主要在几百赫兹以下;干扰特别强。

干扰既来自生物体内,如肌电干扰、呼吸干扰等;也来自生物体外,如工频干扰、信号拾取时因不良接地等引入的其他外来串扰等;干扰信号与心电信号本身频带重叠(如工频干扰等)。

2、工频干扰抑制:现在使用较多的方法是使用滤波器对工频干扰进行抑制。

3、基线漂移:基线漂移是因为呼吸,肢体活动或运动心电图测试所引起的,故这样使得ECG信号的基准线呈现上下漂移的情况。

三、实验内容及步骤1、查询心电信号处理相关资料。

了解心电信号的记录、处理,心电信号的特点、心电信号的噪声抑制,工频干扰的抑制与基线纠漂。

(1)心电信号相关资料人体心电信号是非常微弱的生理低频电信号,通常最大的幅值不超过5mV,信号频率在0.05~100Hz之间。

心电信号是通过安装在人体皮肤表面的电极来拾取的。

由于电极和皮肤组织之间会发生极化现象,会对心电信号产生严重的干扰。

加之人体是一个复杂的生命系统,存在各种各样的其他生理电信号对心电信号产生干扰。

同时由于我们处在一个电磁包围的环境中,人体就像一根会移动的天线,从而会对心电信号产生50Hz左右的干扰信号。

心电信号具有微弱、低频、高阻抗等特性,极容易受到干扰,所以分析干扰的来源,针对不同干扰采取相应的滤除措施,是数据采集重点考虑的一个问题。

(2)心电信号具有以下几个特点:信号极其微弱,一般只有0.05~4mV,典型值为1mV;频率范围较低,频率范围为0.1~35Hz,主要集中在5~20Hz;存在不稳定性。

人体内部各器官问的相互影响以及各人的心脏位置、呼吸、年龄、是否经常锻炼等因素,都会使心电信号发生相应变化;干扰噪声很强。

对心电信号进行测量时,必然要与外界联系,但由于其自身的信号非常微弱,因此,各种干扰噪声非常容易影响测量。

其噪声可能来自工频(50Hz)干扰、电极接触噪点、运动伪迹、肌电噪声、呼吸引起的基线漂移和心电幅度变化以及其他电子设备的机器噪声等诸多方面。

2、编译、理解所提供的程序程序clear; %清空工作区close all; %关闭所有窗口clc; %清空命令区域load 100_ECG_0_20 %读取心电信号%%%Eliminate Baseline Drift %消除基线漂移s1=ECG_2;s2=smooth(s1,150);ecgsmooth=s1-s2;%%%apply Wavelet Transform %进行小波变换[C,L]=wavedec(ecgsmooth,8,'db4');[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);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);C1=[a5;d5;d4;d3];L1=[length(a5);length(d5);length(d4);length(d3);length(cleanecg)]; R_detect_signal=waverec(C1,L1,'db4');R_detect_squared=R_detect_signal.^2; %%%%%%%%%%%%%%%%%%%%%%%%%% %计算心率%%%Beat_Rate_Extraction_Algorithmfor a=1:length(R_detect_squared)if R_detect_squared(a)>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)-1if R_detect_new(q)< mean_R_detectR_detect_new(q)=0;endend%%%%%%%%%%%%%%%%%%d=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_Number=av_time/.2;beat_Rate=300/Square_Number;high=max(R_detect_new); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Plot the Orginal Signal and Eliminating Baseline Drift signalsubplot(411);plot(s1);title('Orginal Signal');subplot(412);plot(s1-s2);title('Baseline drift Elimination');subplot(413);plot(cleanecg);title('Main Signal');subplot(414);plot(R_detect_new);title('R detected Signal');text(length(R_detect_new)/2,high,['Beat Rate=',num2str(fix(beat_Rate))],'EdgeColor','red'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%3、利用MATLAB GUI平面设计与本实验有关的GUI程序选择并绘制心电信号% --- Executes on button press in pushbutton1.function pushbutton1_Callback(hObject, eventdata, handles)% hObject handle to pushbutton1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global s1load 100_ECG_0_20sel = get(handles.popupmenu1,'value');switch selcase 1s1 = ECG_1;case 2s1 = ECG_2;end%s1=ECG_1plot(handles.axes1,s1,'red');绘制s1-s2心电信号图% --- Executes on button press in pushbutton2.function pushbutton2_Callback(hObject, eventdata, handles)% hObject handle to pushbutton2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global s1 ecgsmooths2=smooth(s1,150);ecgsmooth=s1-s2;plot(handles.axes2,s1-s2,'red');画cleanecg图% --- Executes on button press in pushbutton3.function pushbutton3_Callback(hObject, eventdata, handles)% hObject handle to pushbutton3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global ecgsmooth cleanecg C L d8 d7 d6 d5 d4 d3 d2 d1[C,L]=wavedec(ecgsmooth,8,'db4');[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);cleanecg=wdencmp('gbl',C,L,'db4',8,thr,sorh,keepapp);plot(handles.axes3,cleanecg,'red');画 R_detect_new图% --- Executes on button press in pushbutton4.function pushbutton4_Callback(hObject, eventdata, handles)% hObject handle to pushbutton4 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)%%%thresholding1global cleanecg C L d5 d4 d3 R_detect_new threshold R_detect_squared max_value=max(cleanecg);mean_value=mean(cleanecg);threshold=(max_value-mean_value)/2;%%%R detection algorithma5=appcoef(C,L,'db4',5);C1=[a5;d5;d4;d3];L1=[length(a5);length(d5);length(d4);length(d3);length(cleanecg)];R_detect_signal=waverec(C1,L1,'db4');R_detect_squared=R_detect_signal.^2;plot(handles.axes4,R_detect_new,'red')选择心电信号区间% --- Executes on selection change in popupmenu1.function popupmenu1_Callback(hObject, eventdata, handles)% hObject handle to popupmenu1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: contents = get(hObject,'String') returns popupmenu1 contents as cell array% contents{get(hObject,'Value')} returns selected item from popupmenu1显示心率大小function edit1_Callback(hObject, eventdata, handles)% hObject handle to edit1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit1 as text% str2double(get(hObject,'String')) returns contents of edit1 as a double控制edite显示心率的按键% --- Executes on button press in pushbutton5.function pushbutton5_Callback(hObject, eventdata, handles)% hObject handle to pushbutton5 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)%%%Beat_Rate_Extraction_Algorithmglobal R_detect_new indext time_diff high cleanecg C L d5 d4 d3 threshold R_detect_squaredmax_value=max(cleanecg);mean_value=mean(cleanecg);threshold=(max_value-mean_value)/2;%%%R detection algorithma5=appcoef(C,L,'db4',5);C1=[a5;d5;d4;d3];L1=[length(a5);length(d5);length(d4);length(d3);length(cleanecg)];R_detect_signal=waverec(C1,L1,'db4');R_detect_squared=R_detect_signal.^2;for a=1:length(R_detect_squared)if R_detect_squared(a)>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)-1if R_detect_new(q)< mean_R_detectR_detect_new(q)=0;endend%%%%%%%%%%%%%%%%%%d=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_Number=av_time/.2;beat_Rate=300/Square_Number;high=max(R_detect_new);set(handles.edit1,'string',beat_Rate);(2)GUI界面设计用GUI平台设计界面,5个Push Button按键分别为:pushbutton1输入信s1;pushbutton2输入信号s1-s2;pushbutton3输入信号cleanecg;pushbutton4输入信号R_detect_new,pushbutton5显示Beat Rate四个Axes分别为:axes1, axes2,axes3,axes4。

相关主题