Home > vbmeg > functions > device > vb_info_set_active_channel.m

vb_info_set_active_channel

PURPOSE ^

<<setter>> set active_channel value to info (MEGinfo or EEGinfo)

SYNOPSIS ^

function [info, result] = vb_info_set_active_channel(info, active_channel)

DESCRIPTION ^

 <<setter>> set active_channel value to info (MEGinfo or EEGinfo)
 [usage]
   [info] = vb_info_set_active_channel(info, active_channel)
 [input]
              info : <required> <<struct>> MEGinfo or EEGinfo
    active_channel : <required> [Nchannel x 1]
 [output]
              info : updated info
                   :  newly added field is ActiveChannel [Nchannel x 1 boolean]
            result :  0) success
                   :  1) failure - info is invalid
                   :  2) failure - active_channel is empty
                   :  4) failure - different lengths
 [note]
   If the length of active_channel is different from the number of all the
   channel, this function does not update info.
 [history]
   2008-04-11 (Sako) initial version
   2009-07-07 (Sako) modified to update info.ChannelInfo.Active

 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 [info, result] = vb_info_set_active_channel(info, active_channel)
0002 % <<setter>> set active_channel value to info (MEGinfo or EEGinfo)
0003 % [usage]
0004 %   [info] = vb_info_set_active_channel(info, active_channel)
0005 % [input]
0006 %              info : <required> <<struct>> MEGinfo or EEGinfo
0007 %    active_channel : <required> [Nchannel x 1]
0008 % [output]
0009 %              info : updated info
0010 %                   :  newly added field is ActiveChannel [Nchannel x 1 boolean]
0011 %            result :  0) success
0012 %                   :  1) failure - info is invalid
0013 %                   :  2) failure - active_channel is empty
0014 %                   :  4) failure - different lengths
0015 % [note]
0016 %   If the length of active_channel is different from the number of all the
0017 %   channel, this function does not update info.
0018 % [history]
0019 %   2008-04-11 (Sako) initial version
0020 %   2009-07-07 (Sako) modified to update info.ChannelInfo.Active
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('active_channel', 'var'), active_channel = []; end
0028 [info, active_channel, result] = ...
0029   inner_check_arguments(info, active_channel);
0030 
0031 if result ~= 0
0032   return;
0033 end
0034 
0035 % --- MAIN PROCEDURE --------------------------------------------------------- %
0036 %
0037 info.ActiveChannel = active_channel;
0038 info.ChannelInfo.Active = info.ActiveChannel;
0039 return;
0040 %
0041 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0042 
0043 
0044 % --- INNER FUNCTIONS -------------------------------------------------------- %
0045 %
0046 % --- inner_check_arguments()
0047 %
0048 function [info, active_channel, err_code] = ...
0049   inner_check_arguments(info, active_channel)
0050 func_ = mfilename;
0051 err_code = 0;
0052 if isempty(info)
0053   fprintf('(%s)info is a required parameter\n', func_);
0054   err_code = bitor(err_code,1);
0055 end
0056 
0057 if isempty(active_channel)
0058 %   fprintf('(%s)active_channel is a required parameter\n', func_);
0059 %   err_code = bitor(err_code, 2);
0060 end
0061 
0062 if err_code ~= 0
0063   return;
0064 end
0065 
0066 % ----- check length
0067 n_channel = vb_info_get_Nchannel(info);
0068 n_active  = length(active_channel);
0069 
0070 if n_channel ~= n_active
0071   fprintf('(%s)numbers are different', func_);
0072   fprintf(' - active_channel (%d) and number of channel (%d)\n', ...
0073     n_active, n_channel);
0074   err_code = bitor(err_code, 4);
0075 end
0076 
0077 % arrange to [N x 1]
0078 if ~isempty(active_channel)
0079   active_channel = vb_util_arrange_list(active_channel);
0080 end
0081 
0082 return;
0083 %
0084 % --- end of inner_check_arguments()
0085 %
0086 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0087 
0088 %%% END OF FILE %%%

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