肌电信号的时域和频域分析

更新时间:2023-11-04 00:36:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

肌电信号的时域和频域分析

摘要:肌电信号是产生肌肉力的电信号根源,它是肌肉中很多运动单元动作电 位在时间和空间上的叠加,反映了神经,肌肉的功能状态,在基础医学研究、 临床诊断和康复工程中有广泛的应用。

其种类重要有两种:一,临床肌电图检查多采用针电极插入肌肉检测肌 电图,其优点是干扰小,定位性好,易识别,但由于它是一种有创伤的检测 方法,其应用收到了一定的限制。二,表面肌电则是从人体皮肤表面通过电 极记录下来的神经肌肉活动时发放的生物电信号,属于无创伤性,操作简单, 病人易接受,有着广泛的应用前景。

本次设计基于matlab用小波变换对肌电信号进行消噪处理,分别选用20N的肌电信号数据和50N的肌电数据进行对比,最后在GUI界面上完成相应的功能处理。

关键字:肌电信号 Matlab 小波去噪 GUI

第一章 绪论

肌电信号是产生肌肉力的电信号根源,它是肌肉中很多运动单元动作电位 在 时 间 和 空 间 上 的 叠 加,反 映 了 神 经,肌 肉 的 功 能 状 态,在基础医学研究、临床诊断和康复工程中有广泛的应用。

其种类重要有两种:一,临床肌电图检查多采用针电极插入肌肉检测肌电图,其优点是干扰小,定位性好,易识别,但由于它是一种有创伤的检测方法,其应用收到了一定的限制。二,表面肌电则是从人体皮肤表面通过电极记录下来的神经肌肉活动时发放的生物电信号,属于无创伤性,操作简单,病人易接受,有着广泛的应用前景。

肌电信号本身是一种较微弱的电信号。检测和记录表面肌电信号,需要考虑的主要问题是尽量消除噪声和干扰的影响, 提高信号的保真度[1] 。

第二章 肌电信号的时域分析

2.1 肌电信号时域图的显示及比较

肌电信号采用两个不同的数据进行比较,通过比较时域图及其特性来进行

分析[2]。其图像如下所示:

如上图所示:肌电数据分别是同一个体在20N的力和50N的力所反映的图像。可以看出在不同作用力时,其图像的差别很大。

2.2 时域参数

2.2.1 均值

对于一个随机变量来说,均值是一个很重要的数值特征。粗略的说,就是来描述一个群体的平均水平。其严格的数学定义非常的简单,就是一个随机变量关于概率测度的积分。这样的积分在测度轮或者实分析里是没有什么直观的解释的。而在概率论里却成为了一个群体的主要指标。在此处,均值表示肌电信号的平均水平。 2.2.2 标准差

标准差(Standard Deviation),也称均方差(mean square error),是各数据偏离平均数的距离的平均数,它是离均差平方和平均后的方根,用σ表示。

2

标准差是方差的算术平方根。标准差能反映一个数据集的离散程度。平均数相同的,标准差未必相同。 2.2.3 方差

方差是各个数据与平均数之差的平方的平均数。在概率论和数理统计中,方(英文Variance)用来度量随机变量和其数学期望(即均值)之间的偏离程度。在许多实际问题中,研究随机变量和均值之间的偏离程度有着很重要的意义。

选取一个信号,其执行结果如下所示:

其部分程序代码如下所示:

clear; clc;

s=load('E:\\肌电信号数据\\EMG\\EMG3.txt'); %s=load('E:\\肌电信号数据\\EMG\\bs1.txt'); a=s(:,7); t=s(:,1);

fprintf('\\n数据基本信息:\\n');

fprintf(' 均值=%7.5f\\n',mean(a));

fprintf(' 标准差=%7.5f\\n',sqrt(var(a))); fprintf(' 方差=%7.5f\\n',var(a));

fprintf(' 积分肌电值IEMG=%7.5f\\n',mean(abs(a))); fprintf(' 均方跟有效值RMS=%7.5f\\n',sqrt(mean(a.^2)));

3

第三章 肌电信号的时域分析

3.1 傅里叶变换

