TEAP (Toolbox for Emotion Analysis using Physiological Signals) doc
HST_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 HST_feat_extr.m
17 %> @brief Computes Skin temperature features
18 %> @b WARNING: this function will give 'strange' results when applied on a relative
19 %> signal
20 %
21 %> @param HSTsignal the temperature signal.
22 %> @param varargin you can choose which features to extract (see featureSelector)
23 %> the list of available features is:
24 %> - mean_: average temprature
25 %> - std_: standard deviation of the temperature
26 %> - kurtosis_: Kurtosis of the temperature
27 %> - skewness_: skewness of the temperature
28 %> - sp0001: Spectral power 0-0.1Hz,
29 %> - sp0102: Spectral power 0.1-0.2Hz,
30 %
31 %> @retval HST_feats list of features values
32 %> @retval HST_feats_names names of the computed features (it is good pratice to
33 %> check this vector since the order of requested features
34 %> can be different than the requested one)
35 %> @author Copyright Frank Villaro-Dixon, 2015
36 
37 
38 function [HST_feats, HST_feats_names] = HST_feat_extr(HSTsignal,varargin)
39 
40 % Check inputs and define unknown values
41 narginchk(1, Inf);
42 
43 %Make sure we have a HST signal
44 HSTsignal = HST__assert_type(HSTsignal);
45 
46 
47 if(~Signal__has_preproc_lowpass(HSTsignal))
48  warning(['For the function to work well, you should low-pass the signal' ...
49  '. Preferably with a mean filter']);
50 end
51 
52 if(Signal__get_absolute(HSTsignal) ~= true)
53  warning('The signal was baselined/relative, are you sure you want that ?');
54 end
55 
56 
57 % Define full feature list and get features selected by user
58 featuresNames = {'mean_', 'std_', 'kurtosis_','skewness_','sp0001', 'sp0102'};
59 HST_feats_names = featuresSelector(featuresNames,varargin{:});
60 
61 %If some features are selected
62 if(~isempty(HST_feats_names))
63  raw = Signal__get_raw(HSTsignal);
64  %statistical moments
65  if any(strcmp('mean_',HST_feats_names)) || any(strcmp('std_',HST_feats_names)) || any(strcmp('kurtosis_',HST_feats_names)) || any(strcmp('skewness_',HST_feats_names))
66  [mean_,std_, kurtosis_, skewness_] = Signal_feat_stat_moments(HSTsignal);
67  end
68  %spectral power features in bands; these two bands are chosen due to
69  %the low frequency content in this signal
70  if any(strncmp('sp',HST_feats_names,2))
71  bands = [0, 0.1; 0.1, 0.2];
72  [powerBands] = Signal_feat_bandEnergy(HSTsignal, bands);
73  sp0001 = powerBands(1);
74  sp0102 = powerBands(2);
75  end
76  %Write the values to the final vector output
77  for (i = 1:length(HST_feats_names))
78  eval(['HST_feats(i) = ' HST_feats_names{i} ';']);
79  end
80 else %no features selected
81  HST_feats = [];
82 end
83 
Signal__has_preproc_lowpass
function Signal__has_preproc_lowpass(in Signal)
HST_feat_extr
function HST_feat_extr(in HSTsignal, in varargin)
Signal__get_raw
function Signal__get_raw(in Signal)
Signal__get_absolute
function Signal__get_absolute(in Signal)
HST__assert_type
function HST__assert_type(in Signal)
Signal_feat_bandEnergy
function Signal_feat_bandEnergy(in Signal, in bands)
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.