Home > functions > device > meg > vb_megfile_get_sensor_position_by_type.m

vb_megfile_get_sensor_position_by_type

PURPOSE ^

return information of sensor position

SYNOPSIS ^

function [position, direction, coilweight, center, result] =vb_megfile_get_sensor_position_by_type(megfile, ch_type, active_swt)

DESCRIPTION ^

 return information of sensor position

 [usage]
   [position, direction, coilweight, center, result] = ...
     vb_megfile_get_sensor_position(megfile, ch_type, active_swt)

 [input]
      megfile : <required> <<file>> MEG-MAT file
      ch_type : <optional> <<string>> user specifies sensor type ['']
              :  '' or 'MEG' : MEG channels
              :        'REF' : REFFERENCE channels
              :        'ALL' : MEG and REFFERENCE channels
              :      'AXIAL' : AXIAL channels
              :     'PLANAR' : PLANAR channels
              :  case-insensitive
   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) [Nchannel x 3]
    direction : direction data of sensors
              :  (Qpick in MEG-MAT) [Nchannel x 3]
   coilweight : matrix of coil weight [Nchannel x Ncoil]
              :  this value depends on ch_type (channel type) as follows
              :   'MEG' : CoilWeight of MEG channels
              :   'REF' : CoilWeight of REFFERENCE channels
              :   'ALL' : CoilWeight of MEG and REFFERENCE channels
       center : center coordinates [1 x 3]
       resule : <<integer>> error code
              :  0) success
              :  1) error - bad megfile
              :  2) error - bad Measurement
              :  4) error - bad ch_type

 [note]
   See also
     vb_load_yokogawa_sensor

 [history]
   2007-07-24 (Sako) initial version
   2008-03-31 (Sako) supported the case of empty Vcenter
   2008-04-15 (Sako) added active_swt, result
   2009-09-01 (Sako) replaced active cheking function
   2011-06-01 (Sako) converted return values of vb_load_device to upper case
   2011-07-26 (Sako) added two types channels as supported 'AXIAL' and 'PLANAR'
   2011-08-31 (Sako) modified how to get data in the case of unknown device

 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, coilweight, center, result] = ...
