【心电信号】基于matlab实现心音诊断系统含GUI

1 简介

心血管疾病已成为导致人类死亡最主要的原因,是世界范围内的临床医学和人类社会负担.在临床方面:心脏性猝死,孕产妇心脏健康问题,麻醉安全问题与心脏都有着直接或间接的联系.目前,临床关于心脏性猝死的预警,心脏监护室和危重病人监护,麻醉安全监测项目中都没有对心脏储备指标的监测,忽略了从心力,心律,心率等几个方面同时观察研究.因此,开展基于"心音和心电综合分析"的研究具有重要的学术意义和实用价值.本文从心音位置、心音峰值、心音门限等方面进行心音​的诊断。​

2 部分代码

function varargout = xingyingzhengduan(varargin)% XINGYINGZHENGDUAN M-file for xingyingzhengduan.fig%      XINGYINGZHENGDUAN, by itself, creates a new XINGYINGZHENGDUAN or raises the existing%      singleton*.%%      H = XINGYINGZHENGDUAN returns the handle to a new XINGYINGZHENGDUAN or the handle to%      the existing singleton*.%%      XINGYINGZHENGDUAN('CALLBACK',hObject,eventData,handles,...) calls the local%      function named CALLBACK in XINGYINGZHENGDUAN.M with the given input arguments.%%      XINGYINGZHENGDUAN('Property','Value',...) creates a new XINGYINGZHENGDUAN or raises the%      existing singleton*.  Starting from the left, property value pairs are%      applied to the GUI before xingyingzhengduan_OpeningFcn gets called.  An%      unrecognized property name or invalid value makes property application%      stop.  All inputs are passed to xingyingzhengduan_OpeningFcn via varargin.%%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one%      instance to run (singleton)".%% See also: GUIDE, GUIDATA, GUIHANDLES% Edit the above text to modify the response to help xingyingzhengduan% Last Modified by GUIDE v2.5 03-May-2021 02:33:20% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name',       mfilename, ...                   'gui_Singleton',  gui_Singleton, ...                   'gui_OpeningFcn', @xingyingzhengduan_OpeningFcn, ...                   'gui_OutputFcn',  @xingyingzhengduan_OutputFcn, ...                   'gui_LayoutFcn',  [] , ...                   'gui_Callback',   []);if nargin && ischar(varargin{1})    gui_State.gui_Callback = str2func(varargin{1});endif nargout    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});else    gui_mainfcn(gui_State, varargin{:});end% End initialization code - DO NOT EDIT% --- Executes just before xingyingzhengduan is made visible.function xingyingzhengduan_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, see OutputFcn.% hObject    handle to figure% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% varargin   command line arguments to xingyingzhengduan (see VARARGIN)% Choose default command line output for xingyingzhengduanhandles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes xingyingzhengduan wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = xingyingzhengduan_OutputFcn(hObject, eventdata, handles) % varargout  cell array for returning output args (see VARARGOUT);% hObject    handle to figure% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Get default command line output from handles structurevarargout{1} = handles.output;%==========================================================================%handles.DoorHeartSoundsAfterShann = DoorPa;handles.DoorHeartSoundsAfterShannT = (1:1:length(DoorPa)).*22/2205;handles.NumSick = 0;if (handles.numCanyonMax3 >2 ||handles.numCanyonMin3 >3)||((handles.numCanyonMax3 ==1) && (handles.numCanyonMax3+handles.numCanyonMin3)>4) %设置分裂基准数    handles.NumSick = handles.NumSick+1;    handles.SickDescribe(handles.NumSick,1:9) = '心音存在分裂   ';endif (handles.numCanyonMax5 >1 ||handles.numCanyonMin5 >3)||((handles.numCanyonMax5 ==1) && (numCanyonMax5+numCanyonMin5)>3) %设置分裂基准数    handles.NumSick = handles.NumSick+1;    handles.SickDescribe(handles.NumSick,1:9) ='心音存在严重分裂 ';endif handles.S1RangeAverage<0.08    handles.NumSick = handles.NumSick+1;    handles.SickDescribe(handles.NumSick,1:9) ='第一心音狭窄   ';else if handles.S1RangeAverage>0.12         handles.NumSick = handles.NumSick+1;         handles.SickDescribe(handles.NumSick,1:9) ='第一心音肥厚   ';    endendif handles.S2RangeAverage<0.08    handles.NumSick = handles.NumSick+1;     handles.SickDescribe(handles.NumSick,1:9) = '第二心音狭窄   ';else if handles.S2RangeAverage>0.12         handles.NumSick = handles.NumSick+1;         handles.SickDescribe(handles.NumSick,1:9) ='第二心音肥厚   ';    endendif (handles.S1AndS2DoorRange<0.3)||(handles.S1AndS2DoorRange>0.5)     handles.NumSick = handles.NumSick+1;        handles.SickDescribe(handles.NumSick,1:9) ='第一二心音间隔异常';end    if (handles.S1ToS1DoorRange<0.7)||(handles.S1AndS2DoorRange>0.9)     handles.NumSick = handles.NumSick+1;        handles.SickDescribe(handles.NumSick,1:9) ='心动周期间隔异常 ';end      set(handles.describe, 'string' , handles.SickDescribe);   if handles.NumSick>2    set(handles.result, 'string' , '心音异常--仅供参考');    set(handles.advise, 'string' , '请根据自身情况尽早去医院检查--仅供参考');else    set(handles.result, 'string' , '心音正常--仅供参考');    set(handles.advise, 'string' , '您很健康,祝您身体健康!--仅供参考');endguidata(hObject , handles);%=========================================================================%% --- Executes on button press in pushbutton19.function pushbutton19_Callback(hObject, eventdata, handles)% hObject    handle to pushbutton19 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --- Executes on button press in Shannon.function Shannon_Callback(hObject, eventdata, handles)% hObject    handle to Shannon (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)if(get(hObject,'Value')==get(hObject,'Max')) %被选中了的操作    set(findobj('Tag','Threshold'),'enable','off');    set(findobj('Tag','DownThreshold'),'enable','off');    set(findobj('Tag','ChangeThreshold'),'enable','off');    hold off;    plot(handles.axes1,handles.HeartSoundsAfterShanT,handles.HeartSoundsAfterShan);    title('香农能量分布');else    set(findobj('Tag','Threshold'),'enable','on');    set(findobj('Tag','DownThreshold'),'enable','on');    set(findobj('Tag','ChangeThreshold'),'enable','on');end    % Hint: get(hObject,'Value') returns toggle state of Shannon% --- Executes on button press in S1OrS2Door.function S1OrS2Door_Callback(hObject, eventdata, handles)% hObject    handle to S1OrS2Door (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)if(get(hObject,'Value')==get(hObject,'Max')) %被选中了的操作    set(findobj('Tag','Threshold'),'enable','on');    set(findobj('Tag','DownThreshold'),'enable','on');    set(findobj('Tag','ChangeThreshold'),'enable','on');    hold off;    plot(handles.axes1,handles.DoorHeartSoundsAfterShannT,handles.DoorHeartSoundsAfterShann);    axis([0 , max(handles.DoorHeartSoundsAfterShannT),-0.2 ,1.2]);title('S1,S2时间门');else    set(findobj('Tag','Threshold'),'enable','of');    set(findobj('Tag','DownThreshold'),'enable','of');    set(findobj('Tag','ChangeThreshold'),'enable','of');end% Hint: get(hObject,'Value') returns toggle state of S1OrS2Door% --- Executes on button press in NoiseDown.function NoiseDown_Callback(hObject, eventdata, handles)% hObject    handle to NoiseDown (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)if(get(hObject,'Value')==get(hObject,'Max')) %被选中了的操作  set(findobj('Tag','Threshold'),'enable','off');  set(findobj('Tag','DownThreshold'),'enable','off');  set(findobj('Tag','ChangeThreshold'),'enable','off');  hold off;  plot(handles.axes1,handles.HeartSoundsNoiseDownT,handles.HeartSoundsNoiseDown);title('强制降噪后');else     set(findobj('Tag','Threshold'),'enable','on');     set(findobj('Tag','DownThreshold'),'enable','on');     set(findobj('Tag','ChangeThreshold'),'enable','on');end% Hint: get(hObject,'Value') returns toggle state of NoiseDownfunction DownThreshold_Callback(hObject, eventdata, handles)% hObject    handle to DownThreshold (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 DownThreshold as text%        str2double(get(hObject,'String')) returns contents of DownThreshold as a double% --- Executes during object creation, after setting all properties.function DownThreshold_CreateFcn(hObject, eventdata, handles)% hObject    handle to DownThreshold (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.%       See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor','white');end% --- Executes on button press in ViewTogetherNoiseAndOriganl.function ViewTogetherNoiseAndOriganl_Callback(hObject, eventdata, handles)% hObject    handle to ViewTogetherNoiseAndOriganl (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)hold off;    plot(handles.axes1,handles.HeartSoundsOriginalCutT ,handles.HeartSoundsOriginalCut,'r--');    axis([0,max(handles.HeartSoundsOriginalCutT) ,min(handles.HeartSoundsOriginalCut)*1.1, max(handles.HeartSoundsOriginalCut)*1.1]);    hold on;plot(handles.axes1,handles.HeartSoundsNoiseDownT,handles.HeartSoundsNoiseDown);% --- Executes on button press in ViewTogetherShanAndDoor.function ViewTogetherShanAndDoor_Callback(hObject, eventdata, handles)% hObject    handle to ViewTogetherShanAndDoor (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)hold off;plot(handles.axes1,handles.HeartSoundsAfterShanT,handles.HeartSoundsAfterShan);hold on;plot(handles.axes1,handles.DoorHeartSoundsAfterShannT,handles.DoorHeartSoundsAfterShann,'g--');axis([0 , max(handles.DoorHeartSoundsAfterShannT),min(handles.HeartSoundsAfterShan) ,max(handles.HeartSoundsAfterShan)]);title('S1,S2时间门');% --- Executes on button press in Db6Division.function Db6Division_Callback(hObject, eventdata, handles)% hObject    handle to Db6Division (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)figure(2),subplot(221),plot(handles.td1,handles.cd1) ,axis([0,max(handles.td1) ,-handles.cmax , handles.cmax]),...    title('cd1:551--1102Hz'),subplot(222 ) , plot(handles.td2 ,handles.cd2), axis([0,max(handles.td1) ,-handles.cmax , handles.cmax]),...    title('cd2:275--551Hz'),subplot(223),plot(handles.td3,handles.cd3),axis([0,max(handles.td1) ,-handles.cmax , handles.cmax]),title('cd3:138--275Hz'),...subplot(224),plot(handles.ta3,handles.ca3),axis([0,max(handles.td1) ,-handles.cmax , handles.cmax]),title('ca3:0--138Hz');% --- Executes during object creation, after setting all properties.function uipanel5_CreateFcn(hObject, eventdata, handles)% hObject    handle to uipanel5 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called

3 仿真结果

【心电信号】基于matlab实现心音诊断系统含GUI_第1张图片

4 参考文献

[1]王东. 基于心音和心电的心功能检测系统研究[D]. 重庆大学, 2010.

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

部分理论引用网络文献,若有侵权联系博主删除。

你可能感兴趣的