Home > vbmeg > functions > device > eeg > vb_eeginfo_get_sensor_position.m

vb_eeginfo_get_sensor_position

PURPOSE ^

get sensor position data from EEGinfo struct

SYNOPSIS ^

function [SensorPosition, center, result, channel_info] =vb_eeginfo_get_sensor_position(EEGinfo, active_swt)

DESCRIPTION ^

 get sensor position data from EEGinfo struct
 [usage]
   [SensorPosition, center] = vb_eeginfo_get_sensor_position(EEGinfo, active_swt)
 [input]
          EEGinfo : <required> EEGinfo struct data
       active_swt : <optional> <<boolean>> [false] active filter switch
                  :   true) return only active
                  :  false) return all the channels
 [output]
   SensorPosition : [N_sensor x 3] 3-D coordinates of sensor
           center : [1 x 3] coordinate of center point
           result : <<integer>> error code
                  :  0) success
                  :  1) bad eeginfo
     channel_info : <<struct>> channel information of loaded data
                    :  .Active [Nchannel x 1]
                    :  .Name   [Nchannel x 1]
                    :  .Type   [Nchannel x 1]
                    :  .ID     [Nchannel x 1]% [note]
 [note]
   @see vb_eeginfo_set_sensor_position
 [history]
   2006-12-06 (Sako) initial version
   2008-04-15 (Sako) added active_swt, result

 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 [SensorPosition, center, result, channel_info] = ...
0002   vb_eeginfo_get_sensor_position(EEGinfo, active_swt)
0003 % get sensor position data from EEGinfo struct
0004 % [usage]
0005 %   [SensorPosition, center] = vb_eeginfo_get_sensor_position(EEGinfo, active_swt)
0006 % [input]
0007 %          EEGinfo : <required> EEGinfo struct data
0008 %       active_swt : <optional> <<boolean>> [false] active filter switch
0009 %                  :   true) return only active
0010 %                  :  false) return all the channels
0011 % [output]
0012 %   SensorPosition : [N_sensor x 3] 3-D coordinates of sensor
0013 %           center : [1 x 3] coordinate of center point
0014 %           result : <<integer>> error code
0015 %                  :  0) success
0016 %                  :  1) bad eeginfo
0017 %     channel_info : <<struct>> channel information of loaded data
0018 %                    :  .Active [Nchannel x 1]
0019 %                    :  .Name   [Nchannel x 1]
0020 %                    :  .Type   [Nchannel x 1]
0021 %                    :  .ID     [Nchannel x 1]% [note]
0022 % [note]
0023 %   @see vb_eeginfo_set_sensor_position
0024 % [history]
0025 %   2006-12-06 (Sako) initial version
0026 %   2008-04-15 (Sako) added active_swt, result
0027 %
0028 % Copyright (C) 2011, ATR All Rights Reserved.
0029 % License : New BSD License(see VBMEG_LICENSE.txt)
0030 
0031 if ~exist('EEGinfo', 'var'), EEGinfo = []; end
0032 if ~exist('active_swt', 'var'), active_swt = []; end
0033 [EEGinfo, active_swt, result] = inner_check_arguments(EEGinfo, active_swt);
0034 
0035 % --- MAIN PROCEDURE --------------------------------------------------------- %
0036 %
0037 SensorPosition = [];
0038 center = [];
0039 channel_info = [];
0040 
0041 if result ~= 0
0042   return;
0043 end
0044 
0045 if isfield(EEGinfo, 'Vcenter')
0046   center = EEGinfo.Vcenter;
0047 end
0048 
0049 if isfield(EEGinfo, 'Coord')
0050   SensorPosition = EEGinfo.Coord;
0051   % --- channel_info as a return value
0052   if isfield(EEGinfo, 'ChannelName')
0053       ch_info = vb_eeginfo_make_channel_info(EEGinfo, EEGinfo.ChannelName);
0054   else
0055       return;
0056   end
0057 end
0058 
0059 % --- active channel filter
0060 if isempty(SensorPosition)
0061   % --- end here
0062   return;
0063 end
0064 
0065 if ~vb_info_active_channel_is_valid(EEGinfo)
0066   % do nothing any more
0067   return;
0068 end
0069 
0070 active_list = vb_info_get_active_channel(EEGinfo);
0071 if length(active_list) ~= size(SensorPosition, 1)
0072   fprintf('(%s) different length - active list and sensor position\n', ...
0073     mfilename);
0074   return;
0075 end
0076 
0077 if active_swt
0078   % --- filtered sensor position
0079   active_ix = find(active_list == 1);
0080 else
0081   % --- all the sensor position
0082   active_ix = [1:length(active_list)];
0083 end
0084 
0085 SensorPosition = SensorPosition(active_ix,:);
0086 channel_info.Active = ones(length(active_ix), 1);
0087 channel_info.Name   = ch_info.Name(active_ix);
0088 channel_info.Type   = ch_info.Type(active_ix);
0089 channel_info.ID     = ch_info.ID(active_ix);
0090 
0091 return;
0092 %
0093 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0094 
0095 % --- INNER FUNCTIONS -------------------------------------------------------- %
0096 %
0097 % --- inner_check_arguments()
0098 %
0099 function [EEGinfo, active_swt, result] = ...
0100   inner_check_arguments(EEGinfo, active_swt)
0101 func_ = mfilename;
0102 result = 0;
0103 
0104 if isempty(EEGinfo)
0105   fprintf('(%s)EEGinfo is a required parameter\n', func_);
0106   result = 1;
0107   return;
0108 end
0109 
0110 if isempty(active_swt)
0111   active_swt = false;
0112 end
0113 return;
0114 %
0115 % --- end of inner_check_arguments()
0116 %
0117 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0118 
0119 % --- END OF FILE --- %

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005