傅里叶是离散傅立叶变换的快速算法,可以将一个信号变换到频域。有些信号在时域上是很难看出什么特征的,但是如果变换到频域之后就很容易看出特征了。另外,FFT可以将一个信号的频谱提取出来,这在频谱分析方面也是经常用的。一个模拟信号,经过ADC采样之后,就变成了数字信号。采样得到的数字信号,就可以做FFT变换了。N个采样点,经过FFT之后,就可以得到N个点的FFT结果。本次设计选取N=20000来进行肌电信号的频域分析[3]。

通过傅里叶变换后,两个不同信号的幅频图如下所示:

肌电相频图如下所示:

4

3.2 功率谱分析

能量谱密度、功率谱密度函数表示信号的能量、功率密度随频率变化的情况。通过研究功率谱密度,可以帮助了解信号的功率分布情况,确定信号的频带等。 功率密度谱虽然描述了随机信号的功率在各个不同频率上的分布,但因为它仅与幅度频谱有关,没有相位信息,所以从已知功率谱还难以完整地恢复原来的功率信号。

通过执行相应程序后,其功率谱的显示图如下所示:

其部分程序代码如下所示: global a; global t;

5

thr2=thselect(cD2,'rigrsure'); thr3=thselect(cD3,'rigrsure'); TR=[thr1,thr2,thr3]; SORH='s';

[XC,CXC,LXC,PERFO,PERF2]=wdencmp('lvd',a,... 'db5',3,TR,SORH); y1=fft(XC,2000); fs=2000; N=length(y1);

mag=abs(y1); f=(0:N-1)/N*fs; power2=(mag.^2)/2000; plot(handles.axes5,power2);

16

第五章 GUI界面的设计

GUI是由窗口、光标、按键、菜单、文字说明等对象(Objects)构成的一个用户界面。用户通过一定的方法(如鼠标或键盘)选择、激活这些图形对象,使计算机产生某种动作或变化,比如实现计算、绘图等。一个好的GUI 能够使程序更加容易的使用。它提供用户一个常见的界面,还提供一些控件,例如,按钮,列表框,滑块,菜单等。用户图形界面应当是易理解且操作是可以预告的,所以当用户进行某一项操作,它知道如何去做。例如,当鼠标在一个按钮上发生了单击事件,用户图形界面初始化它的操作,并在按钮的标签上对这个操作进行描述。

本次设计的GUI界面整体图如下所示:

程序运行之后产生的界面图如下所示:

17

本次设计模块涵盖多个功能,都是通过按钮来进行相应的信号处理。只要M

文件在当前目录或在Matlab搜索路径上,在Matlab命令窗口输入对应的M文件,就能打如上图所示的图形用户界面。在此界面上可以进行相关的操作。

例如点击open按扭就会打开如下界面:

18

Open按钮的回调函数如下填写:

[filename,filepath]=uigetfile('*.txt','选择文件');%选择数据文件 str=[filepath filename];

其他的按钮都按照此方法去激活,以实现相应的功能。

学习心得

通过这次设计,我对MATLAB有了更深入的理解,学会了在GUI界面通过按钮来实现相应的功能,对以前未接触的小波变换也有了大概了解。

在设计的过程中,我也认识到了自己所学知识的不足。这也让我再次认识到知识是无尽的,只有不断的充实自己、完善自己的知识理论体系,才能够更好的胜任自己以后的工作。设计过程中知识的不足也让我更加坚定了终身学习的决心。

1.谢平、王娜、林洪斌等主编,信号处理原理及应用。北京:机械工业出版社, 2008.10

参考文献

19

2. 聂祥飞、王海宝、谭泽富主编,Matlab程序设计及其在信号处理中的应用。 成都:西南交通大学出版社,2005

3.吴大正、高西全等主编,Matlab及在电子信息课程中的应用。北京:电子工业出版社,2006.3

4.李培芳、孙晖、李江主编,信号与系统分析基础。北京:清华大学出版社,2006.12

程序附录

function varargout = a1fig(varargin) gui_Singleton = 1;

gui_State = struct('gui_Name', mfilename, ...

'gui_Singleton', gui_Singleton, ...

'gui_OpeningFcn', @a1fig_OpeningFcn, ... 'gui_OutputFcn', @a1fig_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 a1fig is made visible.

function a1fig_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 a1fig (see VARARGIN)

% Choose default command line output for a1fig handles.output = hObject;

20

% Update handles structure guidata(hObject, handles);

% UIWAIT makes a1fig wait for user response (see UIRESUME) % uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line. function varargout = a1fig_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 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 s; global a; global t;

[filename,filepath]=uigetfile('*.txt','选择文件');%选择数据文件 str=[filepath filename]; s=load(str); a=s(:,7); t=s(:,1);

% --- 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) try

