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

📄 icademo.m

📁 含有多种ICA算法的eeglab工具箱
💻 M
📖 第 1 页 / 共 2 页
字号:
% icademo() - a sample ICA analysis script using the ICA/ERP package %             of Matlab functions distributed via%             http://www.sccn.ucsd.edu/eeglab%% Notes:%   Reads ascii ERP data file:            pnas.adt%   Reads example ascii ERP data files:   chan.nam   chan14.locs (=chan_locs)%% Author: Scott Makeig, SCCN/INC/UCSD, La Jolla, 5-18-97 %% See also: runica(), icavar(), icaproj(), icaact()%123456789012345678901234567890123456789012345678901234567890123456789012% Copyright (C) 5-18-97 Scott Makeig, SCCN/INC/UCSD, scott@sccn.ucsd.edu%% This program is free software; you can redistribute it and/or modify% it under the terms of the GNU General Public License as published by% the Free Software Foundation; either version 2 of the License, or% (at your option) any later version.%% This program is distributed in the hope that it will be useful,% but WITHOUT ANY WARRANTY; without even the implied warranty of% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the% GNU General Public License for more details.%% You should have received a copy of the GNU General Public License% along with this program; if not, write to the Free Software% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA% $Log: icademo.m,v $% Revision 1.12  2004/04/28 06:03:13  scott% restoring full function%% Revision 1.11  2004/04/28 06:02:10  scott% othing% nothing%% Revision 1.10  2003/12/04 01:54:10  arno% updating paths%% Revision 1.9  2003/12/03 00:28:50  arno% channel location file%% Revision 1.8  2003/09/20 01:10:56  arno% add try, catch clause for movie%% Revision 1.7  2003/09/17 02:13:53  arno% allow automatic run%% Revision 1.6  2003/09/16 23:34:21  arno% debug channel location%% Revision 1.5  2002/11/13 18:15:36  arno% debugging for new function format%% Revision 1.4  2002/09/06 19:48:40  arno% updating eegplot calls%% Revision 1.3  2002/09/05 17:28:13  arno% debugging%% Revision 1.2  2002/09/05 15:38:39  arno% debug for new functions%% Revision 1.1  2002/04/05 17:36:45  jorn% Initial revision%% This version tested on package version% Added envproj(), used maxmap in compplot() 6-18-97 -sm% Reworked to use actual sample ERP data 6-27-97 -sm% Pruned again 7/18/97 -sm% Adjusted envproj, plotproj, icaproj to remove datamean, distributing %     mean offset (if any) among component projections 7/23/97 -sm% Fixed plotproj() call - it can't label arbitrry channel lists -sm % Adjusted envproj etc. 12/08/97 -sm% Added timtopo() 1-16-98 -sm% Added more formatting, fixed compplot and eegmovie plotting 10-9-99 -sm% 12-19-00 revised icaproj args -sm% 01-05-01 advertised the web tutorial, fixed chanproj(), improved eegmovie() -sm% 01-12-01 removed 'sphere' arg from plotproj(), icaact() -sm% 01-25-02 reformated help & license, added links -ad    chans  = 14;  % data channels (rows in data matrix)   frames = 312; % frames per data epoch (columns in data submatrix)   epochs = 2;   % epochs in simulated data   srate  = 312.5; % data sampling rate in Hz   limits = [0 995 0 0]; % epoch time limits in msec, y limits unspecified   off    = [25 -25 0 0];   % successive figure offset in pixels   icadefs  % run icadefs to see whether the user has changed the XXX reference.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Begin%fprintf('\n *************************************************************\n');  fprintf(' * Demonstration script showing several ICA package analysis *\n')  fprintf(' * and plotting routines applied to sample lowpass ERP data  *\n');  fprintf(' *                                                           *\n');  fprintf(' * Note: Use of these and other toolbox functions is now     *\n');  fprintf(' *           documented in an online tutorial at:            *\n');  fprintf(' *         http://www.cnl.salk.edu/~scott/tutorial/          *\n');fprintf(' *************************************************************\n\n');v=version;if v(1) < 5  fprintf('Not all segments may work for Matlab version 4.\n')end% add path to access if ~exist('pnas.flt')    p = which('eeglab');    p = p(1:findstr(p,'eeglab.m')-1);    addpath([ p 'sample_data' ] );end;% name of channel locations filechan_locs  = 'pnas_chan14.locs';chan_locs2 = 'pnas_chan.locs';figureset(gcf,'Color',BACKCOLOR);plot([-4 -4 4 4 -4],[-4.5 3 3 -4.5 -4.5],'w','Linewidth',3);hold on;axis([-4 4 -5 5]);t=text(0,2,'icademo()');set(t,'FontSize',14,'HorizontalAlignment','center');t=text(0,1,' Demonstration script showing several ICA toolbox ');set(t,'FontSize',14,'HorizontalAlignment','center');t=text(0,0,'analysis and plotting routines'); set(t,'FontSize',14,'HorizontalAlignment','center');t=text(0,-1,'applied to sample lowpass ERP data');set(t,'FontSize',14,'HorizontalAlignment','center');t=text(0,-2.5,'See http://www.cnl.salk.edu/~scott/tutorial/');set(t,'FontSize',14,'HorizontalAlignment','center');t=text(0,-3.5,'for more details.');set(t,'FontSize',14,'HorizontalAlignment','center');axis('off')if ~exist('icademoauto')    fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%%end;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Load an ascii ERP data matrix %fprintf('Loading sample data...\n');   load pnas.adt -asciifprintf('Reshaping sample data...\n');   data = [pnas(15:28,:) pnas(1:14,:)]; % lapses (will plot red), hits (blue)   clear pnas% Scale to uVdata = data/24.2;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Lowpass filter (if available)%lowpass = 30; % filter band lowpass freq in Hzif exist('firls')  % if signal processing toolbox is installed . . .  fprintf('Lowpass filtering the data using eegfilt()...\n');  % data = eegfilt(data,srate,lowpassHz,highpassHz,frames);    [data,filtwts] = eegfilt(data,srate,0,lowpass,frames);                                         % lowpass filter below 30 Hzelse                                    % filter each epoch similarly  fprintf('Script eegfilt() requires the Matlab signal processing toolbox.\n');endpos = get(gcf,'Position'); % record figure position to use as a base for later figuresif ~exist('icademoauto')    fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%%end;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Overplot the 2 312-point data epochs at each channel using plotdata.m% Assume that the epoch timebase is 0 to 995 msec.% Read 4-character channel identifiers from the file 'chan.nam'% Use the default color order.%fprintf('\nOverplotting the two sample auditory ERP target responses\n')fprintf('        of %d chans by %d frames using plotdata()...\n\n', ...                               size(data,1),size(data,2));figure('Position',pos+off/2); % #2aplotdata(data,frames,[0 995 -10 10],'ERP Data', chan_locs2 ,0,'(2 conditions)');if ~exist('icademoauto')    fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%%end;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%fprintf('\nOverplotting the two sample auditory ERP target responses\n')fprintf('        of %d chans by %d frames using plottopo()...\n\n', ...                               size(data,1),size(data,2));%figure('Position',pos+off); % #2b% plotttopo(data,chan_locs,frames,limits,title,axsize,colors) plottopo(data,chan_locs,frames,[0 995 -10 10],'ERP Data');if ~exist('icademoauto')      fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%%end;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% run timtopo.m%fprintf('\nPlotting the Hit responses with topo maps at specified times ...\n')figure('Position',pos+off*3/2); % #2c% timtopo(data,chan_locs,[limits],[plottimes]','title',[plotchans],[voffsets]);timtopo(data(:,1:frames),chan_locs,[0 995 -10 10],[250 320 390 500],'Target Hits');if ~exist('icademoauto')    fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%%end;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% run eegplot.m%fprintf(...'Plotting the same data as two consecutive 1-sec epochs using eegplot().\n');fprintf('Try using the on-screen and menu control elements...\n')%  >> eegplot(data,srate,spacing,eloc_file,windowlength,title)     %eegplotold(data,srate,0,chan_locs,1,'Two data epochs using eegplot()')     eegplot(data,'srate',srate, 'spacing', 0,'eloc_file',chan_locs, ...				'winlength',1,'title','Two data epochs using eegplot()')     %set(gcf,'Position',pos+2*off); % #3 - eegplot() makes its own figureif ~exist('icademoauto')    fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%%end;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%fprintf(...'Plotting the same data as two consecutive 1-sec epochs using eegplotold()...\n');fprintf('Thus, eegplotold() can be used to embed plots in larger figures.\n')%% >> eegplot('noui',data,srate,spacing,eloc_file,startsec,color)%figure('Position',pos+2.5*off); subplot(1,2,1)  %eegplot('noui',data(:,1:312),'srate',srate,'spacing', 0,'eloc_file', chan_locs, 'color', {{'b'}} );  eegplotold('noui',data(:,1:312),srate,0,chan_locs,0,'b');  title('Lapses')subplot(1,2,2)  %eegplot('noui',data(:,1:313:624),'srate',srate,'spacing', 0,'eloc_file', chan_locs, 'color', {{'b'}} );  eegplotold('noui',data(:,313:624),srate,0,chan_locs,0,'r');  title('Hits')

⌨️ 快捷键说明

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