Home > vbmeg > functions > device > eeg > vb_eeg_make_channel_bit_array.m

vb_eeg_make_channel_bit_array

PURPOSE ^

make bit arrays of specified channels

SYNOPSIS ^

function bit_arrays = vb_eeg_make_channel_bit_array(status_data,target_ch,bit_len)

DESCRIPTION ^

 make bit arrays of specified channels
 [usage]
   bit_arrays = vb_eeg_make_channel_bit_array(status_data,target_ch,bit_len)
 [input]
   status_data : <required> status data [1 x N]
               : 80-ch data is usually the corresponding channel
     target_ch : <required> target channels index number [1 x N]
               : this is the index of trigger channels (normally 1-16)
               : plural channels are accessible
       bit_len : <optional> length of bit [24]
 [output]
    bit_arrays : bit arrays which is extracted [N_channel x N_sample]
 [note]
 [history]
   2007-01-11 (Sako) initial version

 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:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function bit_arrays = vb_eeg_make_channel_bit_array(status_data,target_ch,bit_len)
0002 % make bit arrays of specified channels
0003 % [usage]
0004 %   bit_arrays = vb_eeg_make_channel_bit_array(status_data,target_ch,bit_len)
0005 % [input]
0006 %   status_data : <required> status data [1 x N]
0007 %               : 80-ch data is usually the corresponding channel
0008 %     target_ch : <required> target channels index number [1 x N]
0009 %               : this is the index of trigger channels (normally 1-16)
0010 %               : plural channels are accessible
0011 %       bit_len : <optional> length of bit [24]
0012 % [output]
0013 %    bit_arrays : bit arrays which is extracted [N_channel x N_sample]
0014 % [note]
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 vb_define_device;
0022 
0023 % --- CHECK ARGUMENTS --- %
0024 if ~exist('status_data', 'var'), status_data = []; end;
0025 if ~exist('target_ch', 'var'), target_ch = []; end;
0026 if ~exist('bit_len', 'var'), bit_len = []; end;
0027 [status_data, target_ch, bit_len] = ...
0028   inner_check_arguments(status_data, target_ch, bit_len);
0029 
0030 
0031 % --- MAIN PROCEDURE --------------------------------------------------------- %
0032 %
0033 % prepare buffers
0034 data_len = size(status_data,2);
0035 ch_num = size(target_ch,2);
0036 
0037 BIT_LEN = bit_len;
0038 
0039 % result sizes are [N_channel x N_sample]
0040 bit_arrays = zeros(ch_num,data_len);
0041 
0042 for nch = target_ch
0043   check_bit = 2 ^ (nch-1);
0044   bit_arrays(nch,:) = ...
0045     (vb_bitand_ex(status_data(:,:),check_bit,BIT_LEN) == check_bit);
0046 end
0047 
0048 % --- INNER FUNCTIONS -------------------------------------------------------- %
0049 %
0050 % --- inner_check_arguments()
0051 %
0052 function [status_data, target_ch, bit_len] = ...
0053   inner_check_arguments(status_data, target_ch, bit_len)
0054 
0055 vb_define_device;
0056 
0057 if isempty(status_data) error('status_data is a required parameter'); end;
0058 if isempty(target_ch) error('target_ch is a required parameter'); end;
0059 if isempty(bit_len)
0060   bit_len = DEFAULT_BIT_LEN;
0061 end
0062 
0063 % re-arrange for this function
0064 status_data = vb_util_arrange_list(status_data, 1);
0065 target_ch = vb_util_arrange_list(target_ch, 1);
0066 
0067 % use valid channels
0068 target_ch = target_ch(find(target_ch < bit_len));
0069 if isempty(target_ch) error('no valid target_ch'); end;
0070 %
0071 % --- end of inner_check_arguments()
0072 
0073 %%% END OF FILE %%%

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