delete(allchild(handles.axes1)); end

21

% --- 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 a; global t;

plot(handles.axes1,t,a);title('信号1');

% --- 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) global a; global t; global y;

%a=EMG3(1:points,2);

y=fft(a,20000); %对信号进行快速Fourier变换 fs=2000;

N=length(y);

mag=abs(y);%求得Fourier变换后的振幅 f=(0:N-1)/N*fs; %频率序列

plot(handles.axes1,f,mag);%绘制图形

% --- 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 a; global t; global y; fs=2000;

N=length(y); f=(0:N-1)/N*fs;

plot(handles.axes1,f,angle(y));

% --- Executes on button press in pushbutton6.

function pushbutton6_Callback(hObject, eventdata, handles)

22

% 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) %小波去噪 global a; global t; global s; global y; % global IR; % global SORH; M =length (a) ; N=length(y); p=size(a); s=a(1:20000);

[C L]=wavedec(a,4,'db5'); cA3=appcoef(C,L,'db5',4); cD1=detcoef(C,L,1); cD2=detcoef(C,L,2); cD3=detcoef(C,L,3); cD4=detcoef(C,L,4);

thr1=thselect(cD1,'rigrsure'); thr2=thselect(cD2,'rigrsure'); thr3=thselect(cD3,'rigrsure'); thr4=thselect(cD4,'rigrsure'); TR=[thr1,thr2,thr3,thr4]; SORH='s';

[XC,CXC,LXC,PERFO,PERF2]=wdencmp('lvd',a,... 'db5',4,TR,SORH); L=p(2); x=a; h=XC; F=0; M=0;

for ii=1:L

m(ii)=(x(ii)-y(ii))^2; t(ii)=y(ii)^2;

f(ii)=t(ii)/m(ii); F=F+f(ii); M=M+m(ii); end;

SNR=10*log10(F); MSE=M/N; SM=SNR/MSE; % K=length(d);

23

% t1=(0:K-1)/2000;

plot(handles.axes5,XC(1:20000));

% --- 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 % handles structure with handles and user data (see GUIDATA) %去噪后幅频 global a; global t; %global h;

[C L]=wavedec(a,3,'db5'); cA3=appcoef(C,L,'db5',3); cD1=detcoef(C,L,1); cD2=detcoef(C,L,2); cD3=detcoef(C,L,3);

thr1=thselect(cD1,'rigrsure'); thr2=thselect(cD2,'rigrsure'); thr3=thselect(cD3,'rigrsure'); TR=[thr1,thr2,thr3]; SORH='s';

[XC,CXC,LXC,PERFO,PERF2]=wdencmp('lvd',a,... 'db5',3,TR,SORH); y1=fft(XC,20000); fs=2000;

N=length(y1); mag1=abs(y1); f=(0:N-1)/N*fs;

plot(handles.axes5,f,mag1);

% --- Executes on button press in pushbutton8.

function pushbutton8_Callback(hObject, eventdata, handles) % hObject handle to pushbutton8 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) %去噪后相频 global a; global t;

[C L]=wavedec(a,3,'db5'); cA3=appcoef(C,L,'db5',3);

24

cD1=detcoef(C,L,1); cD2=detcoef(C,L,2); cD3=detcoef(C,L,3);

thr1=thselect(cD1,'rigrsure'); thr2=thselect(cD2,'rigrsure'); thr3=thselect(cD3,'rigrsure'); TR=[thr1,thr2,thr3]; SORH='s';

[XC,CXC,LXC,PERFO,PERF2]=wdencmp('lvd',a,... 'db5',3,TR,SORH); y1=fft(XC,20000); fs=2000;

N=length(y1); mag1=abs(y1); f=(0:N-1)/N*fs;

plot(handles.axes5,f,angle(y1));

% --- Executes on button press in pushbutton9.

function pushbutton9_Callback(hObject, eventdata, handles) % hObject handle to pushbutton9 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) %功率谱 global a; global t; global s;

s=fft(a,2000);

