Home > vbmeg > functions > device > vb_info_get_channel_info.m

vb_info_get_channel_info

PURPOSE ^

return ChannelInfo struct in info (MEGinfo or EEGinfo)

SYNOPSIS ^

function ch_info = vb_info_get_channel_info(info, ch_type)

DESCRIPTION ^

 return ChannelInfo struct in info (MEGinfo or EEGinfo)
 [usage]
   [ch_info] = vb_info_get_channel_info(info, ch_type)
 [input]
      info : <required> <<struct>> MEGinfo or EEGinfo
   ch_type : <optional> [0] | 1 | 2
           :  0) info.ChannelInfo
           :  1) info.ExtraChannelInfo
           :  2) all channels
 [output]
   ch_info : <<struct>> fields are as follows:
           :   .Active [Nchannel x 1] <<boolean>>
           :   .Name   {Nchannel x 1}
           :   .ID     [Nchannel x 1]
           :   .Type   [Nchannel x 1]
 [note]
   return format is like info.ChannelInfo not be like ExtraChannelInfo
 [history]
   2009-07-27 (Sako) initial version

 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 ch_info = vb_info_get_channel_info(info, ch_type)
0002 % return ChannelInfo struct in info (MEGinfo or EEGinfo)
0003 % [usage]
0004 %   [ch_info] = vb_info_get_channel_info(info, ch_type)
0005 % [input]
0006 %      info : <required> <<struct>> MEGinfo or EEGinfo
0007 %   ch_type : <optional> [0] | 1 | 2
0008 %           :  0) info.ChannelInfo
0009 %           :  1) info.ExtraChannelInfo
0010 %           :  2) all channels
0011 % [output]
0012 %   ch_info : <<struct>> fields are as follows:
0013 %           :   .Active [Nchannel x 1] <<boolean>>
0014 %           :   .Name   {Nchannel x 1}
0015 %           :   .ID     [Nchannel x 1]
0016 %           :   .Type   [Nchannel x 1]
0017 % [note]
0018 %   return format is like info.ChannelInfo not be like ExtraChannelInfo
0019 % [history]
0020 %   2009-07-27 (Sako) initial version
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('info', 'var'), info = []; end
0027 if ~exist('ch_type', 'var'), ch_type = []; end
0028 [info, ch_type] = inner_check_arguments(info, ch_type);
0029 
0030 % --- MAIN PROCEDURE --------------------------------------------------------- %
0031 %
0032 % --- initialize
0033 ch_info = [];
0034 
0035 if ch_type == 0
0036   if isfield(info, 'ChannelInfo') && ~isempty(info.ChannelInfo)
0037     ch_info = info.ChannelInfo;
0038   end
0039 elseif ch_type == 1
0040   if isfield(info, 'ExtraChannelInfo') && ~isempty(info.ExtraChannelInfo)
0041     ex_info = info.ExtraChannelInfo;
0042     ch_info.Active = ex_info.Channel_active;
0043     ch_info.Name   = ex_info.Channel_name;
0044     ch_info.Type   = ex_info.Channel_type;
0045     ch_info.ID     = ex_info.Channel_id;
0046   end
0047 elseif ch_type == 2
0048   if isfield(info, 'ChannelInfo') && ~isempty(info.ChannelInfo)
0049     ch_info = info.ChannelInfo;
0050   else
0051     ch_info.Active = [];
0052     ch_info.Name   = {};
0053     ch_info.ID     = [];
0054     ch_info.Type   = [];
0055   end
0056   if isfield(info, 'ExtraChannelInfo') && ~isempty(info.ExtraChannelInfo)
0057     ex_info = info.ExtraChannelInfo;
0058     ch_info.Active = [ch_info.Active; ex_info.Channel_active];
0059     ch_info.Name   = [ch_info.Name;   ex_info.Channel_name];
0060     ch_info.Type   = [ch_info.Type;   ex_info.Channel_type];
0061     ch_info.ID     = [ch_info.ID;     ex_info.Channel_id];
0062   end
0063 else
0064   warning('(%s) unknown ch_type : %d\n', mfilename, ch_type);
0065 end
0066 
0067 return;
0068 %
0069 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0070 
0071 % --- INNER FUNCTIONS -------------------------------------------------------- %
0072 %
0073 % --- inner_check_arguments()
0074 %
0075 function [info, ch_type] = inner_check_arguments(info, ch_type)
0076 func_ = mfilename;
0077 if isempty(info)
0078   error('(%s) info is a required parameter', func_);
0079 end
0080 
0081 if isempty(ch_type)
0082   ch_type = 0;
0083 end
0084 return;
0085 %
0086 % --- end of inner_check_arguments()
0087 %
0088 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0089 
0090 % --- END OF FILE --- %

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