TEAP (Toolbox for Emotion Analysis using Physiological Signals) doc
RES_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 RES_feat_extr.m
17 %> @brief Computes Skin respiration features
18 %> @param RESsignal: the respiration 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 respiration
23 %> - kurtosis_: Kurtosis of the respiration
24 %> - skewness_: skewness of the respiration
25 %> - main_freq: main frenquency of the respiration
26 %> - spxxyy: power spectral power between [xx,yy] /10 Hz
27 %> available values are: 'sp0001', 'sp0102','sp0203', 'sp0304',
28 %> 'sp0407', 'sp0710','sp1025'
29 %> @retval RES_feats: list of features values
30 %> @retval RES_feats_names: names of the computed features (it is good pratice to
31 %> check this vector since the order of requested features
32 %> can be different than the requested one)
33 %> @author Copyright Frank Villaro-Dixon, 2015
34 function [RES_feats, RES_feats_names] = RES_feat_extr(RESsignal,varargin)
35 
36 % Check inputs and define unknown values
37 narginchk(1, Inf);
38 %
39 % WARNING: this function will give 'strange' results when applied on a relative
40 % signal
41 %
42 
43 %Make sure we have a RES signal
44 RESsignal = RES__assert_type(RESsignal);
45 
46 
47 if(~Signal__has_preproc_lowpass(RESsignal))
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(RESsignal) ~= 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', ...
59  'sp0102','sp0203', 'sp0304', 'sp0407', 'sp0710','sp1025', 'main_freq'};
60 RES_feats_names = featuresSelector(featuresNames,varargin{:});
61 
62 %If some features are selected
63 if(~isempty(RES_feats_names))
64  %statistical moments
65  if any(strcmp('mean_', RES_feats_names)) || any(strcmp('std_', RES_feats_names)) || any(strcmp('kurtosis_', RES_feats_names)) || any(strcmp('skewness_', RES_feats_names))
66  [mean_,std_, kurtosis_, skewness_] = Signal_feat_stat_moments(RESsignal);
67  end
68 
69  %spectral power features in differnet bands defined in bands
70  % these bands are arbitrarily chosen based on the spectral content
71  %you can change them to what you prefer
72  if any(strncmp('sp',RES_feats_names,2))
73  bands = [0, 0.1; 0.1, 0.2; 0.2,0.3;0.3, 0.4; 0.4, 0.7;0.7,1;1,2.5];
74 
75  [powerBands] = Signal_feat_bandEnergy(RESsignal, bands);
76  sp0001 = powerBands(1);
77  sp0102 = powerBands(2);
78  sp0203 = powerBands(3);
79  sp0304 = powerBands(4);
80  sp0407 = powerBands(5);
81  sp0710 = powerBands(6);
82  sp1025 = powerBands(7);
83  end
84 
85  %Main frequency of respiration rhythm
86  if any(strcmp('main_freq', RES_feats_names))
87  [main_freq] = RES_feat_mainfreq(RESsignal);
88  end
89 
90  %Write the values to the final vector output
91  for (i = 1:length(RES_feats_names))
92  eval(['RES_feats(i) = ' RES_feats_names{i} ';']);
93  end
94 
95 else %no features selected
96  RES_feats = [];
97 end
98 
99 
100 
Signal__has_preproc_lowpass
function Signal__has_preproc_lowpass(in Signal)
RES_feat_mainfreq
function RES_feat_mainfreq(in RESsignal)
RES_feat_extr
function RES_feat_extr(in RESsignal, in varargin)
Signal__get_absolute
function Signal__get_absolute(in Signal)
Signal_feat_bandEnergy
function Signal_feat_bandEnergy(in Signal, in bands)
RES__assert_type
function RES__assert_type(in 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.