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

vb_timeseries_viewer_new

PURPOSE ^

GUI for checking time series and trial data.

SYNOPSIS ^

function [fig] = vb_timeseries_viewer_new(org_file, window_len, data_ch_list,trial_list, trig_ch_list, proc_spec_list)

DESCRIPTION ^

 GUI for checking time series and trial data.
 [USAGE]
    [fig] = vb_timeseries_viewer_new(org_file, window_len, ...
                              data_ch_list, trial_list, trig_ch_list);
 [IN]
      org_file : MEG/EEG Continuous data file
    window_len : display window length [sec]
  data_ch_list : data channel name list {Nx1}
    trial_list : trial list [Nx1]
                 N x <<struct>>
                  .from : trial starts here [sec]
                  .to   : trial ends here   [sec]
  trig_ch_list : trigger channel name list {Nx1}
  proc_spec_list : processing specification list for specified channel. <<cell>>
               proc_spec <<struct>>
                  .ch_name   : channel name
                  .type : process type
                  .parm : process parameter.
 [OUT]
    fig : figure handle.

 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 [fig] = vb_timeseries_viewer_new(org_file, window_len, data_ch_list, ...
0002                                     trial_list, trig_ch_list, proc_spec_list)
0003 % GUI for checking time series and trial data.
0004 % [USAGE]
0005 %    [fig] = vb_timeseries_viewer_new(org_file, window_len, ...
0006 %                              data_ch_list, trial_list, trig_ch_list);
0007 % [IN]
0008 %      org_file : MEG/EEG Continuous data file
0009 %    window_len : display window length [sec]
0010 %  data_ch_list : data channel name list {Nx1}
0011 %    trial_list : trial list [Nx1]
0012 %                 N x <<struct>>
0013 %                  .from : trial starts here [sec]
0014 %                  .to   : trial ends here   [sec]
0015 %  trig_ch_list : trigger channel name list {Nx1}
0016 %  proc_spec_list : processing specification list for specified channel. <<cell>>
0017 %               proc_spec <<struct>>
0018 %                  .ch_name   : channel name
0019 %                  .type : process type
0020 %                  .parm : process parameter.
0021 % [OUT]
0022 %    fig : figure handle.
0023 %
0024 % Copyright (C) 2011, ATR All Rights Reserved.
0025 % License : New BSD License(see VBMEG_LICENSE.txt)
0026 
0027 %
0028 % --- Previous check
0029 %
0030 if ~exist('org_file', 'var')
0031     error('org_file is a required parameter.');
0032 end
0033 if ~exist('window_len', 'var')
0034     window_len = 30;
0035 end
0036 if ~exist('data_ch_list', 'var')
0037     error('data_ch_list is a required parameter.');
0038 end
0039 if ~exist('trial_list', 'var')
0040     trial_list = [];
0041 end
0042 if ~exist('trig_ch_list', 'var')
0043     trig_ch_list = [];
0044 end
0045 if ~exist('proc_spec_list' ,'var')
0046     proc_spec_list = [];
0047 end
0048 
0049 %
0050 % --- Main Procedure
0051 %
0052 
0053 obj = struct;
0054 
0055 obj.proc_spec_list = proc_spec_list;
0056 
0057 % Set original file to view external channel
0058 obj.org_file     = vb_continuous_file_new(org_file, trig_ch_list); % only read specified channel
0059 obj.trig_ch_list = trig_ch_list;
0060 
0061 
0062 % Get measurement type('MEG' or 'EEG')
0063 MEGinfo = vb_continuous_file_get_meg_info(obj.org_file);
0064 measurement = vb_info_get_measurement(MEGinfo);
0065 
0066 if strcmpi(measurement, 'MEG')
0067     ext = '.meg.mat';
0068 elseif strcmpi(measurement, 'EEG')
0069     ext = '.eeg.mat';
0070 end
0071 
0072 % Set preview file to view measurement data
0073 [o_path, o_file] = vb_get_file_parts(strrep(org_file, ext, ''));
0074 preview_file = [o_path, '/', o_file, '_50Hz', ext];
0075 preview_file = org_file;
0076 
0077 % Channel name to plot
0078 obj.data_ch_list = data_ch_list;
0079 if exist(preview_file, 'file') ~= 2 || isempty(obj.data_ch_list)
0080     obj.preview_file = [];
0081 else
0082     obj.preview_file = vb_continuous_file_new(preview_file, data_ch_list);
0083 end
0084 obj.figure = openfig('vb_timeseries_viewer.fig', 'new', 'invisible');
0085 %set(obj.figure, 'Visible', 'on');% debug
0086 obj.H      = guihandles(obj.figure);
0087 
0088 obj = vb_timeseries_viewer_set_trial(obj, trial_list);
0089 
0090 %
0091 % --- cache data
0092 %
0093 H = obj.H;
0094 
0095 if ~isempty(obj.preview_file)
0096     Nsample = vb_continuous_file_get_Nsample(obj.preview_file);
0097     freq    = vb_continuous_file_get_sample_freq(obj.preview_file);
0098     % read data for cache
0099     [obj.preview_file, data] = vb_continuous_file_get_sample(obj.preview_file, ...
0100                                                           obj.data_ch_list, ...
0101                                                           1, Nsample);
0102     % Fix Ylimit
0103     max_value = max(data(:));
0104     min_value = min(data(:));
0105     ylim(H.data_axes, [min_value, max_value]);
0106     set(H.ylimit_high_edit, 'String', num2str(max_value));
0107     set(H.ylimit_low_edit, 'String', num2str(min_value));
0108     clear data;
0109 end
0110 
0111 %
0112 % --- cache trigger data
0113 %
0114 if ~isempty(obj.org_file)
0115     Nsample = vb_continuous_file_get_Nsample(obj.org_file);
0116     freq    = vb_continuous_file_get_sample_freq(obj.org_file);
0117     % read data for cache
0118     [obj.org_file] = vb_continuous_file_get_sample(obj.org_file, ...
0119                                                        obj.trig_ch_list, ...
0120                                                           1, Nsample);
0121 end
0122 
0123 obj.freq = freq;
0124 obj.Nsample = Nsample;
0125 obj.total_time_sec = (Nsample / freq);
0126 
0127 %
0128 % --- Scaling Slider
0129 %
0130 if window_len >= obj.total_time_sec;
0131     window_len = obj.total_time_sec;
0132 end
0133 obj.window_len = window_len;
0134 
0135 max_value = get(H.Yscale_slider, 'Max');
0136 set(H.Yscale_slider, 'Value', max_value-(obj.window_len / 100));
0137 
0138 % Time point setup
0139 axis(H.timepoint_axes, 'manual');
0140 xlim(H.timepoint_axes, [0, Nsample/freq]);
0141 %xlim(H.timepoint_axes, [obj.window_len/2, Nsample/freq]);
0142 set(H.timepoint_axes, 'YTickLabel', '');
0143 
0144 h = xlabel(H.timepoint_axes, 'Display position[sec]', ...
0145                          'FontName', 'Times', ...
0146                          'FontSize', 14, 'FontUnit', 'points');
0147 set(h, 'FontSize', 14); % ??? If it remove this line, font size doesn't set collectly.
0148 set(h, 'FontUnit', 'normalized');
0149 
0150 % update display time range
0151 obj.event_number = 0;
0152 obj = vb_timeseries_viewer_update_display_time_range(obj);
0153 
0154 % save data
0155 guidata(obj.figure, obj);
0156 
0157 %
0158 % --- Time slider
0159 %
0160 
0161 % slider continuous callback(using MATLAB hack)
0162 tp_listener = handle.listener(H.timeseries_slider, ...
0163                               'ActionEvent', ...
0164                               @vb_timeseries_viewer_slider_event);
0165 setappdata(H.timeseries_slider, 'mySliderListener', tp_listener);
0166 setappdata(H.timeseries_slider, 'Figure', obj.figure);
0167 
0168 yscale_listener = handle.listener(H.Yscale_slider, ...
0169                                   'ActionEvent', ...
0170                                   @vb_timeseries_viewer_slider_event);
0171 setappdata(H.Yscale_slider, 'mySliderListener', yscale_listener);
0172 setappdata(H.Yscale_slider, 'Figure', obj.figure);
0173 
0174 %
0175 % --- Axes settings
0176 %
0177 
0178 %%%%%%%%%%%%%%%%%%%%%
0179 % Data axes settings
0180 %%%%%%%%%%%%%%%%%%%%%
0181 h = xlabel(H.data_axes, 'Time[sec]', ...
0182                         'FontName', 'Times', 'FontUnit', 'points', ...
0183                         'FontSize', 14);
0184 set(h, 'FontUnit', 'normalized');
0185 
0186 h = ylabel(H.data_axes, 'Measurement data', 'FontUnit', 'points', ...
0187                         'FontName', 'Times', 'FontSize', 14);
0188 set(h, 'FontUnit', 'normalized');
0189 
0190 % Set Axes font
0191 set(H.data_axes, 'FontUnit', 'points', 'FontName', 'Times', ...
0192                  'FontSize', 14);
0193 set(H.data_axes, 'FontUnit', 'normalized');
0194 
0195 %%%%%%%%%%%%%%%%%%%%%%%%%%
0196 % External axes settings
0197 %%%%%%%%%%%%%%%%%%%%%%%%%%
0198 h = xlabel(H.trigger_axes, 'Time[sec]', ...
0199                         'FontName', 'Times', ...
0200                         'FontUnit', 'points', 'FontSize', 14);
0201 set(h, 'FontUnit', 'normalized');
0202 h = ylabel(H.trigger_axes, 'External trigger', ...
0203                        'FontName', 'Times', ...
0204                        'FontUnit', 'points', 'FontSize', 14);
0205 set(h, 'FontUnit', 'normalized');
0206 % Set Axis font
0207 set(H.trigger_axes, 'FontName', 'Times', ...
0208                     'FontUnit', 'points');
0209 set(H.trigger_axes, 'FontSize', 14);
0210 set(H.trigger_axes, 'FontUnit', 'normalized');
0211 
0212 
0213 %
0214 % --- Final step
0215 %
0216 set(obj.figure, 'Visible', 'on');
0217 set(obj.figure, 'Name', 'Trigger viewer'); 
0218 
0219 fig = obj.figure;

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