Home > functions > gui > preAnalysis > trial_extractor > vb_trial_extractor_notify_viewer.m

vb_trial_extractor_notify_viewer

PURPOSE ^

updated vb_timeseries_viewer trial data.

SYNOPSIS ^

function [data] = vb_trial_extractor_notify_viewer(data, updated_labels)

DESCRIPTION ^

 updated vb_timeseries_viewer trial data.
 [USAGE]
    [data] = vb_trial_extractor_notify_viewer(data, updated_labels);
 [IN]
              data : vb_trial_extractor_object.
    updated_labels : Changed label name list [cell string]
 [OUT]
    data : updated vb_trial_extractor 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:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [data] = vb_trial_extractor_notify_viewer(data, updated_labels)
0002 % updated vb_timeseries_viewer trial data.
0003 % [USAGE]
0004 %    [data] = vb_trial_extractor_notify_viewer(data, updated_labels);
0005 % [IN]
0006 %              data : vb_trial_extractor_object.
0007 %    updated_labels : Changed label name list [cell string]
0008 % [OUT]
0009 %    data : updated vb_trial_extractor 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('data', 'var')
0018     error('data is a required parameter.');
0019 end
0020 if ~exist('updated_labels', 'var')
0021     error('updated_labels is a required parameter.');
0022 end
0023 if ischar(updated_labels)
0024     updated_labels = {updated_labels};
0025 end
0026 %
0027 % --- Main Procedure
0028 %
0029 
0030 % Check if viewers are alive or not
0031 remove_ix = [];
0032 for k=1:length(data.viewer)
0033     if ~ishandle(data.viewer{k}.figure)
0034         % figure is already removed
0035         remove_ix = [remove_ix, k];
0036     end
0037 end
0038 % remove unavailable handle of viewers.
0039 if ~isempty(remove_ix)
0040     data.viewer(remove_ix) = [];
0041 end
0042 
0043 % Update viewers
0044 for k=1:length(data.viewer)
0045     % Check if the viewer has updated label?
0046     update_flag = false;
0047     for j=1:length(updated_labels)
0048         ix = strmatch(updated_labels{j}, data.viewer{k}.labels);
0049         if ~isempty(ix)
0050             update_flag = true;
0051             break;
0052         end
0053     end
0054 
0055     if update_flag
0056         trial_list_sec = [];
0057         % create trial list
0058         trial_list = create_trial_list(data.label_list, ...
0059                                        data.viewer{k}.labels, ...
0060                                        data.trial_list);
0061         if ~isempty(trial_list)
0062             trial_list_sec = vb_trial_extractor_convert_trial_into_sec(data, trial_list);
0063         end
0064         % update viewer
0065         vb_timeseries_viewer_ex_update_trial(data.viewer{k}.figure, ...
0066                                           trial_list_sec);
0067     end
0068 end
0069 
0070 %
0071 % --- After check
0072 %
0073 if nargout ~= 1
0074     error('function caller should receive updated vb_trial_extractor object.');
0075 end
0076 
0077 function trial_list = create_trial_list(label_list, label_name_list, all_trial)
0078 trial_list = [];
0079 tag_objects = [];
0080 
0081 % Find tags
0082 for k=1:length(label_name_list)
0083     tag_obj = vb_tag_util_find_tag(label_list, label_name_list{k});
0084     tag_objects = [tag_objects, tag_obj];
0085 end
0086 
0087 % Union them into 'temp' tag
0088 tmp_tag_obj = vb_tag_util_union_tag(tag_objects, 'temp', all_trial);
0089 
0090 % Get trial list
0091 ix = vb_tag_get_trial_index(tmp_tag_obj);
0092 if ~isempty(ix)
0093     trial_list = all_trial(ix);
0094 end

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