Home > vbmeg > functions > device > vb_info_active_trial_is_valid.m

vb_info_active_trial_is_valid

PURPOSE ^

check whether active trial field is valid or not

SYNOPSIS ^

function [result] = vb_info_active_trial_is_valid(info)

DESCRIPTION ^

 check whether active trial field is valid or not
 [usage]
   [result] = vb_info_active_trial_is_valid(info)
 [input]
     info : <required> <<struct>> MEGinfo or EEGinfo
 [output]
   result : <<boolean>>
          :   true) valid
          :  false) invalid
 [note]
   for now, MEGinfo and EEGinfo has the same field name for active trial
   invalid conditions are as follows.
    * There is not the appropriate field
    * Active trial field is empty
    * The length of active trial is different from the number of trial
 [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 [result] = vb_info_active_trial_is_valid(info)
0002 % check whether active trial field is valid or not
0003 % [usage]
0004 %   [result] = vb_info_active_trial_is_valid(info)
0005 % [input]
0006 %     info : <required> <<struct>> MEGinfo or EEGinfo
0007 % [output]
0008 %   result : <<boolean>>
0009 %          :   true) valid
0010 %          :  false) invalid
0011 % [note]
0012 %   for now, MEGinfo and EEGinfo has the same field name for active trial
0013 %   invalid conditions are as follows.
0014 %    * There is not the appropriate field
0015 %    * Active trial field is empty
0016 %    * The length of active trial is different from the number of trial
0017 % [history]
0018 %   2008-04-11 (Sako) initial version
0019 %
0020 % Copyright (C) 2011, ATR All Rights Reserved.
0021 % License : New BSD License(see VBMEG_LICENSE.txt)
0022 
0023 % --- CHECK ARGUMENTS --- %
0024 if ~exist('info', 'var'), info = []; end
0025 [info] = inner_check_arguments(info);
0026 
0027 
0028 % --- MAIN PROCEDURE --------------------------------------------------------- %
0029 %
0030 result = false;
0031 if ~isfield(info, 'ActiveTrial') || isempty(info.ActiveTrial)
0032   return;
0033 end
0034 
0035 Ntrial = inner_get_trial_number(info);
0036 len_active = length(info.ActiveTrial);
0037 if Ntrial ~= len_active
0038   fprintf('(%s)numbers are different trial(%d) and ActiveTrial(%d)\n', ...
0039     mfilename, Ntrial, len_active);
0040   return;
0041 end
0042 
0043 result = true;
0044 return;
0045 %
0046 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0047 
0048 % --- INNER FUNCTIONS -------------------------------------------------------- %
0049 %
0050 % --- inner_check_arguments()
0051 %
0052 function [info] = inner_check_arguments(info)
0053 func_ = mfilename;
0054 if isempty(info)
0055   error('(%s)info is a required parameter', func_);
0056 end
0057 return;
0058 %
0059 % --- end of inner_check_arguments()
0060 
0061 % --- inner_get_trial_number()
0062 %
0063 function Ntrial = inner_get_trial_number(info)
0064 if isfield(info, 'Trial')
0065   Ntrial = length(info.Trial);
0066 else
0067   Ntrial = 0;
0068 end
0069 return;
0070 %
0071 % --- end of inner_get_trial_number()
0072 %
0073 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0074 
0075 %%% END OF FILE %%%

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