


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]
channel_info : <<struct>> channel information of loaded data
: .Active [Nchannel x 1]
: .Name [Nchannel x 1]
: .Type [Nchannel x 1]
: .ID [Nchannel x 1]
not supported reference channel info.
[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)


0001 function [pick, Qpick, CoilWeight, Vcenter, channel_info] = ... 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 % channel_info : <<struct>> channel information of loaded data 0028 % : .Active [Nchannel x 1] 0029 % : .Name [Nchannel x 1] 0030 % : .Type [Nchannel x 1] 0031 % : .ID [Nchannel x 1] 0032 % not supported reference channel info. 0033 % [history] 0034 % 2007-07-10 (Sako) supported refference sensor 0035 % 2009-08-03 (Sako) modified not to use vb_load_meg_info 0036 % 2011-07-21 (Sako) modified how to deal with sensor_weight_ref 0037 % 0038 % Copyright (C) 2011, ATR All Rights Reserved. 0039 % License : New BSD License(see VBMEG_LICENSE.txt) 0040 0041 % --- CHECK ARGUMENTS --- % 0042 if ~exist('meg_file', 'var'), meg_file = ''; end 0043 if ~exist('ref_swt', 'var'), ref_swt = []; end 0044 if ~exist('active_swt', 'var'), active_swt = []; end 0045 [meg_file, ref_swt, active_swt] = ... 0046 inner_check_arguments(meg_file, ref_swt, active_swt); 0047 0048 % --- MAIN PROCEDURE --------------------------------------------------------- % 0049 % 0050 channel_info = []; 0051 0052 if ~ref_swt 0053 % --- meg channels 0054 load(meg_file, 'MEGinfo', 'pick', 'Qpick'); 0055 0056 CoilWeight = vb_meginfo_get_sensor_weight_meg(MEGinfo); 0057 0058 if isfield(MEGinfo, 'Vcenter') 0059 Vcenter = MEGinfo.Vcenter; 0060 else 0061 Vcenter = []; 0062 end 0063 0064 % ----- active filter 0065 ch_info_meg = vb_load_channel_info(meg_file, 'MEG'); 0066 active_channel = vb_info_get_active_channel(MEGinfo, 1); 0067 if isempty(active_channel) 0068 active_swt = false; 0069 end 0070 0071 if ~active_swt 0072 channel_info = ch_info_meg; 0073 return; 0074 else 0075 active_idx = find(active_channel == 1); 0076 n_channel = vb_info_get_Nchannel(MEGinfo); 0077 active_coil_idx = [active_idx; (active_idx + n_channel)]; 0078 0079 if ~isempty(pick) 0080 pick = pick(active_coil_idx, :); 0081 end 0082 0083 if ~isempty(Qpick) 0084 Qpick = Qpick(active_coil_idx, :); 0085 end 0086 0087 if ~isempty(CoilWeight) 0088 CoilWeight = CoilWeight(active_idx, active_coil_idx); 0089 end 0090 end 0091 channel_info.Active = ch_info_meg.Active(active_idx); 0092 channel_info.Name = ch_info_meg.Name(active_idx); 0093 channel_info.Type = ch_info_meg.Type(active_idx); 0094 channel_info.ID = ch_info_meg.ID(active_idx); 0095 else 0096 0097 % --- reference channels 0098 ref_pick = []; 0099 ref_Qpick = []; 0100 0101 load(meg_file, 'MEGinfo', 'ref_pick', 'ref_Qpick'); 0102 0103 Nref = size(ref_pick,1); 0104 0105 % --- sensor_weight_ref 0106 cur_s_w_r = vb_meginfo_get_sensor_weight_refmg(MEGinfo); 0107 if isempty(cur_s_w_r) 0108 MEGinfo = vb_meginfo_init_sensor_weight_refmg(MEGinfo, Nref); 0109 end 0110 CoilWeight = vb_meginfo_get_sensor_weight_refmg(MEGinfo); 0111 0112 if isfield(MEGinfo, 'Vcenter') 0113 Vcenter = MEGinfo.Vcenter; 0114 else 0115 Vcenter = []; 0116 end 0117 0118 if ~exist('ref_pick', 'var') 0119 pick = []; 0120 else 0121 pick = ref_pick; 0122 end 0123 0124 if ~exist('ref_Qpick', 'var') 0125 Qpick = []; 0126 else 0127 Qpick = ref_Qpick; 0128 end 0129 0130 if ~active_swt 0131 return; 0132 end 0133 0134 ch_info_ref = vb_load_channel_info(meg_file, 'REFERENCE'); 0135 if isempty(ch_info_ref) 0136 active_swt = false; 0137 end 0138 0139 % ----- active filter for reference channels 0140 if ~active_swt 0141 return; 0142 else 0143 active_idx = find(ch_info_ref.Active == 1); 0144 if ~isempty(pick) 0145 pick = pick(active_idx, :); 0146 end 0147 0148 if ~isempty(Qpick) 0149 Qpick = Qpick(active_idx, :); 0150 end 0151 0152 if ~isempty(CoilWeight) 0153 CoilWeight = CoilWeight(active_idx, active_idx); 0154 end 0155 end 0156 end 0157 % 0158 % --- END OF MAIN PROCEDURE -------------------------------------------------- % 0159 0160 % --- INNER FUNCTIONS -------------------------------------------------------- % 0161 % 0162 % --- inner_check_arguments() 0163 % 0164 function [meg_file, ref_swt, active_swt] = ... 0165 inner_check_arguments(meg_file, ref_swt, active_swt) 0166 func_ = mfilename; 0167 0168 if isempty(meg_file) 0169 error('(%s) meg_file is a required parameter', func_); 0170 end 0171 0172 if exist(meg_file, 'file') ~= 2 0173 error('(%s) cannot find meg_file (%s)', func_, meg_file); 0174 end 0175 0176 if isempty(ref_swt) 0177 ref_swt = false; 0178 end 0179 0180 if isempty(active_swt) 0181 active_swt = false; 0182 end 0183 return; 0184 % 0185 % --- end of inner_check_arguments() 0186 % 0187 % --- END OF INNER FUNCTIONS ------------------------------------------------- % 0188 0189 % --- END OF FILE --- % 0190