Home > vbmeg > functions > job > job_plot_meg_dir > job_plot_meg_update_timecourse.m

job_plot_meg_update_timecourse

PURPOSE ^

Update timecourse of MEG signal

SYNOPSIS ^

function job_plot_meg_update_timecourse(inst_id,flag)

DESCRIPTION ^

 Update timecourse of MEG signal

 --- Syntax
 function job_plot_meg_update_timecourse(inst_id,flag)

 --- History
 2008-09-02 Taku Yoshioka
 2015-12-14 rhayashi
      save showing data(selected_sensor_name, plotting_timecourse)

 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 job_plot_meg_update_timecourse(inst_id,flag)
0002 % Update timecourse of MEG signal
0003 %
0004 % --- Syntax
0005 % function job_plot_meg_update_timecourse(inst_id,flag)
0006 %
0007 % --- History
0008 % 2008-09-02 Taku Yoshioka
0009 % 2015-12-14 rhayashi
0010 %      save showing data(selected_sensor_name, plotting_timecourse)
0011 %
0012 % Copyright (C) 2011, ATR All Rights Reserved.
0013 % License : New BSD License(see VBMEG_LICENSE.txt)
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 % Global variables
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 % Time window range check
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 % Select sensor
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 % Plot time course
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   %ylabel('MEG signal [fT]');
0095 end
0096 
0097 %
0098 % Set callback function
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 % Convert Timewindow from msec to index
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 % Update text box
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))));

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