Home > functions > device > meg > yokogawa > vb_load_yokogawa_sensor.m

vb_load_yokogawa_sensor

PURPOSE ^

Load Yokogawa MEG sensor information

SYNOPSIS ^

function [pick, Qpick, CoilWeight, Vcenter] =vb_load_yokogawa_sensor(meg_file, ref_swt, active_swt)

DESCRIPTION ^

 Load Yokogawa MEG sensor information
 [usage]
   [pick, Qpick, CoilWeight, Vcenter] = ...
     vb_load_yokogawa_sensor(meg_file, ref_swt, active_swt)

 [input]
     meg_file : <required> meg-mat file
      ref_swt : <optional> <<boolean>> flag whether to return normal sensors
              :  or reference sensors
              :    true) : reference sensor
              : [false]) : normal sensor
   active_swt : <optional> <<boolean>> flag whether to filter active channels
              :    true) : Yes. This function filters active channels.
              : [false]) : No. This function does not filter active channels.

 [output]
    pick(1:n,1:3)     : position of detector coils.
                      : if ref is true, these are positions of refference.
        (n+1:2n, 1:3) : position of conpensation detector coils.
    Qpick(1:2n, 1:3)  : direction of coils.
                      : if ref is true, these are directions of refference
    CoilWeight        : (m,n) n-th coil weight for m-th sensor channel
                  basis(channel,dipole) = sensor_weight * basis(coil,dipole)
    Vcenter           : % origin of sphere model [m]
 [history]
   2007-07-10 (Sako) supported refference sensor
   2009-08-03 (Sako) modified not to use vb_load_meg_info
   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 [pick, Qpick, CoilWeight, Vcenter] = ...
