TEAP (Toolbox for Emotion Analysis using Physiological Signals) doc
featuresSelector.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 featuresSelector.m
17 %> @brief This function select a subset of features from 'featuresNames' based on
18 %> 'include' / 'exclude' satements.
19 %> Features are always returned in the same order than 'features name'
20 %
21 %> If no Include/exclude statement is specifed all features are returned.
22 %
23 %> So far only one include/options option can be specified. If several are
24 %> specified only the last will be taken into account.
25 %
26 %> Proposed features which are not included in 'featuresNames' are rejected
27 %> (no error output).
28 %
29 %> Examples:
30 %> featuresSelector({'A','B',C'},'Include',{'A','C'})
31 %> returns {'A','C'}
32 %> featuresSelector({'A','B',C'},'Exclude',{'A'})
33 %> returns {'B','C'}
34 %> @author Guillaume Chanel
35 %
36 %> @param featuresNames cell array containing the complete list of features
37 %> names
38 %> @param varargin pair of arguments in the matlab style. The second argument
39 %> represent a subset of features as a cell array. The first
40 %> argument tells if the subset should be removed from the full
41 %> set of features ('exclude') or included in an empty set ('include')
42 %
43 %> @retval selFeatures a cell array of selected features
44 function [selfeatures] = featuresSelector(featuresNames,varargin)
45 
46 %If varargin is not specified than all features are computed (default)
47 if(isempty(varargin))
48  selfeatures = featuresNames;
49 else
50  %Process varargin inputs
51  for(i=1:2:length(varargin))
52  switch(lower(varargin{i}))
53  case 'include'
54  selfeatures = intersect(featuresNames,varargin{i+1});
55  case 'exclude'
56  [~, selfeaturesIndices] = setdiff(featuresNames,varargin{i+1});
57  selfeatures = featuresNames(sort(selfeaturesIndices));
58  otherwise
59  error('TEAP:badarg',['Unkown option: ' varargin{1}])
60  end
61  end
62 end
function
function()
featuresSelector
function featuresSelector(in featuresNames, in varargin)
If no Include/exclude statement is specifed all features are returned.