TEAP (Toolbox for Emotion Analysis using Physiological Signals) doc
gettrigger.m
Go to the documentation of this file.
1 function TRIG = gettrigger(s,TH,rfp);
2 % GETTRIGGER identifies trigger points
3 %
4 % TRIG = gettrigger( s [,TH [,rfp]]); % trigger at ascending edge
5 % TRIG = gettrigger(-s [,TH [,rfp]]); % trigger at decending edge
6 %
7 % input : s signal
8 % TH Threshold; default: (max+min)/2
9 % rfp refractory period (default=0)
10 % output: TRIG TRIGGER time points
11 %
12 % see also: TRIGG
13 
14 % $Id: gettrigger.m 2202 2009-10-27 12:06:45Z schloegl $
15 % Copyright (C) 2002-2003,2008 by Alois Schloegl <a.schloegl@ieee.org>
16 
17 % This library is free software; you can redistribute it and/or
18 % modify it under the terms of the GNU Library General Public
19 % License as published by the Free Software Foundation; either
20 % Version 2 of the License, or (at your option) any later version.
21 %
22 % This library is distributed in the hope that it will be useful,
23 % but WITHOUT ANY WARRANTY; without even the implied warranty of
24 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 % Library General Public License for more details.
26 %
27 % You should have received a copy of the GNU Library General Public
28 % License along with this library; if not, write to the
29 % Free Software Foundation, Inc., 59 Temple Place - Suite 330,
30 % Boston, MA 02111-1307, USA.
31 
32 
33 if nargin<2,
34  TH = (max(s)+min(s))/2;
35 end;
36 if nargin<3,
37  rfp = 0;
38 end;
39 
40 TRIG = find(diff(sign(s-TH))>0)+1;
41 % perform check of trigger points
42 
43 if (rfp<=0), return; end;
44 
45 % refractory period
46 k0=1;
47 k1=2;
48 while k1<length(TRIG);
49  T0 = TRIG(k0);
50  T1 = TRIG(k1);
51  if (T1-T0)<rfp,
52  TRIG(k1)=NaN;
53  else
54  k0 = k1;
55  end
56  k1 = k1+1;
57 end;
58 TRIG=TRIG(~isnan(TRIG));
59 
60 
gettrigger
function gettrigger(in s, in TH, in rfp)