Home > functions > device > meg > vb_meginfo_get_channel_index_refmg.m

vb_meginfo_get_channel_index_refmg

PURPOSE ^

<getter> return reference channel's index in extra channel list

SYNOPSIS ^

function [idx, result] =vb_meginfo_get_channel_index_refmg(meg_info, ch_name, active_swt)

DESCRIPTION ^

 <getter> return reference channel's index in extra channel list
 [usage]
   [idx, result] = ...
      vb_meginfo_get_channel_index_refmg(meg_info, ch_name, active_swt)
 [input]
     meg_info : <required> <<struct>> MEGinfo
              :  which is expected to have ExtraChannelInfo
      ch_name : <optional> {Nch x 1 cell} channel name list ['']
              :  if this is empty, return current reference channel id
              :  if this is not empty, return specified index of original
   active_swt : <optinal> <<boolean>> [false] switch to filter active channels
              :   true) only active channels
              :  false) active filter does not have effect
 [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 empty array
 [history]
   2007-06-29 (Sako) initial version
   2008-02-21 (Sako) thoroughly modified according to new specification
   2008-04-21 (Sako) added active_swt

 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] = ...
0002   vb_meginfo_get_channel_index_refmg(meg_info, ch_name, active_swt)
0003 % <getter> return reference channel's index in extra channel list
0004 % [usage]
0005 %   [idx, result] = ...
0006 %      vb_meginfo_get_channel_index_refmg(meg_info, ch_name, active_swt)
0007 % [input]
0008 %     meg_info : <required> <<struct>> MEGinfo
0009 %              :  which is expected to have ExtraChannelInfo
0010 %      ch_name : <optional> {Nch x 1 cell} channel name list ['']
0011 %              :  if this is empty, return current reference channel id
0012 %              :  if this is not empty, return specified index of original
0013 %   active_swt : <optinal> <<boolean>> [false] switch to filter active channels
0014 %              :   true) only active channels
0015 %              :  false) active filter does not have effect
0016 % [output]
0017 %          idx : index list of channels [N x 1]
0018 %       result : <<integer>> error code
0019 %              :  0) success
0020 %              :  1) error - bad MEGinfo
0021 % [note]
0022 %   for only YOKOGAWA now
0023 %   if device is not YOKOGAWA, return empty array
0024 % [history]
0025 %   2007-06-29 (Sako) initial version
0026 %   2008-02-21 (Sako) thoroughly modified according to new specification
0027 %   2008-04-21 (Sako) added active_swt
0028 %
0029 % Copyright (C) 2011, ATR All Rights Reserved.
0030 % License : New BSD License(see VBMEG_LICENSE.txt)
0031 
0032 % --- CHECK ARGUMENTS --- %
0033 if ~exist('meg_info', 'var'), meg_info = []; end
0034 if ~exist('ch_name', 'var'), ch_name = ''; end
0035 if ~exist('active_swt', 'var'), active_swt = []; end
0036 [meg_info, ch_name, active_swt, result] = ...
0037   inner_check_arguments(meg_info, ch_name, active_swt);
0038 
0039 % --- MAIN PROCEDURE --------------------------------------------------------- %
0040 %
0041 idx = [];
0042 
0043 if result ~= 0
0044   return;
0045 end
0046 
0047 if ~strcmp('YOKOGAWA', vb_meginfo_get_device(meg_info))
0048   return;
0049 end
0050 
0051 if isempty(ch_name);
0052   all_idx = vb_meginfo_get_channel_id_extra(meg_info);
0053   all_tps = vb_meginfo_get_channel_type_extra(meg_info);
0054   % in YOKOGAWA data, types over zero mean reference
0055   idx = all_idx(all_tps > 0);
0056 else
0057   % get labels of all the channels
0058   all_idx = vb_meginfo_get_channel_id_extra(meg_info);
0059   all_label = vb_meginfo_get_channel_label_extra(meg_info, false, true);
0060   all_label_ref = vb_meginfo_get_channel_label_refmg(meg_info, active_swt);
0061 
0062   [ref_label_idx] = vb_util_get_index(all_label_ref, ch_name);
0063   target_label = all_label_ref(ref_label_idx);
0064   
0065   [label_idx] = vb_util_get_index(all_label, target_label);
0066   idx = all_idx(label_idx);
0067 end
0068 return;
0069 %
0070 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0071 
0072 % --- INNER FUNCTIONS -------------------------------------------------------- %
0073 %
0074 % --- inner_check_arguments()
0075 %
0076 function [meg_info, ch_name, active_swt, result] = ...
0077   inner_check_arguments(meg_info, ch_name, active_swt)
0078 func_ = mfilename;
0079 result = 0;
0080 
0081 if isempty(meg_info)
0082   fprintf('(%s)meg_info is a required parameter\n', func_);
0083   result = 1;
0084   return;
0085 end
0086 
0087 if ~isfield(meg_info, 'ExtraChannelInfo')
0088   fprintf('(%s)meg_info does not have ExtraChannelInfo field\n', func_);
0089   result = 1;
0090   return;
0091 end
0092 
0093 if ~isempty(ch_name) && ~iscell(ch_name)
0094   ch_name = {ch_name};
0095 end
0096 
0097 if isempty(active_swt)
0098   active_swt = false;
0099 end
0100 return;
0101 %
0102 % --- end of inner_check_arguments()
0103 %
0104 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0105 
0106 %%% END OF FILE %%%

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