Home > functions > device > trigger_timing > vb_multi_bit_start.m

vb_multi_bit_start

PURPOSE ^

Find time points that signal changes to the given multi channel bit pattern

SYNOPSIS ^

function ix = vb_multi_bit_start(y,status,t_stay)

DESCRIPTION ^

 Find time points that signal changes to the given multi channel bit pattern
     ix = vb_multi_bit_start(y,status)
     ix = vb_multi_bit_start(y,status,t_stay)
 y(n,t) : event signal for n-th ch at time 't' [Nch x T]
 status : multi channel bit pattern [Nch x 1]
 t_stay : minimum length to stay the specified value [default = 10]
          'y' should be stay at the value 'status' for more than t_stay
 
 ix : index corresponding to the start point 
      'y' changes to 'status' from other value
      
 2012-1-4 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_multi_bit_start(y,status,t_stay)
0002 % Find time points that signal changes to the given multi channel bit pattern
0003 %     ix = vb_multi_bit_start(y,status)
0004 %     ix = vb_multi_bit_start(y,status,t_stay)
0005 % y(n,t) : event signal for n-th ch at time 't' [Nch x T]
0006 % status : multi channel bit pattern [Nch x 1]
0007 % t_stay : minimum length to stay the specified value [default = 10]
0008 %          'y' should be stay at the value 'status' for more than t_stay
0009 %
0010 % ix : index corresponding to the start point
0011 %      'y' changes to 'status' from other value
0012 %
0013 % 2012-1-4 Masa-aki Sato
0014 %
0015 % Copyright (C) 2011, ATR All Rights Reserved.
0016 % License : New BSD License(see VBMEG_LICENSE.txt)
0017 
0018 if nargin < 3, t_stay = 10; end;
0019 
0020 [N,T] = size(y);
0021 
0022 flg = ones(1,T-t_stay);
0023 tt  = 1:T-t_stay;
0024 
0025 % 'y' is not 'status' value beforehand
0026 for n=1:N
0027     flg = flg .* (y(n,tt ) == status(n));
0028 end
0029 
0030 flg = (flg ~= 1);
0031 
0032 % 'y' should be stay at the value 'status' for more than t_stay
0033 for n=1:N
0034     for t=1:t_stay
0035         flg = flg .* (y(n,tt + t) == status(n));
0036     end
0037 end
0038 
0039 ix = find(flg == 1);
0040 
0041 return

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005