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

vb_trigger_onset_pre

PURPOSE ^

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

SYNOPSIS ^

function ix = vb_trigger_onset_pre(y,y0,tpre,ymax,twin)

DESCRIPTION ^

 Find onset time that signal exceed the threshold value 'y0'
    vb_trigger_onset_pre(y,y0,tpre)
    vb_trigger_onset_pre(y,y0,tpre,ymax,twin)
 --- main input
 y  : analog signal
 y0 : threshold value
 --- condition for event rejection
 time to previous event shoud be larger than 'tpre'
 'y' value shoud be larger than 'ymax' within 'twin' period, if ymax~=[]
 --- Output
 ix : extracted onset time index
      
 2009-6-16 Masa-aki Sato

 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_pre(y,y0,tpre,ymax,twin)
0002 % Find onset time that signal exceed the threshold value 'y0'
0003 %    vb_trigger_onset_pre(y,y0,tpre)
0004 %    vb_trigger_onset_pre(y,y0,tpre,ymax,twin)
0005 % --- main input
0006 % y  : analog signal
0007 % y0 : threshold value
0008 % --- condition for event rejection
0009 % time to previous event shoud be larger than 'tpre'
0010 % 'y' value shoud be larger than 'ymax' within 'twin' period, if ymax~=[]
0011 % --- Output
0012 % ix : extracted onset time index
0013 %
0014 % 2009-6-16 Masa-aki Sato
0015 %
0016 % Copyright (C) 2011, ATR All Rights Reserved.
0017 % License : New BSD License(see VBMEG_LICENSE.txt)
0018 
0019 % find event start (signal exceed the threshold)
0020 ix = vb_trigger_start(y,y0);
0021 
0022 if isempty(ix), return; end;
0023 
0024 N  = length(ix);
0025 %  avoid dimension swap for exceptional case
0026 y  = y(:);
0027 
0028 if nargin == 5 && ~isempty(ymax) && twin > 0
0029     twin = round(twin);
0030     t  = 1:twin;
0031     ii = repmat(ix(:)',twin,1) + repmat(t(:),1,N);
0032     ii = min(ii, length(y));
0033     
0034     yy = max(y(ii), [], 1);
0035     
0036     jj = find(yy >= ymax);
0037     
0038     ix = ix(jj);
0039 end
0040 
0041 % time to previous event shoud be larger than tpre
0042 dx = [tpre diff(ix)];
0043 jj = find(dx >= tpre);
0044 ix = ix(jj) ;
0045

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