Home > functions > device > meg > yokogawa > vb_meg_yokogawa_load_ref_sensor.m

vb_meg_yokogawa_load_ref_sensor

PURPOSE ^

load reference sensor coordinates from YOKOGAWA file

SYNOPSIS ^

function [pick, Qpick, Nref] =vb_meg_yokogawa_load_ref_sensor(channel_info_base)

DESCRIPTION ^

 load reference sensor coordinates from YOKOGAWA file

 [usage]
   [pick, Qpick, Nref] = vb_meg_yokogawa_load_ref_sensor(channel_info_base)

 [input]
   channel_info_base : <required> <<struct>> return value of getYkgwHdrChannel

 [output]
    pick : [Nch x 3] sensor coordinates
   Qpick : [Nch x 3] vector
    Nref : number of reference channel

 [note]
   
 [history]
   2008-03-28 (Sako) thoroughly modified
   2011-06-22 (Sako) Completely renewed to be adapted to the new library

 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 [pick, Qpick, Nref] = ...
0002   vb_meg_yokogawa_load_ref_sensor(channel_info_base)
0003 % load reference sensor coordinates from YOKOGAWA file
0004 %
0005 % [usage]
0006 %   [pick, Qpick, Nref] = vb_meg_yokogawa_load_ref_sensor(channel_info_base)
0007 %
0008 % [input]
0009 %   channel_info_base : <required> <<struct>> return value of getYkgwHdrChannel
0010 %
0011 % [output]
0012 %    pick : [Nch x 3] sensor coordinates
0013 %   Qpick : [Nch x 3] vector
0014 %    Nref : number of reference channel
0015 %
0016 % [note]
0017 %
0018 % [history]
0019 %   2008-03-28 (Sako) thoroughly modified
0020 %   2011-06-22 (Sako) Completely renewed to be adapted to the new library
0021 %
0022 % Copyright (C) 2011, ATR All Rights Reserved.
0023 % License : New BSD License(see VBMEG_LICENSE.txt)
0024 
0025 % --- CHECK ARGUMENTS --- %
0026 if ~exist('channel_info_base', 'var'), channel_info_base = []; end
0027 [channel_info_base] = inner_check_arguments(channel_info_base);
0028 
0029 % --- MAIN PROCEDURE --------------------------------------------------------- %
0030 %
0031 % --- <<struct array>> fields are 'type' and 'data'
0032 ch_info_list = channel_info_base.channel;
0033 
0034 % '4' means reference channel
0035 ref_ch_types = vb_yokogawa_get_channel_type(4);
0036 
0037 Channel_active = [];
0038 Channel_name = [];
0039 Channel_type = [];
0040 Channel_id = [];
0041 
0042 % --- channel information list [1 x n_channel]
0043 ch_type_list = [ch_info_list(:).type];
0044 
0045 for i_type = 1:length(ref_ch_types)
0046   cur_type = ref_ch_types(i_type).id;
0047 
0048   cur_idx = find(ch_type_list(:) == cur_type);
0049   
0050   if isempty(cur_idx)
0051     continue;
0052   end
0053 
0054   num_ch = length(cur_idx);
0055   
0056 
0057   % active or not (NullChannel or not)
0058   Channel_active = [Channel_active; ones(num_ch,1)];
0059   Channel_name   = [Channel_name; (cur_idx + 1)];
0060   Channel_type   = [Channel_type; ch_type_list(cur_idx)];
0061   Channel_id     = [Channel_id; cur_idx];
0062 end
0063 
0064 Nref = length(Channel_active == 1);
0065 
0066 if Nref == 0
0067   pick = [];
0068   Qpick = [];
0069   return;
0070 end
0071 
0072 %
0073 % -- Coil information
0074 %
0075 pick = zeros(Nref,3);
0076 normline= zeros(Nref,3);
0077 unit_vector= zeros(Nref,3);
0078 
0079 % --- current (reference channel) list
0080 cur_data_list = [ch_info_list(Channel_id).data];
0081 
0082 % --- NewYKGWLib field format of channel_info.channel.data ------------------- %
0083 %
0084 % ----- If channel type is AxialGradioMeter or ReferenceAxialGradioMeter
0085 %
0086 % .x          : x coordinate of inner coil position [meter]
0087 % .y          : y coordinate of inner coil position [meter]
0088 % .z          : z coordinate of inner coil position [meter]
0089 % .zdir       : Sensor orientation from z-axis [degree]
0090 % .xdir       : Sensor orientation from x-axis [degree]
0091 % .baseline   : Baseline length [meter]
0092 % .size       : Inner coil size [meter]
0093 % .name       : Abbreviation name
0094 %
0095 % ---------------------------------------------------------------------------- %
0096 
0097 pick(:, 1) = [cur_data_list(:).x]; % X
0098 pick(:, 2) = [cur_data_list(:).y]; % Y
0099 pick(:, 3) = [cur_data_list(:).z]; % Z
0100 
0101 % normal line of pick
0102 zdir = [cur_data_list(:).zdir] * (pi/180); % zdir1 -- 6
0103 xdir = [cur_data_list(:).xdir] * (pi/180); % xdir1 -- NOTICE -- not 8
0104 
0105 normline(:, 1) = (sin(zdir) .* cos(xdir));
0106 normline(:, 2) = (sin(zdir) .* sin(xdir));
0107 normline(:, 3) = (cos(zdir));
0108 size_normline = ...
0109   sqrt(normline(:, 1).^2 + normline(:, 2).^2 + normline(:, 3).^2);
0110 unit_vector(:, 1) = normline(:, 1) ./ size_normline(:);
0111 unit_vector(:, 2) = normline(:, 2) ./ size_normline(:);
0112 unit_vector(:, 3) = normline(:, 3) ./ size_normline(:);
0113 
0114 %
0115 % normal line vector of pick
0116 %
0117 Qpick = unit_vector;
0118 
0119 % --- INNER FUNCTIONS -------------------------------------------------------- %
0120 %
0121 % --- inner_check_arguments()
0122 %
0123 function [channel_info] = inner_check_arguments(channel_info)
0124 func_ = mfilename;
0125 if isempty(channel_info)
0126   error('(%s) channel_info is a required parameter', func_);
0127 end
0128 
0129 % --- check new channel_info
0130 if ~isfield(channel_info, 'channel_count') ...
0131     || ~isfield(channel_info, 'channel')
0132   error('(%s) channel_info is not what is expected', func_);
0133 end
0134 return;
0135 %
0136 % --- end of inner_check_arguments()
0137 %
0138 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0139 
0140 %--- END OF FILE ---%

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