⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eegplot.m

📁 含有多种ICA算法的eeglab工具箱
💻 M
📖 第 1 页 / 共 5 页
字号:
  timestring = ['FIGH = gcbf;',...	            'AXESH = findobj(''tag'',''eegaxis'',''parent'',FIGH);',...	            'if size(get(AXESH,''xgrid''),2) == 2' ... %on		        '  set(AXESH,''xgrid'',''off'');',...		        '  set(gcbo,''label'',''X grid on'');',...		        'else' ...		        '  set(AXESH,''xgrid'',''on'');',...		        '  set(gcbo,''label'',''X grid off'');',...		        'end;' ...		        'clear FIGH AXESH;' ];  uimenu('Parent',m(3),'Label',fastif(strcmp(g.xgrid, 'off'), 'X grid on','X grid off'), 'Callback',timestring)    % Y grid %%%%%%%%%%%%%  timestring = ['FIGH = gcbf;',...	            'AXESH = findobj(''tag'',''eegaxis'',''parent'',FIGH);',...	            'if size(get(AXESH,''ygrid''),2) == 2' ... %on		        '  set(AXESH,''ygrid'',''off'');',...		        '  set(gcbo,''label'',''Y grid on'');',...		        'else' ...		        '  set(AXESH,''ygrid'',''on'');',...		        '  set(gcbo,''label'',''Y grid off'');',...		        'end;' ...		        'clear FIGH AXESH;' ];  uimenu('Parent',m(3),'Label',fastif(strcmp(g.ygrid, 'off'), 'Y grid on','Y grid off'), 'Callback',timestring)  % Grid Style %%%%%%%%%  m(5) = uimenu('Parent',m(3),'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;',...	        'eegplot(''scaleeye'',OBJ1,FIG1);',...		'clear OBJ1 FIG1;'];  m(7) = uimenu('Parent',m(1),'Label','Show scale','Callback',timestring);    % Title %%%%%%%%%%%%  uimenu('Parent',m(1),'Label','Title','Callback','eegplot(''title'')')    % Settings Menu %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  m(2) = uimenu('Parent',figh,...      'Label','Settings');     % Window %%%%%%%%%%%%  uimenu('Parent',m(2),'Label','Time range to display',...      'Callback','eegplot(''window'')')    % Electrode window %%%%%%%%  uimenu('Parent',m(2),'Label','Number of channels to display',...      'Callback','eegplot(''winelec'')')    % Electrodes %%%%%%%%  m(6) = uimenu('Parent',m(2),'Label','Channel labels');    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','Show number','Callback',timestring)  uimenu('Parent',m(6),'Label','Load .loc(s) file',...      'Callback','eegplot(''loadelect'');')    % Zooms %%%%%%%%  zm = uimenu('Parent',m(2),'Label','Zoom off/on');  commandzoom = [ 'tmpstr = get(gcbf, ''windowbuttondownfcn'');' ...                  'set(gcbf, ''windowbuttondownfcn'', [ tmpstr ''; eegplot(''''zoom'''', gcbf, 1);'' ]);' ...                  'tmpg = get(gcbf, ''userdata'');' ...                  'set(gcbf, ''windowbuttonmotionfcn'', tmpg.commandselect{2}); clear tmpg tmpstr;'];      %uimenu('Parent',zm,'Label','Zoom time', 'callback', ...  %             [ 'zoom(gcbf, ''xon'');' commandzoom ]);  %uimenu('Parent',zm,'Label','Zoom channels', 'callback', ...  %             [ 'zoom(gcbf, ''yon'');' commandzoom ]);  uimenu('Parent',zm,'Label','Zoom on', 'callback', ...               [ 'zoom(gcbf, ''on'');' commandzoom ]);  uimenu('Parent',zm,'Label','Zoom off', 'separator', 'on', 'callback', ...     ['zoom(gcbf, ''off''); tmpg = get(gcbf, ''userdata'');' ...     'set(gcbf, ''windowbuttondownfcn'', tmpg.commandselect{1});' ...     'set(gcbf, ''windowbuttonmotionfcn'', tmpg.commandselect{2});' ...     'set(gcbf, ''windowbuttonupfcn'', tmpg.commandselect{3});' ...     'clear tmpg;' ]);  uimenu('Parent',figh,'Label', 'Help', 'callback', 'pophelp(''eegplot'');');  % Events %%%%%%%%  zm = uimenu('Parent',m(2),'Label','Events');  complotevent = [ 'tmpg = get(gcbf, ''userdata'');' ...                  'tmpg.plotevent = ''on'';' ...                                    'set(gcbf, ''userdata'', tmpg); clear tmpg; eegplot(''drawp'', 0);'];  comnoevent   = [ 'tmpg = get(gcbf, ''userdata'');' ...                  'tmpg.plotevent = ''off'';' ...                                    'set(gcbf, ''userdata'', tmpg); clear tmpg; eegplot(''drawp'', 0);'];  comeventleg  = [ 'eegplot(''drawlegend'', gcbf);'];      uimenu('Parent',zm,'Label','Events on'    , 'callback', complotevent, 'enable', fastif(isempty(g.events), 'off', 'on'));  uimenu('Parent',zm,'Label','Events off'   , 'callback', comnoevent  , 'enable', fastif(isempty(g.events), 'off', 'on'));  uimenu('Parent',zm,'Label','Events'' legend', 'callback', comeventleg , 'enable', fastif(isempty(g.events), 'off', 'on'));    % %%%%%%%%%%%%%%%%%  % Set up autoselect  % %%%%%%%%%%%%%%%%%  % push button: create/remove window or select electrode  commandpush = ['ax1 = findobj(''tag'',''backeeg'',''parent'',gcbf);' ... 			 'tmppos = get(ax1, ''currentpoint'');' ...  			 'g = get(gcbf,''UserData'');' ... % get data of backgroung image {g.trialstag g.winrej incallback}             'if g.incallback ~= 1' ... % interception of nestest calls 			 '   if g.trialstag ~= -1,' ...			 '   	lowlim = round(g.time*g.trialstag+1);' ... 			 '   else,' ...			 '   	lowlim = round(g.time*g.srate+1);' ...  			 '   end;' ...			 '  if isempty(g.winrej) Allwin=0;' ...			 '  else Allwin = (g.winrej(:,1) < lowlim+tmppos(1)) & (g.winrej(:,2) > lowlim+tmppos(1));' ...			 '  end;' ...			 '  if any(Allwin)' ... % remove the mark or select electrode if necessary			 '    lowlim = find(Allwin==1);' ... 			 '    if g.setelectrode' ...  % select electrode   			 '      ax2 = findobj(''tag'',''eegaxis'',''parent'',gcbf);' ...			 '      tmppos = get(ax2, ''currentpoint'');' ...    		 '      tmpelec = g.chans + 1 - round(tmppos(1,2) / g.spacing);' ...    		 '      tmpelec = min(max(tmpelec, 1), g.chans);' ...			 '      g.winrej(lowlim,tmpelec+5) = ~g.winrej(lowlim,tmpelec+5);' ... % set the electrode			 '    else' ...  % remove mark			 ... % '      for tmpi = lowlim''' ...			 ... %'          tmpcolor = g.winrej(tmpi,3)+10*g.winrej(tmpi,4)+100*g.winrej(tmpi,5);' ...		     ... %'          if any(tmpcolor == g.colmodif);' ...			 ... %'              g.winrej(tmpi,:) = []; ' ...			 ... %'          end;' ...			 ... %'       end;' ... % THIS PART WAS TO DESELECT COLOR SELECTIVELLY              '       g.winrej(lowlim,:) = [];' ...             '    end;' ...			 '  else' ...			 '    if g.trialstag ~= -1' ... % find nearest trials boundaries if epoched data			 '      alltrialtag = [0:g.trialstag:g.frames];' ...			 '      I1 = find(alltrialtag < (tmppos(1)+lowlim) );' ... 			 '      if ~isempty(I1) & I1(end) ~= length(alltrialtag),' ...			 '            g.winrej = [g.winrej'' [alltrialtag(I1(end)) alltrialtag(I1(end)+1) g.wincolor zeros(1,g.chans)]'']'';' ...			 '      end;' ... 			 '    else,' ...			 '	    g.incallback = 1;' ...  % set this variable for callback for continuous data			 '      g.winrej = [g.winrej'' [tmppos(1)+lowlim tmppos(1)+lowlim g.wincolor zeros(1,g.chans)]'']'';' ...			 '    end;' ...			 '  end;' ...  			 '  set(gcbf,''UserData'', g);' ...			 '  eegplot(''drawp'', 0);' ...  % redraw background             'end;' ...             'clear g hhdat hh tmpelec tmppos ax2 ESpacing lowlim Allwin Fs winlength EPosition ax1 I1 tmpi' ];			 		  % motion button: move windows or display current position (channel, g.time and activation)  commandmove = ['ax1 = findobj(''tag'',''backeeg'',''parent'',gcbf);' ... 			 'tmppos = get(ax1, ''currentpoint'');' ... 			 'g = get(gcbf,''UserData'');' ...    		 'if isstruct(g)' ...      %check if we are dealing with the right window 			 '   if g.trialstag ~= -1,' ...			 '   	lowlim = round(g.time*g.trialstag+1);' ... 			 '   else,' ...			 '   	lowlim = round(g.time*g.srate+1);' ...  			 '   end;' ...			 '   if g.incallback' ...			 '      g.winrej = [g.winrej(1:end-1,:)'' [g.winrej(end,1) tmppos(1)+lowlim g.winrej(end,3:end)]'']'';' ... 			 '      set(gcbf,''UserData'', g);' ... 			 '      eegplot(''drawb'');' ... 			 '   else' ... 			 '     hh = findobj(''tag'',''Etime'',''parent'',gcbf);' ... 			 '     if g.trialstag ~= -1,' ... 			 '        set(hh, ''string'', num2str(mod(tmppos(1)+lowlim-1,g.trialstag)/g.trialstag*(g.limits(2)-g.limits(1)) + g.limits(1)));' ... 			 '     else,' ...  			 '     	  set(hh, ''string'', num2str((tmppos(1)+lowlim-1)/g.srate));' ... % put g.time in the box  			 '     end;' ...  			 '     ax1 = findobj(''tag'',''eegaxis'',''parent'',gcbf);' ... 			 '     tmppos = get(ax1, ''currentpoint'');' ...    		 '     tmpelec = round(tmppos(1,2) / g.spacing);' ...    		 '     tmpelec = min(max(double(tmpelec), 1),g.chans);' ...    		 '     labls = get(ax1, ''YtickLabel'');' ... 			 '     hh = findobj(''tag'',''Eelec'',''parent'',gcbf);' ...  % put electrode in the box 			 '     set(hh, ''string'', labls(tmpelec+1,:));' ... 			 '     hh = findobj(''tag'',''Evalue'',''parent'',gcbf);' ...             '     eegplotdata = get(ax1, ''userdata'');' ...  			 '     set(hh, ''string'', num2str(eegplotdata(g.chans+1-tmpelec, min(g.frames,max(1,double(round(tmppos(1)+lowlim)))))));' ...  % put value in the box    		 '  end;' ...			 'end;' ...			 'clear g labls eegplotdata tmpelec nbdat ESpacing tmppos ax1 hh lowlim Fs winlength;' ];  % release button: check window consistency, adpat to trial boundaries  commandrelease = ['ax1 = findobj(''tag'',''backeeg'',''parent'',gcbf);' ...  			 'g = get(gcbf,''UserData'');' ... 			 'g.incallback = 0;' ...			 'set(gcbf,''UserData'', g); ' ... % early save in case of bug in the following			 'if ~isempty(g.winrej)', ...			 '	if g.winrej(end,1) == g.winrej(end,2)' ... % remove unitary windows			 '		g.winrej = g.winrej(1:end-1,:);' ...			 '  else' ...             '    if g.winrej(end,1) > g.winrej(end,2)' ... % reverse values if necessary             '       g.winrej(end, 1:2) = [g.winrej(end,2) g.winrej(end,1)];' ...             '    end;' ...			 '    g.winrej(end,1) = max(1, g.winrej(end,1));' ...			 '    g.winrej(end,2) = min(g.frames, g.winrej(end,2));' ...             '    if g.trialstag == -1' ... % find nearest trials boundaries if necessary			 '      I1 = find((g.winrej(end,1) >= g.winrej(1:end-1,1)) & (g.winrej(end,1) <= g.winrej(1:end-1,2)) );' ... 			 '      if ~isempty(I1)' ...			 '		    g.winrej(I1,2) = max(g.winrej(I1,2), g.winrej(end,2));' ... % extend epoch			 '		    g.winrej = g.winrej(1:end-1,:);' ... % remove if empty match			 '      else,' ...			 '          I2 = find((g.winrej(end,2) >= g.winrej(1:end-1,1)) & (g.winrej(end,2) <= g.winrej(1:end-1,2)) );' ... 			 '          if ~isempty(I2)' ...			 '		        g.winrej(I2,1) = min(g.winrej(I2,1), g.winrej(end,1));' ... % extend epoch			 '		        g.winrej = g.winrej(1:end-1,:);' ... % remove if empty match			 '		    else,' ...			 '              I2 = find((g.winrej(end,1) <= g.winrej(1:end-1,1)) & (g.winrej(end,2) >= g.winrej(1:end-1,1)) );' ... 			 '              if ~isempty(I2)' ...			 '		            g.winrej(I2,:) = [];' ... % remove if empty match			 '              end;' ...			 '		    end;' ...			 '		end;' ...			 '    end;' ...			 '  end;' ...			 'end;' ...          'set(gcbf,''UserData'', g);' ...          'eegplot(''drawp'', 0);' ...          'clear alltrialtag g tmptmp ax1 I1 I2 trialtag hhdat hh;'];    set(figh, 'windowbuttondownfcn', commandpush);  set(figh, 'windowbuttonmotionfcn', commandmove);  set(figh, 'windowbuttonupfcn', commandrelease);  set(figh, 'interruptible', 'off');  set(figh, 'busyaction', 'cancel');    % prepare event array if any  % --------------------------  if ~isempty(g.events)      if ~isfield(g.events, 'type') | ~isfield(g.events, 'latency'), g.events = []; end;  end;        if ~isempty(g.events)      if isstr(g.events(1).type)           [g.eventtypes tmpind indexcolor] = unique({g.events.type}); % indexcolor countinas the event type      else [g.eventtypes tmpind indexcolor] = unique(cell2mat({g.events.type}));      end;      g.eventcolors     = { 'r', [0 0.8 0], 'm', 'c', 'k', 'b', [0 0.8 0] };        g.eventstyle      = { '-' '-' '-'  '-'  '-' '-' '-' '--' '--' '--'  '--' '--' '--' '--'};      g.eventwidths     = [ 2.5 1 ];      g.eventtypecolors = g.eventcolors(mod([1:length(g.eventtypes)]-1 ,length(g.eventcolors))+1);      g.eventcolors     = g.eventcolors(mod(indexcolor-1               ,length(g.eventcolors))+1);      g.eventtypestyle  = g.eventstyle (mod([1:length(g.eventtypes)]-1 ,length(g.eventstyle))+1);      g.eventstyle      = g.eventstyle (mod(indexcolor-1               ,length(g.eventstyle))+1);            % for width, only boundary events have width 2 (for the line)      % -----------------------------------------------------------      indexwidth = ones(1,length(g.eventtypes))*2;      if iscell(g.eventtypes)          for index = 1:length(g.eventtypes)              if strcmpi(g.eventtypes{index}, 'boundary'), indexwidth(index) = 1; end;          end;      end;      g.eventtypewidths = g.eventwidths (mod(indexwidth([1:length(g.eventtypes)])-1 ,length(g.eventwidths))+1);      g.eventwidths     = g.eventwidths (mod(indexwidth(indexcolor)-1               ,length(g.eventwidths))+1);            % latency and duration of events      % ------------------------------      g.eventlatencies  = cell2mat({g.events.latency})+1;      if isfield(g.events, 'duration')           g.eventlatencyend   = g.eventlatencies + cell2mat({g.events.duration})+1;      else g.eventlatencyend   = [];      end;      g.plotevent       = 'on';  end;  if isempty(g.events)      g.plotevent      = 'off';  end;  g.commandselect = { commandpush commandmove commandrelease };             set(figh, 'userdata', g);    % %%%%%%%%%%%%%%%%%%%%%%%%%%  % Plot EEG Data  % %%%%%%%%%%%%%%%%%%%%%%%%%%  axes(ax1)  hold on    % %%%%%%%%%%%%%%%%%%%%%%%%%%  % Plot Spacing I  % %%%%%%%%%%%%%%%%%%%%%%%%%%  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  if strcmp(SPACING_EYE,'on'),  set(m(7),'checked','on')  else set(m(7),'checked','off');  end   eegplot('scaleeye', [], gcf);  if strcmp(lower(g.scale), 'off')	  eegplot('scaleeye', 'off', gcf);  end;    eegplot('drawp', 0);  eegplot('drawp', 0);  if g.dispchans ~= g.chans  	   eegplot('zoom', gcf);  end;    eegplot('scaleeye', [], gcf);    h = findobj(gcf, 'style', 'pushbutton');  set(h, 'backgroundcolor', BUTTON_COLOR);  h = findobj(gcf, 'tag', 'eegslider');  set(h, 'backgroundcolor', BUTTON_COLOR);  set(figh, 'visible', 'on');  % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -