0001 function [pick, Qpick, CoilWeight, Vcenter] = ...
0002 vb_load_yokogawa_sensor(meg_file, ref_swt, 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 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
0043
0044 if ~ref_swt
0045
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
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
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
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
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
0151
0152
0153
0154
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
0178
0179
0180
0181
0182