0001 function vb_yokogawa_plot_sensor(megfile, plot_spec)
0002
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 if ~exist('megfile', 'var') || exist(megfile, 'file') ~= 2
0053 error('megfile is a required parameter.');
0054 end
0055
0056 parm = DEFAULT_PARAMETER;
0057
0058
0059 if exist('plot_spec', 'var')
0060 fields = fieldnames(plot_spec);
0061 Nfields = length(fields)
0062 for k=1:Nfields
0063 if ~isfield(parm, fields{k})
0064 error('Unknown parameter : %s', fields{k});
0065 end
0066 end
0067
0068
0069 for k=1:Nfields
0070 parm.(fields{k}) = plot_spec.(fields{k});
0071 end
0072 end
0073
0074
0075
0076
0077
0078
0079 MagnetoMeter = 1;
0080 AxialGradioMeter = 2;
0081 PlanarGradioMeter = 3;
0082
0083
0084 load(megfile, 'pick', 'Qpick', 'MEGinfo');
0085 CoilWeight = MEGinfo.sensor_weight;
0086 if isfield(MEGinfo, 'ChannelInfo')
0087 ChannelInfo = MEGinfo.ChannelInfo;
0088 else
0089 ChannelInfo.Type = repmat(AxialGradioMeter, [MEGinfo.Nch, 1]);
0090 ChannelInfo.Name = MEGinfo.MEGch_name;
0091 end
0092
0093
0094 ix_axial = find(ChannelInfo.Type == AxialGradioMeter );
0095 ChannelName = ChannelInfo.Name;
0096 Nch_axial = length(ix_axial);
0097 ix_axial_pair = zeros(Nch_axial, 1);
0098 for n=1:Nch_axial
0099 ix_axial_pair(n) = find(CoilWeight(ix_axial(n),:) < 0 );
0100 end
0101 pick1_axial = pick(ix_axial,:);
0102 pick2_axial = pick(ix_axial_pair,:);
0103 Qpick1_axial = Qpick(ix_axial,:);
0104 Qpick2_axial = Qpick(ix_axial_pair,:);
0105
0106
0107 ix_plane = find(ChannelInfo.Type == PlanarGradioMeter);
0108 Nch_plane = length(ix_plane);
0109 ix_plane_pair = zeros(Nch_plane, 1);
0110 for n=1:Nch_plane
0111 ix_plane_pair(n) = find(CoilWeight(ix_plane(n),:) < 0 );
0112 end
0113 pick1_plane = pick(ix_plane,:);
0114 pick2_plane = pick(ix_plane_pair,:);
0115 Qpick1_plane = Qpick(ix_plane,:);
0116 Qpick2_plane = Qpick(ix_plane_pair,:);
0117
0118
0119
0120
0121
0122
0123 fig = figure;
0124 h = axes; hold on;
0125 set(h, 'Color', parm.AxisBackgroundColor);
0126
0127
0128 if parm.PlotDetectorCoil
0129 if( parm.ChannelType == 0 || parm.ChannelType == 1 )
0130
0131 plot3(pick1_axial(:, 1), pick1_axial(:, 2), pick1_axial(:, 3), ...
0132 parm.DetectorMtype, ...
0133 'MarkerSize', parm.DetectorMsize);
0134
0135 if parm.PlotNormalVector
0136 dx = parm.VectorLength;
0137 pos_x = [pick1_axial(:, 1), pick1_axial(:, 1) + dx * Qpick1_axial(:, 1)]';
0138 pos_y = [pick1_axial(:, 2), pick1_axial(:, 2) + dx * Qpick1_axial(:, 2)]';
0139 pos_z = [pick1_axial(:, 3), pick1_axial(:, 3) + dx * Qpick1_axial(:, 3)]';
0140 plot3(pos_x, pos_y, pos_z, '-');
0141 end
0142 end
0143 if( parm.ChannelType == 0 || parm.ChannelType == 2 )
0144
0145 plot3(pick1_plane(:, 1), pick1_plane(:, 2), pick1_plane(:, 3), ...
0146 parm.DetectorMtype, ...
0147 'MarkerSize', parm.DetectorMsize);
0148
0149 if parm.PlotNormalVector
0150 dx = parm.VectorLength;
0151 pos_x = [pick1_plane(:, 1), pick1_plane(:, 1) + dx * Qpick1_plane(:, 1)]';
0152 pos_y = [pick1_plane(:, 2), pick1_plane(:, 2) + dx * Qpick1_plane(:, 2)]';
0153 pos_z = [pick1_plane(:, 3), pick1_plane(:, 3) + dx * Qpick1_plane(:, 3)]';
0154 plot3(pos_x, pos_y, pos_z, '-');
0155 end
0156 end
0157 end
0158
0159
0160 if parm.PlotCompensationCoil
0161
0162 if( parm.ChannelType == 0 || parm.ChannelType == 1 )
0163
0164 plot3(pick2_axial(:, 1), pick2_axial(:, 2), pick2_axial(:, 3), ...
0165 parm.CompensationMtype, ...
0166 'MarkerSize', parm.DetectorMsize);
0167
0168 if parm.PlotNormalVector
0169 dx = parm.VectorLength;
0170 pos_x = [pick2_axial(:, 1), pick2_axial(:, 1) + dx * Qpick2_axial(:, 1)]';
0171 pos_y = [pick2_axial(:, 2), pick2_axial(:, 2) + dx * Qpick2_axial(:, 2)]';
0172 pos_z = [pick2_axial(:, 3), pick2_axial(:, 3) + dx * Qpick2_axial(:, 3)]';
0173 plot3(pos_x, pos_y, pos_z, '-');
0174 end
0175 end
0176 if( parm.ChannelType == 0 || parm.ChannelType == 2 )
0177
0178 plot3(pick2_plane(:, 1), pick2_plane(:, 2), pick2_plane(:, 3), ...
0179 parm.CompensationMtype, ...
0180 'MarkerSize', parm.DetectorMsize);
0181
0182 if parm.PlotNormalVector
0183 dx = parm.VectorLength;
0184 pos_x = [pick2_plane(:, 1), pick2_plane(:, 1) + dx * Qpick2_plane(:, 1)]';
0185 pos_y = [pick2_plane(:, 2), pick2_plane(:, 2) + dx * Qpick2_plane(:, 2)]';
0186 pos_z = [pick2_plane(:, 3), pick2_plane(:, 3) + dx * Qpick2_plane(:, 3)]';
0187 plot3(pos_x, pos_y, pos_z, '-');
0188 end
0189 end
0190 end
0191
0192
0193 if parm.PlotPairLine
0194 if parm.PlotDetectorCoil && parm.PlotCompensationCoil
0195 if( parm.ChannelType == 0 || parm.ChannelType == 1 )
0196
0197 pos_x = [pick1_axial(:, 1), pick2_axial(:, 1)]';
0198 pos_y = [pick1_axial(:, 2), pick2_axial(:, 2)]';
0199 pos_z = [pick1_axial(:, 3), pick2_axial(:, 3)]';
0200 plot3(pos_x, pos_y, pos_z, parm.PairLineType);
0201 end
0202 if( parm.ChannelType == 0 || parm.ChannelType == 2 )
0203
0204 pos_x = [pick1_plane(:, 1), pick2_plane(:, 1)]';
0205 pos_y = [pick1_plane(:, 2), pick2_plane(:, 2)]';
0206 pos_z = [pick1_plane(:, 3), pick2_plane(:, 3)]';
0207 plot3(pos_x, pos_y, pos_z, parm.PairLineType);
0208 end
0209 end
0210 end
0211
0212
0213 if parm.PlotSphere
0214 [F, V] = vb_make_fullsphere(1000);
0215 V = V * parm.SphereRadius;
0216 patch('Faces', F, 'Vertices', V, 'Edgecolor', 'none', ...
0217 'FaceColor', parm.SphereColor);
0218 end
0219
0220 axis equal;
0221 axis tight;
0222
0223
0224 Title = [];
0225 if parm.PlotDetectorCoil
0226 Title = 'Detector Coils';
0227 end
0228 if parm.PlotCompensationCoil
0229 if ~isempty(Title)
0230 Title = [Title, ' & '];
0231 end
0232 Title = [Title, 'Compensation Coils'];
0233 end
0234
0235 Title = [Title, '( Axial gradiometer and Planar gradiometer )'];
0236
0237 if parm.ChannelType == 2 || isempty(pick1_axial)
0238 Title = strrep(Title, 'Axial gradiometer', '');
0239 Title = strrep(Title, 'and ', '');
0240 end
0241 if parm.ChannelType == 1 || isempty(pick1_plane)
0242 Title = strrep(Title, 'Planar gradiometer', '');
0243 Title = strrep(Title, 'and ', '');
0244 end
0245
0246 set(fig, 'Name', Title);
0247 set(fig, 'NumberTitle', 'off');
0248
0249 rotate3d on;
0250
0251 return;
0252
0253
0254
0255
0256 function plot_spec = DEFAULT_PARAMETER
0257
0258
0259 plot_spec = struct;
0260
0261
0262 plot_spec.AxisBackgroundColor = 'k';
0263 plot_spec.ChannelType = 0;
0264
0265
0266 plot_spec.PlotDetectorCoil = true;
0267 plot_spec.DetectorMtype = 'r.';
0268 plot_spec.DetectorMsize = 30;
0269
0270
0271 plot_spec.PlotCompensationCoil = true;
0272 plot_spec.CompensationMtype = 'c.';
0273 plot_spec.CompensationMsize = 30;
0274
0275
0276 plot_spec.PlotPairLine = false;
0277 plot_spec.PairLineType = 'b-';
0278
0279
0280 plot_spec.PlotNormalVector = true;
0281 plot_spec.VectorLength = 0.01;
0282
0283
0284 plot_spec.PlotSphere = true;
0285 plot_spec.SphereRadius = 0.1;
0286 plot_spec.SphereColor = [0.8 0.8 0.8];
0287