[C L]=wavedec(a,3,'db5'); cA3=appcoef(C,L,'db5',3); cD1=detcoef(C,L,1); cD2=detcoef(C,L,2); cD3=detcoef(C,L,3);

thr1=thselect(cD1,'rigrsure'); thr2=thselect(cD2,'rigrsure'); thr3=thselect(cD3,'rigrsure'); TR=[thr1,thr2,thr3]; SORH='s';

[XC,CXC,LXC,PERFO,PERF2]=wdencmp('lvd',a,... 'db5',3,TR,SORH); y1=fft(XC,20000); fs=2000;

N=length(y1);

25

mag=abs(s);

f=(0:N-1)/N*fs;

power1=(mag.^2)/2000;

plot(handles.axes1,power1);

% --- Executes on button press in pushbutton10.

function pushbutton10_Callback(hObject, eventdata, handles) % hObject handle to pushbutton10 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global a; global t; global s;

s=fft(a,2000);

[C L]=wavedec(a,3,'db5'); cA3=appcoef(C,L,'db5',3); cD1=detcoef(C,L,1); cD2=detcoef(C,L,2); cD3=detcoef(C,L,3);

thr1=thselect(cD1,'rigrsure'); thr2=thselect(cD2,'rigrsure'); thr3=thselect(cD3,'rigrsure'); TR=[thr1,thr2,thr3]; SORH='s';

[XC,CXC,LXC,PERFO,PERF2]=wdencmp('lvd',a,... 'db5',3,TR,SORH); y1=fft(XC,2000); fs=2000;

N=length(y1);

mag=abs(y1); f=(0:N-1)/N*fs;

power2=(mag.^2)/2000;

plot(handles.axes5,power2);

% --- Executes on button press in pushbutton11.

function pushbutton11_Callback(hObject, eventdata, handles) % hObject handle to pushbutton11 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global a; x=mean(a);

26

set(handles.edit1,'string',x);

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 pushbutton12.

function pushbutton12_Callback(hObject, eventdata, handles) % hObject handle to pushbutton12 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global a;

x=sqrt(var(a));

set(handles.edit2,'string',x);

function edit2_Callback(hObject, eventdata, handles) % hObject handle to edit2 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

27

% Hints: get(hObject,'String') returns contents of edit2 as text % str2double(get(hObject,'String')) returns contents of edit2 as a double

% --- Executes during object creation, after setting all properties. function edit2_CreateFcn(hObject, eventdata, handles) % hObject handle to edit2 (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 pushbutton13.

function pushbutton13_Callback(hObject, eventdata, handles) % hObject handle to pushbutton13 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

global a; x=(var(a));

set(handles.edit3,'string',x);

function edit3_Callback(hObject, eventdata, handles) % hObject handle to edit3 (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 edit3 as text % str2double(get(hObject,'String')) returns contents of edit3 as a double

% --- Executes during object creation, after setting all properties. function edit3_CreateFcn(hObject, eventdata, handles) % hObject handle to edit3 (see GCBO)

28

% 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 pushbutton14.

function pushbutton14_Callback(hObject, eventdata, handles) % hObject handle to pushbutton14 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

global a;

x=mean(abs(a));

set(handles.edit4,'string',x);

function edit4_Callback(hObject, eventdata, handles) % hObject handle to edit4 (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 edit4 as text % str2double(get(hObject,'String')) returns contents of edit4 as a double

% --- Executes during object creation, after setting all properties. function edit4_CreateFcn(hObject, eventdata, handles) % hObject handle to edit4 (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');

29

end

% --- Executes on button press in pushbutton15.

function pushbutton15_Callback(hObject, eventdata, handles) % hObject handle to pushbutton15 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

global a;

x=sqrt(mean(a.^2));

set(handles.edit5,'string',x);

function edit5_Callback(hObject, eventdata, handles) % hObject handle to edit5 (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 edit5 as text % str2double(get(hObject,'String')) returns contents of edit5 as a double

% --- Executes during object creation, after setting all properties. function edit5_CreateFcn(hObject, eventdata, handles) % hObject handle to edit5 (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 pushbutton17.

function pushbutton17_Callback(hObject, eventdata, handles) % hObject handle to pushbutton17 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global n;

30

本文来源:https://www.bwwdw.com/article/g0w2.html

Top