Home > functions > device > vb_info_get_trial_list.m

vb_info_get_trial_list

PURPOSE ^

return list of trial index from MEGinfo or EEGinfo

SYNOPSIS ^

function trial_list = vb_info_get_trial_list(info, user_list, active_swt)

DESCRIPTION ^

 return list of trial index from MEGinfo or EEGinfo
 [usage]
   trial_list = vb_info_get_trial_list(info, user_list, active_swt)
 [input]
         info : <required> <<struct>> MEGinfo or EEGinfo
    user_list : <optional> [N x 1] user specified index list
              :  not being specified or empty means all the trials [[]]
   active_swt : <optional> <<boolean>> return switch [false]
              :   true) return only active trials
              :  false) return all the trials
 [output]
   trial_list : list of trial number [N x 1]
              : narrowed by the condition of user_list and active_swt
 [note]
   support old fashioned MEGinfo
 [history]
   2008-04-17 (Sako) initial version
   2008-06-06 (DK) function "inner_check_arguments" is modified
   2009-07-07 (Sako) modified not to check active trial if it does not need

 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 trial_list = vb_info_get_trial_list(info, user_list, active_swt)
0002 % return list of trial index from MEGinfo or EEGinfo
0003 % [usage]
0004 %   trial_list = vb_info_get_trial_list(info, user_list, active_swt)
0005 % [input]
0006 %         info : <required> <<struct>> MEGinfo or EEGinfo
0007 %    user_list : <optional> [N x 1] user specified index list
0008 %              :  not being specified or empty means all the trials [[]]
0009 %   active_swt : <optional> <<boolean>> return switch [false]
0010 %              :   true) return only active trials
0011 %              :  false) return all the trials
0012 % [output]
0013 %   trial_list : list of trial number [N x 1]
0014 %              : narrowed by the condition of user_list and active_swt
0015 % [note]
0016 %   support old fashioned MEGinfo
0017 % [history]
0018 %   2008-04-17 (Sako) initial version
0019 %   2008-06-06 (DK) function "inner_check_arguments" is modified
0020 %   2009-07-07 (Sako) modified not to check active trial if it does not need
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('user_list', 'var'), user_list = []; end
0028 if ~exist('active_swt', 'var'), active_swt = []; end
0029 [info, user_list, active_swt] = ...
0030   inner_check_arguments(info, user_list, active_swt);
0031 
0032 % --- MAIN PROCEDURE --------------------------------------------------------- %
0033 %
0034 n_trial = length(info.Trial);
0035 if n_trial == 0
0036   trial_list = [];
0037   return;
0038 end
0039 
0040 trial_list = zeros(n_trial,1);
0041 
0042 for i_trial = 1:n_trial
0043   trial_list(i_trial) = info.Trial(i_trial).number;
0044 end
0045 
0046 if active_swt && vb_info_active_trial_is_valid(info)
0047   active_list = vb_info_get_active_trial(info);
0048   trial_list = trial_list(active_list==1);
0049 end
0050 
0051 if ~isempty(user_list)
0052   [match_idx] = vb_util_get_index(trial_list, user_list);
0053   trial_list = trial_list(match_idx);
0054 end
0055 
0056 return;
0057 %
0058 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0059 
0060 
0061 % --- INNER FUNCTIONS -------------------------------------------------------- %
0062 %
0063 % --- inner_check_arguments()
0064 %
0065 function [info, user_list, active_swt] = ...
0066   inner_check_arguments(info, user_list, active_swt)
0067 
0068 func_ = mfilename;
0069 if isempty(info)
0070   error('(%s)info is a required parameter', func_);
0071 end
0072 
0073 if ~isfield(info, 'Trial')
0074   measurement = vb_info_get_measurement(info);
0075   
0076   if strcmp(measurement, 'MEG')
0077     % for old fashioned
0078     n_trial = vb_info_get_Nrepeat(info);
0079 
0080     if isfield(info, 'TrialNumber')
0081       for i_trial = 1:n_trial
0082     info.Trial(i_trial).number = info.TrialNumber(i_trial); 
0083       end
0084     else
0085       % temporary measure
0086       for i_trial = 1:n_trial
0087     info.Trial(i_trial).number = i_trial;
0088       end
0089     end
0090   else
0091     info.Trial = [];
0092   end
0093 end
0094 
0095 if isempty(user_list)
0096   % do nothing
0097 end
0098 
0099 if isempty(active_swt)
0100   active_swt = false;
0101 end
0102 return;
0103 %
0104 % --- end of inner_check_arguments()
0105 
0106 %
0107 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0108 
0109 %%% END OF FILE %%%

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