一、心电信号预处理方法简介
理论知识参考文献:心电信号预处理方法研究
二、部分源代码
function varargout = kaishi(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @kaishi_OpeningFcn, ...
'gui_OutputFcn', @kaishi_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before kaishi is made visible.
function kaishi_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 kaishi (see VARARGIN)
% Choose default command line output for kaishi
%handles.output = hObject;
ha=axes('units','normalized','position',[0 0 1 1]);
colormap gray
set(ha,'handlevisibility','off','visible','off');
% Update handles structure
global xd;
handles.output = xd;
guidata(hObject, handles);
% UIWAIT makes kaishi wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = kaishi_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 structure
varargout{1} = handles.output;
% --- Executes on button press in xhxz.
function xhxz_Callback(hObject, eventdata, handles)
% hObject handle to xhxz (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global m;
global xd;
global a;
global n;
n=25000;
[filename, pathname,index] = uigetfile('*.txt', '请选择信号');
m=index;
if isequal(filename,0)
f = errordlg('没有选择有效信号', '注意!', 'modal');
else
f1=importdata(filename);
plot(xd);
title('选取的心电信号');
end
% --- Executes on button press in exit_1.
function exit_1_Callback(hObject, eventdata, handles)
% hObject handle to exit_1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close(gcf);
% --- Executes during object creation, after setting all properties.
function figure1_CreateFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% --- Executes on button press in FD.
function FD_Callback(hObject, eventdata, handles)
% hObject handle to FD (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%xd=a(13000:5:25000);
%plot(xd);
% --- Executes on button press in SX.
function SX_Callback(hObject, eventdata, handles)
% hObject handle to SX (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 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)
global m;
XZLB;
else
f0 = errordlg('没有选择有效信号', '注意!', 'modal');
end
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
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (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 pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton6 (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 pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
close(gcf);
JGXS;
% --- Executes on button press in FD1.
function FD1_Callback(hObject, eventdata, handles)
% hObject handle to FD1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global xd;
global a;
global n;
global c;
if n>15000
n=n-2000;
else
n=n;
end
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @XBQZCS_OpeningFcn, ...
'gui_OutputFcn', @XBQZCS_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if 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 XBQZCS is made visible.
function XBQZCS_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 XBQZCS (see VARARGIN)
% Choose default command line output for XBQZCS
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
ha=axes('units','normalized','position',[0 0 1 1]);
uistack(ha,'down')
II=imread('aa6.jpg');%里面的参数可以是你自己的图片,把名字连同格式写进去就可以了
image(II)
colormap gray
set(ha,'handlevisibility','off','visible','off');
% UIWAIT makes XBQZCS wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = XBQZCS_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 structure
varargout{1} = handles.output;
% --- Executes on button press in goon_2.
function goon_2_Callback(hObject, eventdata, handles)
% hObject handle to goon_2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close(gcf);
JGXS;
% --- Executes on button press in exit_5.
function exit_5_Callback(hObject, eventdata, handles)
% hObject handle to exit_5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close(gcf);
XZLB;
% --- Executes when selected object is changed in uipanel3.
function uipanel3_SelectionChangeFcn(hObject, eventdata, handles)
% hObject handle to the selected object in uipanel3
% eventdata structure with the following fields (see UIBUTTONGROUP)
% EventName: string 'SelectionChanged' (read only)
% OldValue: handle of the previously selected object or empty if none was selected
% NewValue: handle of the currently selected object
% handles structure with handles and user data (see GUIDATA)
global xd;
global Y1;
tString=get(hObject,'tag');
switch tString
case 'sym_4'
Y1=wden(xd,'heursure','s','one',3,'sym4'); %进行相应的操作
case 'sym_6'
Y1=wden(xd,'heursure','s','one',3,'sym6');%进行相应的操作
case 'sym_8'
Y1=wden(xd,'heursure','s','one',3,'sym8');%进行相应的操作
case 'sym_10'
Y1=wden(xd,'heursure','s','one',3,'sym10'); %进行相应的操作
end
三、运行结果
四、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1] 沈再阳.精通MATLAB信号处理[M].清华大学出版社,2015.
[2]高宝建,彭进业,王琳,潘建寿.信号与系统——使用MATLAB分析与实现[M].清华大学出版社,2020.
[3]王文光,魏少明,任欣.信号处理与系统分析的MATLAB实现[M].电子工业出版社,2018.
[4]王旭,钱伟,余宇帆.心电信号预处理方法研究[J].中国医学工程. 2018,26(12)