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

📄 rejstatepoch.m

📁 含有多种ICA算法的eeglab工具箱
💻 M
📖 第 1 页 / 共 2 页
字号:
	% EEGPLOT button	% --------------	if ~isempty(g.plotcom)			h  = uicontrol(gcf, 'backgroundcolor', GUIBUTTONCOLOR, 'Style', 'pushbutton', 'string', 'EEGPLOT', 'Units','Normalized','Position',[95 -2 15 6].*s+q, ...					'callback',['TMPEEG = get(gcbf, ''userdata'');' ...								'TMPREJ = TMPEEG{3};' ...								'TMPREJELEC = TMPEEG{4};' ...								g.plotcom ] );			posaccept = [95 -10 15 6];	else	posaccept = [95 -6 15 6];	end;									% ACCEPT button	% -------------	command = 'fprintf(''Rejection indices has been put in the matrix TMPREJ\n'')'; 	haccept  = uicontrol(gcf, 'backgroundcolor', GUIBUTTONCOLOR, 'Style', 'pushbutton', 'string', 'UPDATE', 'Units','Normalized','Position', posaccept.*s+q, ...					'callback', [	'set(gcbo, ''userdata'', 1);' ... %signal to signify termination 									'TMPEEG = get(gcbf, ''userdata'');' ...									'TMPREJ = TMPEEG{3};' ...									'TMPREJELEC = TMPEEG{4};' ...									command ] );	command = [ 'entwin = get(gcbf, ''currentobject'');' ... 				'tmptype = get(entwin,''type'');' ...				'if tmptype(1) == ''l'' entwin = get(entwin, ''parent''); end;' ... 				'tagwin = get(entwin,''tag'');' ... % either entropy or kurtosis 				'switch tagwin,' ...				' case ''Plotwin'',' ... % check if the user clicked on the right window				'   alldata = get(gcf, ''userdata'');' ...				'   plotsig = alldata{1};' ... 				'   pnts = alldata{2};' ... 				'   fig = figure(''position'', [100 300 600 400],''color'', [1 1 1]);' ...				'   I = alldata{3};' ... 				'   sweeps = size(plotsig,2) /pnts;' ... 				'   h1 = axes(''parent'', fig, ''Units'',''Normalized'', ''Position'',[0.6 0.11 0.27 0.815]);' ...				'   pos = get(entwin, ''currentpoint'');' ...				'   component = round(pos(1) / sweeps + 0.5);' ... % determine the component number				'   alldata = get(entwin, ''userdata'');' ...		    	'   rej = alldata{1};' ... 				'   if component <= size(rej,1)' ... % component 				'        rej_threshold = alldata{3};' ... 				'        component = max(1,min(component, size(rej,1))); ' ... 		    	'   	 rej = rej(component, :);' ... 				'        titlegraph = sprintf(''' g.title ' #%d'', component);' ... 				'        colorgraph = ''b'';' ...				'   else' ...                        % global 		    	'   	 rej = alldata{2};' ... 				'        rej_threshold = alldata{4};' ... 				'        titlegraph = sprintf(''' g.title ' global'');' ... 				'        colorgraph = ''g'';' ...				'   end;' ...				'   plot([1:length(rej)], rej, ''color'', colorgraph);' ... 				'   ss = get(h1, ''xlim'');' ...				'   set(h1, ''view'', [90 90]);' ...				'   set(h1, ''xdir'', ''reverse'');' ...				'   set(h1, ''XLim'', ss);' ...				'   hold on;' ...  % plot component				'   yl = get(h1, ''ylim'');' ...				'   set(h1, ''xtickmode'', ''manual'', ''xtick'', sweeps/2, ''xticklabel'', component, ''xlim'', [ 0 sweeps ]);' ...				'   title( titlegraph );' ...				'   plot( get(h1, ''xlim''), [rej_threshold rej_threshold], ''r'');' ... % plot limit		  				'   plot( get(h1, ''xlim''), [-rej_threshold -rej_threshold], ''r'');' ... % plot limit		  				'   set(h1, ''xticklabel'', []);' ...				'   hold on;' ...				'   h2 = axes(''parent'', fig,''Units'',''Normalized'', ''Position'',[0.13 0.11 0.27 0.815]);' ...				'   erpimage( plotsig, ones(1,size(plotsig,2)/pnts), [0:1/(pnts-1):1], '''', 3, 1, ''nosort'', ''noplot'');' ...				'   title(''Currentset all chans''); xlabel(''''); ylabel(''''); ' ...				'   set(gca, ''xticklabel'', []);' ...				'   hold on;' ...				'   h3 = axes(''parent'', fig,''Units'',''Normalized'', ''Position'',[0.45 0.11 0.1 0.815]);' ...				'   if any(I ~= 0)' ...				'      rejImage = (I'' * ones(1, 10))'';' ...				'      imagesc( rejImage'' );' ...				'      set(gca, ''ydir'', ''normal'');' ...				'   end;' ...				'   title(''Rejected (all)''); xlabel(''''); ylabel('''');' ... 				'   set(gca, ''xticklabel'', [], ''yticklabel'', []);' ... 				'end;' ...				'clear fig tmptype tagwin alldata rej rejImage plotsig sweeps pnts rej_threshold ss q s h1 h2 h3 pos component yl;' ];%				'      erpimage( rejImage(:)'', ones(1,size(I,2)), [0:1/(10-1):1], '''', 1, 0, ''nosort'', ''noplot'');' ...	set(gcf, 'WindowButtonDownFcn', command);				rejstatepoch('draw');	switch g.plot,		case 'on', waitfor( haccept, 'userdata'); drawnow;	end;	threshold  = g.threshold;	thresholdg = g.thresholdg;	Irej = [];	Irejdetails = [];	n = 0;	try		TMPEEG = get(gcf, 'userdata');		Irej = TMPEEG{3};		Irejdetails = TMPEEG{4};		n = length(find(Irej == 1));		plothandler = findobj( 'parent', gcf, 'tag', 'Plotwin');		TMPEEG = get(plothandler, 'userdata');		threshold = TMPEEG{3};		thresholdg = TMPEEG{4};		close(gcf);	catch, end;else %if signal is a string draw everything	% retreive data	% -------------	gcfdata = get(gcf, 'userdata');	plotsig = gcfdata {1};	pnts    = gcfdata {2};    sweeps  = size(plotsig,2)/pnts;	h6 = findobj('parent', gcf, 'tag', 'Plotwin');	alldata = get(h6, 'userdata');	g.rej       = alldata {1};	g.rejg      = alldata {2};	g.threshold   = alldata {3};	g.thresholdg  = alldata {4};	set(h6, 'userdata', alldata);	nbchans = size(g.rej,1);	% reject trials	% -------------	rejelec = abs(g.rej) > g.threshold;	rej  = max(rejelec,[],1);	n1 = sum(rej(:));	if ~isempty( g.rejg )		rej2 = abs(g.rejg) > g.thresholdg;		n2 = sum(rej2(:));		rej = rej | rej2(:)';	end;	fprintf('%d trials rejected (single:%d, all:%d)\n', sum(rej(:)), n1, n2);	gcfdata {3} = rej;	gcfdata {4} = rejelec;	set(gcf, 'userdata', gcfdata);		% plot the sorted entropy curve	% -----------------------------	plotstat( 'Plotwin');end;return;function plotstat( id );	% plot the sorted entropy curve	% -----------------------------	h6 = findobj('parent', gcf, 'tag', id);	axes(h6); cla;	ttmp = get(gca, 'title');	oldtitle = get(ttmp, 'string');	% get datas    % ---------   	alldata = get(gca, 'userdata');	g.rej       = alldata {1};	g.rejg      = alldata {2};	g.threshold   = alldata {3};	g.thresholdg  = alldata {4};	g.labels      = alldata {5};	nbchans = size(g.rej,1);	sweeps  = size(g.rej,2);	% plot datas    % ----------	g.rej = g.rej'; plot(g.rej(:)); g.rej = g.rej'; 	hold on;	yl = get(gca, 'ylim');	% plot vertival bars to separate components and the trehsold	% ----------------------------------------------------------	set( gca, 'tag',  id, 'ylimmode', 'manual');	set(gca, 'xtickmode', 'manual', 'xtick', [0:sweeps:(size(g.rej(:),1)-1+2*sweeps)] + sweeps/2, ...			 'xticklabel', g.labels, 'xlim', [ 0 (size(g.rej(:),1)-1+2*sweeps)]);	plot( [1 size(g.rej(:),1)], [-g.threshold -g.threshold], 'r');	% plot threshold	  	plot( [1 size(g.rej(:),1)], [g.threshold g.threshold], 'r');	% plot threshold	  	if ~isempty(g.rejg) % plot global ?	 		plot([size(g.rej(:),1)+sweeps:size(g.rej(:),1)+2*sweeps-1],  g.rejg(:), 'g');		pp = patch([size(g.rej(:),1) size(g.rej(:),1) size(g.rej(:),1)+sweeps size(g.rej(:),1)+sweeps], [yl(1)-1 yl(2)+1 yl(2)+1 yl(1)-1], get(gcf, 'color'), 'clipping', 'off');		set(pp, 'EdgeColor',  get(gcf, 'color'));		plot( [size(g.rej(:),1)+sweeps length(g.rejg)+size(g.rej(:),1)+sweeps], [-g.thresholdg -g.thresholdg], 'r');	% plot threshold	  		plot( [size(g.rej(:),1)+sweeps length(g.rejg)+size(g.rej(:),1)+sweeps], [g.thresholdg g.thresholdg], 'r');	% plot threshold	  		plot([size(g.rej(:),1)+sweeps size(g.rej(:),1)+sweeps], yl, 'k');	else		pp = patch([size(g.rej(:),1) size(g.rej(:),1) size(g.rej(:),1)+2*sweeps size(g.rej(:),1)+2*sweeps], [yl(1)-1 yl(2)+1 yl(2)+1 yl(1)-1], get(gcf, 'color'), 'clipping', 'off');		set(pp, 'EdgeColor',  get(gcf, 'color'));	end;	for index = 0:sweeps:size(g.rej(:),1); 		plot([index index], yl, 'k');	end;	% restore properties	title(oldtitle);	set(h6, 'userdata', alldata);return;function makebutton( string, ax, pos1, pos2, userindex, init, GUIBUTTONCOLOR );	h  = uicontrol(gcf , 'backgroundcolor', GUIBUTTONCOLOR, 'Style', 'radiobutton', 'string', string, 'value', fastif(init == 0, 0, 1), 'Units','Normalized', 'Position', pos1, ...					'callback', [ 'textresh = findobj(''parent'', gcbf, ''tag'', ''' string ''');' ...								  'checkstatus = get(gcbo, ''value'');' ...								  'ax = findobj(''parent'', gcbf, ''tag'', ''' ax ''');' ...								  'tmpdat = get(ax, ''userdata'');' ...								  'if checkstatus' ... % change status of the textbox 								  '   set(textresh, ''enable'', ''on'');' ...								  '   tmpdat{' int2str(userindex) '} = str2num(get(textresh, ''string''));' ...								  'else' ... 										  '   set(textresh, ''enable'', ''off'');' ...								  '   tmpdat{' int2str(userindex) '} = 0;' ...								  'end;' ...								  'set(ax, ''userdata'' , tmpdat);' ...								  'rejstatepoch(''draw'');' ...								  'clear tmpdat ax checkstatus textresh;'  ] );	h  = uicontrol(gcf, 'Style', 'edit', 'backgroundcolor', [1 1 1], 'tag', string, 'string', num2str(init), 'enable', fastif(init == 0, 'off', 'on'), 'Units','Normalized', 'Position', pos2, ...					'callback', [ 	'ax = findobj(''parent'', gcbf, ''tag'', ''' ax ''');' ...								    'tmpdat = get(ax, ''userdata'');' ...									'tmpdat{' int2str(userindex) '} = str2num(get(gcbo, ''string''));' ...									'set(ax, ''userdata'' , tmpdat);' ...								    'rejstatepoch(''draw'');' ...									'clear tmpdat ax;' ] );return;

⌨️ 快捷键说明

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