eegplotold.m
来自「含有多种ICA算法的eeglab工具箱」· M 代码 · 共 1,005 行 · 第 1/3 页
M
1,005 行
'clear FIGH AXESH;']; uimenu('Parent',m(4),'Label','off','Callback',timestring) % Grid Style %%%%%%%%% m(5) = uimenu('Parent',m(1),'Label','Grid Style'); timestring = ['FIGH = gcbf;',... 'AXESH = findobj(''tag'',''eegaxis'',''parent'',FIGH);',... 'set(AXESH,''gridlinestyle'',''--'');',... 'clear FIGH AXESH;']; uimenu('Parent',m(5),'Label','- -','Callback',timestring) timestring = ['FIGH = gcbf;',... 'AXESH = findobj(''tag'',''eegaxis'',''parent'',FIGH);',... 'set(AXESH,''gridlinestyle'',''-.'');',... 'clear FIGH AXESH;']; uimenu('Parent',m(5),'Label','_ .','Callback',timestring) timestring = ['FIGH = gcbf;',... 'AXESH = findobj(''tag'',''eegaxis'',''parent'',FIGH);',... 'set(AXESH,''gridlinestyle'','':'');',... 'clear FIGH AXESH;']; uimenu('Parent',m(5),'Label','. .','Callback',timestring) timestring = ['FIGH = gcbf;',... 'AXESH = findobj(''tag'',''eegaxis'',''parent'',FIGH);',... 'set(AXESH,''gridlinestyle'',''-'');',... 'clear FIGH AXESH;']; uimenu('Parent',m(5),'Label','__','Callback',timestring) % Scale Eye %%%%%%%%% timestring = ['[OBJ1,FIG1] = gcbo;',... 'eegplotold(''scaleeye'',OBJ1,FIG1);',... 'clear OBJ1 FIG1;']; m(7) = uimenu('Parent',m(1),'Label','Scale I','Callback',timestring); % Title %%%%%%%%%%%% uimenu('Parent',m(1),'Label','Title','Callback','eegplotold(''title'')') % Settings Menu %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% m(2) = uimenu('Parent',figh,... 'Label','Settings'); % Window %%%%%%%%%%%% uimenu('Parent',m(2),'Label','Window',... 'Callback','eegplotold(''window'')') % Samplerate %%%%%%%% uimenu('Parent',m(2),'Label','Samplerate',... 'Callback','eegplotold(''samplerate'')') % Electrodes %%%%%%%% m(6) = uimenu('Parent',m(2),'Label','Electrodes'); timestring = ['FIGH = gcbf;',... 'AXESH = findobj(''tag'',''eegaxis'',''parent'',FIGH);',... 'set(AXESH,''YTickLabel'',[]);',... 'clear FIGH AXESH;']; uimenu('Parent',m(6),'Label','none','Callback',timestring) timestring = ['FIGH = gcbf;',... 'AXESH = findobj(''tag'',''eegaxis'',''parent'',FIGH);',... 'YTICK = get(AXESH,''YTick'');',... 'YTICK = length(YTICK);',... 'set(AXESH,''YTickLabel'',flipud(str2mat(num2str((1:YTICK-1)''),'' '')));',... 'clear FIGH AXESH YTICK;']; uimenu('Parent',m(6),'Label','numbered','Callback',timestring) uimenu('Parent',m(6),'Label','load file',... 'Callback','eegplotold(''loadelect'');') % %%%%%%%%%%%%%%%%%%%%%%%%%% % Plot EEG Data % %%%%%%%%%%%%%%%%%%%%%%%%%% meandata = mean(data(:,1:round(min(frames,winlength*Fs)))'); axes(ax1) hold on for i = 1:chans plot(data(chans-i+1,... 1:round(min(frames,winlength*Fs)))-meandata(chans-i+1)+i*spacing,... 'color',DEFAULT_PLOT_COLOR) end % %%%%%%%%%%%%%%%%%%%%%%%%%% % Plot Spacing I % %%%%%%%%%%%%%%%%%%%%%%%%%% if strcmp(SPACING_EYE,'on') YLim = get(ax1,'Ylim'); A = DEFAULT_AXES_POSITION; axes('Position',[A(1)+A(3) A(2) 1-A(1)-A(3) A(4)],... 'Visible','off','Ylim',YLim,'tag','eyeaxes') axis manual Xl = [.3 .6 .45 .45 .3 .6]; Yl = [spacing*2 spacing*2 spacing*2 spacing*1 spacing*1 spacing*1]; line(Xl,Yl,'color',DEFAULT_AXIS_COLOR,'clipping','off',... 'tag','eyeline') text(.5,YLim(2)/23+Yl(1),num2str(spacing,4),... 'HorizontalAlignment','center','FontSize',10,... 'tag','thescale') if strcmp(YAXIS_NEG,'off') text(Xl(2)+.1,Yl(1),'+','HorizontalAlignment','left',... 'verticalalignment','middle') text(Xl(2)+.1,Yl(4),'-','HorizontalAlignment','left',... 'verticalalignment','middle') else text(Xl(2)+.1,Yl(4),'+','HorizontalAlignment','left',... 'verticalalignment','middle') text(Xl(2)+.1,Yl(1),'-','HorizontalAlignment','left',... 'verticalalignment','middle') end if ~isempty(SPACING_UNITS_STRING) text(.5,-YLim(2)/23+Yl(4),SPACING_UNITS_STRING,... 'HorizontalAlignment','center','FontSize',10) end set(m(7),'checked','on') elseif strcmp(SPACING_EYE,'off') YLim = get(ax1,'Ylim'); A = DEFAULT_AXES_POSITION; axes('Position',[A(1)+A(3) A(2) 1-A(1)-A(3) A(4)],... 'Visible','off','Ylim',YLim,'tag','eyeaxes') axis manual set(m(7),'checked','off') end % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% End Main Function% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%else switch data case 'drawp' % Redraw EEG and change position figh = gcbf; % figure handle if strcmp(get(figh,'tag'),'dialog') figh = get(figh,'UserData'); end ax1 = findobj('tag','eegaxis','parent',figh); % axes handle EPosition = findobj('tag','EPosition','parent',figh); % ui handle ESpacing = findobj('tag','ESpacing','parent',figh); % ui handle data = get(ax1,'UserData'); % Data (Note: this could also be global) timestr = get(EPosition,'string'); % current position % if timestr == 'end' % time = ceil(frames/Fs)-winlength; % fprintf('timestr = %s\n',timestr); % else time = str2num(timestr); % current position % end spacing = str2num(get(ESpacing,'string')); % current spacing winlength = get(figh,'UserData'); Fs = winlength(2); % samplerate winlength = winlength(1); % window length [chans,frames] = size(data); if p1 == 1 time = time-winlength; % << subtract one window length elseif p1 == 2 time = time-1; % < subtract one second elseif p1 == 3 time = time+1; % > add one second elseif p1 == 4 time = time+winlength; % >> add one window length end time = max(0,min(time,ceil(frames/Fs)-winlength)); set(EPosition,'string',num2str(time)) % Update edit box % keyboard % Plot data and update axes meandata = mean(data(:,round(time*Fs+1):round(min((time+winlength)*Fs,... frames)))'); axes(ax1) cla for i = 1:chans plot(data(chans-i+1,round(time*Fs+1):round(min((time+winlength)*Fs,... frames)))-meandata(chans-i+1)+i*spacing,... 'color',DEFAULT_PLOT_COLOR,'clipping','off') end set(ax1,'XTickLabel',... num2str((time:DEFAULT_GRID_SPACING:time+winlength)'),... 'Xlim',[0 winlength*Fs],... 'XTick',[0:Fs*DEFAULT_GRID_SPACING:winlength*Fs]) case 'draws' % Redraw EEG and change scale figh = gcbf; % figure handle ax1 = findobj('tag','eegaxis','parent',figh); % axes handle EPosition = findobj('tag','EPosition','parent',figh); % ui handle ESpacing = findobj('tag','ESpacing','parent',figh); % ui handle data = get(ax1,'UserData'); % data time = str2num(get(EPosition,'string')); % current position spacing = str2num(get(ESpacing,'string')); % current spacing winlength = get(figh,'UserData'); if isempty(spacing) | isempty(time) return % return if valid numbers are not in the edit boxes end Fs = winlength(2); % samplerate winlength = winlength(1); % window length orgspacing = round(max(max(data')-min(data'))); % original spacing [chans,frames] = size(data); if p1 == 1 spacing = spacing + .05*orgspacing; % increase spacing (5%) elseif p1 == 2 spacing = max(0,spacing-.05*orgspacing); % decrease spacing (5%) if spacing == 0 spacing = spacing + .05*orgspacing; end end set(ESpacing,'string',num2str(spacing,4)) % update edit box % plot data and update axes meandata = mean(data(:,round(time*Fs+1):round(min((time+winlength)*Fs,... frames)))'); axes(ax1) cla for i = 1:chans plot(data(chans-i+1,... round(time*Fs+1):round(min((time+winlength)*Fs,... frames)))-meandata(chans-i+1)+i*spacing,... 'color',DEFAULT_PLOT_COLOR,'clipping','off') end set(ax1,'YLim',[0 (chans+1)*spacing],... 'YTick',[0:spacing:chans*spacing]) % update scaling eye if it exists eyeaxes = findobj('tag','eyeaxes','parent',figh); if ~isempty(eyeaxes) eyetext = findobj('type','text','parent',eyeaxes,'tag','thescale'); set(eyetext,'string',num2str(spacing,4)) end case 'window' % get new window length with dialog box fig = gcbf; oldwinlen = get(fig,'UserData'); pos = get(fig,'Position'); figx = 400; figy = 200; fhand = figure('Units','pixels',... 'Position',... [pos(1)+pos(3)/2-figx/2 pos(2)+pos(4)/2-figy/2 figx figy],... 'Resize','off','CloseRequestFcn','','menubar','none',... 'numbertitle','off','tag','dialog','userdata',fig); uicolor = get(fhand,'Color'); uicontrol('Style','Text','Units','Pixels',... 'String','Enter new window length(secs):',... 'Position',[20 figy-40 300 25],'HorizontalAlignment','left',... 'BackgroundColor',uicolor,'FontSize',14) timestring = ['[OBJ1,FIGH1] = gcbo;',... 'FIH0 = get(OBJ1,''UserData'');',... 'AXH0 = findobj(''tag'',''eegaxis'',''parent'',FIH0);',... 'WLEN = str2num(get(OBJ1,''String''));',... 'if ~isempty(WLEN);',... 'UDATA = get(FIH0,''UserData'');',... 'UDATA(1) = WLEN;',... 'set(FIH0,''UserData'',UDATA);',... 'eegplotold(''drawp'',0);',... 'delete(FIGH1);',... 'end;',... 'clear OBJ1 FIGH1 FIH0 AXH0 WLEN UDATA;']; ui1 = uicontrol('Style','Edit','Units','Pixels',... 'FontSize',12,... 'Position',[120 figy-100 70 30],... 'Callback',timestring,'UserData',fig,... 'String',num2str(oldwinlen(1))); timestring = ['[OBJ1,FIGH1] = gcbo;',... 'FIH0 = get(OBJ1,''UserData'');',... 'AXH0 = findobj(''tag'',''eegaxis'',''parent'',FIH0(1));',... 'SRAT = str2num(get(FIH0(2),''String''));',... 'if ~isempty(SRAT);',... 'UDATA = get(FIH0(1),''UserData'');',... 'UDATA(2) = SRAT;',... 'set(FIH0(1),''UserData'',UDATA);',... 'eegplotold(''drawp'',0);',... 'delete(FIGH1);',... 'end;',... 'clear OBJ1 FIGH1 FIH0 AXH0 SRAT UDATA;']; uicontrol('Style','PushButton','Units','Pixels',... 'String','OK','FontSize',14,... 'Position',[figx/4-20 10 65 30],... 'Callback',timestring,'UserData',[fig,ui1]) TIMESTRING = ['[OBJ1,FIGH1] = gcbo;',... 'delete(FIGH1);',... 'clear OBJ1 FIGH1;']; uicontrol('Style','PushButton','Units','Pixels',... 'String','Cancel','FontSize',14,... 'Position',[3*figx/4-20 10 65 30],... 'Callback',TIMESTRING) case 'samplerate' % Get new samplerate fig = gcbf; oldsrate = get(fig,'UserData'); pos = get(fig,'Position'); figx = 400; figy = 200; fhand = figure('Units','pixels',... 'Position',... [pos(1)+pos(3)/2-figx/2 pos(2)+pos(4)/2-figy/2 figx figy],... 'Resize','off','CloseRequestFcn','','menubar','none',... 'numbertitle','off','tag','dialog','userdata',fig); uicolor = get(fhand,'Color'); uicontrol('Style','Text','Units','Pixels',... 'String','Enter new samplerate:',... 'Position',[20 figy-40 300 25],'HorizontalAlignment','left',... 'BackgroundColor',uicolor,'FontSize',14) timestring = ['[OBJ1,FIGH1] = gcbo;',... 'FIH0 = get(OBJ1,''UserData'');',... 'AXH0 = findobj(''tag'',''eegaxis'',''parent'',FIH0);',... 'SRAT = str2num(get(OBJ1,''String''));',... 'if ~isempty(SRAT);',... 'UDATA = get(FIH0,''UserData'');',... 'UDATA(2) = SRAT;',... 'set(FIH0,''UserData'',UDATA);',... 'eegplotold(''drawp'',0);',... 'delete(FIGH1);',... 'end;',... 'clear OBJ1 FIGH1 FIH0 AXH0 SRAT UDATA;']; ui1 = uicontrol('Style','Edit','Units','Pixels',... 'FontSize',12,...
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?