Home > functions > gui > preAnalysis > trial_extractor > private > vb_tag_util_union_tag.m

vb_tag_util_union_tag

PURPOSE ^

Create new tag from multiple tags.

SYNOPSIS ^

function [new_tag] = vb_tag_util_union_tag(tags, new_name, trial_list)

DESCRIPTION ^

 Create new tag from multiple tags.
 trial index are sorted by time.
 [IN]
          tags : tag object list [1xN], [Nx1]
      new_name : new tag name.
    trial_list : trial object list.
 [OUT]
    new_tag : new tag object.

 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:

SOURCE CODE ^

0001 function [new_tag] = vb_tag_util_union_tag(tags, new_name, trial_list)
0002 % Create new tag from multiple tags.
0003 % trial index are sorted by time.
0004 % [IN]
0005 %          tags : tag object list [1xN], [Nx1]
0006 %      new_name : new tag name.
0007 %    trial_list : trial object list.
0008 % [OUT]
0009 %    new_tag : new tag object.
0010 %
0011 % Copyright (C) 2011, ATR All Rights Reserved.
0012 % License : New BSD License(see VBMEG_LICENSE.txt)
0013 
0014 %
0015 % --- Previous check
0016 %
0017 if ~exist('tags', 'var')
0018     error('tag list are required.');
0019 end
0020 if ~exist('new_name', 'var')
0021     error('new_name is a required parameter.');
0022 end
0023 if ~exist('trial_list', 'var')
0024     error('trial_list is a required parameter.');
0025 end
0026 
0027 %
0028 % --- Main Procedure
0029 %
0030 Ntags = length(tags);
0031 tags_trial_ix = [];
0032 for k=1:Ntags
0033     tags_trial_ix = [tags_trial_ix; ...
0034                      vb_tag_get_trial_index(tags(k))];
0035 end
0036 
0037 tags_trial_ix = unique(tags_trial_ix);
0038 trial_set     = trial_list(tags_trial_ix);
0039 Ntrial = length(trial_set);
0040 
0041 new_tag = vb_tag_new(new_name);
0042 
0043 % Create new tag
0044 if Ntrial
0045     % Sort by 'from'
0046     [tmp, time_ix] = sort([trial_set.from]);
0047 
0048     % Sort trial index
0049     new_trial_ix = tags_trial_ix(time_ix);
0050     new_tag = vb_tag_add_trial_index(new_tag, new_trial_ix);
0051 end
0052 
0053 %
0054 % --- After check
0055 %
0056 if nargout ~= 1
0057     error('function caller should receive new tag object.');
0058 end
0059

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