Home > functions > device > meg > vb_meginfo_get_channel_index_extra.m

vb_meginfo_get_channel_index_extra

PURPOSE ^

<getter> return index list of extra channel (except for reference channel)

SYNOPSIS ^

function [idx, result] = vb_meginfo_get_channel_index_extra(meg_info,ex_type, ch_name, active_swt, ref_swt)

DESCRIPTION ^

 <getter> return index list of extra channel (except for reference channel)
 [usage]
   [idx, result] = vb_meginfo_get_channel_index_extra(meg_info, ...
     ex_type, ch_name, active_swt, ref_swt)
 [input]
     meg_info : <required> <<struct>> MEGinfo
              :  which is expected to have ExtraChannelInfo
      ex_type : <optional> extra channel type [1] | 0 | -1 | -2 | -3 | -4
              :  - YOKOGAWA definition
              :  [1]) all channel
              :   0 ) Null Channel
              :  -1 ) Trigger Channel
              :  -2 ) Eeg Channel
              :  -3 ) Ecg Channel
              :  -4 ) Etc Channel
              :  this has priority over ch_name
      ch_name : <optional> {Nch x 1 cell} channel name list ['']
              :  if this is not empty and ex_type is empty, 
              :  return specified index of original
   active_swt : <optional> <<boolean>> active filter switch [false]
              :   true) filter active channels
              :  false) all the channels
      ref_swt : <optinal> <<boolean>> switch to include reference channels
              :     true ) include
              :   [false]) not include
 [output]
          idx : index list of channels [N x 1]
       result : <<integer>> error code
              :  0) success
              :  1) error - bad meginfo
 [note]
   for only YOKOGAWA now
   if device is not YOKOGAWA, return index of all channel
 [history]
   2007-06-29 (Sako) initial version
   2008-02-21 (Sako) modified thoroughly according to new specification
   2008-04-18 (Sako) added active_swt and result

 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 [idx, result] = vb_meginfo_get_channel_index_extra(meg_info, ...
0002   ex_type, ch_name, active_swt, ref_swt)
0003 % <getter> return index list of extra channel (except for reference channel)
0004 % [usage]
0005 %   [idx, result] = vb_meginfo_get_channel_index_extra(meg_info, ...
0006 %     ex_type, ch_name, active_swt, ref_swt)
0007 % [input]
0008 %     meg_info : <required> <<struct>> MEGinfo
0009 %              :  which is expected to have ExtraChannelInfo
0010 %      ex_type : <optional> extra channel type [1] | 0 | -1 | -2 | -3 | -4
0011 %              :  - YOKOGAWA definition
0012 %              :  [1]) all channel
0013 %              :   0 ) Null Channel
0014 %              :  -1 ) Trigger Channel
0015 %              :  -2 ) Eeg Channel
0016 %              :  -3 ) Ecg Channel
0017 %              :  -4 ) Etc Channel
0018 %              :  this has priority over ch_name
0019 %      ch_name : <optional> {Nch x 1 cell} channel name list ['']
0020 %              :  if this is not empty and ex_type is empty,
0021 %              :  return specified index of original
0022 %   active_swt : <optional> <<boolean>> active filter switch [false]
0023 %              :   true) filter active channels
0024 %              :  false) all the channels
0025 %      ref_swt : <optinal> <<boolean>> switch to include reference channels
0026 %              :     true ) include
0027 %              :   [false]) not include
0028 % [output]
0029 %          idx : index list of channels [N x 1]
0030 %       result : <<integer>> error code
0031 %              :  0) success
0032 %              :  1) error - bad meginfo
0033 % [note]
0034 %   for only YOKOGAWA now
0035 %   if device is not YOKOGAWA, return index of all channel
0036 % [history]
0037 %   2007-06-29 (Sako) initial version
0038 %   2008-02-21 (Sako) modified thoroughly according to new specification
0039 %   2008-04-18 (Sako) added active_swt and result
0040 %
0041 % Copyright (C) 2011, ATR All Rights Reserved.
0042 % License : New BSD License(see VBMEG_LICENSE.txt)
0043 
0044 % --- CHECK ARGUMENTS --- %
0045 if ~exist('meg_info', 'var'), meg_info = []; end
0046 if ~exist('ex_type', 'var'), ex_type = []; end
0047 if ~exist('ch_name', 'var'), ch_name = ''; end
0048 if ~exist('active_swt', 'var'), active_swt = []; end
0049 if ~exist('ref_swt', 'var'), ref_swt = []; end
0050 [meg_info, ex_type, ch_name, active_swt, ref_swt, result] = ...
0051   inner_check_arguments(meg_info, ex_type, ch_name, active_swt, ref_swt);
0052 
0053 % --- MAIN PROCEDURE --------------------------------------------------------- %
0054 %
0055 idx = [];
0056 
0057 if result ~= 0
0058   return;
0059 end
0060   
0061 % include reference channels
0062 all_index = vb_meginfo_get_channel_id_extra(meg_info);
0063 all_types = vb_meginfo_get_channel_type_extra(meg_info);
0064 active_list = vb_meginfo_get_channel_active_extra(meg_info, active_swt);
0065 
0066 if isempty(ex_type) && isempty(ch_name)
0067   criterion = bitand((active_list == 1),(all_types <= 0));
0068   idx = all_index(criterion == 1);
0069   return;
0070 end
0071 
0072 if ~isempty(ex_type)
0073   if ex_type == 1
0074     criterion = bitand((active_list == 1),(all_types <= 0));
0075     idx = all_index(criterion == 1);
0076   else
0077     criterion = bitand((active_list == 1),(all_types == ex_type));
0078     idx = all_index(criterion == 1);
0079   end
0080 else
0081   % --- select by channel names
0082   % ----- get labels of all the channels
0083   ch_label = vb_meginfo_get_channel_label_extra(meg_info, false, ref_swt);
0084   ch_idx = vb_util_get_index(ch_label, ch_name);
0085   a_list = find(active_list == 1);
0086   alist_idx = vb_util_get_index(a_list, ch_idx);
0087   idx = a_list(alist_idx);
0088 end
0089 return;
0090 %
0091 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0092 
0093 % --- INNER FUNCTIONS -------------------------------------------------------- %
0094 %
0095 % --- inner_check_arguments()
0096 %
0097 function [meg_info, ex_type, ch_name, active_swt, ref_swt, result] = ...
0098   inner_check_arguments(meg_info, ex_type, ch_name, active_swt, ref_swt)
0099 func_ = mfilename;
0100 result = 0;
0101 
0102 if isempty(meg_info)
0103   fprintf('(%s)meg_info is a required parameter\n', func_);
0104   result = 1;
0105   return;
0106 end
0107 
0108 if ~isfield(meg_info, 'ExtraChannelInfo')
0109   fprintf('(%s)meg_info does not have ExtraChannelInfo field\n', func_);
0110   result = 1;
0111   return;
0112 end
0113 
0114 if isempty(ex_type)
0115   if isempty(ch_name)
0116     ex_type = 1; % all channel
0117   end
0118 end
0119 
0120 if ~strcmp('YOKOGAWA', vb_meginfo_get_device(meg_info))
0121   fprintf('(%s)return all the extra channels because of not YOKOGAWA\n', ...
0122     func_);
0123   ex_type = 1;
0124 end
0125 
0126 % priority
0127 if ~isempty(ch_name) && ~iscell(ch_name)
0128     ch_name = {ch_name};
0129 end
0130 
0131 if isempty(active_swt)
0132   active_swt = false;
0133 end
0134 
0135 if isempty(ref_swt)
0136   ref_swt = false;
0137 end
0138 return;
0139 %
0140 % --- end of inner_check_arguments()
0141 %
0142 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0143 
0144 %%% END OF FILE %%%

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005