Home > vbmeg > functions > device > vb_info_adjust_trial.m

vb_info_adjust_trial

PURPOSE ^

adjust trial according to Trial field of MEGinfo or EEGinfo

SYNOPSIS ^

function [info, result] = vb_info_adjust_trial(info, aim_code)

DESCRIPTION ^

 adjust trial according to Trial field of MEGinfo or EEGinfo
 [usage]
   [info, result] = vb_info_adjust_trial(info, aim_code)
 [input]
       info : <required> <<struct>> MEGinfo or EEGinfo
   aim_code : <optional> [1]
            :  0) update Nrepeat only
            :  1) update Nrepeat and Trial.Active
 [output]
     info : updated MEGinfo or EEGinfo
   result : <<integer>> error code
          :  0) success
          :  1) error - bad info
 [note]
    .Nrepeat
    .ActiveTrial
 [history]
   2008-04-23 (Sako) initial version
   2008-06-10 (Sako) modified to set ActiveTrial correctly
   2009-07-13 (Sako) added aim_code

 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_adjust_trial(info, aim_code)
0002 % adjust trial according to Trial field of MEGinfo or EEGinfo
0003 % [usage]
0004 %   [info, result] = vb_info_adjust_trial(info, aim_code)
0005 % [input]
0006 %       info : <required> <<struct>> MEGinfo or EEGinfo
0007 %   aim_code : <optional> [1]
0008 %            :  0) update Nrepeat only
0009 %            :  1) update Nrepeat and Trial.Active
0010 % [output]
0011 %     info : updated MEGinfo or EEGinfo
0012 %   result : <<integer>> error code
0013 %          :  0) success
0014 %          :  1) error - bad info
0015 % [note]
0016 %    .Nrepeat
0017 %    .ActiveTrial
0018 % [history]
0019 %   2008-04-23 (Sako) initial version
0020 %   2008-06-10 (Sako) modified to set ActiveTrial correctly
0021 %   2009-07-13 (Sako) added aim_code
0022 %
0023 % Copyright (C) 2011, ATR All Rights Reserved.
0024 % License : New BSD License(see VBMEG_LICENSE.txt)
0025 
0026 % --- CHECK ARGUMENTS --- %
0027 if ~exist('info', 'var'), info = []; end
0028 if ~exist('aim_code', 'var'), aim_code = []; end
0029 [info, aim_code, result] = inner_check_arguments(info, aim_code);
0030 
0031 % --- MAIN PROCEDURE --------------------------------------------------------- %
0032 %
0033 if result ~= 0
0034   return;
0035 end
0036 
0037 cur_trial = vb_info_get_trial_list(info);
0038 N_trial = length(cur_trial);
0039 info = vb_info_set_Nrepeat(info, N_trial);
0040 
0041 if aim_code == 0
0042   return;
0043 end
0044 
0045 active_trial = ones(N_trial,1);
0046 
0047 % --- new format
0048 if isfield(info, 'Trial')
0049   for i_tr = 1:N_trial
0050     if isfield(info.Trial(i_tr), 'Active')
0051       active_trial(i_tr) = info.Trial(i_tr).Active;
0052     else
0053       active_trial(i_tr) = 1;
0054     end
0055   end
0056 end
0057 info = vb_info_set_active_trial(info, active_trial);
0058 return;
0059 %
0060 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0061 
0062 % --- INNER FUNCTIONS -------------------------------------------------------- %
0063 %
0064 % --- inner_check_arguments()
0065 %
0066 function [info, aim_code, result] = inner_check_arguments(info, aim_code)
0067 func_ = mfilename;
0068 result = 0;
0069 
0070 if isempty(info)
0071   fprintf('(%s)info is a required parameter\n', func_);
0072   result = 1;
0073   return;
0074 end
0075 
0076 if isempty(aim_code)
0077   aim_code = 1;
0078 end
0079 return;
0080 %
0081 % --- end of inner_check_arguments()
0082 %
0083 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0084 
0085 %%% END OF FILE %%%

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