0001 function [position, direction, coilweight, center, result] = ...
0002 vb_megfile_get_sensor_position_by_type(megfile, ch_type, active_swt)
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
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
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
0105 if ~isempty(center)
0106 center = vb_util_arrange_list(center, 1);
0107 end
0108
0109 return;
0110
0111
0112
0113
0114
0115
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
0126 result = 1;
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
0134 result = 1;
0135 return;
0136 end
0137
0138 if isempty(ch_type)
0139 ch_type = 'MEG';
0140 end
0141
0142
0143 ch_type = upper(ch_type);
0144
0145 if isempty(active_swt)
0146 active_swt = false;
0147 end
0148 return;
0149
0150
0151
0152
0153
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
0163 case 'REF'
0164 position = [];
0165 direction = [];
0166 coilweight = [];
0167 case 'ALL'
0168
0169 otherwise
0170 error('(%s) undefined ch_type : %s', mfilename, ch_type);
0171 end
0172 return;
0173
0174
0175
0176
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
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
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
0208 [pick, Qpick, CW, center] = ...
0209 vb_load_yokogawa_sensor(megfile, false, active_swt);
0210
0211
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
0227 coilweight = zeros(ch_len, coil_len);
0228
0229
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
0235
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
0246 if isempty(center)
0247 meginfo = vb_megfile_load_meginfo(megfile);
0248
0249 if isfield(meginfo, 'Vcenter')
0250
0251 center = meginfo.Vcenter;
0252 end
0253 end
0254 return;
0255
0256
0257
0258
0259
0260