0001 function [pick, Qpick, CoilWeight, Vcenter, channel_info] = ...
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
0037
0038
0039
0040
0041
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
0049
0050 channel_info = [];
0051
0052 if ~ref_swt
0053
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
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
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
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
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
0159
0160
0161
0162
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
0186
0187
0188
0189
0190