0002   vb_load_yokogawa_sensor(meg_file, ref_swt, active_swt)
0003 % Load Yokogawa MEG sensor information
0004 % [usage]
0005 %   [pick, Qpick, CoilWeight, Vcenter] = ...
0006 %     vb_load_yokogawa_sensor(meg_file, ref_swt, active_swt)
0007 %
0008 % [input]
0009 %     meg_file : <required> meg-mat file
0010 %      ref_swt : <optional> <<boolean>> flag whether to return normal sensors
0011 %              :  or reference sensors
0012 %              :    true) : reference sensor
0013 %              : [false]) : normal sensor
0014 %   active_swt : <optional> <<boolean>> flag whether to filter active channels
0015 %              :    true) : Yes. This function filters active channels.
0016 %              : [false]) : No. This function does not filter active channels.
0017 %
0018 % [output]
0019 %    pick(1:n,1:3)     : position of detector coils.
0020 %                      : if ref is true, these are positions of refference.
0021 %        (n+1:2n, 1:3) : position of conpensation detector coils.
0022 %    Qpick(1:2n, 1:3)  : direction of coils.
0023 %                      : if ref is true, these are directions of refference
0024 %    CoilWeight        : (m,n) n-th coil weight for m-th sensor channel
0025 %                  basis(channel,dipole) = sensor_weight * basis(coil,dipole)
0026 %    Vcenter           : % origin of sphere model [m]
0027 % [history]
0028 %   2007-07-10 (Sako) supported refference sensor
0029 %   2009-08-03 (Sako) modified not to use vb_load_meg_info
0030 %   2011-07-21 (Sako) modified how to deal with sensor_weight_ref
0031 %
0032 % Copyright (C) 2011, ATR All Rights Reserved.
0033 % License : New BSD License(see VBMEG_LICENSE.txt)
0034 
0035 % --- CHECK ARGUMENTS --- %
0036 if ~exist('meg_file', 'var'), meg_file = ''; end
0037 if ~exist('ref_swt', 'var'), ref_swt = []; end
0038 if ~exist('active_swt', 'var'), active_swt = []; end
0039 [meg_file, ref_swt, active_swt] = ...
0040   inner_check_arguments(meg_file, ref_swt, active_swt);
0041 
0042 % --- MAIN PROCEDURE --------------------------------------------------------- %
0043 %
0044 if ~ref_swt
0045   % --- meg channels
0046   load(meg_file, 'MEGinfo', 'pick', 'Qpick');
0047 
0048   CoilWeight = vb_meginfo_get_sensor_weight_meg(MEGinfo);
0049   
0050   if isfield(MEGinfo, 'Vcenter')
0051     Vcenter = MEGinfo.Vcenter;
0052   else
0053     Vcenter = [];
0054   end
0055   
0056   if ~active_swt
0057     return;
0058   end
0059   
0060   % ----- active filter
0061   ch_info_meg = vb_load_channel_info(meg_file, 'MEG');
0062   if isempty(ch_info_meg)
0063     active_swt = false;
0064   end
0065 
0066   if ~active_swt
0067     return;
0068 
0069   else
0070     active_idx = find(ch_info_meg.Active == 1);
0071     n_channel = vb_info_get_Nchannel(MEGinfo);
0072     active_coil_idx = [active_idx; (active_idx + n_channel)];
0073 
0074     if ~isempty(pick)
0075       pick = pick(active_coil_idx, :);
0076     end
0077     
0078     if ~isempty(Qpick)
0079       Qpick = Qpick(active_coil_idx, :);
0080     end
0081     
0082     if ~isempty(CoilWeight)
0083       CoilWeight = CoilWeight(active_idx, active_coil_idx);
0084     end
0085   end
0086   
0087 else
0088   
0089   % --- reference channels
0090   ref_pick = [];
0091   ref_Qpick = [];
0092   
0093   load(meg_file, 'MEGinfo', 'ref_pick', 'ref_Qpick');
0094   
0095   Nref = size(ref_pick,1);
0096 
0097   % --- sensor_weight_ref
0098   cur_s_w_r = vb_meginfo_get_sensor_weight_refmg(MEGinfo);
0099   if isempty(cur_s_w_r)
0100     MEGinfo = vb_meginfo_init_sensor_weight_refmg(MEGinfo, Nref);
0101   end
0102   CoilWeight = vb_meginfo_get_sensor_weight_refmg(MEGinfo);
0103   
0104   if isfield(MEGinfo, 'Vcenter')
0105     Vcenter = MEGinfo.Vcenter;
0106   else
0107     Vcenter = [];
0108   end
0109 
0110   if ~exist('ref_pick', 'var')
0111     pick = [];
0112   else
0113     pick = ref_pick;
0114   end
0115   
0116   if ~exist('ref_Qpick', 'var')
0117     Qpick = [];
0118   else
0119     Qpick = ref_Qpick;
0120   end
0121 
0122   if ~active_swt
0123     return;
0124   end
0125   
0126   ch_info_ref = vb_load_channel_info(meg_file, 'REFERENCE');
0127   if isempty(ch_info_ref)
0128     active_swt = false;
0129   end
0130 
0131   % ----- active filter for reference channels
0132   if ~active_swt
0133     return;
0134   else
0135     active_idx = find(ch_info_ref.Active == 1);
0136     if ~isempty(pick)
0137       pick = pick(active_idx, :);
0138     end
0139     
0140     if ~isempty(Qpick)
0141       Qpick = Qpick(active_idx, :);
0142     end
0143     
0144     if ~isempty(CoilWeight)
0145       CoilWeight = CoilWeight(active_idx, active_idx);
0146     end
0147   end
0148 end
0149 %
0150 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0151 
0152 % --- INNER FUNCTIONS -------------------------------------------------------- %
0153 %
0154 % --- inner_check_arguments()
0155 %
0156 function [meg_file, ref_swt, active_swt] = ...
0157   inner_check_arguments(meg_file, ref_swt, active_swt)
0158 func_ = mfilename;
0159 
0160 if isempty(meg_file)
0161   error('(%s) meg_file is a required parameter', func_);
0162 end
0163 
0164 if exist(meg_file, 'file') ~= 2
0165   error('(%s) cannot find meg_file (%s)', func_, meg_file);
0166 end
0167 
0168 if isempty(ref_swt)
0169   ref_swt = false;
0170 end
0171 
0172 if isempty(active_swt)
0173   active_swt = false;
0174 end
0175 return;
0176 %
0177 % --- end of inner_check_arguments()
0178 %
0179 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0180 
0181 % --- END OF FILE --- %
0182

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