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 GSR features
19 %> @param GSRsignal: the GSR signal.
20 %> @param varargin: you can choose which features to extract (see featureSelector)
21 %> the list of available features is:
22 %> - nbPeaks: number of GSR peaks per second
23 %> - ampPeaks: average amplitude of peaks
24 %> - riseTime: average rise time of peaks
25 %> - meanGSR: average GSR value
26 %> - stdGSR: variance of GSR
28 %> @retval GSR_feats: list of features values
29 %> @retval GSR_feats_names: names of the computed features (it is good pratice to
30 %> check
this vector since the order of requested features
31 %> can be different than the requested one)
32 %> @author Copyright XXX 2011
33 %> @author Copyright Frank Villaro-Dixon, 2014
34 function [GSR_feats, GSR_feats_names] =
GSR_feat_extr(GSRsignal,varargin)
36 % Check inputs and define unknown values
39 %Check signals and get sample rate
42 warning([
'For the function to work well, you should low-pass the signal' ...
43 '. Preferably with a median filter']);
47 % Define full feature list and get features selected by user
48 featuresNames = {
'nbPeaks',
'ampPeaks',
'riseTime',
'meanGSR',
'stdGSR',
'firstQuartileGSR',
'thirdQuartileGSR'};
53 if strcmp(signalUnit,
'Ohm')
55 elseif strcmp(signalUnit, 'nS')
56 %convert from nano siemens to resistance
62 error(['The GSR unit (' ...
63 signalUnit ') is unknown; please fix it - a threshold shall be adjusted to the unit'])
66 %If some features are selected
67 if(~isempty(GSR_feats_names))
69 if any(strcmp('nbPeaks',GSR_feats_names)) || any(strcmp('ampPeaks',GSR_feats_names)) || any(strcmp('riseTime',GSR_feats_names))
71 [nbPeaks, ampPeaks, riseTime, posPeaks] =
GSR_feat_peaks(GSRsignal,ampThresh);
72 nbPeaks = nbPeaks/(length(GSRsignal)/samprate);
73 ampPeaks = mean(ampPeaks);
74 riseTime = mean(riseTime);
75 %TODO what is this good for? posPeaks
79 if any(strcmp('meanGSR',GSR_feats_names))
83 %standard devisation computation
84 if any(strcmp('stdGSR',GSR_feats_names))
88 if any(strcmp('firstQuartileGSR',GSR_feats_names))
93 if any(strcmp('thirdQuartileGSR',GSR_feats_names))
98 %Write the values to the final vector output
99 for (i = 1:length(GSR_feats_names))
100 eval(['GSR_feats(i) = ' GSR_feats_names{i}
';']);
103 else %no features selected