Home > functions > device > meg > vb_megfile_get_sensor_position_by_name.m

vb_megfile_get_sensor_position_by_name

PURPOSE ^

return information of sensor position specified by name

SYNOPSIS ^

function [position, direction, coil_weight, center] =vb_megfile_get_sensor_position_by_name(megfile, ch_name, active_swt)

DESCRIPTION ^

 return information of sensor position specified by name

 [usage]
   [position, direction, coil_weight, center] = ...
     vb_megfile_get_sensor_position_by_name(megfile, ch_name, active_swt)

 [input]
      megfile : <required> <<file>> MEG-MAT file
      ch_name : <optional> <<cell array>> channel name list {''}
              :  If this is invalid, return positions of 'MEG' channels
   active_swt : <optional> <<boolean>> [false] only for MEG channels
              :    true) return only active channels (MEG)
              :   false) return all the channels (MEG)

 [output]
     position : position data of sensors
              :  (pick in MEG-MAT) [Ncoil x 3]
    direction : direction data of sensors
              :  (Qpick in MEG-MAT) [Ncoil x 3]
  coil_weight : coil weight [Nchannel x Ncoil]
       center : center coordinate [1 x 3]

 [note]

   See also
     vb_load_yokogawa_sensor, vb_megfile_get_sensor_position_by_type

 [history]
   2011-07-26 (Sako) initial version

 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 [position, direction, coil_weight, center] = ...
