Home > functions > device > vb_info_set_active_flag.m

vb_info_set_active_flag

PURPOSE ^

set active flag to each Trial data of MEGinfo or EEGinfo

SYNOPSIS ^

function [info] = vb_info_set_active_flag(info, active_trial)

DESCRIPTION ^

 set active flag to each Trial data of MEGinfo or EEGinfo
 [usage]
   [info] = vb_info_set_active_flag(info, active_trial)
 [input]
           info : <required> <<struct>> MEGinfo or EEGinfo
                :  which has Trial field which is struct array ([Ntrial x 1])
                :  if this does not have Trial field, do nothing
   active_trial : <optional> [Ntrial x 1 boolean]
                :  if this is empty or not be specified, all the Trials will
                :  be set <.Active = true>.
 [output]
           info : MEGinfo or EEGinfo with updated Trial list
 [note]

 [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] = vb_info_set_active_flag(info, active_trial)
0002 % set active flag to each Trial data of MEGinfo or EEGinfo
0003 % [usage]
0004 %   [info] = vb_info_set_active_flag(info, active_trial)
0005 % [input]
0006 %           info : <required> <<struct>> MEGinfo or EEGinfo
0007 %                :  which has Trial field which is struct array ([Ntrial x 1])
0008 %                :  if this does not have Trial field, do nothing
0009 %   active_trial : <optional> [Ntrial x 1 boolean]
0010 %                :  if this is empty or not be specified, all the Trials will
0011 %                :  be set <.Active = true>.
0012 % [output]
0013 %           info : MEGinfo or EEGinfo with updated Trial list
0014 % [note]
0015 %
0016 % [history]
0017 %   2008-04-11 (Sako) initial version
0018 %
0019 % Copyright (C) 2011, ATR All Rights Reserved.
0020 % License : New BSD License(see VBMEG_LICENSE.txt)
0021 
0022 % --- CHECK ARGUMENTS --- %
0023 if ~exist('info', 'var'), info = []; end
0024 if ~exist('active_trial', 'var'), active_trial = []; end
0025 [info, active_trial, err_code] = inner_check_arguments(info, active_trial);
0026 
0027 if err_code ~= 0
0028   % do nothing
0029   return;
0030 end
0031 
0032 % --- MAIN PROCEDURE --------------------------------------------------------- %
0033 %
0034 n_trial = length(info.Trial);
0035 for i_trial = 1:n_trial
0036   info.Trial(i_trial).Active = active_trial(i_trial);
0037 end
0038 return;
0039 %
0040 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0041 
0042 % --- INNER FUNCTIONS -------------------------------------------------------- %
0043 %
0044 % --- inner_check_arguments()
0045 %
0046 function [info, active_trial, err_code] = ...
0047   inner_check_arguments(info, active_trial)
0048 func_ = mfilename;
0049 err_code = 0;
0050 
0051 if isempty(info)
0052   error('(%s)info is a required parameter', func_);
0053 end
0054 
0055 if ~isfield(info, 'Trial')
0056   err_code = 1;
0057   return;
0058 end
0059 
0060 if isempty(active_trial)
0061   n_trial = length(Trial);
0062   active_trial = ones(n_trial, 1);
0063 end
0064 return;
0065 %
0066 % --- end of inner_check_arguments()
0067 %
0068 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0069 
0070 %%% END OF FILE %%%

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