0002   vb_megfile_get_sensor_position_by_type(megfile, ch_type, active_swt)
0003 % return information of sensor position
0004 %
0005 % [usage]
0006 %   [position, direction, coilweight, center, result] = ...
0007 %     vb_megfile_get_sensor_position(megfile, ch_type, active_swt)
0008 %
0009 % [input]
0010 %      megfile : <required> <<file>> MEG-MAT file
0011 %      ch_type : <optional> <<string>> user specifies sensor type ['']
0012 %              :  '' or 'MEG' : MEG channels
0013 %              :        'REF' : REFFERENCE channels
0014 %              :        'ALL' : MEG and REFFERENCE channels
0015 %              :      'AXIAL' : AXIAL channels
0016 %              :     'PLANAR' : PLANAR channels
0017 %              :  case-insensitive
0018 %   active_swt : <optional> <<boolean>> [false] only for MEG channels
0019 %              :    true) return only active channels (MEG)
0020 %              :   false) return all the channels (MEG)
0021 %
0022 % [output]
0023 %     position : position data of sensors
0024 %              :  (pick in MEG-MAT) [Nchannel x 3]
0025 %    direction : direction data of sensors
0026 %              :  (Qpick in MEG-MAT) [Nchannel x 3]
0027 %   coilweight : matrix of coil weight [Nchannel x Ncoil]
0028 %              :  this value depends on ch_type (channel type) as follows
0029 %              :   'MEG' : CoilWeight of MEG channels
0030 %              :   'REF' : CoilWeight of REFFERENCE channels
0031 %              :   'ALL' : CoilWeight of MEG and REFFERENCE channels
0032 %       center : center coordinates [1 x 3]
0033 %       resule : <<integer>> error code
0034 %              :  0) success
0035 %              :  1) error - bad megfile
0036 %              :  2) error - bad Measurement
0037 %              :  4) error - bad ch_type
0038 %
0039 % [note]
0040 %   See also
0041 %     vb_load_yokogawa_sensor
0042 %
0043 % [history]
0044 %   2007-07-24 (Sako) initial version
0045 %   2008-03-31 (Sako) supported the case of empty Vcenter
0046 %   2008-04-15 (Sako) added active_swt, result
0047 %   2009-09-01 (Sako) replaced active cheking function
0048 %   2011-06-01 (Sako) converted return values of vb_load_device to upper case
0049 %   2011-07-26 (Sako) added two types channels as supported 'AXIAL' and 'PLANAR'
0050 %   2011-08-31 (Sako) modified how to get data in the case of unknown device
0051 %
0052 % Copyright (C) 2011, ATR All Rights Reserved.
0053 % License : New BSD License(see VBMEG_LICENSE.txt)
0054 
0055 % --- CHECK ARGUMENTS --- %
0056 if ~exist('megfile', 'var'), megfile = []; end
0057 if ~exist('ch_type', 'var'), ch_type = ''; end
0058 if ~exist('active_swt', 'var'), active_swt = []; end
0059 [megfile, ch_type, active_swt, result] = ...
0060   inner_check_arguments(megfile, ch_type, active_swt);
0061 
0062 % --- MAIN PROCEDURE --------------------------------------------------------- %
0063 %
0064 position = [];
0065 direction = [];
0066 coilweight = [];
0067 center = [];
0068 if result ~= 0
0069   return;
0070 end
0071 
0072 func_ = mfilename;
0073 
0074 [Measurement, device] = vb_load_device(megfile);
0075 
0076 Device = upper(device);
0077 
0078 if ~strcmpi(Measurement, 'MEG')
0079   msg = sprintf('(%s) Measurement is ''%s'', not ''MEG''.(%s)', ...
0080     func_, Measurement, megfile);
0081   vb_disp(msg);
0082   result = 2;
0083   return;
0084 end
0085 
0086 switch  Device
0087   case  'SBI'
0088     [position, direction, coilweight, center] = ...
0089       inner_get_info_sbi(megfile, ch_type);
0090     
0091   case  'YOKOGAWA'
0092     [position, direction, coilweight, center] = ...
0093       inner_get_info_yokogawa(megfile, ch_type, active_swt);
0094 
0095   otherwise
0096     msg = sprintf('(%s)unexpected Device : %s', func_, Device);
0097     vb_disp(msg);
0098 
0099     result = 2;
0100     [position, direction, coilweight, center] = ...
0101       inner_get_info_yokogawa(megfile, ch_type, active_swt);
0102 end
0103 
0104 % arrange center to [1 x 3]
0105 if ~isempty(center)
0106   center = vb_util_arrange_list(center, 1);
0107 end
0108 
0109 return;
0110 %
0111 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0112 
0113 % --- INNER FUNCTIONS -------------------------------------------------------- %
0114 %
0115 % --- inner_check_arguments()
0116 %
0117 function [megfile, ch_type, active_swt, result] = ...
0118   inner_check_arguments(megfile, ch_type, active_swt)
0119 func_ = mfilename;
0120 result = 0;
0121 
0122 if isempty(megfile)
0123   msg = sprintf('(%s)MEG-MAT file is a required parameter', func_);
0124   vb_disp(msg);
0125 %   fprintf('(%s)MEG-MAT file is a required parameter\n', func_);
0126   result = 1; % error code 1 means bad megfile
0127   return;
0128 end
0129 
0130 if exist(megfile, 'file') ~= 2
0131   msg = sprintf('(%s)cannot find MEG-MAT file : %s', megfile);
0132   vb_disp(msg);
0133 %   fprintf('(%s)cannot find MEG-MAT file : %s\n', megfile);
0134   result = 1;
0135   return;
0136 end
0137 
0138 if isempty(ch_type)
0139   ch_type = 'MEG';
0140 end
0141 
0142 % case-insensitive
0143 ch_type = upper(ch_type);
0144 
0145 if isempty(active_swt)
0146   active_swt = false;
0147 end
0148 return;
0149 %
0150 % --- end of inner_check_arguments()
0151 
0152 
0153 % --- inner_get_info_sbi
0154 %
0155 function [position, direction, coilweight, center] = ...
0156       inner_get_info_sbi(megfile, ch_type)
0157 
0158 [position, direction, coilweight, center] = load_sbi_sensor(megfile);
0159 
0160 switch ch_type
0161   case  'MEG'
0162     % require no special action
0163   case  'REF'
0164     position = [];
0165     direction = [];
0166     coilweight = [];
0167   case  'ALL'
0168     % require no special action
0169   otherwise
0170     error('(%s) undefined ch_type : %s', mfilename, ch_type);
0171 end
0172 return;
0173 %
0174 % --- end of inner_get_info_sbi()
0175 
0176 % --- inner_get_info_yokogawa
0177 %
0178 function [position, direction, coilweight, center] = ...
0179       inner_get_info_yokogawa(megfile, ch_type, active_swt)
0180 %{
0181 position = [];
0182 direction = [];
0183 coilweight = [];
0184 center = [];
0185 %}
0186 
0187 switch ch_type
0188   case  'MEG'
0189     % get MEG channel information
0190     [pick, Qpick, CW, center] = ...
0191       vb_load_yokogawa_sensor(megfile, false, active_swt);
0192 
0193     position = pick;
0194     direction = Qpick;
0195     coilweight = CW;
0196     
0197   case  'REF'
0198     % get REFFERENCE channel information
0199     [ref_pick, ref_Qpick, ref_CW, center] = ...
0200       vb_load_yokogawa_sensor(megfile, true, active_swt);
0201 
0202     position = ref_pick;
0203     direction = ref_Qpick;
0204     coilweight = ref_CW;
0205     
0206   case  'ALL'
0207     % get MEG channel information
0208     [pick, Qpick, CW, center] = ...
0209       vb_load_yokogawa_sensor(megfile, false, active_swt);
0210 
0211     % get REFFERENCE channel information
0212     [ref_pick, ref_Qpick, ref_CW, center] = ...
0213       vb_load_yokogawa_sensor(megfile, true, active_swt);
0214 
0215     position = [pick; ref_pick];
0216     direction = [Qpick; ref_Qpick];
0217 
0218     meg_ch_len = size(CW,1);
0219     meg_coil_len = size(CW,2);
0220     ref_ch_len = size(ref_CW,1);
0221     ref_coil_len = size(ref_CW,2);
0222       
0223     ch_len = meg_ch_len + ref_ch_len;
0224     coil_len = meg_coil_len + ref_coil_len;
0225 
0226     % initialize
0227     coilweight = zeros(ch_len, coil_len);
0228       
0229     % MEG channel
0230     coilweight(1:meg_ch_len, 1:meg_coil_len) = CW;
0231     coilweight((meg_ch_len+1):ch_len, (meg_coil_len+1):coil_len) = ref_CW;
0232     
0233   otherwise
0234     % ---  supporse that a type name is specified
0235     % ---  ONLY 'MEG' CHANNELS ('AXIAL' or 'PLANAR')
0236     ch_info = vb_load_channel_info(megfile, ch_type);
0237     if isempty(ch_info)
0238       error('(%s) unknown ch_type : %s', mfilename, ch_type);
0239     end
0240     
0241     [position, direction, coilweight, center] = ...
0242       vb_megfile_get_sensor_position_by_name(megfile, ch_info.Name, active_swt);
0243 end
0244 
0245 % --- solve center
0246 if isempty(center)
0247   meginfo = vb_megfile_load_meginfo(megfile);
0248 
0249   if isfield(meginfo, 'Vcenter')
0250     % center coordinate
0251     center = meginfo.Vcenter;
0252   end
0253 end
0254 return;
0255 %
0256 % --- end of inner_get_info_yokogawa()
0257 %
0258 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0259 
0260 % --- END OF FILE --- %

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