Home > vbmeg > functions > gui > preAnalysis > meeg_processor > utility > timeseries_viewer > 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, window_from, window_to)

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

 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 [obj] = vb_timeseries_viewer_plot_trial(obj, window_from, window_to)
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 % Copyright (C) 2011, ATR All Rights Reserved.
0011 % License : New BSD License(see VBMEG_LICENSE.txt)
0012 
0013 %
0014 % --- Previous check
0015 %
0016 if ~exist('obj', 'var')
0017     error('obj is a required parameter.');
0018 end
0019 
0020 %
0021 % --- Main Procedure
0022 %
0023 H = obj.H;
0024 trig_yinfo = ylim(H.data_axes) * 0.98;
0025 
0026 try
0027     % remove previous plot
0028     handles = [obj.trial_range_handles; 
0029                obj.trial_onset_handles;
0030                obj.ext_onset_handles];
0031 
0032     valid_ix = find(ishandle(handles) == 1);
0033     if ~isempty(valid_ix)
0034         delete(handles(valid_ix));
0035     end
0036 catch
0037 end
0038 obj.trial_range_handles = [];
0039 obj.trial_onset_handles = [];
0040 obj.ext_onset_handles   = [];
0041 
0042 % plot onset
0043 data_yinfo = ylim(H.data_axes);
0044 trig_yinfo = ylim(H.trigger_axes);
0045 
0046 % Check trial number in display timewindow.
0047 t_index = [];
0048 for k=1:length(obj.trial_list)
0049     t = obj.trial_list(k);
0050     if (t.to >=  window_from && t.to <= window_to) || ...
0051        (t.from >= window_from && t.to <= window_to) || ...
0052        (t.from >= window_from && t.from <= window_to) || ...
0053        (t.from <= window_from && t.to >= window_to)
0054       
0055        t_index = [t_index; k];
0056     end
0057 end
0058 
0059 set(0, 'CurrentFigure', obj.figure);
0060 set(obj.figure, 'CurrentAxes', H.data_axes);
0061 for k=1:length(t_index)
0062     t = obj.trial_list(t_index(k));
0063     % trial(horizontal short lines)
0064     if t.invalid
0065         trial_bar_col = [0, 0, 0];
0066     else
0067         trial_bar_col = get(H.trial_color_axes, 'Color');
0068     end
0069     y = data_yinfo(1) + (mod(t_index(k)-1, 4)+1)*(data_yinfo(2)-data_yinfo(1))/30;
0070     hold on;
0071     
0072     t_h = plot([t.from, t.to], [y, y], ...
0073                'Color', trial_bar_col, 'LineWidth', 5);
0074     click_on_trial = 'vb_timeseries_viewer_trial_click(gcf, gcbo)';
0075     set(t_h, 'ButtonDownFcn', click_on_trial);
0076     setappdata(t_h, 'trialNum', t_index(k));
0077     obj.trial_range_handles = [obj.trial_range_handles; t_h];
0078 
0079     % onset(red vertical lines)
0080     if t.invalid, continue; end
0081     obj.trial_onset_handles = [obj.trial_onset_handles; ...
0082                                    plot([t.onset, t.onset], ...
0083                                      [data_yinfo(1), data_yinfo(2)], ...
0084                                      'r', 'LineWidth', 1)];
0085     set(obj.trial_onset_handles(end), 'HitTest', 'off');
0086 end
0087 set(obj.figure, 'CurrentAxes', H.trigger_axes);
0088 for k=1:length(t_index)
0089     t = obj.trial_list(t_index(k));
0090     if t.invalid, continue; end
0091 
0092     % onset on trigger axes(red vertical lines)
0093     hold on;
0094     obj.ext_onset_handles =   [obj.ext_onset_handles; ...
0095                                plot([t.onset, t.onset], ...
0096                                     [trig_yinfo(1), trig_yinfo(2)], ...
0097                                     'r', 'LineWidth', 1)];
0098 end
0099 
0100 
0101 % Trial explanation
0102 group = [obj.H.trial_explain_axes;
0103          obj.H.trial_explain_text;
0104          obj.H.trial_color_axes;
0105          obj.H.trigger_explain_axes;
0106          obj.H.trigger_explain_text];
0107 if isempty(obj.trial_list)
0108     set(group, 'Visible', 'off');
0109 else
0110     set(group, 'Visible', 'on');
0111 end
0112 %
0113 % --- After check
0114 %
0115 if nargout ~= 1
0116     error('you should receive updated vb_timeseries_viewer object.');
0117 end

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005