return channel number from EEGinfo struct [usage] [Nchannel] = vb_eeginfo_get_channel_number(eeginfo, active_swt) [input] eeginfo : <required> <<struct>> EEG header information active_swt : <optional> <<boolean>> [false] : switch to return whether all the channels or only active : true) only active channels : false) all the channels [output] Nchannel : number of channel [note] target channel is sensor channels except for external channels [history] 2007-08-02 (Sako) initial version 2008-04-15 (Sako) added active_swt Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function [Nchannel] = vb_eeginfo_get_channel_number(eeginfo, active_swt) 0002 % return channel number from EEGinfo struct 0003 % 0004 % [usage] 0005 % [Nchannel] = vb_eeginfo_get_channel_number(eeginfo, active_swt) 0006 % 0007 % [input] 0008 % eeginfo : <required> <<struct>> EEG header information 0009 % active_swt : <optional> <<boolean>> [false] 0010 % : switch to return whether all the channels or only active 0011 % : true) only active channels 0012 % : false) all the channels 0013 % 0014 % [output] 0015 % Nchannel : number of channel 0016 % 0017 % [note] 0018 % target channel is sensor channels except for external channels 0019 % 0020 % [history] 0021 % 2007-08-02 (Sako) initial version 0022 % 2008-04-15 (Sako) added active_swt 0023 % 0024 % Copyright (C) 2011, ATR All Rights Reserved. 0025 % License : New BSD License(see VBMEG_LICENSE.txt) 0026 0027 % --- CHECK ARGUMENTS --- % 0028 if ~exist('eeginfo', 'var'), eeginfo = []; end 0029 if ~exist('active_swt', 'var'), active_swt = []; end 0030 [eeginfo, active_swt] = inner_check_arguments(eeginfo, active_swt); 0031 0032 % --- MAIN PROCEDURE --------------------------------------------------------- % 0033 % 0034 if ~vb_info_active_channel_is_valid(eeginfo) 0035 ChannelLabel = vb_eeginfo_get_channel_label(eeginfo); 0036 Nchannel = length(ChannelLabel); 0037 return; 0038 end 0039 0040 if ~active_swt 0041 ChannelLabel = vb_eeginfo_get_channel_label(eeginfo); 0042 Nchannel = length(ChannelLabel); 0043 return; 0044 end 0045 0046 active_list = vb_info_get_active_channel(eeginfo); 0047 Nchannel = length(find(active_list==1)); 0048 return; 0049 % 0050 % --- END OF MAIN PROCEDURE -------------------------------------------------- % 0051 0052 % --- INNER FUNCTIONS -------------------------------------------------------- % 0053 % 0054 % --- inner_check_arguments() 0055 % 0056 function [eeginfo, active_swt] = inner_check_arguments(eeginfo, active_swt) 0057 func_ = mfilename; 0058 0059 if isempty(eeginfo) 0060 error('(%s)eeginfo is a required parameter', func_); 0061 end 0062 0063 if isempty(active_swt) 0064 % return all the channel 0065 active_swt = false; 0066 end 0067 0068 if ~isfield(eeginfo, 'Nchannel') 0069 eeginfo.Nchannel = 0; 0070 end 0071 return; 0072 % 0073 % --- end of inner_check_arguments() 0074 % 0075 % --- END OF INNER FUNCTIONS ------------------------------------------------- % 0076 0077 % --- END OF FILE --- %