1 %This file is part of TEAP.
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.
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.
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/>.
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)
36 % Check inputs and define unknown values
39 % WARNING:
this function will give
'strange' results when applied on a relative
43 %Make sure we have a RES signal
48 warning([
'For the function to work well, you should low-pass the signal' ...
49 '. Preferably with a mean filter']);
53 warning(
'The signal was baselined/relative, are you sure you want that ?');
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'};
62 %If some features are selected
63 if(~isempty(RES_feats_names))
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))
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];
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);
85 %Main frequency of respiration rhythm
86 if any(strcmp('main_freq', RES_feats_names))
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}
';']);
95 else %no features selected