<getter> MEGinfo return channel index of MEG [usage] [idx, ch_name_idx] = ... vb_meginfo_get_channel_index_meg(meginfo, ch_name, active_swt) [input] meginfo : <required> <<struct>> MEGinfo ch_name : <optional> {Nch x 1 cell} channel name list [''] : if this is empty, return current MEGch_id : if this is not empty, return specified index of original active_swt : <optional> <<boolean>> active filter switch [false] : true) filter active channels : false) all the channels [output] idx : [N_sameCh x 1] index of MEG channel ch_name_idx : [N_sameCh x 1] index of ch_name [note] [history] 2008-02-21 (Sako) initial version 2008-04-15 (Sako) added active_flag as return 2008-08-25 (Sako) changed interface - added active_swt 2009-06-25 (Sako) added return value "ch_name_idx" Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function [idx, ch_name_idx] = ... 0002 vb_meginfo_get_channel_index_meg(meginfo, ch_name, active_swt) 0003 % <getter> MEGinfo return channel index of MEG 0004 % [usage] 0005 % [idx, ch_name_idx] = ... 0006 % vb_meginfo_get_channel_index_meg(meginfo, ch_name, active_swt) 0007 % [input] 0008 % meginfo : <required> <<struct>> MEGinfo 0009 % ch_name : <optional> {Nch x 1 cell} channel name list [''] 0010 % : if this is empty, return current MEGch_id 0011 % : if this is not empty, return specified index of original 0012 % active_swt : <optional> <<boolean>> active filter switch [false] 0013 % : true) filter active channels 0014 % : false) all the channels 0015 % [output] 0016 % idx : [N_sameCh x 1] index of MEG channel 0017 % ch_name_idx : [N_sameCh x 1] index of ch_name 0018 % [note] 0019 % 0020 % [history] 0021 % 2008-02-21 (Sako) initial version 0022 % 2008-04-15 (Sako) added active_flag as return 0023 % 2008-08-25 (Sako) changed interface - added active_swt 0024 % 2009-06-25 (Sako) added return value "ch_name_idx" 0025 % 0026 % Copyright (C) 2011, ATR All Rights Reserved. 0027 % License : New BSD License(see VBMEG_LICENSE.txt) 0028 0029 % --- CHECK ARGUMENTS --- % 0030 if ~exist('meginfo', 'var'), meginfo = []; end 0031 if ~exist('ch_name', 'var'), ch_name = ''; end 0032 if ~exist('active_swt', 'var'), active_swt = []; end 0033 [meginfo, ch_name, active_swt] = ... 0034 inner_check_arguments(meginfo, ch_name, active_swt); 0035 0036 % --- MAIN PROCEDURE --------------------------------------------------------- % 0037 % 0038 active_list = vb_meginfo_get_channel_active_meg(meginfo, active_swt); 0039 0040 if isempty(ch_name) 0041 idx = meginfo.MEGch_id; 0042 ch_name_idx = []; 0043 else 0044 % ----- get all the channel label of MEG 0045 ch_label = vb_meginfo_get_channel_label_meg(meginfo, false); 0046 if ~isempty(ch_label) 0047 [ch_idx] = vb_util_get_index(ch_label, ch_name); 0048 a_list = find(active_list == 1); 0049 [alist_idx,ch_name_idx] = vb_util_get_index(a_list, ch_idx); 0050 idx = a_list(alist_idx); 0051 else 0052 idx = []; 0053 ch_name_idx = []; 0054 end 0055 end 0056 return; 0057 % 0058 % --- END OF MAIN PROCEDURE -------------------------------------------------- % 0059 0060 % --- INNER FUNCTIONS -------------------------------------------------------- % 0061 % 0062 function [meginfo, ch_name, active_swt] = ... 0063 inner_check_arguments(meginfo, ch_name, active_swt) 0064 func_ = mfilename; 0065 if isempty(meginfo) 0066 error('(%s)meginfo is a required parameter', func_); 0067 end 0068 0069 if ~isfield(meginfo, 'MEGch_id') 0070 meginfo.MEGch_id = []; 0071 end 0072 0073 if isempty(ch_name) 0074 % require no action 0075 elseif ~iscell(ch_name) 0076 ch_name = {ch_name}; 0077 end 0078 0079 if isempty(active_swt) 0080 active_swt = false; 0081 end 0082 return; 0083 % 0084 % --- END OF INNER FUNCTIONS ------------------------------------------------- % 0085 0086 %%% END OF FILE %%%