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

vb_timeseries_viewer_plot_trigger_data

PURPOSE ^

plot trigger data

SYNOPSIS ^

function [obj] = vb_timeseries_viewer_plot_trigger_data(obj, window_from, window_to)

DESCRIPTION ^

 plot trigger data
 [USAGE]
    [obj] = vb_timeseries_viewer_plot_trigger_data(obj, window_from, window_to);
 [IN]
    obj : vb_timeseries_viewer object.
 [OUT]
    obj : 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_trigger_data(obj, window_from, window_to)
0002 % plot trigger data
0003 % [USAGE]
0004 %    [obj] = vb_timeseries_viewer_plot_trigger_data(obj, window_from, window_to);
0005 % [IN]
0006 %    obj : vb_timeseries_viewer object.
0007 % [OUT]
0008 %    obj : 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 
0024 H = obj.H;
0025 
0026 % get previous legend position
0027 if isfield(obj, 'ext_legend_handle') && ishandle(obj.ext_legend_handle)
0028     obj.l_pos = get(obj.ext_legend_handle, 'Position');
0029 end
0030 
0031 cla(H.trigger_axes);
0032 if ~isempty(obj.trig_ch_list)
0033     freq    = vb_continuous_file_get_sample_freq(obj.org_file);
0034     [obj.org_file, trig_data, from, to] = vb_continuous_file_get_sample(obj.org_file, ...
0035                                                        obj.trig_ch_list, ...
0036                                                        ceil(freq*window_from), ceil(freq*window_to));
0037     plot(H.trigger_axes, from/freq:1/freq:to/freq, trig_data);
0038 
0039     % Data processing by proc_spec_list
0040     if ~isempty(obj.proc_spec_list)
0041         Nprocessor = length(obj.proc_spec_list);
0042         for k=1:Nprocessor
0043             proc_spec = obj.proc_spec_list{k};
0044             ix = strmatch(proc_spec.ch_name, obj.trig_ch_list, 'exact');
0045             if strcmp(proc_spec.type, 'digital_data_adjustment') && ~isempty(ix)
0046                 bitmask = proc_spec.parm.bitmask;
0047                 offset  = proc_spec.parm.offset;
0048                 trig_data(ix, :) = vb_get_status_mask(trig_data(ix, :), bitmask, offset);
0049             end
0050         end
0051     end
0052 
0053     obj.trigger_max = max(trig_data(:));
0054     obj.trigger_min = min(trig_data(:));
0055 
0056     % plot trigger
0057     step = 1;
0058     t  = [from-1:to-1]/freq;
0059     ix = [1:step:size(trig_data,2)];
0060     obj.handle_ext_lines = ...
0061             plot(H.trigger_axes, t(1:step:length(t)), trig_data(:, ix));
0062 
0063     set(obj.handle_ext_lines, 'ButtonDownFcn', ...
0064         'vb_timeseries_viewer_callback(guidata(gcf), gcbo)', 'Tag', 'ext_trig_line');
0065 
0066     % Graph color explanation
0067     l_h = legend(H.trigger_axes, obj.trig_ch_list);
0068     set(l_h, 'FontSize', 12, 'FontUnit', 'points');
0069     set(l_h, 'FontUnit', 'normalized');
0070 
0071     % set position
0072     if isfield(obj, 'l_pos')
0073         set(l_h, 'Position', obj.l_pos);
0074     end
0075     obj.ext_legend_handle = l_h;
0076 
0077     % trigger onset
0078 %    Ntrial = length(obj.trial_list);
0079 %    ymax = max(trig_data(:));
0080 %    ymin = min(trig_data(:));
0081 end
0082 
0083 % set(obj.figure, 'CurrentAxes', H.trigger_axes);
0084 % axes(H.trigger_axes);
0085 % for k=1:Ntrial
0086 %     t = obj.trial_list(k);
0087 %     patch([t.onset, t.onset, t.onset, t.onset], ...
0088 %                            [ymin, ymin, ymax, ymax], ...
0089 %                            [0.2, 0.2, 0.2]);
0090 %
0091 % end
0092 
0093 % Set Label(should be done after plotting)
0094 % h = xlabel(H.trigger_axes, 'Time[sec]', ...
0095 %                         'FontName', 'Times', ...
0096 %                         'FontUnit', 'points', 'FontSize', 14);
0097 % set(h, 'FontUnit', 'normalized');
0098 %
0099 % h = ylabel(H.trigger_axes, 'External trigger', ...
0100 %                        'FontName', 'Times', ...
0101 %                        'FontUnit', 'points', 'FontSize', 14);
0102 % set(h, 'FontUnit', 'normalized');
0103 %
0104 % % Set Axis font
0105 % set(H.trigger_axes, 'FontName', 'Times', ...
0106 %                     'FontUnit', 'points');
0107 % set(H.trigger_axes, 'FontSize', 14);
0108 % set(H.trigger_axes, 'FontUnit', 'normalized');
0109 
0110 
0111 % Set Grid on
0112 set(H.trigger_axes, 'XGrid', 'on');
0113 set(H.trigger_axes, 'YGrid', 'on');
0114 
0115 
0116 % Yrange
0117 range = ylim(H.trigger_axes);
0118 set(H.ylimit_trigger_low_edit, 'String', num2str(range(1)));
0119 set(H.ylimit_trigger_high_edit, 'String', num2str(range(2)));
0120 
0121 xlim(H.trigger_axes, [window_from, window_to]);

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