TEAP (Toolbox for Emotion Analysis using Physiological Signals) doc
EMG_feat_extr.m
Go to the documentation of this file.
1 %This file is part of TEAP.
2 %
3 %TEAP is free software: you can redistribute it and/or modify
4 %it under the terms of the GNU General Public License as published by
5 %the Free Software Foundation, either version 3 of the License, or
6 %(at your option) any later version.
7 %
8 %TEAP is distributed in the hope that it will be useful,
9 %but WITHOUT ANY WARRANTY; without even the implied warranty of
10 %MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 %GNU General Public License for more details.
12 %
13 %You should have received a copy of the GNU General Public License
14 %along with TEAP. If not, see <http://www.gnu.org/licenses/>.
15 
16 %> @file EMG_feat_extr.m
17 %> @brief Computes Skin EMG featuEMG
18 %> @param EMGsignal: the EMG signal.
19 %> @param varargin: you can choose which features to extract (see featureSelector)
20 %> the list of available features is:
21 %> - mean_: average temprature
22 %> - std_: standard deviation of the EMG
23 %> - kurtosis_: Kurtosis of the EMG
24 %> - skewness_: skewness of the EMG
25 %> - EMG_power: power spectral power above 20Hz
26 
27 %> @retval EMG_feats: list of featuEMG values
28 %> @retval EMG_feats_names: names of the computed features (it is good pratice to
29 %> check this vector since the order of requested features
30 %> can be different than the requested one)
31 %> @author Copyright Frank Villaro-Dixon, 2015
32 
33 %
34 %> @b WARNING: this function will give 'strange' results when applied on a relative
35 %> signal
36 %
37 function [EMG_feats, EMG_feats_names] = EMG_feat_extr(EMGsignal, varargin)
38 
39 % Check inputs and define unknown values
40 narginchk(1, Inf);
41 
42 %Make sure we have a EMG signal
43 EMGsignal = EMG__assert_type(EMGsignal);
44 
45 
46 % Define full feature list and get featuEMG selected by user
47 featuEMGNames = {'mean_', 'std_', 'kurtosis_','skewness_','EMG_power'};
48 EMG_feats_names = featuresSelector(featuEMGNames,varargin{:});
49 
50 %If some featuEMG are selected
51 if(~isempty(EMG_feats_names))
52  samprate = Signal__get_samprate(EMGsignal);
53  %statistical moments
54  if any(strcmp('mean_',EMG_feats_names)) || any(strcmp('std_',EMG_feats_names)) || any(strcmp('kurtosis_',EMG_feats_names)) || any(strcmp('skewness_',EMG_feats_names))
55  [mean_,std_, kurtosis_, skewness_] = Signal_feat_stat_moments(EMGsignal);
56  end
57  %EMG power above 20Hz; this is associated with muscule contractions
58  if any(strcmp('EMG_power',EMG_feats_names))
59  bands = [20,samprate/2];
60  EMG_power = Signal_feat_bandEnergy(EMGsignal, bands)';
61  end
62 
63  %Write the values to the final vector output
64  for (i = 1:length(EMG_feats_names))
65  eval(['EMG_feats(i,:) = ' EMG_feats_names{i} ';']);
66  end
67 
68 else %no featuEMG selected
69  EMG_feats = [];
70 end
71 
Signal__get_samprate
function Signal__get_samprate(in Signal)
Signal_feat_bandEnergy
function Signal_feat_bandEnergy(in Signal, in bands)
EMG__assert_type
function EMG__assert_type(in Signal)
EMG_feat_extr
function EMG_feat_extr(in EMGsignal, in varargin)
WARNING: this function will give 'strange' results when applied on a relative signal
Signal_feat_stat_moments
function Signal_feat_stat_moments(in Signal)
featuresSelector
function featuresSelector(in featuresNames, in varargin)
If no Include/exclude statement is specifed all features are returned.