0002   vb_megfile_get_sensor_position_by_name(megfile, ch_name, active_swt)
0003 % return information of sensor position specified by name
0004 %
0005 % [usage]
0006 %   [position, direction, coil_weight, center] = ...
0007 %     vb_megfile_get_sensor_position_by_name(megfile, ch_name, active_swt)
0008 %
0009 % [input]
0010 %      megfile : <required> <<file>> MEG-MAT file
0011 %      ch_name : <optional> <<cell array>> channel name list {''}
0012 %              :  If this is invalid, return positions of 'MEG' channels
0013 %   active_swt : <optional> <<boolean>> [false] only for MEG channels
0014 %              :    true) return only active channels (MEG)
0015 %              :   false) return all the channels (MEG)
0016 %
0017 % [output]
0018 %     position : position data of sensors
0019 %              :  (pick in MEG-MAT) [Ncoil x 3]
0020 %    direction : direction data of sensors
0021 %              :  (Qpick in MEG-MAT) [Ncoil x 3]
0022 %  coil_weight : coil weight [Nchannel x Ncoil]
0023 %       center : center coordinate [1 x 3]
0024 %
0025 % [note]
0026 %
0027 %   See also
0028 %     vb_load_yokogawa_sensor, vb_megfile_get_sensor_position_by_type
0029 %
0030 % [history]
0031 %   2011-07-26 (Sako) initial version
0032 %
0033 % Copyright (C) 2011, ATR All Rights Reserved.
0034 % License : New BSD License(see VBMEG_LICENSE.txt)
0035 
0036 % --- CHECK ARGUMENTS --- %
0037 if ~exist('megfile', 'var'), megfile = []; end
0038 if ~exist('ch_name', 'var'), ch_name = ''; end
0039 if ~exist('active_swt', 'var'), active_swt = []; end
0040 [megfile, ch_name, active_swt] = ...
0041   inner_check_arguments(megfile, ch_name, active_swt);
0042 
0043 % --- MAIN PROCEDURE --------------------------------------------------------- %
0044 %
0045 meg_info = vb_megfile_load_meginfo(megfile);
0046 ch_info_cur = vb_load_channel_info(megfile, 'USER', ch_name);
0047 
0048 % --- for 'MEG' channels
0049 ch_info_meg = vb_load_channel_info(megfile, 'MEG');
0050 if isempty(ch_info_meg)
0051   active_swt = false;
0052 end
0053 
0054 if active_swt
0055   active_idx = find(ch_info_meg.Active == true);
0056   base_names = ch_info_meg.Name(active_idx, :);
0057 else
0058   base_names = ch_info_meg.Name;
0059 end
0060 
0061 base_idx = vb_util_get_matching_label_index(base_names, ch_info_cur.Name);
0062 
0063 if ~isempty(base_idx)
0064   target_idx = base_idx;
0065 
0066   [pick, Qpick] = vb_load_yokogawa_sensor(megfile, false, false);
0067   c_weight = vb_meginfo_get_sensor_weight_meg(meg_info);
0068 
0069   n_ch = vb_info_get_Nchannel(meg_info);
0070 
0071   target_coil_idx = [target_idx; (n_ch + target_idx)];
0072 
0073   pick_meg = pick(target_coil_idx, :);
0074   Qpick_meg = Qpick(target_coil_idx, :);
0075   c_weight_meg = c_weight(target_idx, target_coil_idx);
0076 else
0077   pick_meg = [];
0078   Qpick_meg = [];
0079   c_weight_meg = [];
0080 end
0081 
0082 % --- for 'REFERENCE' channels
0083 ch_info_ref = vb_load_channel_info(megfile, 'REFERENCE');
0084 if isempty(ch_info_ref)
0085   active_swt = false;
0086 end
0087 
0088 n_ref = size(ch_info_ref.Name, 1);
0089 
0090 if active_swt
0091   active_idx = find(ch_info_ref.Active == true);
0092   base_names = ch_info_ref.Name(active_idx, :);
0093 else
0094   base_names = ch_info_ref.Name;
0095 end
0096 
0097 base_idx = vb_util_get_matching_label_index(base_names, ch_info_cur.Name);
0098 
0099 if ~isempty(base_idx)
0100   target_idx = base_idx;
0101 
0102   [pick_ref, Qpick_ref] = vb_load_yokogawa_sensor(megfile, true, false);
0103   c_weight_ref = vb_meginfo_get_sensor_weight_refmg(meg_info);
0104 
0105   target_coil_idx = target_idx;
0106 
0107   pick_ref = pick_ref(target_coil_idx, :);
0108   Qpick_ref = Qpick_ref(target_coil_idx, :);
0109   c_weight_ref = c_weight_ref(target_idx, target_coil_idx);
0110 else
0111   pick_ref = [];
0112   Qpick_ref = [];
0113   c_weight_ref = [];
0114 end
0115 
0116 % --- combine data
0117 position = [pick_meg; pick_ref];
0118 direction = [Qpick_meg; Qpick_ref];
0119 
0120 len_meg_ch = size(c_weight_meg, 1);
0121 len_meg_cl = size(c_weight_meg, 2);
0122 len_ref_ch = size(c_weight_ref, 1);
0123 len_ref_cl = size(c_weight_ref, 2);
0124 
0125 len_ch = len_meg_ch + len_ref_ch;
0126 len_coil = len_meg_cl + len_ref_cl;
0127 coil_weight = zeros(len_ch, len_coil);
0128 
0129 % --- coil weight for meg channels
0130 coil_weight(1:len_meg_ch, 1:len_meg_cl) = c_weight_meg;
0131 
0132 % --- coil_weight for reference channels
0133 coil_weight((len_meg_ch+1):len_ch, (len_meg_cl+1):len_coil) = c_weight_ref;
0134 
0135 % --- solve center coordinate
0136 center = [];
0137 if isfield(meg_info, 'Vcenter')
0138   center = meg_info.Vcenter;
0139 end
0140 
0141 return;
0142 %
0143 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0144 
0145 % --- INNER FUNCTIONS -------------------------------------------------------- %
0146 %
0147 % --- inner_check_arguments()
0148 %
0149 function [megfile, ch_name, active_swt] = ...
0150   inner_check_arguments(megfile, ch_name, active_swt)
0151 func_ = mfilename;
0152 
0153 if isempty(megfile)
0154   error('(%s) MEG-MAT file is a required parameter', func_);
0155 end
0156 
0157 if exist(megfile, 'file') ~= 2
0158   error('(%s)cannot find MEG-MAT file : %s', megfile);
0159 end
0160 
0161 [Measurement] = vb_load_device(megfile);
0162 
0163 if ~strcmpi(Measurement, 'MEG')
0164   error('(%s)this file is not MEG file : %s', func_, megfile);
0165 end
0166 
0167 if ~iscell(ch_name)
0168   ch_name = {ch_name};
0169 end
0170 
0171 if isempty(ch_name{1})
0172   ch_info = vb_load_channel_info(megfile, 'MEG');
0173   ch_name = ch_info.Name;
0174 end
0175 
0176 if isempty(active_swt)
0177   active_swt = false;
0178 end
0179 return;
0180 %
0181 % --- end of inner_check_arguments()
0182 %
0183 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0184 
0185 % --- END OF FILE --- %

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