get ON bit indices ALL and BEGINNING and ENDING [usage] [idx_info] = vb_util_get_bit_on_list(bit_list, bit_len) [input] bit_list: <required> bit list [1 x N_sample] bit_len : <optional> length of data bit [DEFAULT_BIT_LEN] [output] idx_info : <struct> sample numbers information of trigger : - all_idx : list of index of "ON" bit : - beg_idx : index that "ON" bit begins : - end_idx : index that "ON" bit breathe [note] DEFAULT_BIT_LEN is defined in 'define_biosemi.m' [history] 2007-01-11 (Sako) initial version Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function [idx_info] = vb_util_get_bit_on_list(bit_list, bit_len) 0002 % get ON bit indices ALL and BEGINNING and ENDING 0003 % [usage] 0004 % [idx_info] = vb_util_get_bit_on_list(bit_list, bit_len) 0005 % [input] 0006 % bit_list: <required> bit list [1 x N_sample] 0007 % bit_len : <optional> length of data bit [DEFAULT_BIT_LEN] 0008 % [output] 0009 % idx_info : <struct> sample numbers information of trigger 0010 % : - all_idx : list of index of "ON" bit 0011 % : - beg_idx : index that "ON" bit begins 0012 % : - end_idx : index that "ON" bit breathe 0013 % [note] 0014 % DEFAULT_BIT_LEN is defined in 'define_biosemi.m' 0015 % [history] 0016 % 2007-01-11 (Sako) initial version 0017 % 0018 % Copyright (C) 2011, ATR All Rights Reserved. 0019 % License : New BSD License(see VBMEG_LICENSE.txt) 0020 0021 % --- CHECK ARGUMENTS --- % 0022 if ~exist('bit_list', 'var'), bit_list = []; end; 0023 if ~exist('bit_len', 'var'), bit_len = []; end; 0024 [bit_list, bit_len, data_len] = inner_check_arguments(bit_list, bit_len); 0025 0026 % --- MAIN PROCEDURE --------------------------------------------------------- % 0027 % 0028 idx_info = []; 0029 beg_idx = []; 0030 end_idx = []; 0031 0032 all_idx = find(bit_list == 1); 0033 0034 if ~isempty(all_idx) 0035 0036 prev_idx = all_idx(1); 0037 beg_idx = all_idx(1); 0038 for nb = 2:size(all_idx,2) 0039 if all_idx(nb) ~= prev_idx + 1 0040 beg_idx = [beg_idx, all_idx(nb)]; 0041 if nb > 1 0042 end_idx = [end_idx, all_idx(nb-1)]; 0043 end 0044 end 0045 prev_idx = all_idx(nb); 0046 end 0047 end 0048 0049 idx_info.all_idx = all_idx; 0050 idx_info.beg_idx = beg_idx; 0051 idx_info.end_idx = end_idx; 0052 % 0053 % --- END OF MAIN PROCEDURE -------------------------------------------------- % 0054 0055 % --- INNER FUNCTIONS -------------------------------------------------------- % 0056 % 0057 % --- inner_check_arguments() 0058 % 0059 function [bit_list, bit_len, data_len] = ... 0060 inner_check_arguments(bit_list, bit_len) 0061 0062 vb_define_device; 0063 0064 if isempty(bit_list) 0065 error('bit_list is a required parameter'); 0066 end 0067 0068 if isempty(bit_len) 0069 bit_len = DEFAULT_BIT_LEN; 0070 end 0071 0072 % arrange to [1 x N] 0073 bit_list = vb_util_arrange_list(bit_list, 1); 0074 data_len = size(bit_list,2); 0075 % 0076 % --- end of inner_check_arguments() 0077 0078 % --- END OF FILE --- %