Home > vbmeg > functions > device > meg > vb_meginfo_get_channel_number_extra.m

vb_meginfo_get_channel_number_extra

PURPOSE ^

get number of extra channel from MEGinfo struct

SYNOPSIS ^

function [Nchannel, result] =vb_meginfo_get_channel_number_extra(meginfo, ex_type, active_swt)

DESCRIPTION ^

 get number of extra channel from MEGinfo struct
 [usage]
   [Nchannel, result] = ...
      vb_meginfo_get_channel_number_extra(meginfo, ex_type, active_swt)
 [input]
      meginfo : <required> <<struct>> MEG information
      ex_type : <optional> extra type 0 | 10
              :  [0]) except reference magnetometer channels
              :  10 ) include reference magnetometer channels (as old)
   active_swt : <optional> <<boolean>> [false] switch for active filter
              :   true) only active channels
              :  false) all the channels
 [output]
   Nchannel : number of extra channel
     result : <<integer>> error code
            :  0) success
            :  1) error - bad MEGinfo
            :  2) error - bad parameter (ex_type)
 [note]
   in new specification, refference magnetometer channel (refmg_ch) is 
   set apart from extra channels
   only 'YOKOGAWA'
 [history]
   2007-06-27 (Sako) initial version
   2008-02-01 (Sako) modified according to new channel_label spec
   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 [Nchannel, result] = ...
0002   vb_meginfo_get_channel_number_extra(meginfo, ex_type, active_swt)
0003 % get number of extra channel from MEGinfo struct
0004 % [usage]
0005 %   [Nchannel, result] = ...
0006 %      vb_meginfo_get_channel_number_extra(meginfo, ex_type, active_swt)
0007 % [input]
0008 %      meginfo : <required> <<struct>> MEG information
0009 %      ex_type : <optional> extra type 0 | 10
0010 %              :  [0]) except reference magnetometer channels
0011 %              :  10 ) include reference magnetometer channels (as old)
0012 %   active_swt : <optional> <<boolean>> [false] switch for active filter
0013 %              :   true) only active channels
0014 %              :  false) all the channels
0015 % [output]
0016 %   Nchannel : number of extra channel
0017 %     result : <<integer>> error code
0018 %            :  0) success
0019 %            :  1) error - bad MEGinfo
0020 %            :  2) error - bad parameter (ex_type)
0021 % [note]
0022 %   in new specification, refference magnetometer channel (refmg_ch) is
0023 %   set apart from extra channels
0024 %   only 'YOKOGAWA'
0025 % [history]
0026 %   2007-06-27 (Sako) initial version
0027 %   2008-02-01 (Sako) modified according to new channel_label spec
0028 %   2008-04-21 (Sako) added active_swt
0029 %
0030 % Copyright (C) 2011, ATR All Rights Reserved.
0031 % License : New BSD License(see VBMEG_LICENSE.txt)
0032 
0033 % --- CHECK ARGUMENTS --- %
0034 if ~exist('meginfo', 'var'), meginfo = []; end
0035 if ~exist('ex_type', 'var'), ex_type = []; end
0036 if ~exist('active_swt', 'var'), active_swt = []; end
0037 [meginfo, ex_type, active_swt, result] = ...
0038   inner_check_arguments(meginfo, ex_type, active_swt);
0039 
0040 % --- MAIN PROCEDURE --------------------------------------------------------- %
0041 %
0042 if result ~= 0
0043   return;
0044 end
0045 func_ = mfilename;
0046 
0047 ch_type = vb_meginfo_get_channel_type_extra(meginfo);
0048 
0049 if active_swt
0050   ch_active = vb_meginfo_get_channel_active_extra(meginfo);
0051   ch_type = ch_type(ch_active == 1);
0052 end
0053 
0054 switch ex_type
0055   case  0 % new spec (except refmg_ch)
0056     % yokogawa spec
0057     target_ch = find(ch_type <=0);
0058 
0059   case  10 % old spec (include refmg_ch)
0060     target_ch = ch_type;
0061 
0062   otherwise
0063     fprintf('(%s)unexpected ex_type : %d\n', func_, ex_type);
0064     result = 2;
0065     return;
0066 end
0067 
0068 Nchannel = length(target_ch);
0069 return;
0070 %
0071 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0072 
0073 % --- INNER FUNCTIONS -------------------------------------------------------- %
0074 %
0075 % --- inner_check_arguments()
0076 %
0077 function [meginfo, ex_type, active_swt, result] = ...
0078   inner_check_arguments(meginfo, ex_type, active_swt)
0079 
0080 func_ = mfilename;
0081 result = 0;
0082 
0083 if isempty(meginfo)
0084   fprintf('(%s)meginfo is a required parameter\n', func_);
0085   result = 1;
0086   return;
0087 end
0088 
0089 if ~isfield(meginfo, 'ExtraChannelInfo')
0090   fprintf('(%s)meginfo must have ExtraChannelInfo field\n', func_);
0091   result = 1;
0092   return;
0093 end
0094 
0095 if isempty(ex_type)
0096   ex_type = 0;
0097 end
0098 
0099 if ~strcmp(meginfo.device, 'YOKOGAWA')
0100   fprintf('(%s)sorry, we have NOT supported except for YOKOGAWA\n', func_);
0101   ex_type = 10;
0102 end
0103 
0104 if isempty(active_swt)
0105   active_swt = false;
0106 end
0107 return;
0108 %
0109 % --- end of inner_check_arguments()
0110 %
0111 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0112 
0113 %%% END OF FILE %%%

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