Home > vbmeg > functions > gui > preAnalysis > meeg_processor > utility > timeseries_viewer > 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(meg_file, window_len, data_ch_list,trial_list, trig_ch_list, trigger_file)

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]
      meg_file : MEG/EEG file(.meg.mat/.eeg.mat)
    window_len : (optional) display window length [sec]
  data_ch_list : (optional) data channel name list {Nx1}
    trial_list : (optional) trial list [Nx1]
                             N x <<struct>>
                              .from : trial starts here [sec]
                              .to   : trial ends here   [sec]
                           If you speficy trigger_file, this is
                           overwritten.
  trig_ch_list : (optional)trigger channel name list {Nx1}
                           If you speficy trigger_file, this is
                           overwritten.
  trigger_file : (optional)trigger filename(.trig.mat).

 [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(meg_file, window_len, data_ch_list, ...
0002                                           trial_list, trig_ch_list, trigger_file)
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 %      meg_file : MEG/EEG file(.meg.mat/.eeg.mat)
0009 %    window_len : (optional) display window length [sec]
0010 %  data_ch_list : (optional) data channel name list {Nx1}
0011 %    trial_list : (optional) trial list [Nx1]
0012 %                             N x <<struct>>
0013 %                              .from : trial starts here [sec]
0014 %                              .to   : trial ends here   [sec]
0015 %                           If you speficy trigger_file, this is
0016 %                           overwritten.
0017 %  trig_ch_list : (optional)trigger channel name list {Nx1}
0018 %                           If you speficy trigger_file, this is
0019 %                           overwritten.
0020 %  trigger_file : (optional)trigger filename(.trig.mat).
0021 %
0022 % [OUT]
0023 %    fig : figure handle.
0024 %
0025 % Copyright (C) 2011, ATR All Rights Reserved.
0026 % License : New BSD License(see VBMEG_LICENSE.txt)
0027 
0028 %
0029 % --- Previous check
0030 %
0031 if ~exist('meg_file', 'var')
0032     error('meg_file is a required parameter.');
0033 end
0034 if ~exist('window_len', 'var')
0035     window_len = 30;
0036 end
0037 if ~exist('data_ch_list', 'var')
0038     ch_info = vb_load_channel_info(meg_file);
0039     data_ch_list = ch_info.Name;
0040 end
0041 if ~exist('trial_list', 'var')
0042     trial_list = [];
0043 end
0044 if ~exist('trig_ch_list', 'var')
0045     trig_ch_list = [];
0046 end
0047 if ~exist('trigger_file' ,'var')
0048     trigger_file = [];
0049 end
0050 if exist(meg_file, 'file') ~= 2
0051     error('Specified MEG/EEG file not found.');
0052 end
0053 if ischar(trig_ch_list)
0054     trig_ch_list = {trig_ch_list};
0055 end
0056 
0057 %
0058 % --- Main Procedure
0059 %
0060 obj = struct;
0061 
0062 % Prepare for read MEG/EEG Data channel
0063 obj.data_ch_list = data_ch_list;
0064 obj.data_ch_list_plot_ix = [1:length(data_ch_list)]';
0065 if exist(meg_file, 'file') ~= 2
0066     return;
0067 end
0068 obj.meg_obj = vb_continuous_file_new(meg_file, data_ch_list);
0069 
0070 % Get measurement type('MEG' or 'EEG')
0071 measurement = vb_continuous_file_get_measurement(obj.meg_obj);
0072 
0073 
0074 % if trigger file specified, trial and trigger used for trial extraction.
0075 if exist(trigger_file, 'file') == 2
0076     % Load trigger file
0077     [trial_list, trig_ch_list] = ...
0078          vb_timeseries_viewer_load_trigger_file(obj.meg_obj, trigger_file);
0079 elseif ~isempty(trigger_file)
0080     error('Specified trigger file(.trig.mat) not found.');
0081 end
0082 
0083 % Prepare for read External channel
0084 obj.trigger_obj = vb_continuous_file_new(meg_file, trig_ch_list);
0085 
0086 % Trigger properties.
0087 obj.trig_ch_list         = trig_ch_list;
0088 obj.trig_ch_list_plot_ix = [1:length(trig_ch_list)]';
0089 obj.trigger_file         = trigger_file;
0090 
0091 % Open figure
0092 obj.figure = openfig('vb_timeseries_viewer.fig', 'new', 'invisible');
0093 obj.H      = guihandles(obj.figure);
0094 %set(obj.figure, 'Visible', 'on');% debug
0095 
0096 % Set trial information
0097 obj = vb_timeseries_viewer_set_trial(obj, trial_list);
0098 
0099 %
0100 % --- Read and cache MEG/EEG data
0101 %
0102 H = obj.H;
0103 
0104 if ~isempty(obj.meg_obj)
0105     Nsample = vb_continuous_file_get_Nsample(obj.meg_obj);
0106     freq    = vb_continuous_file_get_sample_freq(obj.meg_obj);
0107     % read and cache data
0108     [obj.meg_obj, data] = vb_continuous_file_get_sample(obj.meg_obj, ...
0109                                                           obj.data_ch_list, ...
0110                                                           1, Nsample);
0111     % Fix Ylimit
0112     if ~isempty(data)
0113         max_value = max(data(:));
0114         min_value = min(data(:));
0115         ylim(H.data_axes, [min_value, max_value]);
0116         set(H.ylimit_high_edit, 'String', num2str(max_value));
0117         set(H.ylimit_low_edit, 'String', num2str(min_value));
0118     end
0119     clear data;
0120 end
0121 
0122 %
0123 % --- Read and cache Trigger data
0124 %
0125 if ~isempty(obj.trigger_obj)
0126     Nsample = vb_continuous_file_get_Nsample(obj.trigger_obj);
0127     freq    = vb_continuous_file_get_sample_freq(obj.trigger_obj);
0128     % read and cache data
0129     [obj.trigger_obj] = vb_continuous_file_get_sample(obj.trigger_obj, ...
0130                                                    obj.trig_ch_list, ...
0131                                                    1, Nsample);
0132 end
0133 
0134 obj.freq = freq;
0135 obj.Nsample = Nsample;
0136 obj.total_time_sec = (Nsample / freq);
0137 
0138 %
0139 % --- Scaling Slider
0140 %
0141 if window_len >= obj.total_time_sec;
0142     window_len = obj.total_time_sec;
0143 end
0144 obj.window_len = window_len;
0145 
0146 max_value = get(H.Yscale_slider, 'Max');
0147 set(H.Yscale_slider, 'Value', max_value-(obj.window_len / 100));
0148 
0149 % Time point setup
0150 axis(H.timepoint_axes, 'manual');
0151 xlim(H.timepoint_axes, [0, Nsample/freq]);
0152 set(H.timepoint_axes, 'YTickLabel', '');
0153 
0154 h = xlabel(H.timepoint_axes, 'Display position[sec]', ...
0155                          'FontName', 'Times', ...
0156                          'FontSize', 14, 'FontUnit', 'points');
0157 set(h, 'FontSize', 14); % ??? If it remove this line, font size doesn't set collectly.
0158 set(h, 'FontUnit', 'normalized');
0159 
0160 % update display
0161 obj.event_number = 0;
0162 obj = vb_timeseries_viewer_update_display_time_range(obj);
0163 
0164 % save data
0165 guidata(obj.figure, obj);
0166 
0167 %
0168 % --- Time slider
0169 %
0170 
0171 % slider continuous callback(using MATLAB hack)
0172 try
0173 tp_listener = handle.listener(H.timeseries_slider, ...
0174                               'ActionEvent', ...
0175                               @vb_timeseries_viewer_slider_event);
0176 setappdata(H.timeseries_slider, 'mySliderListener', tp_listener);
0177 catch
0178 addlistener(H.timeseries_slider, 'Value', 'PostSet', @vb_timeseries_viewer_slider_event);
0179 end
0180 
0181 setappdata(H.timeseries_slider, 'Figure', obj.figure);
0182 
0183 try
0184 yscale_listener = handle.listener(H.Yscale_slider, ...
0185                                   'ActionEvent', ...
0186                                   @vb_timeseries_viewer_slider_event);
0187 setappdata(H.Yscale_slider, 'mySliderListener', yscale_listener);
0188 catch
0189 addlistener(H.Yscale_slider, 'Value', 'PostSet', @vb_timeseries_viewer_slider_event);
0190 end
0191 setappdata(H.Yscale_slider, 'Figure', obj.figure);
0192 
0193 %
0194 % --- Axes settings
0195 %
0196 
0197 %%%%%%%%%%%%%%%%%%%%%
0198 % Data axes settings
0199 %%%%%%%%%%%%%%%%%%%%%
0200 % h = xlabel(H.data_axes, 'Time[sec]', ...
0201 %                         'FontName', 'Times', 'FontUnit', 'points', ...
0202 %                         'FontSize', 14);
0203 % set(h, 'FontUnit', 'normalized');
0204 
0205 if strcmpi(measurement, 'MEG')
0206     h1 = title(H.data_axes, 'MEG');
0207     h2 = ylabel(H.data_axes, 'Magnetic field [T]', 'FontUnit', 'points', ...
0208                         'FontName', 'Times', 'FontSize', 14);
0209     h = [h1; h2];
0210 elseif strcmpi(measurement, 'EEG')
0211     h1 = title(H.data_axes, 'EEG');
0212     h2 = ylabel(H.data_axes, 'Electric potential [V]', 'FontUnit', 'points', ...
0213                         'FontName', 'Times', 'FontSize', 14);
0214     h = [h1; h2];
0215 end
0216 set(h, 'FontUnit', 'normalized');
0217 
0218 % Set Axes font
0219 set(H.data_axes, 'FontUnit', 'points', 'FontName', 'Times', ...
0220                  'FontSize', 14);
0221 set(H.data_axes, 'FontUnit', 'normalized');
0222 
0223 if isempty(data_ch_list)
0224     set(H.data_channel_push, 'Enable', 'off');
0225 end
0226 
0227 
0228 %%%%%%%%%%%%%%%%%%%%%%%%%%
0229 % External axes settings
0230 %%%%%%%%%%%%%%%%%%%%%%%%%%
0231 h = xlabel(H.trigger_axes, 'Time[sec]', ...
0232                         'FontName', 'Times', ...
0233                         'FontUnit', 'points', 'FontSize', 14);
0234 set(h, 'FontUnit', 'normalized');
0235 if isempty(trial_list)
0236     h = title(H.trigger_axes, 'External channel', ...
0237                        'FontName', 'Times', ...
0238                        'FontUnit', 'points', 'FontSize', 14);
0239 else
0240     h = title(H.trigger_axes, 'Trigger channel', ...
0241                        'FontName', 'Times', ...
0242                        'FontUnit', 'points', 'FontSize', 14);
0243 end
0244 set(h, 'FontUnit', 'normalized');
0245 
0246 % Set Axis font
0247 set(H.trigger_axes, 'FontName', 'Times', ...
0248                     'FontUnit', 'points');
0249 set(H.trigger_axes, 'FontSize', 14);
0250 set(H.trigger_axes, 'FontUnit', 'normalized');
0251 
0252 if isempty(trig_ch_list)
0253     set(H.trigger_channel_push, 'Enable', 'off');
0254 end
0255 
0256 % Zoom in/out button Icons
0257 cdata_zoom_in  = load('zoomplus.mat');
0258 cdata_zoom_out = load('zoomminus.mat');
0259 
0260 set(H.scale_plus_push,  'Cdata', cdata_zoom_in.cdata);
0261 set(H.scale_minus_push, 'Cdata', cdata_zoom_out.cdata);
0262 
0263 %%%%%%%%%%%%%%%%%%%%%%%%%%
0264 % Menu settings
0265 %%%%%%%%%%%%%%%%%%%%%%%%%%
0266 
0267 % File->Save trigger file
0268 if ~isempty(obj.trigger_file)
0269     set(H.save_trigger_file, 'Enable', 'on');
0270 else
0271     set(H.save_trigger_file, 'Enable', 'off');
0272 end
0273 
0274 %
0275 % --- Final step
0276 %
0277 set(obj.figure, 'Name', meg_file);
0278 set(obj.figure, 'Menubar', 'none');
0279 set(obj.figure, 'Toolbar', 'none');
0280 set(obj.figure, 'HandleVisibility', 'callback');
0281 set(obj.figure, 'Visible', 'on');
0282 
0283 fig = obj.figure;

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