0001 function job_plot_meg_update_timecourse(inst_id,flag)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 global vbmeg_inst;
0016 define_job_plot_meg_const;
0017 if isempty(vbmeg_inst.plotmeg{inst_id}.bexp), return; end
0018 if ~exist('flag', 'var'), flag = []; end;
0019
0020
0021
0022
0023
0024 h_fig = vbmeg_inst.plotmeg{inst_id}.h_fig;
0025 h_time = vbmeg_inst.plotmeg{inst_id}.h_time;
0026 n_trial = vbmeg_inst.plotmeg{inst_id}.n_trial;
0027 T = vbmeg_inst.plotmeg{inst_id}.T;
0028 N = vbmeg_inst.plotmeg{inst_id}.N;
0029 t = vbmeg_inst.plotmeg{inst_id}.t;
0030 rb1 = vbmeg_inst.plotmeg{inst_id}.rb1;
0031 twin_lim = vbmeg_inst.plotmeg{inst_id}.twin_lim;
0032 bexp = vbmeg_inst.plotmeg{inst_id}.bexp(:,:,n_trial);
0033 MEGinfo = vbmeg_inst.plotmeg{inst_id}.MEGinfo;
0034 ylabel_str = vbmeg_inst.plotmeg{inst_id}.ylabel_str;
0035
0036
0037
0038
0039
0040 if t(1)<min(T(twin_lim)), t(1)=min(T(twin_lim)); end;
0041 if t(1)>max(T(twin_lim)), t(1)=max(T(twin_lim)); end;
0042 if t(2)<min(T(twin_lim)), t(2)=min(T(twin_lim)); end;
0043 if t(2)>max(T(twin_lim)), t(2)=max(T(twin_lim)); end;
0044 if t(1)>t(2), t=t(2:-1:1); end;
0045 vbmeg_inst.plotmeg{inst_id}.t = t;
0046
0047
0048
0049
0050
0051 sensor_type = vbmeg_inst.plotmeg{inst_id}.sensor_type;
0052 ch_name = [];
0053 if isfield(vbmeg_inst.plotmeg{inst_id}.MEGinfo.ChannelInfo, 'Name')
0054 ch_name = vbmeg_inst.plotmeg{inst_id}.MEGinfo.ChannelInfo.Name;
0055 end
0056
0057 if sensor_type~=-1,
0058 ix = find(MEGinfo.ChannelInfo.Type==sensor_type);
0059 bexp = bexp(ix,:);
0060 ch_name = ch_name(ix);
0061 end
0062
0063 if isfield(vbmeg_inst.plotmeg{inst_id}, 'selected_sensor')
0064 selected_sensor_ix = vbmeg_inst.plotmeg{inst_id}.selected_sensor;
0065 if ~isempty(selected_sensor_ix)
0066 bexp = bexp(selected_sensor_ix, :);
0067 if ~isempty(ch_name)
0068 vbmeg_inst.plotmeg{inst_id}.selected_sensor_name = ch_name(selected_sensor_ix);
0069 end
0070 else
0071 vbmeg_inst.plotmeg{inst_id}.selected_sensor_name = ch_name;
0072 end
0073 end
0074 vbmeg_inst.plotmeg{inst_id}.plotting_timecourse = bexp;
0075
0076
0077
0078
0079
0080 set(h_fig,'CurrentAxes',h_time);
0081 if flag == FORCE_UPDATE
0082 cla(h_time);
0083 if get(rb1,'Value')==1,
0084 h_plot = plot(T,sqrt(sum(bexp.^2,1)/size(bexp,1)));
0085 else
0086 h_plot = plot(repmat(T,[size(bexp,1) 1])',bexp');
0087 end
0088 set(h_plot, 'HitTest', 'off');
0089 set(h_time, 'Box', 'off');
0090 set(h_time, 'TickDir', 'out');
0091 xlim([min(T) max(T)]);
0092 xlabel('Time [ms]');
0093 ylabel(ylabel_str);
0094
0095 end
0096
0097
0098
0099
0100
0101 str = ['vbmeg_inst.plotmeg{' num2str(inst_id) '}'];
0102 command = ['global vbmeg_inst; ' ...
0103 str '.t = xrange;' ...
0104 'inst_id = job_plot_meg_get_inst_id(gcf);' ...
0105 'job_plot_meg_update_timecourse(inst_id);' ...
0106 'job_plot_meg_update_spatialpattern(inst_id);'];
0107 select_xrange('init',gca,'ButtonUpFcn',command,...
0108 'InitialRange',t);
0109
0110
0111
0112
0113
0114 temp = abs(T - t(1));
0115 twin_meg(1) = min(find(temp == min(temp)));
0116 temp = abs(T - t(2));
0117 twin_meg(2) = min(find(temp == min(temp)));
0118 vbmeg_inst.plotmeg{inst_id}.twin_meg = twin_meg;
0119
0120
0121
0122
0123
0124 set(vbmeg_inst.plotmeg{inst_id}.ed2,'String',num2str(t(1)));
0125 set(vbmeg_inst.plotmeg{inst_id}.ed3,'String',num2str(t(2)));
0126 set(vbmeg_inst.plotmeg{inst_id}.twin_min_range, 'String', num2str(T(min(twin_lim))));
0127 set(vbmeg_inst.plotmeg{inst_id}.twin_max_range, 'String', num2str(T(max(twin_lim))));