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

vb_timeseries_viewer_plot_trial

PURPOSE ^

plot trial on timeseries data.

SYNOPSIS ^

function [obj] = vb_timeseries_viewer_plot_trial(obj)

DESCRIPTION ^

 plot trial on timeseries data.
 [USAGE]
    [obj] = vb_timeseries_viewer_plot_trial(obj);
 [IN]
    obj : vb_timeseries_viewer object
 [OUT]
    obj : updated vb_timeseries_viewer object

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [obj] = vb_timeseries_viewer_plot_trial(obj)
0002 % plot trial on timeseries data.
0003 % [USAGE]
0004 %    [obj] = vb_timeseries_viewer_plot_trial(obj);
0005 % [IN]
0006 %    obj : vb_timeseries_viewer object
0007 % [OUT]
0008 %    obj : updated vb_timeseries_viewer object
0009 
0010 %
0011 % --- Previous check
0012 %
0013 if ~exist('obj', 'var')
0014     error('obj is a required parameter.');
0015 end
0016 
0017 %
0018 % --- Main Procedure
0019 %
0020 H = obj.H;
0021 y_range = ylim(H.data_axes) * 0.98;
0022 
0023 % plot trial
0024 try
0025     % remove previous plot
0026     valid_ix = find(ishandle(obj.trial_patch_handles) == 1);
0027     if ~isempty(valid_ix)
0028         delete(obj.trial_patch_handles(valid_ix));
0029     end
0030 catch
0031 end
0032 obj.trial_patch_handles = [];
0033 for k=1:length(obj.trial_list)
0034     t = obj.trial_list(k);
0035     set(0, 'CurrentFigure', obj.figure);
0036     set(obj.figure, 'CurrentAxes', H.data_axes);
0037 
0038     % trial(square area)
0039     obj.trial_patch_handles = [obj.trial_patch_handles; ...
0040                                patch([t.from, t.to, t.to, t.from],...
0041                                      [y_range(1), y_range(1), y_range(2), y_range(2)], ...
0042                                      get(H.trial_color_axes, 'Color'), ...
0043                                      'EdgeColor', 'k')];
0044 
0045     % transparent property
0046     alpha(obj.trial_patch_handles, 0.5);
0047 
0048     % onset(red vertical line)
0049     obj.trial_patch_handles = [obj.trial_patch_handles; ...
0050                                patch([t.onset, t.onset, t.onset, t.onset], ...
0051                                      [y_range(1), y_range(1), y_range(2), y_range(2)], ...
0052                                      'r', 'EdgeColor', 'r')];
0053 end
0054 
0055 % plot onset
0056 y_range = ylim(H.trigger_axes);
0057 
0058 try
0059     % remove previous plot
0060     valid_ix = find(ishandle(obj.trigger_onset_patches_handle) == 1);
0061     if ~isempty(valid_ix)
0062         delete(obj.trigger_onset_patches_handle(valid_ix));
0063     end
0064 catch
0065 end
0066 obj.trigger_onset_patches_handle = [];
0067 for k=1:length(obj.trial_list)
0068     t = obj.trial_list(k);
0069     set(0, 'CurrentFigure', obj.figure);
0070     set(obj.figure, 'CurrentAxes', H.trigger_axes);
0071     obj.trigger_onset_patches_handle = ...
0072         [obj.trigger_onset_patches_handle; 
0073         patch([t.onset, t.onset, t.onset, t.onset], ...
0074           [y_range(1), y_range(1), y_range(2), y_range(2)], ...
0075           'r', 'EdgeColor', 'r')];
0076 end
0077 
0078 %
0079 % --- After check
0080 %
0081 if nargout ~= 1
0082     error('you should receive updated vb_timeseries_viewer object.');
0083 end

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