TEAP (Toolbox for Emotion Analysis using Physiological Signals) doc
Signal__assert_range.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 Signal__assert_range.m
17 %> @brief Asserts that the signal is a TEAP one
18 %
19 %> @param Signal: the signal to test
20 %> @param minVal: the minimum value (default to -Inf)
21 %> @param maxVal: the maximum value (defaults to +Inf)
22 %> @param soft: boolean indicating if the assert is soft (i.e. 1 -> warning) or hard (i.e. 0 -> error), defaults to 0
23 %
24 %> @author Copyright Guillaume Chanel, 2016
25 function Signal__assert_range(Signal, minVal, maxVal, soft)
26 
27 if(nargin > 4 || nargin < 1)
28  error('Usage: Signal__assert_mine(Signal)');
29 end
30 
31 if(nargin < 2)
32  minVal = -Inf;
33 end
34 
35 if(nargin < 3)
36  maxVal = +Inf;
37 end
38 
39 if(nargin < 4)
40  soft = 0;
41 end
42 
43 %Check the range of signals and construct potential warning/error
44 %message
45 msg = '';
46 minSig = min(Signal__get_raw(Signal));
47 if(minSig < minVal )
48  msg = [msg 'The value ' num2str(minSig) ' is too low for ' Signal__get_signame(Signal) ' signals (min = ' num2str(minVal) '). '];
49 end
50 
51 
52 maxSig = max(Signal__get_raw(Signal));
53 if(maxSig > maxVal)
54  msg = [msg 'The value ' num2str(maxSig) ' is too high for ' Signal__get_signame(Signal) ' signals (max = ' num2str(maxVal) '). '];
55 end
56 
57 if(~isempty(msg))
58  if(soft == 1)
59  warning([msg 'This might lead to other warnings']);
60  else
61  error(msg);
62  end
63 end
64 
Signal__get_raw
function Signal__get_raw(in Signal)
Signal__assert_range
function Signal__assert_range(in Signal, in minVal, in maxVal, in soft)
Signal__get_signame
function Signal__get_signame(in Signal)