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

vb_meginfo_solve_refmg_channel

PURPOSE ^

update refmg channel data by ch_name without change extra channels

SYNOPSIS ^

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

DESCRIPTION ^

 update refmg channel data by ch_name without change extra channels
 [usage]
   [meginfo, new_ref_pick, new_ref_Qpick] = ...
       vb_meginfo_solve_refmg_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 sensor_weight_ref is updated
    new_ref_pick : [Nchannel_ref_new x 3] updated ref_pick
   new_ref_Qpick : [Nchannel_ref_new x 3] updated ref_Qpick
 [note]
   @see vb_megfile_make_new_megfile.m
 [history]
   2009-07-07 (Sako) initial version
   2011-07-21 (Sako) modified how to deal with sensor_weight_ref

 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_refmg_channel(meginfo, ref_pick, ref_Qpick, ch_name)
0003 % update refmg channel data by ch_name without change extra channels
0004 % [usage]
0005 %   [meginfo, new_ref_pick, new_ref_Qpick] = ...
0006 %       vb_meginfo_solve_refmg_channel(meginfo, ref_pick, ref_Qpick, ch_name)
0007 % [input]
0008 %     meginfo : <required> <<struct>> MEGinfo
0009 %    ref_pick : <required> [Nchannel_ref x 3] coordinates of refmg channels
0010 %   ref_Qpick : <required> [Nchannel_ref x 3] normal vectors of refmg channels
0011 %     ch_name : <optional> {Nchannel x 1 cell} channel name list ['']
0012 %             :  if this is empty, do nothing
0013 % [output]
0014 %         meginfo : MEGinfo after updating sensor_weight_ref is updated
0015 %    new_ref_pick : [Nchannel_ref_new x 3] updated ref_pick
0016 %   new_ref_Qpick : [Nchannel_ref_new x 3] updated ref_Qpick
0017 % [note]
0018 %   @see vb_megfile_make_new_megfile.m
0019 % [history]
0020 %   2009-07-07 (Sako) initial version
0021 %   2011-07-21 (Sako) modified how to deal with sensor_weight_ref
0022 %
0023 % Copyright (C) 2011, ATR All Rights Reserved.
0024 % License : New BSD License(see VBMEG_LICENSE.txt)
0025 
0026 % --- CHECK ARGUMENTS --- %
0027 if ~exist('meginfo', 'var'), meginfo = []; end
0028 if ~exist('ref_pick', 'var'), ref_pick = []; end
0029 if ~exist('ref_Qpick', 'var'), ref_Qpick = []; end
0030 if ~exist('ch_name', 'var'), ch_name = ''; end
0031 [meginfo, ref_pick, ref_Qpick, ch_name] = ...
0032   inner_check_arguments(meginfo, ref_pick, ref_Qpick, ch_name);
0033 
0034 % --- MAIN PROCEDURE --------------------------------------------------------- %
0035 %
0036 if ~isfield(meginfo, 'ExtraChannelInfo') || isempty(ch_name)
0037   % do nothing
0038   return;
0039 end
0040 
0041 ext_ch = vb_meginfo_get_channel_label_extra(meginfo, false);
0042 
0043 % ----- arrange list
0044 ext_ch = vb_util_arrange_list(ext_ch, 0);
0045 ch_name = vb_util_arrange_list(ch_name, 0);
0046 new_ext_ch_name = [ext_ch; ch_name];
0047 
0048 base_ch_label = meginfo.ExtraChannelInfo.Channel_name;
0049               
0050 if ~isempty(base_ch_label)
0051   [idx] = vb_util_get_index(base_ch_label, new_ext_ch_name);
0052 
0053   ex_info = meginfo.ExtraChannelInfo;
0054 
0055   % information for reference channels
0056   ref_ch = vb_meginfo_get_channel_label_refmg(meginfo);
0057   ref_idx = vb_util_get_index(ref_ch, ch_name);
0058   
0059   new_ref_pick = ref_pick(ref_idx, :);
0060   new_ref_Qpick = ref_Qpick(ref_idx, :);
0061   
0062   if vb_meginfo_sensor_weight_refmg_exist(meginfo)
0063     org_weight = vb_meginfo_get_sensor_weight_refmg(meginfo);
0064     meginfo = ...
0065       vb_meginfo_set_sensor_weight_refmg(meginfo, org_weight(ref_idx,ref_idx));
0066   end
0067   
0068   % --- information for all extra channels
0069   meginfo.ExtraChannelInfo.Channel_active = ex_info.Channel_active(idx);
0070   meginfo.ExtraChannelInfo.Channel_name = ex_info.Channel_name(idx);
0071   meginfo.ExtraChannelInfo.Channel_type = ex_info.Channel_type(idx);
0072   meginfo.ExtraChannelInfo.Channel_id = ex_info.Channel_id(idx);
0073   
0074 else
0075   meginfo.ExtraChannelInfo.Channel_active = [];
0076   meginfo.ExtraChannelInfo.Channel_name = [];
0077   meginfo.ExtraChannelInfo.Channel_type = [];
0078   meginfo.ExtraChannelInfo.Channel_id = [];
0079   
0080   meginfo = vb_meginfo_set_sensor_weight_refmg(meginfo, []);
0081 end
0082 return;
0083 %
0084 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0085 
0086 % --- INNER FUNCTIONS -------------------------------------------------------- %
0087 %
0088 % --- inner_check_arguments()
0089 %
0090 function [meginfo, ref_pick, ref_Qpick, ch_name] = ...
0091   inner_check_arguments(meginfo, ref_pick, ref_Qpick, ch_name)
0092 func_ = mfilename;
0093 if isempty(meginfo)
0094   error('(%s)meginfo is a required parameter', func_);
0095 end
0096 
0097 if isempty(ref_pick)
0098   % require no action
0099 end
0100 
0101 if isempty(ref_Qpick)
0102   % require no action
0103 end
0104 
0105 if ~isempty(ch_name) && ~iscell(ch_name)
0106   ch_name = {ch_name};
0107 end
0108 return;
0109 %
0110 % --- end of inner_check_arguments()
0111 %
0112 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0113 
0114 % --- END OF FILE --- %

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