0001 function [fig] = vb_timeseries_viewer_new(org_file, window_len, data_ch_list, ...
0002 trial_list, trig_ch_list, proc_spec_list)
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
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
0051
0052
0053 obj = struct;
0054
0055 obj.proc_spec_list = proc_spec_list;
0056
0057
0058 obj.org_file = vb_continuous_file_new(org_file, trig_ch_list);
0059 obj.trig_ch_list = trig_ch_list;
0060
0061
0062
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
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
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
0086 obj.H = guihandles(obj.figure);
0087
0088 obj = vb_timeseries_viewer_set_trial(obj, trial_list);
0089
0090
0091
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
0099 [obj.preview_file, data] = vb_continuous_file_get_sample(obj.preview_file, ...
0100 obj.data_ch_list, ...
0101 1, Nsample);
0102
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
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
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
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
0139 axis(H.timepoint_axes, 'manual');
0140 xlim(H.timepoint_axes, [0, Nsample/freq]);
0141
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);
0148 set(h, 'FontUnit', 'normalized');
0149
0150
0151 obj.event_number = 0;
0152 obj = vb_timeseries_viewer_update_display_time_range(obj);
0153
0154
0155 guidata(obj.figure, obj);
0156
0157
0158
0159
0160
0161
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
0176
0177
0178
0179
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
0191 set(H.data_axes, 'FontUnit', 'points', 'FontName', 'Times', ...
0192 'FontSize', 14);
0193 set(H.data_axes, 'FontUnit', 'normalized');
0194
0195
0196
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
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
0215
0216 set(obj.figure, 'Visible', 'on');
0217 set(obj.figure, 'Name', 'Trigger viewer');
0218
0219 fig = obj.figure;