Clinical Biomechanics Research Group MATLAB Help
Analysis of Electromyographic Data This webpage provides basic information on how electromyographic (EMG) data can be analysed using MatLab MatLab.. You will need MatLab Version 7.0 or later and the associated Signal Processing Toolbox. Toolbox . You may right-click right-click an example example of emg signals - emg.txt - to try out the commands described below. Loading the EMG data into the MATLAB environment y=load('emg.txt'); y is the variable (vector) (vector) that contains the EMG data. Plotting the data plot(y) xlabel('Sample number') ylabel('EMG signal') You will obtain obtain the following following graph.
Remove any DC offset of the signal y2=detrend(y); y2 is the signal without DC offset. Rectification of the EMG signal rec_y=abs(y2); plot(rec_y) xlabel('Sample number') ylabel('Rectified EMG signal')
rec_y is the rectified signal. You will obtain the following graph.
Linear Envelope of the EMG signal You need to construct a low pass filter of a cut off frequency of say, 10Hz. In this example, the sampling frequency is 1000Hz, and we shall use the 5th order filter. [b,a]=butter(5,10/1000,'low'); The next step is to filter the signals to obtain the linear envelope. The command filtfilt performs filtering in both directions to eliminate any phase shift of the signal. filter_y=filtfilt(b,a,rec_y); plot(filter_y) xlabel('Sample number') ylabel('Low Pass Filtered EMG signal') filt_y is the filtered signal. You should obtain the following.
Detection of onset of muscle contraction You will need to right click and download the m-file onset.m for carrying out this analysis. onset_time=onset(filter_y,500,1000,1000,5000) In this example, (500,1000) are the beginning and end of the sample which refers to the muscle at rest. (1000,5000) are the beginning and end of the sample which is to be analysed. onset_time is the onset time. You should obtain the following graph.
Type help onset if you need help or further information. Fourier Transform (FFT) of the EMG signals You will need to right click and downlaod the m-file psanalyse.m for carrying out this analysis. mf=psanalyse(y2,1000) In this example, we assume a sampling frequency of 1000Hz. This command will compute the median frequency ( mf) of the FFT spectrum which is often employed for analysing muscle fatigue. An FFT plot will be produced as shown below. The plot is very useful in examining the frequency content of the signals, for instance, if there is any dominant noise of 50Hz due to the mains and its harmonics. The following plot shows that the signal is possibly contaminated by the mains.
Saving processed data The following example illustrates how you can save the linear envelope of the signal (filter_y ) in ASCII format using the filename 'filteremg.dat'. The ASCII file may be read by many other data processing software, such as EXCEL. save 'filteremg.dat' filter_y - ascii
Last Update: July 2006 Clinical Biomechanics Research Group, Clinical Research Centre for Health Professions, University of Brighton, 49 Darley Road, Eastbourne, East Sussex, BN20 7UR, UK. Tel: +44 (0)1273 6443647 Fax: +44 (0)1273 6443944