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

vb_meginfo_solve_extra_channel

PURPOSE ^

solve MEGinfo.ExtraChannelInfo data by ch_name which is the list of new data

SYNOPSIS ^

function [meginfo, new_ref_pick, new_ref_Qpick] =vb_meginfo_solve_extra_channel(meginfo, ref_pick, ref_Qpick, ch_name)

DESCRIPTION ^

 solve MEGinfo.ExtraChannelInfo data by ch_name which is the list of new data

 [usage]
   [meginfo, ref_pick, ref_Qpick] = ...
     vb_meginfo_solve_extra_channel(meginfo, ref_pick, ref_Qpick, ch_name)

 [input]
     meginfo : <required> <<struct>> MEGinfo
    ref_pick : <required> [Nchannel_ref x 3] coordinates of refmg channels
   ref_Qpick : <required> [Nchannel_ref x 3] normal vectors of refmg channels
     ch_name : <optional> {Nchannel x 1 cell} channel name list ['']
             :  if this is empty, do nothing

 [output]
         meginfo : MEGinfo after updating ExtraChannelInfo and
                 : sensor_weight_ref
   new_ref_pick  : [Nchannel_ref_new x 3] updated ref_pick
   new_ref_Qpick : [Nchannel_ref_new x 3] updated ref_Qpick

 [note]
   See also
     vb_megfile_make_new_megfile

 [history]
   2008-02-21 (Sako) initial version
   2009-07-08 (Sako) supported refmg channels
   2011-07-21 (Sako) modified sensor_weight_ref according to the new format

 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 [meginfo, new_ref_pick, new_ref_Qpick] = ...
0002   vb_meginfo_solve_extra_channel(meginfo, ref_pick, ref_Qpick, ch_name)
0003 % solve MEGinfo.ExtraChannelInfo data by ch_name which is the list of new data
0004 %
0005 % [usage]
0006 %   [meginfo, ref_pick, ref_Qpick] = ...
0007 %     vb_meginfo_solve_extra_channel(meginfo, ref_pick, ref_Qpick, ch_name)
0008 %
0009 % [input]
0010 %     meginfo : <required> <<struct>> MEGinfo
0011 %    ref_pick : <required> [Nchannel_ref x 3] coordinates of refmg channels
0012 %   ref_Qpick : <required> [Nchannel_ref x 3] normal vectors of refmg channels
0013 %     ch_name : <optional> {Nchannel x 1 cell} channel name list ['']
0014 %             :  if this is empty, do nothing
0015 %
0016 % [output]
0017 %         meginfo : MEGinfo after updating ExtraChannelInfo and
0018 %                 : sensor_weight_ref
0019 %   new_ref_pick  : [Nchannel_ref_new x 3] updated ref_pick
0020 %   new_ref_Qpick : [Nchannel_ref_new x 3] updated ref_Qpick
0021 %
0022 % [note]
0023 %   See also
0024 %     vb_megfile_make_new_megfile
0025 %
0026 % [history]
0027 %   2008-02-21 (Sako) initial version
0028 %   2009-07-08 (Sako) supported refmg channels
0029 %   2011-07-21 (Sako) modified sensor_weight_ref according to the new format
0030 %
0031 % Copyright (C) 2011, ATR All Rights Reserved.
0032 % License : New BSD License(see VBMEG_LICENSE.txt)
0033 
0034 % --- CHECK ARGUMENTS --- %
0035 if ~exist('meginfo', 'var'), meginfo = []; end
0036 if ~exist('ref_pick', 'var'), ref_pick = []; end
0037 if ~exist('ref_Qpick', 'var'), ref_Qpick = []; end
0038 if ~exist('ch_name', 'var'), ch_name = ''; end
0039 [meginfo, ref_pick, ref_Qpick, ch_name] = ...
0040   inner_check_arguments(meginfo, ref_pick, ref_Qpick, ch_name);
0041 
0042 % --- MAIN PROCEDURE --------------------------------------------------------- %
0043 %
0044 
0045 % --- sensor coordinates of refmg
0046 new_ref_pick = [];
0047 new_ref_Qpick = [];
0048 
0049 % --- current label list
0050 refmg_ch_label = vb_meginfo_get_channel_label_refmg(meginfo);
0051 allex_ch_label = vb_meginfo_get_channel_label_extra(meginfo, false, true);
0052 
0053 if ~isfield(meginfo, 'ExtraChannelInfo') ...
0054     || isempty(ch_name) ...
0055     || isempty(allex_ch_label)
0056   
0057   % --- MEGinfo.ExtraChannelInfo
0058   ex_info.Channel_active = [];
0059   ex_info.Channel_name = {};
0060   ex_info.Channel_type = [];
0061   ex_info.Channel_id = [];
0062   meginfo.ExtraChannelInfo = ex_info;
0063   
0064   % --- other fields of MEGinfo
0065   meginfo = vb_meginfo_set_sensor_weight_refmg(meginfo, []);
0066   return;
0067 end
0068 
0069 % get extra channel list and refmg channel list
0070 % base_ch_label = meginfo.ExtraChannelInfo.Channel_name;
0071 % --- ExtraChannelInfo
0072 if ~isempty(allex_ch_label) && ~isempty(ch_name)
0073   [idx] = vb_util_get_index(allex_ch_label, ch_name);
0074 
0075   ex_info = meginfo.ExtraChannelInfo;
0076 
0077   meginfo.ExtraChannelInfo.Channel_active = ex_info.Channel_active(idx);
0078   meginfo.ExtraChannelInfo.Channel_name = ex_info.Channel_name(idx);
0079   meginfo.ExtraChannelInfo.Channel_type = ex_info.Channel_type(idx);
0080   meginfo.ExtraChannelInfo.Channel_id = ex_info.Channel_id(idx);
0081   
0082   % --- refmg channel information
0083   [idx_ref] = vb_util_get_index(refmg_ch_label, ch_name);
0084   if ~isempty(ref_pick)
0085     new_ref_pick = ref_pick(idx_ref, :);
0086   end
0087   
0088   if ~isempty(ref_Qpick)
0089     new_ref_Qpick = ref_Qpick(idx_ref, :);
0090   end
0091 
0092   if vb_meginfo_sensor_weight_refmg_exist(meginfo)
0093     reflen = length(idx_ref);
0094     meginfo = vb_meginfo_init_sensor_weight_refmg(meginfo, reflen);
0095   end
0096   
0097 else
0098   meginfo.ExtraChannelInfo.Channel_active = [];
0099   meginfo.ExtraChannelInfo.Channel_name = [];
0100   meginfo.ExtraChannelInfo.Channel_type = [];
0101   meginfo.ExtraChannelInfo.Channel_id = [];
0102 end
0103 return;
0104 %
0105 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0106 
0107 % --- INNER FUNCTIONS -------------------------------------------------------- %
0108 %
0109 % --- inner_check_arguments()
0110 %
0111 function [meginfo, ref_pick, ref_Qpick, ch_name] = ...
0112   inner_check_arguments(meginfo, ref_pick, ref_Qpick, ch_name)
0113 func_ = mfilename;
0114 if isempty(meginfo)
0115   error('(%s)meginfo is a required parameter', func_);
0116 end
0117 
0118 if isempty(ref_pick)
0119   % require no action
0120 end
0121 
0122 if isempty(ref_Qpick)
0123   % require no action
0124 end
0125 
0126 if ~isempty(ch_name) && ~iscell(ch_name)
0127   ch_name = {ch_name};
0128 end
0129 return;
0130 %
0131 % --- end of inner_check_arguments()
0132 %
0133 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0134 
0135 % --- END OF FILE --- %

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