function varargout = EMG(varargin)
% EMG M-file for EMG.fig
% EMG, by itself, creates a new EMG or raises the existing
% singleton*.
%
% H = EMG returns the handle to a new EMG or the handle to
% the existing singleton*.
%
% EMG('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in EMG.M with the given input arguments.
%
% EMG('Property','Value',...) creates a new EMG or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before EMG_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to EMG_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 EMG
% Last Modified by GUIDE v2.5 26-May-2009 19:09:27
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @EMG_OpeningFcn, ...
'gui_OutputFcn', @EMG_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 EMG is made visible.
function EMG_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 EMG (see VARARGIN)
% Choose default command line output for EMG
handles.output = hObject;
handles.name='';
handles.path='';
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes EMG wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = EMG_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;
% --------------------------------------------------------------------
function file_Callback(hObject, eventdata, handles)
% hObject handle to file (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function open_Callback(hObject, eventdata, handles)
% hObject handle to open (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[name path]= uigetfile ( '*.zip','Select test data file');
set(handles.text4,'string',name)
handles.name=name;
handles.path=path;
guidata(hObject, handles);
% --- Executes on button press in pbtn1.
function pbtn1_Callback(hObject, eventdata, handles,data)
% hObject handle to pbtn1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
u=get(handles.rdb1,'value');
string =[handles.path,handles.name];
channel= get(handles.pop1,'value');
if isempty(string)
errordlg('Select a test data file befor run ( File>open )','File not selected');
end
[ ch_names, ch_data ] = read_file( string );
b=ch_data(:,channel);
if u
set(handles.uipanel7,'Title','RMS Smoothing')
a=abs(b);
s=0;
p=1;
window=200;
k=window-1;
rmsEMG=[];
r=length(a)-window;
for j=1:r
rms=0;
for i=j:j+k
rms=rms+a(i)^2;
end
rmsEMG(j)=sqrt(rms/window);
end
[MaximumRMS WindowNo]=max(rmsEMG);
RMS=MaximumRMS;
if p
plot(handles.axes1,a)
MaxWindowEnd=WindowNo+199;
DataRange=strvcat(['Max. RMS Window : [',num2str(WindowNo),' ',num2str(MaxWindowEnd),']'],...
[' '],['RMS-max = ',num2str(MaximumRMS)]);
plot(handles.axes2,rmsEMG)
set(handles.text6,'string',DataRange)
nft = 2^nextpow2(length(b));
Y = fft(b,nft)/length(b);
f = 1000/2*linspace(0,1,nft/2);
plot(handles.axes3,f,2*abs(Y(1:nft/2)))
xlabel('Frequency (Hz)')
end
s=load('rms_max','rmsmax');
ss=load('rms_min','rmsmin');
rmsMax=s.rmsmax;
rmsMin=ss.rmsmin;
alpha=(RMS-rmsMin)/(rmsMax-rmsMin)
set(handles.text1,'string',num2str(alpha))
else
set(handles.uipanel7,'Title','Int. Smoothing')
a=abs(b);
plt=1;
EMGIntegral=[];
window=200;
k=window-1;
r=length(a)-window;
for j=1:r
WindowIntegral=0;
for i=j:j+k
WindowIntegral=WindowIntegral+0.5*0.001*(a(i)+a(i+1));
end
EMGIntegral(j)=WindowIntegral;
end
[MaximumINT WindowNo]=max(EMGIntegral);
INT=MaximumINT;
if plt
plot(handles.axes1,a)
legend('EMG row data');
plot(handles.axes2,EMGIntegral)
legend('Integral-Smoothing')
MaxWindowEnd=WindowNo+199;
DataRange=strvcat(['Max. INT Window : [',num2str(WindowNo),' ',num2str(MaxWindowEnd),']'],...
[' '],['Int-max = ',num2str(MaximumINT)]);
set(handles.text6,'string',DataRange)
nft = 2^nextpow2(length(b));
Y = fft(b,nft)/length(b);
f = 1000/2*linspace(0,1,nft/2);
plot(handles.axes3,f,2*abs(Y(1:nft/2)))
xlabel('Frequency (Hz)');
end
s=load('int_max','intmax');
ss=load('int_min','intmin');
intMax=s.intmax;
intMin=ss.intmin;
alpha=(INT-intMin)/(intMax-intMin);
set(handles.text1,'string',num2str(alpha))
set(handles.uipanel7,'string','Int. Smoothing')
end
% --------------------------------------------------------------------
function exit_Callback(hObject, eventdata, handles)
% hObject handle to exit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
delete('rms_min.mat');
delete('rms_max.mat');
delete('int_min.mat');
delete('int_max.mat');
clc
close(gcbf)
% --- 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)
u=get(handles.rdb1,'value');
if u
% ----------- gaving MVC data ----------------
[name path]= uigetfile ( '*.zip','Select MVC data file');
string =[path,name];
channel= get(handles.pop1,'value');
[ ch_names, ch_data ] = read_file( string );
b=ch_data(:,channel);
rmsmax =RMS_EMG(b,0);
save('rms_max','rmsmax')
% --------- giving resting data -------------
[name path]= uigetfile ( '*.zip','Select Resting data file');
string =[path,name];
channel= get(handles.pop1,'value');
[ ch_names, ch_data ] = read_file( string );
b=ch_data(:,channel);
rmsmin =RMS_EMG_min(b);
save('rms_min','rmsmin')
else
% ----------- gaving MVC data ----------------
[name path]= uigetfile ( '*.zip','Select MVC data file');
string =[path,name];
channel= get(handles.pop1,'value');
[ ch_names, ch_data ] = read_file( string );
b=ch_data(:,channel);
intmax =INT_EMG(b,0);
save('int_max','intmax');
% --------- giving resting data -------------
[name path]= uigetfile ( '*.zip','Select Resting data file');
string =[path,name];
channel= get(handles.pop1,'value');
intmin =INT_EMG_min(b);
save('int_min','intmin')
end
EMG.rar_EMG MATLAB_EMG_matlab_emg activation_emg gui_emg_activat
版权申诉
5星 · 超过95%的资源 6 浏览量
2022-09-22
20:28:33
上传
评论 2
收藏 18KB RAR 举报
小贝德罗
- 粉丝: 69
- 资源: 1万+
最新资源
- 基于OpenCV的案例:图像边缘、角点和轮廓检测,图像分割,图像增强;图片拼接;运动目标检测,颜色直方图比较,三帧帧差法,抠图
- SmartPlug-html大一笔记
- SmartPlug-proteusdemo
- Preliminary Findings on Handmade Rattan Baby Crib andBassinet Designs Regarding.zip
- aveebfq_v1.2.83_downyi.com.apk
- 基于有机发光二极管(OLED)的建模优化算法的matlab仿真源码+数据+文档说明+项目说明(高分课程设计)
- hash01-test.c 本人哈希表(一)的示例代码,仅供参考!
- 处理数据.py
- 软件实施计划表.xls
- 软件开发应用软件项目提交文档目录要求(全过程)(推荐文档).xls
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