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

vb_eeginfo_get_channel_index

PURPOSE ^

return channel index list

SYNOPSIS ^

function [ch_idx, result] = vb_eeginfo_get_channel_index(eeginfo, active_swt)

DESCRIPTION ^

 return channel index list
 [usage]
   ch_idx = vb_eeginfo_get_channel_index(eeginfo, active_swt)
 [input]
      eeginfo : <required> <<struct>> EEGinfo
   active_swt : <optional> <<boolean>> active filter switch [false]
 [output]
       ch_idx : [Nch x 1] channel index list
       result : <<integer>> error code
              :   0) success
              :   1) error - bad eeginfo
 [note]
   channel index is kept in .ChannelID field of EEGinfo
 [history]
   2008-04-16 (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 [ch_idx, result] = vb_eeginfo_get_channel_index(eeginfo, active_swt)
0002 % return channel index list
0003 % [usage]
0004 %   ch_idx = vb_eeginfo_get_channel_index(eeginfo, active_swt)
0005 % [input]
0006 %      eeginfo : <required> <<struct>> EEGinfo
0007 %   active_swt : <optional> <<boolean>> active filter switch [false]
0008 % [output]
0009 %       ch_idx : [Nch x 1] channel index list
0010 %       result : <<integer>> error code
0011 %              :   0) success
0012 %              :   1) error - bad eeginfo
0013 % [note]
0014 %   channel index is kept in .ChannelID field of EEGinfo
0015 % [history]
0016 %   2008-04-16 (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('eeginfo', 'var'), eeginfo = []; end
0023 if ~exist('active_swt', 'var'), active_swt = []; end
0024 [eeginfo, active_swt, result] = inner_check_arguments(eeginfo, active_swt);
0025 
0026 % --- MAIN PROCEDURE --------------------------------------------------------- %
0027 %
0028 if result ~= 0
0029   ch_idx = [];
0030   return;
0031 end
0032 
0033 if isfield(eeginfo, 'ChannelID')
0034   ch_idx = eeginfo.ChannelID;
0035 else
0036   fprintf('(%s)cannot find ChannelID field\n', mfilename);
0037   result = 1;
0038   ch_idx = [];
0039   return;
0040 end
0041 
0042 if active_swt
0043   if ~vb_info_active_channel_is_valid(eeginfo)
0044     return;
0045   end
0046   active_list = vb_info_get_active_channel(eeginfo);
0047   ch_idx = ch_idx(active_list == 1);
0048 end
0049 return;
0050 %
0051 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0052 
0053 
0054 % --- INNER FUNCTIONS -------------------------------------------------------- %
0055 %
0056 % --- inner_check_arguments()
0057 %
0058 function [eeginfo, active_swt, result] = ...
0059   inner_check_arguments(eeginfo, active_swt)
0060 func_ = mfilename;
0061 result = 0; % success
0062 
0063 if isempty(eeginfo)
0064   fprintf('(%s)eeginfo is a required parameter\n', func_);
0065   result = 1;
0066   return;
0067 end
0068 
0069 if isempty(active_swt)
0070   active_swt = false;
0071 end
0072 return;
0073 %
0074 % --- end of inner_check_arguments()
0075 %
0076 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0077 
0078 %%% END OF FILE %%%

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