Semi-automatic muscle activation segmentation from sEMG
Post: 2020.05.08 16:39
General description
The following algorithm includes code for averaging sEMG data recorded from periodic tasks. Technical details were published here. The code works for single or multi-channel sEMG data. In the following lines, a sample script will be run using test data. Details about data formatting will be provided so other authors can adapt their data to the script provided.
Data format
Current code requires data files containing EMG signals recorded during periodic motion. Moreover, each file must contain information about the data sampling rate.
Each data file must be a ‘.mat’ structure named ‘output’ with the following format:
>> output.emgData
The field ‘emgData’ contains the NxM data matrix where N is the number of channels and M is the number of samples of each channel. The data recorded should be a periodic motion repeated at a relatively stable speed.
>> output.conf.register.fm
>> output.conf.register.muscle_names
The field ‘register’ within ‘conf’ should contain a variable ‘fm’ with the sampling frequency as an integer. In addition the field ‘output.conf.register.muscle_names’ contain a vector of cells with the names of each muscle. This last variable is not necessary for running the code.
Sample material
Download the material required to run this code on the following link
Sample data description
The sample data set consists on a single .mat file containing EMG information recorded during human gait from 5 electrodes located in the lower limb with the following distribution: Soleus, Gastrocnemius Lateralis, Gastrocnemius Medialis, Peroneus Longus and Tibialis Anterior.
Script description
Script Name: segmentateData.m
Script Description: This script has been tested in matlab version 2020a on a computer running windows 10. Functions required to run the script can be found in the library folder from the sample material.
function = segmentateData(output)
% Matlab version R2020a.
% Windows 10.
% Choose a file to process.
files=get_file_names(‘mat’,1);
load(files{1})
% Data preprocessing. Change the cutOffFreq according to the speed of the motion under analysis.
cutOffFreq = 3;
emgData = output.emgData;
[emgDataProcessed] = EMGprocessing(emgData,output.conf.register.fm,cutOffFreq);
% Data segmentation algorithm.
=cutData(emgDataProcessed,output.conf);
% Plot results.
figure
for i = 1:size(output.emgData,1)
subplot(size(output.emgData,1),1,i)
plot(output.emgData(i,:))
vline(output.processing.pattern.minims(i,:),’r’)
end
Running the script: Step-by-Step
1) Download sample material.
2) Set the matlab workspace into the folder DataSegmentation.
3) Add to the path the folder “Library“.
4) Run the code ‘output = segmentateData‘.
5) The script asks for EMG files. Choose the files output the folder ‘Data’.
6) Choose manually the starting and ending points from the plotted figure by clicking on the right positions of the X-axis.
7) Type the number of muscle activations included between the chosen points in the dialog box and click ‘OK’
8) After the processing, the algorithm will show the results of the segmentation on each electrode.
References
Á. Costa-García et al., “Segmentation and Averaging of sEMG Muscle Activations Prior to Synergy Extraction,” in IEEE Robotics and Automation Letters, vol. 5, no. 2, pp. 3106-3112, April 2020, doi: 10.1109/LRA.2020.2975729.