Home > 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

 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 %
0010 % Copyright (C) 2011, ATR All Rights Reserved.
0011 % License : New BSD License(see VBMEG_LICENSE.txt)
0012 
0013 global vbmeg_inst;
0014 define_job_plot_meg_const;
0015 if isempty(vbmeg_inst.plotmeg{inst_id}.bexp), return; end
0016 if ~exist('flag', 'var'), flag = []; end;
0017 
0018 %
0019 % Global variables
0020 %
0021 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0022 h_fig = vbmeg_inst.plotmeg{inst_id}.h_fig; 
0023 h_time = vbmeg_inst.plotmeg{inst_id}.h_time;
0024 n_trial = vbmeg_inst.plotmeg{inst_id}.n_trial;
0025 T = vbmeg_inst.plotmeg{inst_id}.T;
0026 N = vbmeg_inst.plotmeg{inst_id}.N;
0027 t = vbmeg_inst.plotmeg{inst_id}.t;
0028 rb1 = vbmeg_inst.plotmeg{inst_id}.rb1;
0029 twin_lim = vbmeg_inst.plotmeg{inst_id}.twin_lim;
0030 bexp = vbmeg_inst.plotmeg{inst_id}.bexp(:,:,n_trial);
0031 MEGinfo = vbmeg_inst.plotmeg{inst_id}.MEGinfo;
0032 ylabel_str = vbmeg_inst.plotmeg{inst_id}.ylabel_str;
0033 
0034 %
0035 % Time window range check
0036 %
0037 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0038 if t(1)<min(T(twin_lim)), t(1)=min(T(twin_lim)); end;
0039 if t(1)>max(T(twin_lim)), t(1)=max(T(twin_lim)); end;
0040 if t(2)<min(T(twin_lim)), t(2)=min(T(twin_lim)); end;
0041 if t(2)>max(T(twin_lim)), t(2)=max(T(twin_lim)); end;
0042 if t(1)>t(2), t=t(2:-1:1); end;
0043 vbmeg_inst.plotmeg{inst_id}.t = t; 
0044 
0045 %
0046 % Select sensor
0047 %
0048 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0049 sensor_type = vbmeg_inst.plotmeg{inst_id}.sensor_type;
0050 
0051 if sensor_type~=-1, 
0052   ix = find(MEGinfo.ChannelInfo.Type==sensor_type);
0053   bexp = bexp(ix,:);
0054 end
0055 
0056 %
0057 % Plot time course
0058 %
0059 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0060 set(h_fig,'CurrentAxes',h_time);
0061 if flag == FORCE_UPDATE
0062   if get(rb1,'Value')==1, 
0063     plot(T,sqrt(sum(bexp.^2,1)/size(bexp,1)));
0064   else
0065     plot(repmat(T,[size(bexp,1) 1])',bexp');
0066   end
0067   xlim([min(T) max(T)]);
0068   xlabel('Time [ms]');
0069   ylabel(ylabel_str);
0070   %ylabel('MEG signal [fT]');
0071 end
0072 
0073 %
0074 % Set callback function
0075 %
0076 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0077 str = ['vbmeg_inst.plotmeg{' num2str(inst_id) '}']; 
0078 command = ['global vbmeg_inst; ' ...
0079        str '.t = xrange;' ...
0080        'inst_id = job_plot_meg_get_inst_id(gcf);' ...
0081        'job_plot_meg_update_timecourse(inst_id);' ...
0082        'job_plot_meg_update_spatialpattern(inst_id);'];
0083 select_xrange('init',gca,'ButtonUpFcn',command,...
0084           'InitialRange',t);
0085 
0086 %
0087 % Convert Timewindow from msec to index
0088 %
0089 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0090 temp = abs(T - t(1));
0091 twin_meg(1) = min(find(temp == min(temp)));
0092 temp = abs(T - t(2));
0093 twin_meg(2) = min(find(temp == min(temp)));
0094 vbmeg_inst.plotmeg{inst_id}.twin_meg = twin_meg;
0095 
0096 %
0097 % Update text box
0098 %
0099 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0100 set(vbmeg_inst.plotmeg{inst_id}.ed2,'String',num2str(t(1))); 
0101 set(vbmeg_inst.plotmeg{inst_id}.ed3,'String',num2str(t(2))); 
0102 set(vbmeg_inst.plotmeg{inst_id}.twin_min_range, 'String', num2str(T(min(twin_lim))));
0103 set(vbmeg_inst.plotmeg{inst_id}.twin_max_range, 'String', num2str(T(max(twin_lim))));

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