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

📄 icademo.m

📁 含有多种ICA算法的eeglab工具箱
💻 M
📖 第 1 页 / 共 2 页
字号:
if ~exist('icademoauto')    fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%%end;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% run the ICA decomposition using runica.m%% Decompose the data using the ICA algorithm% Specify the baseline vector to be sure that the baselines are zeroed.%         data       = input data (size(data) = [chans,frames*epochs])%         frames     = number of data points in each data epoch %         basevector = data point vector to use in zeroing baseline %fprintf('Now decompose both epochs at once using the ICA algorithm, runica() ...\n\n');if ~exist('icademoauto')    fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%%end;[weights,sphere,activations,bias,signs,lrates] = runica(data);fprintf('\nDone!\n');if ~exist('icademoauto')    fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%%end;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Compute the activation waveforms for the resulting ICA components using icaact.m%  datamean = mean(data')';  activations = icaact(data,weights*sphere,datamean);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Reorder the first 10 components by increasing in-epoch latency to the% point of maximum variance accounted for. Do not take into account % channel 14 in the variance calculation; only use channels 1:13.%fprintf('Re-sorting the resulting components by LATENCY ')fprintf('          using compsort() ...\n\n');fprintf('Note: runica() orders components by size - comport() not commonly needed!!\n')% [windex,maxvar,maxframe,maxepoch,maxmap] ...%                = compsort(data,weights,sphere,datamean, ...%                                         frames,nlargest,chanlist);  [windex,maxvar,maxframe,maxepoch,maxmap] = ...                   compsort(data,weights,sphere,1,...                                          frames,10,[1:13]);fprintf('\nDone!\n');if ~exist('icademoauto')    fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%%end;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Plot the activation waveforms of all the components %        as reordered by compsort()% Identify the components using the original component numbers.%fprintf('Plotting the component activation waveforms using plotdata()')fprintf('using plotdata() ....\n\n');figure('Position',pos+3*off);   plotdata(activations(windex,:),frames,limits,...                 'ICA Component Activations', ...                          windex,0,'(2 conditions)');if ~exist('icademoauto')    fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%%end;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Plot the contributions to the first epoch of data by the first reordered % 10 ICA components. Superimpose their projections on the original data.%fprintf('Plotting contributions of the 1st 10 ICA components ');fprintf('using plotproj()...\n\n');figure('Position',pos+4*off); %   [projdata] = plotproj(data,weights,compnums, ...%                            title,limits,chanlist,channames,colors); [projdata] = plotproj(data(:,1:frames),weights*sphere,windex(1:10), ...               'First epoch (comps. 1-10)',limits,[1:10], chan_locs2 );if ~exist('icademoauto')    fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%%end;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Plot the contributions to the first epoch of data by the 5 largest% ICA components. Superimpose their projections on the original data.%fprintf('Plotting contributions of the 5 largest ICA components ');fprintf('(windex order) using projtopo()...\n\n');figure('Position',pos+4*off); %       >> [projdata] = projtopo(data,weights,[compnums],chan_locs,...%                                 'title',[limits],colors,chans); [projdata] = projtopo(data(:,1:frames),weights*sphere,1:5,chan_locs,...               'First epoch',limits);if ~exist('icademoauto')    fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%%end;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Plot the envelopes of the data epoch 1 and the first 10 components%fprintf('Plotting the [min,max] "envelopes" of the data ');fprintf('and largest 6 components using envproj().\n(Data envelope is in white).\n\n');figure('Position',pos+5*off); % >> [envdata] = envproj(data,weights,compnums, ...%                        title,limits,chanlist,compnames,colors);  [envdata] = envproj(data(:,1:floor(0.6*frames)),weights*sphere,1:6, ...                  'Envelopes of data and largest 6 components (cond. 1)',...                     [0 995*0.6 0 0]);if ~exist('icademoauto')    fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%%end;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%fprintf('Now plotting envelopes PLUS scalp maps using envtopo().\n');figure('Position',pos+5.5*off); %%  >> envtopo(data,weights,chan_locs,[limits],[compnums],...%                                   'title',[plotchans],[voffsets]);  envtopo(data(:,1:floor(0.6*frames)),weights*sphere,'chanlocs',chan_locs,...         'limits', [0 995*0.6],'compnums',[2 3 4 6],'title', 'Largest Components');if ~exist('icademoauto')    fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%%end;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Plot a close-up of the decomposition of epoch 2, channel 2.% Focus on the time interval 250 to 400 msec.%  startframe = fix(0.250*srate)+1; % start 250 msec after epoch start  endframe   = fix(0.400*srate);   % end 400 msec after epoch startfprintf('Plotting contributions of the 1st 5 ICA components ');fprintf('at Cz using chanproj().\nData is in white.\n\n');figure('Position',pos+6*off); % [chandata] = chanproj(projdata,chan,ncomps,framelist,limits,titl,clrs);  [chandata] = chanproj(projdata,1,5,startframe:endframe,...                                 [0 995 0 0],'Epoch 1, channel Fz',0);fprintf('\n Note that two components make up most of the response peak.\n');if ~exist('icademoauto')    fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%%end;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Plot the scalp maps of the first four reordered components % Read the electrode location file chan_locs%fprintf('Plotting 1st 4 ICA component scalp maps using compmap()...\n');figure('Position',pos+7*off); % compmap (winv,eloc_file,index,title,pagesize,labels,printflag)  compmap(maxmap,chan_locs,1:4,'Maps of 1st 4 ICA Components',...                                                   [2 2],windex(1:4));if ~exist('icademoauto')    fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%%end;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Display the projected epoch-1 data for reordered ICA component windex(7) % together with a scalp map at its point of max variance%fprintf('Plotting the scalp maps and 1st-epoch projection of\n');fprintf('   the button press component using compplot()...\n\n');figure('Position',pos+8*off); % compplot(data,plotframe,chan_file,xstart,srate,title);  frame = maxframe(7);  projp3 = icaproj(data(:,frames+1:2*frames),weights*sphere,windex(7));  compplot(projp3,frame,chan_locs,0,srate,'ICA Button Press Component');if ~exist('icademoauto')    fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%%end;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Make and display a brief movie of a small segment of the first data epoch%fprintf('Making a brief movie of an N200 portion of the 1st data epoch\n')fprintf('            using eegmovie() & seemovie()...\n\n');figure('Position',pos+9*off); % [Movie,Colormap] = eegmovie(data,srate,elec_locs,title,movieframes,minmax);try,  [Movie,Colormap] = eegmovie(data(:,313:412),srate,chan_locs,...                                              'Demo of eegmovie()',75:85,0);% Display the movie slowly, then 5 times forward/back%  seemovie(Movie,-5,Colormap); catch,    disp('Problem generating movie');end;if ~exist('icademoauto')    fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%%end;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Run testica script using optimum parameters %    (nsources = ncomponents to separate)% Sources are super-Gaussian %fprintf('Last, running testica() - a simulation script for estimating the accuracy\n')fprintf('         of ICA separation for a given data size and source distribution ...\n\n');fprintf('Perfect separation would produce an identity matrix.\n');fprintf('This is not possible here, since 14 sources are mixed into only 6 channels.\n');fprintf('The figure will show that the 6 largest sources are still recovered clearly ...\n');if ~exist('icademoauto')    fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%%    testica(chans,epochs*frames,14,-0.05,1.4);else     [testresult] = testica(chans,epochs*frames,14,-0.05,1.4);end;% model 14 sources with a wide range of sizes & positive kurtosis%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%set(gcf,'Position',pos+10*off); if ~exist('icademoauto')    fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%%    end; fprintf('\n *************************************************************\n');fprintf(' *               For a tutorial on the toolbox:                *\n');fprintf(' *                                                             *\n');fprintf(' *          http://www.cnl.salk.edu/~scott/tutorial/           *\n');fprintf(' *                                                             *\n');fprintf(' *      For an overview of available scripts  >> help ica      *\n');fprintf(' *      For information about using ICA, see  icafaq.html      *\n');fprintf(' *      For further details and examples, see icabib.html      *\n');fprintf(' *************************************************************\n\n')return

⌨️ 快捷键说明

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