timtopo.m
来自「含有多种ICA算法的eeglab工具箱」· M 代码 · 共 602 行 · 第 1/2 页
M
602 行
% defaults: limits == 0 or [0 0 0 0] if ( length(limits) == 1 & limits==0) | (length(limits)==4 & ~any(limits)) xmin=0; xmax=frames-1; ymin=min(min(data)); ymax=max(max(data)); elseif length(limits) == 2 % [minms maxms] only ymin=min(min(data)); ymax=max(max(data)); elseif length(limits) == 4 xmin = limits(1); xmax = limits(2); if any(limits([3 4])) ymin = limits(3); ymax = limits(4); else % both 0 ymin=min(min(data)); ymax=max(max(data)); end else fprintf('timtopo(): limits format not correct. See >> help timtopo.\n'); return end; if xmax == 0 & xmin == 0, x = (0:1:frames-1); xmin = 0; xmax = frames-1; else dx = (xmax-xmin)/(frames-1); x=xmin*ones(1,frames)+dx*(0:frames-1); % compute x-values end; if xmax<=xmin, fprintf('timtopo() - in limits, maxms must be > minms.\n') return end if ymax == 0 & ymin == 0, ymax=max(max(data)); ymin=min(min(data)); end if ymax<=ymin, fprintf('timtopo() - in limits, maxval must be > minmval.\n') return endsampint = (xmax-xmin)/(frames-1); % sampling interval = 1000/srate;x = xmin:sampint:xmax; % make vector of x-values%%%%%%%%%%%%%%%% Compute plotframes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%if plottimes_set == 0 [mx plotframes] = max(sum(data.*data)); % default plotting frame has max variance if nargin< 4 | isempty(plottimes) plottimes = x(plotframes); else plottimes(find(isnan(plottimes))) = x(plotframes); end; plottimes_set = 1;end;if plottimes_set == 1 plottimes = sort(plottimes); ntopos = length(plottimes); if ntopos > 32 fprintf('timtopo(): too many plottimes!\n'); return end if max(plottimes) > xmax | min(plottimes)< xmin fprintf('timtopo(): plottimes latencies out of range - cannot plot.\n'); return end plottimes = sort(plottimes); % put map latencies in ascending order, else map lines would cross. xshift = [x(2:frames) xmax]; plotframes = ones(size(plottimes)); for t = 1:ntopos time = plottimes(t); plotframes(t) = find(time>=x & time < xshift); endendvlen = length(voffsets); % extend voffsets if necessaryi=1;while vlen< ntopos voffsets = [voffsets voffsets(i)]; i=i+1; vlen=vlen+1;endpos = get(gca,'Position');axis('off')cla % clear the current axesif pos(4)>0.70 titlefont= 16; axfont = 16;elseif pos(4)>0.40 titlefont= 14; axfont = 14;elseif pos(4)>0.30 titlefont= 12; axfont = 12;elseif pos(4)>0.22 titlefont= 10; axfont = 10;else titlefont= 8; axfont = 8;endhead_sep = 0.2;topowidth = pos(3)/(ntopos+(ntopos-1)/5); % width of each topoplotif topowidth> 0.25*pos(4) % dont make too high topowidth = 0.25*pos(4);endhalfn = floor(ntopos/2);if rem(ntopos,2) == 1 % odd number of topos topoleft = pos(3)/2 - (ntopos/2+halfn*head_sep)*topowidth;else % even number of topos topoleft = pos(3)/2 - ((halfn)+(halfn-1)*head_sep)*topowidth;endif max(plotframes) > frames | min(plotframes) < 1 fprintf('Requested map frame %d is outside data range (1-%d)\n',max(plotframes),frames); returnend%%%%%%%%%%%%%%%%%%%%% Print times and frames %%%%%%%%%%%%%%%%%%%%%%%%%%%fprintf('Scalp maps will show latencies: ');for t=1:ntopos fprintf('%4.0f ',plottimes(t));endfprintf('\n');fprintf(' at frames: ');for t=1:ntopos fprintf('%4d ',plotframes(t));endfprintf('\n');%%%%%%%%%%%%%%%%%%%%%%%% Plot the data %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% site the plot at bottom of the figureaxdata = axes('Units','Normalized','Position',[pos(1) pos(2) pos(3) 0.6*pos(4)],'FontSize',axfont);set(axdata,'Color',BACKCOLOR);limits = get(axdata,'Ylim');set(axdata,'GridLineStyle',':')set(axdata,'Xgrid','off')set(axdata,'Ygrid','on')axes(axdata)axcolor = get(gcf,'Color');set(axdata,'Color',BACKCOLOR);pl=plot(x,data(plotchans,:)); % plot the dataif length(plotchans)==1 set(pl,'color','k'); set(pl,'linewidth',2);endl= xlabel('Latency (ms)');set(l,'FontSize',axfont);l=ylabel('Potential (uV)');set(l,'FontSize',axfont);axis([xmin xmax ymin ymax]);hold on%%%%%%%%%%%%%%%%%%%%%%%%%% Plot zero time line %%%%%%%%%%%%%%%%%%%%%%%%%%%if xmin<0 & xmax>0 plot([0 0],[ymin ymax],'k:','linewidth',1.5);else fprintf('xmin %g and xmax %g do not cross time 0.\n',xmin,xmax)end%%%%%%%%%%%%%%%%%%%%%%%%%% Draw vertical lines %%%%%%%%%%%%%%%%%%%%%%%%%%%width = xmax-xmin;height = ymax-ymin;linc = 0.5; % increment line thicknessfor t=1:ntopos % dfraw vertical lines through the data at topoplot frames if length(plotchans)>1 | voffsets(t) l1 = plot([plottimes(t) plottimes(t)],... [min(data(plotchans,plotframes(t))) ... voffsets(t) + max(data(plotchans,plotframes(t)))],'w'); % white underline behind set(l1,'linewidth',2); l1 = plot([plottimes(t) plottimes(t)],... [min(data(plotchans,plotframes(t))) ... voffsets(t) + max(data(plotchans,plotframes(t)))],'b'); % blue line set(l1,'linewidth',1+linc); endend%%%%%%%%%%%%%%%%%%%%%%%%%% Draw oblique lines %%%%%%%%%%%%%%%%%%%%%%%%%%%axall = axes('Position',pos,... 'Visible','Off','FontSize',axfont); % whole-gca invisible axesaxes(axall)set(axall,'Color',BACKCOLOR);axis([0 1 0 1]) axes(axall) axis([0 1 0 1]); set(gca,'Visible','off');for t=1:ntopos % draw oblique lines through to the topoplots maxdata = max(data(:,plotframes(t))); % max data value at plotframe axtp = axes('Units','Normalized','Position',... [topoleft+pos(1)+(t-1)*(1+head_sep)*topowidth ... pos(2)+0.66*pos(4) ... topowidth ... topowidth*(1+head_sep)]); % this will be the topoplot axes axis([-1 1 -1 1]); from = changeunits([plottimes(t),maxdata],axdata,axall); to = changeunits([0,-0.89],axtp,axall); delete(axtp); axes(axall); l1 = plot([from(1) to(1)],[from(2) to(2)]); set(l1,'linewidth',1+linc); hold on set(axall,'Visible','off'); axis([0 1 0 1]);end%%%%%%%%%%%%%%%%%%%%%%%%%% Plot the topoplots %%%%%%%%%%%%%%%%%%%%%%%%%%%for t=1:ntopos % [pos(3)*topoleft+pos(1)+(t-1)*(1+head_sep)*topowidth ... axtp = axes('Units','Normalized','Position',... [topoleft+pos(1)+(t-1)*(1+head_sep)*topowidth ... pos(2)+0.66*pos(4) ... topowidth ... topowidth*(1+head_sep)]); axes(axtp) % topoplot axes cla if ~isempty(varargin) topoargs = varargin{:}; else topoargs = []; end if topowidth<0.12 if ~isempty(topoargs) % topoargs = [',''emarkersize'',4,' topoargs]; topoargs = [',''electrodes'', ''off'', ' topoargs]; else % topoargs = [',''emarkersize'',4']; topoargs = [',''electrodes'', ''off''']; end end topostring = [ 'topoplot(data(:,plotframes(t)),chan_locs' topoargs ');']; % plot the scalp map eval(topostring); % % Else make a 3-D headplot % % headplot(data(:,plotframes(t)),'chan.spline'); timetext = [num2str(plottimes(t),'%4.0f') ' ms']; text(0.00,0.60,timetext,'FontSize',axfont-2,'HorizontalAlignment','Center'); % ,'fontweight','bold');end%%%%%%%%%%%%%%%%%%%%%%%%%%%% Plot a colorbar %%%%%%%%%%%%%%%%%%%%%%%%%%%axcb = axes('Position',[pos(1)+pos(3)*0.985 pos(2)+0.62*pos(4) pos(3)*0.02 pos(4)*0.09]);h=cbar(axcb); % colorbar axespos_cb = get(axcb,'Position');set(h,'Ytick',[]);axes(axall)set(axall,'Color',axcolor);text(0.16,0.635,titl,'FontSize',titlefont,'HorizontalAlignment','Center'); % 'FontWeight','Bold');text(0.966,0.695,'+','FontSize',axfont,'HorizontalAlignment','Center');text(0.966,0.625,'-','FontSize',axfont,'HorizontalAlignment','Center');axes(axall)set(axall,'layer','top'); % bring component lines to top if ~isempty(varargin) try, if ~isempty( strmatch( 'absmax', varargin)) text(0.86,0.624,'0','FontSize',axfont,'HorizontalAlignment','Center'); end; catch, end; end%% Turn on axcopy()%axcopy(gcf);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?