Home > functions > device > vb_info_set_active_trial.m

vb_info_set_active_trial

PURPOSE ^

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

SYNOPSIS ^

function [info, result] = vb_info_set_active_trial(info, active_trial)

DESCRIPTION ^

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

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