Home > functions > device > meg > yokogawa > utility > vb_yokogawa_plot_sensor.m

vb_yokogawa_plot_sensor

PURPOSE ^

Plot yokogawa sensor.

SYNOPSIS ^

function vb_yokogawa_plot_sensor(megfile, plot_spec)

DESCRIPTION ^

 Plot yokogawa sensor.
 [USAGE]
    vb_yokogawa_plot_sensor(<megfile> [,plot_spec]);
 [IN]
    megfile : <<required>> MEG-MAT file.
    plot_spec <<optional>> struct of plot parameter
             .AxisBackgroundColor : Background color of axes
                                    = 'k' %  [DEFAULT]
             .ChannelType   : plot channel type
                              = 0  % all     [DEFAULT]
                              = 1  % Axial  vb_gradio meter
                              = 2  % Planar vb_gradio meter
             .PlotDetectorCoil : plot detector coil
                                  = true   % plot on  [DEFAULT]
                                  = false  % plot off
                .DetectorMtype : plot type of detector coil.
                                 = 'r.'   [DEFAULT]
                .DetectorMsize : plot size of detector coil.
                                  = 30    [DEFAULT]
             .PlotCompensationCoil : plot compensation coil
                                      = true   % plot on
                                      = false  % plot off [DEFAULT]
                .CompensationMtype : plot type of compensation coil.
                                      = 'c.'   [DEFAULT]
                .CompensationMsize : plot size of compensation coil.
                                      = 30    [DEFAULT]
             .ConnectPairLine : connect pair of coils with line
                                  = 'b-'   [DEFAULT]
             .PlotNormalVector : plot normal vector
                                  = true   % plot on  [DEFAULT]
                                  = false  % plot off
                 .VectorLength : normal vector length[m]
                                  = 0.01   [DEFAULT]
             .PlotSphere : plot sphere
                            = true   % plot on  [DEFAULT]
                            = false  % plot off
               .SphereRadius : Sphere radius [m]
                                = 0.1           [DEFAULT]
                .SphereColor : Sphere color
                                = [0.8 0.8 0.8] [DEFAULT]
 [OUT]
    none

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function vb_yokogawa_plot_sensor(megfile, plot_spec)
0002 % Plot yokogawa sensor.
0003 % [USAGE]
0004 %    vb_yokogawa_plot_sensor(<megfile> [,plot_spec]);
0005 % [IN]
0006 %    megfile : <<required>> MEG-MAT file.
0007 %    plot_spec <<optional>> struct of plot parameter
0008 %             .AxisBackgroundColor : Background color of axes
0009 %                                    = 'k' %  [DEFAULT]
0010 %             .ChannelType   : plot channel type
0011 %                              = 0  % all     [DEFAULT]
0012 %                              = 1  % Axial  vb_gradio meter
0013 %                              = 2  % Planar vb_gradio meter
0014 %             .PlotDetectorCoil : plot detector coil
0015 %                                  = true   % plot on  [DEFAULT]
0016 %                                  = false  % plot off
0017 %                .DetectorMtype : plot type of detector coil.
0018 %                                 = 'r.'   [DEFAULT]
0019 %                .DetectorMsize : plot size of detector coil.
0020 %                                  = 30    [DEFAULT]
0021 %             .PlotCompensationCoil : plot compensation coil
0022 %                                      = true   % plot on
0023 %                                      = false  % plot off [DEFAULT]
0024 %                .CompensationMtype : plot type of compensation coil.
0025 %                                      = 'c.'   [DEFAULT]
0026 %                .CompensationMsize : plot size of compensation coil.
0027 %                                      = 30    [DEFAULT]
0028 %             .ConnectPairLine : connect pair of coils with line
0029 %                                  = 'b-'   [DEFAULT]
0030 %             .PlotNormalVector : plot normal vector
0031 %                                  = true   % plot on  [DEFAULT]
0032 %                                  = false  % plot off
0033 %                 .VectorLength : normal vector length[m]
0034 %                                  = 0.01   [DEFAULT]
0035 %             .PlotSphere : plot sphere
0036 %                            = true   % plot on  [DEFAULT]
0037 %                            = false  % plot off
0038 %               .SphereRadius : Sphere radius [m]
0039 %                                = 0.1           [DEFAULT]
0040 %                .SphereColor : Sphere color
0041 %                                = [0.8 0.8 0.8] [DEFAULT]
0042 % [OUT]
0043 %    none
0044 %
0045 % Copyright (C) 2011, ATR All Rights Reserved.
0046 % License : New BSD License(see VBMEG_LICENSE.txt)
0047 
0048 %
0049 % --- Previous check
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 % Check inputted fields
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     % Set parameter to parm
0069     for k=1:Nfields
0070         parm.(fields{k}) = plot_spec.(fields{k});
0071     end
0072 end
0073 
0074 %
0075 % --- Main Procedure
0076 %
0077 
0078 % constant
0079 MagnetoMeter          = 1;
0080 AxialGradioMeter      = 2;
0081 PlanarGradioMeter     = 3;
0082 
0083 % data load
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 % --- AxialGradioMeter
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 % --- PlannerGradioMeter
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 %   Plot section
0121 %%%%%%%%%%%%%%%%%%%%%%
0122 
0123 fig = figure;
0124 h = axes; hold on;
0125 set(h, 'Color', parm.AxisBackgroundColor);
0126 
0127 % Detector coil
0128 if parm.PlotDetectorCoil
0129     if( parm.ChannelType == 0 || parm.ChannelType == 1 )
0130         % Axial Detector coil
0131         plot3(pick1_axial(:, 1), pick1_axial(:, 2), pick1_axial(:, 3), ...
0132               parm.DetectorMtype, ...
0133               'MarkerSize', parm.DetectorMsize);
0134         % Axial Detector coil normal vector
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         % Planar Detector coil
0145         plot3(pick1_plane(:, 1), pick1_plane(:, 2), pick1_plane(:, 3), ...
0146               parm.DetectorMtype, ...
0147               'MarkerSize', parm.DetectorMsize);
0148         % Planar Detector coil normal vector
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 % Compensation Coil
0160 if parm.PlotCompensationCoil
0161 
0162     if( parm.ChannelType == 0 || parm.ChannelType == 1 )
0163         % Axial Compensation Coil
0164         plot3(pick2_axial(:, 1), pick2_axial(:, 2), pick2_axial(:, 3), ...
0165             parm.CompensationMtype, ...
0166             'MarkerSize', parm.DetectorMsize);
0167         % Axial Compensation Coil normal vector
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         % Planar Compensation coil
0178         plot3(pick2_plane(:, 1), pick2_plane(:, 2), pick2_plane(:, 3), ...
0179               parm.CompensationMtype, ...
0180               'MarkerSize', parm.DetectorMsize);
0181         % Planar Compensation coil normal vector
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 % Connect detector coil and compensation coil.
0193 if parm.PlotPairLine
0194     if parm.PlotDetectorCoil && parm.PlotCompensationCoil
0195         if( parm.ChannelType == 0 || parm.ChannelType == 1 )
0196             % Axial pair
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             % Planar pair
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 % Sphere
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 % Figure title
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 % --- Inner function
0254 %
0255 
0256 function plot_spec = DEFAULT_PARAMETER
0257 % set default parameter of this function.
0258 %
0259 plot_spec = struct;
0260 
0261 % Plot channel type
0262 plot_spec.AxisBackgroundColor = 'k';
0263 plot_spec.ChannelType = 0;
0264 
0265 % Detector Coil
0266 plot_spec.PlotDetectorCoil = true;
0267 plot_spec.DetectorMtype = 'r.';
0268 plot_spec.DetectorMsize = 30;
0269 
0270 % Compensation Coil
0271 plot_spec.PlotCompensationCoil  = true;
0272 plot_spec.CompensationMtype = 'c.';
0273 plot_spec.CompensationMsize = 30;
0274 
0275 % ConnectLine between detector coil and Compensation coil.
0276 plot_spec.PlotPairLine = false;
0277 plot_spec.PairLineType = 'b-';
0278 
0279 % NormalVetorLength [m]
0280 plot_spec.PlotNormalVector = true;
0281 plot_spec.VectorLength     = 0.01;
0282 
0283 % Sphere plot
0284 plot_spec.PlotSphere = true;
0285 plot_spec.SphereRadius = 0.1;
0286 plot_spec.SphereColor  = [0.8 0.8 0.8];
0287

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005