Home > vbmeg > functions > device > trigger_timing > vb_trigger_onset_event.m

vb_trigger_onset_event

PURPOSE ^

Find onset time that signal exceed the threshold value 'y0'

SYNOPSIS ^

function ix = vb_trigger_onset_event(y,y0,ymax,twin,Nrate)

DESCRIPTION ^

 Find onset time that signal exceed the threshold value 'y0'
    ix = vb_trigger_onset_event(y,y0,ymax,twin,Nrate)
 --- main input
 y  : analog signal
 y0 : threshold value for 'y'
 ymax : max value threshold within 'twin' period
 twin : period length
 Nrate: y should be larger than ymax for (twin*Nrate) samples
 --- condition for onset 
 if 'twin' is not empty,
 'y' shoud exceed 'ymax' for (twin*Nrate) samples within twin period
 --- Output
 ix : extracted onset time index
      
 2011-12-16 Masa-aki Sato 
 2012-1-8  Masa-aki Sato 
   check exceptional cases
   condition is changed

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function    ix = vb_trigger_onset_event(y,y0,ymax,twin,Nrate)
0002 % Find onset time that signal exceed the threshold value 'y0'
0003 %    ix = vb_trigger_onset_event(y,y0,ymax,twin,Nrate)
0004 % --- main input
0005 % y  : analog signal
0006 % y0 : threshold value for 'y'
0007 % ymax : max value threshold within 'twin' period
0008 % twin : period length
0009 % Nrate: y should be larger than ymax for (twin*Nrate) samples
0010 % --- condition for onset
0011 % if 'twin' is not empty,
0012 % 'y' shoud exceed 'ymax' for (twin*Nrate) samples within twin period
0013 % --- Output
0014 % ix : extracted onset time index
0015 %
0016 % 2011-12-16 Masa-aki Sato
0017 % 2012-1-8  Masa-aki Sato
0018 %   check exceptional cases
0019 %   condition is changed
0020 %
0021 % Copyright (C) 2011, ATR All Rights Reserved.
0022 % License : New BSD License(see VBMEG_LICENSE.txt)
0023 
0024 % find event start (at which signal exceed the threshold)
0025 ix = vb_trigger_start(y,y0);
0026 
0027 if isempty(ix), return; end;
0028 if isempty(twin), return; end;
0029 if isempty(ymax), ymax = y0; end;
0030 if nargin < 5 || isempty(Nrate), Nrate = 0.8; end;
0031 
0032 N  = length(ix);
0033 T  = length(y);
0034 
0035 % time index for 'twin' period
0036 twin = round(twin);
0037 tt = 1:twin;
0038 
0039 % # of samples to exceed 'ymax' within 'twin' period
0040 Ny = zeros(N,1);
0041 
0042 for n=1:N
0043     t = min(ix(n) + tt,T);
0044     Ny(n) = sum(y(t) >= ymax);
0045 end
0046 
0047 % 'y' shoud exceed 'ymax' for (twin*Nrate) samples within twin period
0048 jj = find(Ny >= Nrate*twin);
0049 
0050 ix = ix(jj);
0051 
0052 %ix = vb_onset_check(ix,twin);
0053

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005