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

vb_multi_bit_end

PURPOSE ^

Find time points that signal differ from the given multi channel bit pattern

SYNOPSIS ^

function ix = vb_multi_bit_end(y,status,t_stay)

DESCRIPTION ^

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

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