timtopo() - plot all channels of a data epoch on the same axis and map its scalp map(s) at selected latencies. Usage: >> timtopo(data,'chan_locs'); >> timtopo(data,'chan_locs',[limits],[plottimes]','title',[plotchans], ... [voffsets], 'key', 'val','ylab', ...); Inputs: data = (channels,frames) single-epoch data matrix chan_locs = channel location file or EEG.chanlocs structure. See >> topoplot example for file format. Optional ordered inputs: [limits] = [minms maxms minval maxval] data limits for latency (in ms) and y-values (assumes uV) {default|0 -> use [0 npts-1 data_min data_max]; else [minms maxms] or [minms maxms 0 0] -> use [minms maxms data_min data_max] plottimes = [vector] latencies (in ms) at which to plot scalp maps {default|NaN -> latency of maximum variance} 'title' = [string] plot title {default|0 -> none} plotchans = vector of data channel(s) to plot {default|0 -> all} voffsets = vector of (plotting-unit) distances vertical lines should extend above the data (in special cases) {default -> all = standard} 'ylab' = [string] y-axis label for time series plot {default: 'Correlation'} Optional keyword, arg pair inputs (must come after the above): 'topokey','val' = optional topoplot() scalp map plotting arguments. See >> help topoplot Author: Scott Makeig, SCCN/INC/UCSD, La Jolla, 1-10-98 See also: envtopo(), topoplot()
0001 % timtopo() - plot all channels of a data epoch on the same axis 0002 % and map its scalp map(s) at selected latencies. 0003 % Usage: 0004 % >> timtopo(data,'chan_locs'); 0005 % >> timtopo(data,'chan_locs',[limits],[plottimes]','title',[plotchans], ... 0006 % [voffsets], 'key', 'val','ylab', ...); 0007 % Inputs: 0008 % data = (channels,frames) single-epoch data matrix 0009 % chan_locs = channel location file or EEG.chanlocs structure. 0010 % See >> topoplot example for file format. 0011 % 0012 % Optional ordered inputs: 0013 % [limits] = [minms maxms minval maxval] data limits for latency (in ms) and y-values 0014 % (assumes uV) {default|0 -> use [0 npts-1 data_min data_max]; 0015 % else [minms maxms] or [minms maxms 0 0] -> use 0016 % [minms maxms data_min data_max] 0017 % plottimes = [vector] latencies (in ms) at which to plot scalp maps 0018 % {default|NaN -> latency of maximum variance} 0019 % 'title' = [string] plot title {default|0 -> none} 0020 % plotchans = vector of data channel(s) to plot {default|0 -> all} 0021 % voffsets = vector of (plotting-unit) distances vertical lines should extend 0022 % above the data (in special cases) {default -> all = standard} 0023 % 'ylab' = [string] y-axis label for time series plot {default: 0024 % 'Correlation'} 0025 % 0026 % Optional keyword, arg pair inputs (must come after the above): 0027 % 'topokey','val' = optional topoplot() scalp map plotting arguments. See >> help topoplot 0028 % 0029 % Author: Scott Makeig, SCCN/INC/UCSD, La Jolla, 1-10-98 0030 % 0031 % See also: envtopo(), topoplot() 0032 0033 % Copyright (C) 1-10-98 Scott Makeig, SCCN/INC/UCSD, scott@sccn.ucsd.edu 0034 % 0035 % This program is free software; you can redistribute it and/or modify 0036 % it under the terms of the GNU General Public License as published by 0037 % the Free Software Foundation; either version 2 of the License, or 0038 % (at your option) any later version. 0039 % 0040 % This program is distributed in the hope that it will be useful, 0041 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0042 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0043 % GNU General Public License for more details. 0044 % 0045 % You should have received a copy of the GNU General Public License 0046 % along with this program; if not, write to the Free Software 0047 % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 0048 0049 % $Log: timtopo.m,v $ 0050 % Revision 1.73 2006/10/28 00:50:24 arno 0051 % now clicking plot scalp map at that latency 0052 % 0053 % Revision 1.72 2005/05/16 20:27:46 scott 0054 % adjusted several plotting details, oblique line height, cbar, text, etc. 0055 % 0056 % Revision 1.71 2005/03/05 02:28:36 arno 0057 % debug argument passing to topoplot 0058 % 0059 % Revision 1.70 2004/10/20 15:20:27 scott 0060 % still bug at line 551 -sm 0061 % 0062 % Revision 1.69 2004/10/20 15:19:03 scott 0063 % nothing 0064 % 0065 % Revision 1.68 2004/04/25 20:07:28 scott 0066 % typo 0067 % 0068 % Revision 1.67 2004/04/25 20:05:36 scott 0069 % help message modernize. adjust text, add white vertical underlines, made limits input more flexible 0070 % 0071 % Revision 1.66 2003/11/26 18:20:44 scott 0072 % Time -> Latency 0073 % 0074 % Revision 1.65 2003/08/06 00:27:10 arno 0075 % remove postp (made matlab 5.3 crash 0076 % 0077 % Revision 1.64 2003/03/05 03:22:40 scott 0078 % cleanup 0079 % 0080 % Revision 1.63 2003/03/05 03:19:23 scott 0081 % topoleft 0082 % 0083 % Revision 1.62 2003/03/05 03:17:01 scott 0084 % typo 0085 % 0086 % Revision 1.61 2003/03/05 03:16:41 scott 0087 % typo 0088 % 0089 % Revision 1.60 2003/03/05 03:16:10 scott 0090 % topoleft 0091 % 0092 % Revision 1.59 2003/03/05 03:06:37 scott 0093 % cleanup 0094 % 0095 % Revision 1.58 2003/03/05 03:04:52 scott 0096 % head_sep 0097 % 0098 % Revision 1.57 2003/03/05 03:03:43 scott 0099 % topowidth 0100 % 0101 % Revision 1.56 2003/03/05 02:54:49 scott 0102 % topoargs 0103 % 0104 % Revision 1.55 2003/03/05 02:53:26 scott 0105 % same 0106 % 0107 % Revision 1.54 2003/03/05 02:53:00 scott 0108 % topostring 0109 % 0110 % Revision 1.53 2003/03/05 02:46:01 scott 0111 % topowdith 0112 % 0113 % Revision 1.52 2003/03/05 02:44:04 scott 0114 % topowidth 0115 % ., 0116 % 0117 % Revision 1.51 2003/03/05 02:41:49 scott 0118 % topowidth 0119 % 0120 % Revision 1.50 2003/03/05 02:40:58 scott 0121 % same 0122 % 0123 % Revision 1.49 2003/03/05 02:40:00 scott 0124 % topowidth 0125 % 0126 % Revision 1.48 2003/03/05 02:36:31 scott 0127 % same 0128 % 0129 % Revision 1.47 2003/03/05 02:36:01 scott 0130 % eval topoplot 0131 % 0132 % Revision 1.46 2003/03/05 02:34:32 scott 0133 % topoplot 0134 % 0135 % Revision 1.45 2003/03/05 02:33:01 scott 0136 % topoplot 0137 % 0138 % Revision 1.44 2003/03/05 02:30:37 scott 0139 % emarkersize 0140 % 0141 % Revision 1.43 2003/03/05 02:28:35 scott 0142 % same 0143 % 0144 % Revision 1.42 2003/03/05 02:27:54 scott 0145 % emarkersize 0146 % 0147 % Revision 1.41 2003/03/05 02:04:58 scott 0148 % emarkersize 0149 % 0150 % Revision 1.40 2003/03/05 02:04:07 scott 0151 % emarkersize -sm 0152 % 0153 % Revision 1.39 2003/03/05 01:56:34 scott 0154 % topowidth -sm 0155 % 0156 % Revision 1.38 2003/03/05 01:55:20 scott 0157 % topowidth -sm 0158 % 0159 % Revision 1.37 2003/03/05 01:51:57 scott 0160 % topowidth -sm 0161 % 0162 % Revision 1.36 2003/03/04 21:17:52 scott 0163 % axfont -sm 0164 % 0165 % Revision 1.35 2003/03/04 21:10:50 scott 0166 % titlefont -sm 0167 % 0168 % Revision 1.34 2003/03/04 18:52:41 scott 0169 % cleaning up -sm 0170 % 0171 % Revision 1.33 2003/03/04 18:48:25 scott 0172 % test size -sm 0173 % 0174 % Revision 1.32 2003/03/04 18:44:58 scott 0175 % title text debug -sm 0176 % 0177 % Revision 1.31 2003/03/04 18:43:45 scott 0178 % title text -sm 0179 % 0180 % Revision 1.30 2003/03/04 18:41:09 scott 0181 % title text -sm 0182 % 0183 % Revision 1.29 2003/03/04 18:40:34 scott 0184 % title text -sm 0185 % 0186 % Revision 1.28 2003/03/04 18:38:57 scott 0187 % title text 0188 % 0189 % Revision 1.27 2003/03/04 18:35:02 scott 0190 % cbar text -sm 0191 % 0192 % Revision 1.26 2003/03/04 18:34:07 scott 0193 % cbar text 0194 % 0195 % Revision 1.25 2003/03/04 18:32:59 scott 0196 % cbar text -sm 0197 % 0198 % Revision 1.24 2003/03/04 18:28:38 scott 0199 % cbar text -sm 0200 % 0201 % Revision 1.23 2003/03/04 18:24:36 scott 0202 % final debugs? -sm 0203 % 0204 % Revision 1.22 2003/03/04 18:22:30 scott 0205 % debug last -sm 0206 % 0207 % Revision 1.21 2003/03/04 18:20:01 scott 0208 % debug last -sm 0209 % 0210 % Revision 1.20 2003/03/04 18:15:06 scott 0211 % debug last -sm 0212 % 0213 % Revision 1.19 2003/03/04 18:13:58 scott 0214 % debug last -sm 0215 % 0216 % Revision 1.18 2003/03/04 18:11:36 scott 0217 % debug last -sm 0218 % 0219 % Revision 1.17 2003/03/04 18:09:45 scott 0220 % debug last -sm 0221 % 0222 % Revision 1.16 2003/03/04 18:07:29 scott 0223 % debug last -sm 0224 % 0225 % Revision 1.15 2003/03/04 18:06:21 scott 0226 % using changeunits -sm 0227 % 0228 % Revision 1.14 2003/03/04 17:49:36 scott 0229 % debug oblique lines -sm 0230 % 0231 % Revision 1.13 2003/03/04 17:41:55 scott 0232 % debug last -sm 0233 % 0234 % Revision 1.12 2003/03/04 17:40:51 scott 0235 % debug head size for sbplots -sm 0236 % 0237 % Revision 1.11 2003/03/04 17:37:47 scott 0238 % debug last -sm 0239 % 0240 % Revision 1.10 2003/03/04 17:36:26 scott 0241 % debug last -sm 0242 % 0243 % Revision 1.9 2003/03/04 17:21:43 scott 0244 % debug last -sm 0245 % 0246 % Revision 1.8 2003/03/04 17:20:23 scott 0247 % debug last -sm 0248 % 0249 % Revision 1.7 2003/03/04 17:16:01 scott 0250 % debug last -sm 0251 % 0252 % Revision 1.6 2003/03/04 17:11:51 scott 0253 % edit to work in subplot axes -sm 0254 % 0255 % Revision 1.5 2002/11/15 03:07:45 arno 0256 % header for web 0257 % 0258 % Revision 1.4 2002/08/28 00:52:30 arno 0259 % allow to plot NaN with other latencies 0260 % 0261 % Revision 1.3 2002/08/27 00:20:54 arno 0262 % debugging colorbar->cbar (for menus) 0263 % 0264 % Revision 1.2 2002/08/12 23:48:05 arno 0265 % debug absmax 0266 % 0267 % Revision 1.1 2002/04/05 17:36:45 jorn 0268 % Initial revision 0269 % 0270 0271 % 5-31-00 added o-time line and possibility of plotting 1 channel -sm & mw 0272 % 11-02-99 added maplimits arg -sm 0273 % 01-22-01 added to help message -sm 0274 % 01-25-02 reformated help & license, added link -ad 0275 % 03-15-02 add all topoplot options -ad 0276 0277 function M = timtopo_corr(data,chan_locs,limits,plottimes,titl,plotchans,voffsets,ylab,varargin) 0278 0279 MAX_TOPOS = 24; 0280 0281 if nargin < 1 0282 help timtopo; 0283 return 0284 end 0285 0286 [chans,frames] = size(data); 0287 icadefs; 0288 0289 if nargin < 8 || isempty(ylab) 0290 ylab='Correlation'; 0291 end 0292 0293 if nargin < 7 || voffsets == 0 0294 voffsets = zeros(1,MAX_TOPOS); 0295 end 0296 0297 if nargin < 6 0298 plotchans = 0; 0299 end 0300 0301 if plotchans==0 0302 plotchans = 1:chans; 0303 end 0304 0305 if nargin < 5, 0306 titl = ''; % DEFAULT NO TITLE 0307 end 0308 0309 plottimes_set=1; % flag variable 0310 if nargin< 4 | isempty(plottimes) | any(isnan(plottimes)) 0311 plottimes_set = 0; 0312 end 0313 0314 limitset = 0; 0315 if nargin < 3, 0316 limits = 0; 0317 elseif length(limits)>1 0318 limitset = 1; 0319 end 0320 0321 if nargin < 2 0322 chan_locs = 'chan.locs'; % DEFAULT CHAN_FILE 0323 end 0324 if isnumeric(chan_locs) & chan_locs == 0, 0325 chan_locs = 'chan.locs'; % DEFAULT CHAN_FILE 0326 end 0327 0328 % 0329 %%%%%%%%%%%%%%%%%%%%%%% Read and adjust limits %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0330 % defaults: limits == 0 or [0 0 0 0] 0331 if ( length(limits) == 1 & limits==0) | (length(limits)==4 & ~any(limits)) 0332 xmin=0; 0333 xmax=frames-1; 0334 ymin=min(min(data)); 0335 ymax=max(max(data)); 0336 elseif length(limits) == 2 % [minms maxms] only 0337 ymin=min(min(data)); 0338 ymax=max(max(data)); 0339 xmin = limits(1); 0340 xmax = limits(2); 0341 elseif length(limits) == 4 0342 xmin = limits(1); 0343 xmax = limits(2); 0344 if any(limits([3 4])) 0345 ymin = limits(3); 0346 ymax = limits(4); 0347 else % both 0 0348 ymin=min(min(data)); 0349 ymax=max(max(data)); 0350 end 0351 else 0352 fprintf('timtopo(): limits format not correct. See >> help timtopo.\n'); 0353 return 0354 end; 0355 0356 if xmax == 0 & xmin == 0, 0357 x = (0:1:frames-1); 0358 xmin = 0; 0359 xmax = frames-1; 0360 else 0361 dx = (xmax-xmin)/(frames-1); 0362 x=xmin*ones(1,frames)+dx*(0:frames-1); % compute x-values 0363 end; 0364 if xmax<=xmin, 0365 fprintf('timtopo() - in limits, maxms must be > minms.\n') 0366 return 0367 end 0368 0369 if ymax == 0 & ymin == 0, 0370 ymax=max(max(data)); 0371 ymin=min(min(data)); 0372 end 0373 if ymax<=ymin, 0374 fprintf('timtopo() - in limits, maxval must be > minmval.\n') 0375 return 0376 end 0377 0378 sampint = (xmax-xmin)/(frames-1); % sampling interval = 1000/srate; 0379 x = xmin:sampint:xmax; % make vector of x-values 0380 0381 % 0382 %%%%%%%%%%%%%%% Compute plot times/frames %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0383 % 0384 if plottimes_set == 0 0385 [mx plotframes] = max(sum(data.*data)); 0386 % default plotting frame has max variance 0387 if nargin< 4 | isempty(plottimes) 0388 plottimes = x(plotframes); 0389 else 0390 plottimes(find(isnan(plottimes))) = x(plotframes); 0391 end; 0392 plottimes_set = 1; 0393 end; 0394 0395 if plottimes_set == 1 0396 ntopos = length(plottimes); 0397 if ntopos > MAX_TOPOS 0398 fprintf('timtopo(): too many plottimes - only first %d will be shown!\n',MAX_TOPOS); 0399 plottimes = plottimes(1:MAX_TOPOS); 0400 ntopos = MAX_TOPOS; 0401 end 0402 0403 if max(plottimes) > xmax | min(plottimes)< xmin 0404 fprintf(... 0405 'timtopo(): at least one plottimes value outside of epoch latency range - cannot plot.\n'); 0406 return 0407 end 0408 0409 plottimes = sort(plottimes); % put map latencies in ascending order, 0410 % else map lines would cross. 0411 xshift = [x(2:frames) xmax]; 0412 plotframes = ones(size(plottimes)); 0413 for t = 1:ntopos 0414 time = plottimes(t); 0415 plotframes(t) = find(time>=x & time < xshift); 0416 end 0417 end 0418 0419 vlen = length(voffsets); % extend voffsets if necessary 0420 i=1; 0421 while vlen< ntopos 0422 voffsets = [voffsets voffsets(i)]; 0423 i=i+1; 0424 vlen=vlen+1; 0425 end 0426 0427 % 0428 %%%%%%%%%%%%%%%% Compute title and axes font sizes %%%%%%%%%%%%%%% 0429 % 0430 pos = get(gca,'Position'); 0431 axis('off') 0432 cla % clear the current axes 0433 if pos(4)>0.70 0434 titlefont= 16; 0435 axfont = 16; 0436 elseif pos(4)>0.40 0437 titlefont= 14; 0438 axfont = 14; 0439 elseif pos(4)>0.30 0440 titlefont= 12; 0441 axfont = 12; 0442 elseif pos(4)>0.22 0443 titlefont= 10; 0444 axfont = 10; 0445 else 0446 titlefont= 8; 0447 axfont = 8; 0448 end 0449 0450 % 0451 %%%%%%%%%%%%%%%% Compute topoplot head width and separation %%%%%%%%%%%%%%% 0452 % 0453 head_sep = 0.2; 0454 topowidth = pos(3)/((6*ntopos-1)/5); % width of each topoplot 0455 if topowidth> 0.25*pos(4) % dont make too large (more than 1/4 of axes width)! 0456 topowidth = 0.25*pos(4); 0457 end 0458 0459 halfn = floor(ntopos/2); 0460 if rem(ntopos,2) == 1 % odd number of topos 0461 topoleft = pos(3)/2 - (ntopos/2+halfn*head_sep)*topowidth; 0462 else % even number of topos 0463 topoleft = pos(3)/2 - ((halfn)+(halfn-1)*head_sep)*topowidth; 0464 end 0465 topoleft = topoleft - 0.01; % adjust left a bit for colorbar 0466 0467 if max(plotframes) > frames | min(plotframes) < 1 0468 fprintf('Requested map frame %d is outside data range (1-%d)\n',max(plotframes),frames); 0469 return 0470 end 0471 0472 % 0473 %%%%%%%%%%%%%%%%%%%% Print times and frames %%%%%%%%%%%%%%%%%%%%%%%%%% 0474 % 0475 0476 fprintf('Scalp maps will show latencies: '); 0477 for t=1:ntopos 0478 fprintf('%4.0f ',plottimes(t)); 0479 end 0480 fprintf('\n'); 0481 fprintf(' at frames: '); 0482 for t=1:ntopos 0483 fprintf('%4d ',plotframes(t)); 0484 end 0485 fprintf('\n'); 0486 0487 % 0488 %%%%%%%%%%%%%%%%%%%%%%% Plot the data %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0489 % 0490 % 0491 %%%%%%%%%%%% site the plot at bottom of the figure %%%%%%%%%%%%%%%%%% 0492 % 0493 axdata = axes('Units','Normalized','Position',[pos(1) pos(2) pos(3) 0.6*pos(4)],'FontSize',axfont); 0494 set(axdata,'Color',BACKCOLOR); 0495 0496 limits = get(axdata,'Ylim'); 0497 set(axdata,'GridLineStyle',':') 0498 set(axdata,'Xgrid','off') 0499 set(axdata,'Ygrid','on') 0500 axes(axdata) 0501 axcolor = get(gcf,'Color'); 0502 set(axdata,'Color',BACKCOLOR); 0503 pl=plot(x,data(plotchans,:)); % plot the data 0504 if length(plotchans)==1 0505 set(pl,'color','k'); 0506 set(pl,'linewidth',2); 0507 end 0508 xl= xlabel('Latency (ms)'); 0509 set(xl,'FontSize',axfont); 0510 %yl=ylabel('Potential (\muV)'); %??DG 0511 yl=ylabel(ylab); 0512 set(yl,'FontSize',axfont,'FontAngle','normal'); 0513 axis([xmin xmax ymin ymax]); 0514 hold on 0515 0516 % 0517 %%%%%%%%%%%%%%%%%%%%%%%%% Plot zero time line %%%%%%%%%%%%%%%%%%%%%%%%%% 0518 % 0519 0520 if xmin<0 & xmax>0 0521 plot([0 0],[ymin ymax],'k:','linewidth',1.5); 0522 else 0523 fprintf('xmin %g and xmax %g do not cross time 0.\n',xmin,xmax) 0524 end 0525 % 0526 %%%%%%%%%%%%%%%%%%%%%%%%% Draw vertical lines %%%%%%%%%%%%%%%%%%%%%%%%%% 0527 % 0528 width = xmax-xmin; 0529 height = ymax-ymin; 0530 %lwidth = 1.5; % increment line thickness 0531 lwidth = 2; %dg?? 0532 0533 for t=1:ntopos % dfraw vertical lines through the data at topoplot frames 0534 if length(plotchans)>1 | voffsets(t) 0535 % l1 = plot([plottimes(t) plottimes(t)],... 0536 % [min(data(plotchans,plotframes(t))) ... 0537 % voffsets(t) + max(data(plotchans,plotframes(t)))],'w'); % white underline behind 0538 % set(l1,'linewidth',2); 0539 % l1 = plot([plottimes(t) plottimes(t)],... 0540 % [min(data(plotchans,plotframes(t))) ... 0541 % voffsets(t) + max(data(plotchans,plotframes(t)))],'b'); % blue line 0542 % set(l1,'linewidth',lwidth); 0543 v=axis; %DG?? begin 0544 l1 = plot([plottimes(t) plottimes(t)],... 0545 v(3:4),'k'); % black line 0546 set(l1,'linewidth',lwidth); 0547 end 0548 end 0549 % 0550 %%%%%%%%%%%%%%%%%%%%%%%%% Draw oblique lines %%%%%%%%%%%%%%%%%%%%%%%%%% 0551 % 0552 0553 axall = axes('Position',pos,... 0554 'Visible','Off','FontSize',axfont); % whole-gca invisible axes 0555 axes(axall) 0556 set(axall,'Color',BACKCOLOR); 0557 axis([0 1 0 1]) 0558 axes(axall) 0559 axis([0 1 0 1]); 0560 set(gca,'Visible','off'); % make whole-figure axes invisible 0561 0562 if 0, %DG?? ignore this option for the time being. In the future, note that l1 handle is re-used 0563 %and over-writes l1 handle from verticle lines (the code right about 0564 %this) 0565 0566 0567 for t=1:ntopos % draw oblique lines through to the topoplots 0568 maxdata = max(data(:,plotframes(t))); % max data value at plotframe 0569 axtp = axes('Units','Normalized','Position',... 0570 [pos(1)+topoleft+(t-1)*(1+head_sep)*topowidth ... 0571 pos(2)+0.66*pos(4) ... 0572 topowidth ... 0573 topowidth*(1+head_sep)]); % this will be the topoplot axes 0574 % topowidth]); % this will be the topoplot axes 0575 axis([-1 1 -1 1]); 0576 0577 from = changeunits([plottimes(t),maxdata],axdata,axall); % data axes 0578 to = changeunits([0,-0.74],axtp,axall); % topoplot axes 0579 delete(axtp); 0580 axes(axall); % whole figure axes 0581 l1 = plot([from(1) to(1)],[from(2) to(2)]); 0582 set(l1,'linewidth',lwidth); 0583 0584 hold on 0585 set(axall,'Visible','off'); 0586 axis([0 1 0 1]); 0587 end 0588 0589 end 0590 % 0591 %%%%%%%%%%%%%%%%%%%%%%%%% Plot the topoplots %%%%%%%%%%%%%%%%%%%%%%%%%% 0592 % 0593 0594 topoaxes = zeros(1,ntopos); 0595 for t=1:ntopos 0596 % [pos(3)*topoleft+pos(1)+(t-1)*(1+head_sep)*topowidth ... 0597 axtp = axes('Units','Normalized','Position',... 0598 [topoleft+pos(1)+(t-1)*(1+head_sep)*topowidth ... 0599 pos(2)+0.66*pos(4) ... 0600 topowidth topowidth*(1+head_sep)]); 0601 axes(axtp) % topoplot axes 0602 topoaxes(t) = axtp; % save axes handles 0603 cla 0604 0605 if ~isempty(varargin) 0606 topoargs = varargin; 0607 else 0608 topoargs = {}; 0609 end 0610 if topowidth<0.12 0611 topoargs = { topoargs{:} 'electrodes' 'off' }; 0612 end 0613 %scan to see if cbar scale has been specified, ??DG 0614 cbar_limits=0; 0615 n_args=length(topoargs); 0616 for argloop=1:n_args, 0617 if strcmpi('maplimits',topoargs{argloop}), 0618 cbar_limits=1; 0619 break; 0620 end 0621 end 0622 %if not use +/-abs(max(corr)) 0623 if ~cbar_limits, 0624 abs_mx=max(max(abs(data))); 0625 topoargs{n_args+1}='maplimits'; 0626 topoargs{n_args+2}=[-1 1]*abs_mx; 0627 end 0628 h=topoplotMK( data(:,plotframes(t)),chan_locs, topoargs{:}); 0629 0630 timetext = [num2str(plottimes(t),'%4.0f')]; 0631 % timetext = [num2str(plottimes(t),'%4.0f') ' ms']; % add ' ms' 0632 text(0.00,0.80,timetext,'FontSize',axfont,'HorizontalAlignment','Center'); % ,'fontweight','bold'); 0633 end 0634 0635 % 0636 %%%%%%%%%%%%%%%%%%% Plot a topoplot colorbar %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0637 % 0638 axcb = axes('Position',[pos(1)+pos(3)*0.995 pos(2)+0.62*pos(4) pos(3)*0.02 pos(4)*0.09]); 0639 h=cbar(axcb); % colorbar axes 0640 pos_cb = get(axcb,'Position'); 0641 0642 if ~cbar_limits, 0643 %plot cbar ticks & labels 0644 set(gca,'fontsize',round(axfont*.8),'fontweight','bold'); 0645 cbarV=axis; 0646 set(h,'Ytick',cbarV(3:4),'yticklabel',{num2str(-abs_mx,'%.2f'),[' ' num2str(abs_mx,'%.2f')]}); 0647 else 0648 set(h,'Ytick',[]); 0649 end 0650 0651 axes(axall) 0652 set(axall,'Color',axcolor); 0653 0654 if cbar_limits, 0655 text(0.986,0.695,'+','FontSize',axfont,'HorizontalAlignment','Center'); 0656 text(0.986,0.625,'-','FontSize',axfont,'HorizontalAlignment','Center'); 0657 end 0658 0659 % 0660 %%%%%%%%%%%%%%%%%%%%%%%%% Plot the plot title if any %%%%%%%%%%%%%%%%%%%%%%%%%% 0661 % 0662 % plot title between data panel and topoplots (to avoid crowding at top of figure), on the left 0663 ttl = text(0.03,0.635,titl,'FontSize',titlefont,'HorizontalAlignment','left'); % 'FontWeight','Bold'); 0664 0665 % textent = get(ttl,'extent'); 0666 % titlwidth = textent(3); 0667 % ttlpos = get(ttl,'position'); 0668 % set(ttl,'position',[ ttlpos(2), ttlpos(3)]); 0669 0670 axes(axall) 0671 set(axall,'layer','top'); % bring component lines to top 0672 for t = 1:ntopos 0673 set(topoaxes(t),'layer','top'); % bring topoplots to very top 0674 end 0675 0676 if ~isempty(varargin) 0677 try, 0678 if ~isempty( strmatch( 'absmax', varargin)) 0679 text(0.86,0.624,'0','FontSize',axfont,'HorizontalAlignment','Center'); 0680 end; 0681 catch, end; 0682 end 0683 0684 % 0685 % Turn on axcopy() 0686 % 0687 0688 % clicking on ERP pop_up topoplot 0689 % ------------------------------- 0690 disp('Click on ERP waveform to show scalp map at specific latency'); 0691 0692 dat.times = x; 0693 dat.erp = data; 0694 dat.chanlocs = chan_locs; 0695 dat.options = topoargs; 0696 dat.srate = (size(data,2)-1)/(x(end)-x(1))*1000; 0697 dat.axes = axtp; 0698 dat.line = l1; 0699 0700 cb_code = [ 'tmppos = get(gca, ''currentpoint'');' ... 0701 'fntsize = get(gca,''fontsize'');' ... 0702 'dattmp = get(gcf, ''userdata'');' ... 0703 'set(dattmp.line, ''visible'', ''off'');' ... 0704 'delete(dattmp.line),' ... 0705 'lm=axis; dattmp.line=plot([1 1]*tmppos(1,1),lm(3:4),''k'');' ... 0706 'set(dattmp.line,''linewidth'',2);' ... 0707 'set(gcf,''userdata'',dattmp);' ... 0708 'axes(dattmp.axes); cla;' ... 0709 'latpoint = round((tmppos(1)-dattmp.times(1))/1000*dattmp.srate);' ... 0710 'topoplotMK(dattmp.erp(:,latpoint), dattmp.chanlocs,dattmp.options{:});' ... 0711 'title(sprintf(''%.0f ms'', tmppos(1)),''fontsize'',fntsize);' ... 0712 'clear latpoint dattmp;' ... 0713 ]; 0714 %axcopy; 0715 0716 set(gcf, 'userdata', dat); 0717 set(axdata, 'ButtonDownFcn', cb_code); %windowbuttondownfcn', cb_code); 0718 set(pl, 'ButtonDownFcn', cb_code); 0719 0720 %axcopy(gcf, cb_code); 0721 0722 % 'title(sprintf(''%.0f ms'', tmppos(1)));' ...