diff --git a/.codespellrc b/.codespellrc
new file mode 100644
index 000000000..e6a539389
--- /dev/null
+++ b/.codespellrc
@@ -0,0 +1,2 @@
+[codespell]
+ignore-words-list = alls,aussian,childs,datas,dum,ede,espacing,fastr,fo,hist,htmp,leaded,linke,mapp,nd,nwe,ois,ot,otu,pres,ro,ser,strng,sxl,whos
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100644
index 000000000..2e3038793
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,40 @@
+---
+name: Bug report
+about: Create a report to help us improve EEGLAB
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+### Description
+
+[*Description of the bug or feature
+Attach a link to Dropbox or Google Drive with screenshots and your data if possible.*]
+
+
+#### Steps to Reproduce
+
+1. [*First Step*]
+2. [*Second Step*]
+3. [*and so on...*]
+
+
+
+#### Expected behavior:
+[*What you expected to happen*]
+
+
+
+#### Actual behavior:
+[*What actually happened*]
+
+
+
+#### Versions
+
+| | |
+|----| ---- |
+| OS version | [*fill in*] |
+| Matlab version | [*fill in*] |
+| EEGLAB version | [*fill in*] |
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000..5cf41595e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,8 @@
+# ignore everything in plugin folders, but keep track of plugin submodules
+*.asv
+/plugins/**
+!/plugins/clean_rawdata
+!/plugins/dipfit
+!/plugins/firfilt
+!/plugins/ICLabel
+.DS_Store
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 000000000..592e3efa0
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,15 @@
+[submodule "plugins/dipfit"]
+ path = plugins/dipfit
+ url = https://github.com/sccn/dipfit.git
+[submodule "plugins/clean_rawdata"]
+ path = plugins/clean_rawdata
+ url = https://github.com/sccn/clean_rawdata.git
+[submodule "plugins/ICLabel"]
+ path = plugins/ICLabel
+ url = https://github.com/sccn/ICLabel
+[submodule "tutorial_scripts"]
+ path = tutorial_scripts
+ url = https://github.com/sccn/eeglab_tutorial_scripts.git
+[submodule "plugins/firfilt"]
+ path = plugins/firfilt
+ url = https://github.com/sccn/firfilt
diff --git a/1ST_README.txt b/1ST_README.txt
deleted file mode 100644
index 3223bde00..000000000
--- a/1ST_README.txt
+++ /dev/null
@@ -1,47 +0,0 @@
-
-This dir contains original Matlab functions from the EEGLAB (formerly ICA/EEG)
-Matlab toolbox, all released under the Gnu public license (see eeglablicence.txt).
-See the EEGLAB tutorial and reference paper (URLs given below) for more information.
-
-Sub-directories:
-
- /functions - All distributed EEGLAB functions (admin, sigproc, pop, misc)
- /plugins - Directory to place all downloaded EEGLAB plug-ins. dipfit (1.0)
- is present by default
- /sample_data - Miscellaneous EEGLAB data using in tutorials and references
- /sample_locs - Miscellaneous standard channel location files (10-10, 10-20)
- See the EEGLAB web site http://sccn.ucsd.edu/eeglab/ for more.
-
-To use EEGLAB:
-
-1. Place the Matlab functions in a directory ($DIR) and add
- $DIR/eeglab4.x to (Unix) your matlabpath environment variable.
- Else, within Matlab
- >> addpath('full_path_here')
-
-2. Optional: Edit file "icadefs.m" under the function directory to specify the location of
- the faster binary "ica" function (equivalent to Matlab runica() and called from within
- Matlab by binica()). This requires a (recommended) separate download from
- http://sccn.ucsd.edu/eeglab/binica/
- Also add the path to the EEGLAB tutorial. This requires another (recommended) download. See
- http://sccn.ucsd.edu/eeglab/
- File "icadefs.m" also specifies various limits and constants used in EEGLAB functions.
-
-3. Then start Matlab and type >> eeglab
-
-4. Open the main EEGLAB tutorial page (your downloaded "eeglabtut.html",
- else browse http://sccn.ucsd.edu/eeglab/eeglabtut.html)
-
-5. Please send feedback and suggestions to: eeglab@sccn.ucsd.edu
-
-6. In publications, please reference:
-
-Delorme, A., Makeig, S. (in press) EEGLAB: An open source toolbox for analysis of single-trial
-EEG dynamics including independent component analysis. Journal of Neuroscience Methods.
- http://sccn.ucsd.edu/eeglab/download/eeglab_jnm03.pdf
-
-Enjoy using EEGLAB to explore and analyze your data. Consider contributing to your functions
-and creativity to EEGLAB open source development (see http://sccn.ucsd.edu/eeglab for more details).
-
-Arno Delorme & Scott Makeig
-Fri Sep 6 11:44:29 PDT 2002
diff --git a/Contents.m b/Contents.m
index 1c86dfa8e..8f45b59c7 100644
--- a/Contents.m
+++ b/Contents.m
@@ -1,5 +1,5 @@
% EEGLAB Toolbox to process EEG data
-% Version 13.x (dev)
+% Version - see eeg_getversion()
%
% eeglab() - Matlab graphic user interface environment for
% electrophysiological data analysis incorporating the ICA/EEG toolbox
diff --git a/README.md b/README.md
new file mode 100644
index 000000000..d2e0032f7
--- /dev/null
+++ b/README.md
@@ -0,0 +1,52 @@
+[](https://github.com/sccn/eeglab/issues)
+
+
+# What is EEGLAB?
+EEGLAB is an open source signal processing environment for electrophysiological signals running on Matlab and Octave (command line only for Octave). This folder contains original Matlab functions from the EEGLAB (formerly ICA/EEG) Matlab toolbox, all released under the Gnu public license (see eeglablicence.txt). See the EEGLAB tutorial and reference paper (URLs given below) for more information.
+
+# Installing/cloning
+**Recommended:** Download the official EEGLAB release from https://sccn.ucsd.edu/eeglab/download.php
+
+**Do not download a ZIP file directly from GIT as it will not contain EEGLAB submodules**. Instead clone the reposity while pulling EEGLAB sub-modules.
+
+```
+git clone --recurse-submodules https://github.com/sccn/eeglab.git
+```
+
+If you forgot to clone the submodule, go to the eeglab folder and type
+
+```
+git submodule update --init --recursive --remote
+git pull --recurse-submodules
+```
+
+# Sub-directories:
+
+ - /functions - All distributed EEGLAB functions (admin, sigproc, pop, misc)
+ - /plugins - Directory to place all downloaded EEGLAB plug-ins. dipfit (1.0) is present by default
+ - /sample_data - Miscellaneous EEGLAB data using in tutorials and references
+ - /sample_locs - Miscellaneous standard channel location files (10-10, 10-20). See the EEGLAB web site http://sccn.ucsd.edu/eeglab/ for more.
+
+# To use EEGLAB:
+
+1. Start Matlab
+
+2. Use Matlab to navigate to the folder containing EEGLAB
+
+3. Type "eeglab" at the Matlab command prompt ">>" and press enter
+
+3. Open the main EEGLAB tutorial page (http://sccn.ucsd.edu/wiki/EEGLAB_Wiki)
+
+4. Please send feedback and suggestions to: eeglab@sccn.ucsd.edu
+
+# In publications, please reference:
+
+Delorme, A., & Makeig, S. (2004). EEGLAB: an open source toolbox for analysis of single-trial EEG dynamics including independent component analysis. Journal of neuroscience methods, 134(1), 9-21. (See article [here](http://sccn.ucsd.edu/eeglab/download/eeglab_jnm03.pdf))
+
+# Compiled version of EEGLAB
+
+If you experience problems, try running EEGLAB as administrator.
+
+# Documentation:
+
+EEGLAB documentation is available on the EEGLAB wiki (see http://sccn.ucsd.edu/wiki/EEGLAB_Wiki for more details).
diff --git a/eeglab.m b/eeglab.m
index 34d30c86c..a7f7432a8 100644
--- a/eeglab.m
+++ b/eeglab.m
@@ -8,8 +8,8 @@
%
% Authors: Arnaud Delorme and Scott Makeig, with substantial contributions
% from Colin Humphries, Sigurd Enghoff, Tzyy-Ping Jung, plus
-% contributions
-% from Tony Bell, Te-Won Lee, Luca Finelli and many other contributors.
+% contributions from Tony Bell, Te-Won Lee, Luca Finelli and many
+% other contributors.
%
% Description:
% EEGLAB is Matlab-based software for processing continuous or event-related
@@ -24,14 +24,15 @@
%
% Usage: 1) To (re)start EEGLAB, type
% >> eeglab % Ignores any loaded datasets
+% >> eeglab nogui % Do not pop up GUI
% 2) To redaw and update the EEGLAB interface, type
% >> eeglab redraw % Scans for non-empty datasets
% >> eeglab rebuild % Closes and rebuilds the EEGLAB window
% >> eeglab versions % State EEGLAB version number
%
-% >> type "license.txt" % the GNU public license
-% >> web http://sccn.ucsd.edu/eeglab/tutorial/ % the EEGLAB tutorial
-% >> help eeg_checkset % the EEG dataset structure
+% >> type "eeglablicense.txt" % the EEGLAB open source license
+% >> web http://eeglab.org % the EEGLAB tutorial
+% >> help eeg_checkset % the EEG dataset structure
%
% GUI Functions calling eponymous processing and plotting functions:
% ------------------------------------------------------------------
@@ -42,9 +43,6 @@
% pop_epoch - extract epochs from a continuous dataset (epoch())
% pop_erpimage - plot single epochs as an image (erpimage())
% pop_jointprob - reject epochs using joint probability (jointprob())
-% pop_loaddat - load Neuroscan .DAT info file (loaddat())
-% pop_loadcnt - load Neuroscan .CNT data (lndcnt())
-% pop_loadeeg - load Neuroscan .EEG data (loadeeg())
% pop_loadbva - load Brain Vision Analyser matlab files
% pop_plotdata - plot data epochs in rectangular array (plotdata())
% pop_readegi - load binary EGI data file (readegi())
@@ -120,71 +118,131 @@
% eeg_helppop - help on pop_ and eeg_ functions
% eeg_helpsigproc - help on
-% Copyright (C) 2001 Arnaud Delorme and Scott Makeig, Salk Institute,
+% Copyright (C) 2001 Arnaud Delorme and Scott Makeig, Salk Institute,
% arno@salk.edu, smakeig@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.
+% Copyright (C) 2001 Arnaud Delorme, SCCN/INC/UCSD, arno@salk.edu
%
-% 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.
+% This file is part of EEGLAB, see http://www.eeglab.org
+% for the documentation and 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
+% Redistribution and use in source and binary forms, with or without
+% modification, are permitted provided that the following conditions are met:
+%
+% 1. Redistributions of source code must retain the above copyright notice,
+% this list of conditions and the following disclaimer.
+%
+% 2. Redistributions in binary form must reproduce the above copyright notice,
+% this list of conditions and the following disclaimer in the documentation
+% and/or other materials provided with the distribution.
+%
+% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+% THE POSSIBILITY OF SUCH DAMAGE.
function varargout = eeglab( onearg )
+persistent warningShowed;
+
+ver = version;
+if strcmpi(ver, '9.4.0.813654 (R2018a)')
+ disp('Link to install 2018a Update 2');
+ errordlg( [ 'You are running Matlab version R2018a, which has important bugs' 10 'Matlab crashes when running EEGLAB in this version of Matlab' 10 'Install 2018a Update 2 to fix the issue (link on the command line)' ]);
+end
+
if nargout > 0
varargout = { [] [] 0 {} [] };
- %[ALLEEG, EEG, CURRENTSET, ALLCOM]
-end;
+end
+
+% Warning if in toolbox folder
+% ----------------------------
+if isempty(warningShowed)
+ filterPath = fileparts(fileparts(fileparts(which('filter'))));
+ eeglabPath = fileparts(fileparts(which('eeglab')));
+ if ~isempty(strfind(filterPath, eeglabPath))
+ fprintf(2, 'Warning: EEGLAB is in the MATLAB toolbox folder which is not recommended\n');
+ fprintf(2, ' You may experience errors if a plugin overloads a MATLAB function\n');
+ end
+ warningShowed = true;
+end
% check Matlab version
% --------------------
vers = version;
+indp = find(vers == '.');
+if str2num(vers(indp(1)+1)) > 1, vers = [ vers(1:indp(1)) '0' vers(indp(1)+1:end) ]; end
+indp = find(vers == '.');
+vers = str2num(vers(1:indp(2)-1));
tmpv = which('version');
if ~isempty(findstr(lower(tmpv), 'biosig'))
- [tmpp tmp] = fileparts(tmpv);
+ [tmpp, ~] = fileparts(tmpv);
rmpath(tmpp);
-end;
-if str2num(vers(1)) < 7 && str2num(vers(1)) >= 5
- tmpWarning = warning('backtrace');
- warning backtrace off;
- warning('You are using a Matlab version older than 7.0');
+end
+% remove freemat folder if it exist
+tmpPath = fileparts(fileparts(which('sread')));
+newPath = fullfile(tmpPath, 'maybe-missing', 'freemat3.5');
+if exist(newPath) == 7
+ warning('off', 'MATLAB:rmpath:DirNotFound');
+ rmpath(newPath)
+ warning('on', 'MATLAB:rmpath:DirNotFound');
+end
+if ismatlab && vers < 7
+ tmpWarning = warning('query', 'backtrace');
+ warning('off', 'backtrace');
warning('This Matlab version is too old to run the current EEGLAB');
warning('Download EEGLAB 4.3b at http://sccn.ucsd.edu/eeglab/eeglab4.5b.teaching.zip');
warning('This version of EEGLAB is compatible with all Matlab version down to Matlab 5.3');
- warning(tmpWarning);
+ warning(tmpWarning.state, 'backtrace');
return;
-end;
-
-% check Matlab version
-% --------------------
-vers = version;
-indp = find(vers == '.');
-if str2num(vers(indp(1)+1)) > 1, vers = [ vers(1:indp(1)) '0' vers(indp(1)+1:end) ]; end;
-indp = find(vers == '.');
-vers = str2num(vers(1:indp(2)-1));
-if vers < 7.06
- tmpWarning = warning('backtrace');
- warning backtrace off;
+end
+if ismatlab && vers < 7.06
+ tmpWarning = warning('query','backtrace');
+ warning off backtrace;
warning('You are using a Matlab version older than 7.6 (2008a)');
warning('Some of the EEGLAB functions might not be functional');
warning('Download EEGLAB 4.3b at http://sccn.ucsd.edu/eeglab/eeglab4.5b.teaching.zip');
warning('This version of EEGLAB is compatible with all Matlab version down to Matlab 5.3');
- warning(tmpWarning);
-end;
+ warning( tmpWarning.state, 'backtrace');
+end
+if ~ismatlab
+ warning('off', 'Octave:abbreviated-property-match');
+ warning('off', 'Octave:legacy-function');
+ warning('off', 'Octave:num-to-str');
+ warning('off', 'backtrace');
+ warning('off', 'Octave:divide-by-zero');
+ try
+ pkg load statistics
+ catch
+ warning('Statistics module not found - type "pkg install -forge io" then "pkg install -forge statistics" to install it');
+ end
+ try
+ pkg load signal
+ catch
+ warning('Signal processing module not found - type "pkg install -forge control" then "pkg install -forge signal" to install it');
+ end
+end
+
+% check potential issues with strjoin
+% -----------------------------------
+strjoinPath = fileparts(which('strjoin'));
+[~,strjoinPath2] = fileparts(strjoinPath);
+if ~strcmpi(strjoinPath2, 'strfun')
+ warning(sprintf('Potential function conflict for strjoin.m located in "%s" \nWe suggest removing the path from MATLAB to avoid problems.', strjoinPath));
+end
% check for duplicate versions of EEGLAB
% --------------------------------------
eeglabpath = mywhich('eeglab.m');
eeglabpath = eeglabpath(1:end-length('eeglab.m'));
-if nargin < 1
+if nargin < 1 && ~isdeployed
eeglabpath2 = '';
if strcmpi(eeglabpath, pwd) || strcmpi(eeglabpath(1:end-1), pwd)
cd('functions');
@@ -194,26 +252,25 @@
eeglabpath2 = mywhich('eeglab.m');
cd('..');
else
- try, rmpath(eeglabpath); catch, end;
+ try, rmpath(eeglabpath); catch, end
eeglabpath2 = mywhich('eeglab.m');
- end;
+ end
if ~isempty(eeglabpath2)
- %evalin('base', 'clear classes updater;'); % this clears all the variables
eeglabpath2 = eeglabpath2(1:end-length('eeglab.m'));
- tmpWarning = warning('backtrace');
- warning backtrace off;
+ tmpWarning = warning('query', 'backtrace');
+ warning off backtrace;
disp('******************************************************');
warning('There are at least two versions of EEGLAB in your path');
warning(sprintf('One is at %s', eeglabpath));
warning(sprintf('The other one is at %s', eeglabpath2));
- warning(tmpWarning);
- end;
+ warning(tmpWarning.state, 'backtrace');
+ end
addpath(eeglabpath);
-end;
+end
% add the paths
% -------------
-if strcmpi(eeglabpath, './') || strcmpi(eeglabpath, '.\'), eeglabpath = [ pwd filesep ]; end;
+if strcmpi(eeglabpath, './') || strcmpi(eeglabpath, '.\'), eeglabpath = [ pwd filesep ]; end
% solve BIOSIG problem
% --------------------
@@ -221,51 +278,52 @@
if ~isempty(pathtmp)
try,
rmpath(pathtmp(1:end-15));
- catch, end;
-end;
+ catch, end
+end
% test for local SCCN copy
% ------------------------
-if ~iseeglabdeployed2
+if ~isdeployed
addpathifnotinlist(eeglabpath);
if exist( fullfile( eeglabpath, 'functions', 'adminfunc') ) ~= 7
warning('EEGLAB subfolders not found');
- end;
-end;
+ end
+end
% determine file format
% ---------------------
fileformat = 'maclinux';
comp = computer;
try
- if strcmpi(comp(1:3), 'GLN') | strcmpi(comp(1:3), 'MAC') | strcmpi(comp(1:3), 'SOL')
+ if strcmpi(comp(1:3), 'GLN') || strcmpi(comp(1:3), 'MAC') || strcmpi(comp(1:3), 'SOL')
fileformat = 'maclinux';
elseif strcmpi(comp(1:5), 'pcwin')
fileformat = 'pcwin';
- end;
-end;
+ end
+end
% add paths
% ---------
-if ~iseeglabdeployed2
+if ~isdeployed
tmp = which('eeglab_data.set');
- if ~isempty(which('eeglab_data.set')) && ~isempty(which('GSN-HydroCel-32.sfp'))
- warning backtrace off;
+ if ~isempty(which('eeglab_data.set')) && ~isempty(which('Standard-10-10-Cap47.ced'))
+ tmpWarning = warning('query', 'backtrace');
+ warning off backtrace;
warning(sprintf([ '\n\nPath Warning: It appears that you have added the path to all of the\n' ...
'subfolders to EEGLAB. This may create issues with some EEGLAB extensions\n' ...
'If EEGLAB cannot start or your experience a large number of warning\n' ...
'messages, remove all the EEGLAB paths then go to the EEGLAB folder\n' ...
'and start EEGLAB which will add all the necessary paths.\n\n' ]));
- warning backtrace on;
+ warning(tmpWarning.state, 'backtrace');
foldertorm = fileparts(which('fgetl.m'));
if ~isempty(strfind(foldertorm, 'eeglab'))
rmpath(foldertorm);
- end;
+ end
foldertorm = fileparts(which('strjoin.m'));
if ~isempty(strfind(foldertorm, 'eeglab'))
rmpath(foldertorm);
- end;
- end;
+ end
+ end
myaddpath( eeglabpath, 'eeg_checkset.m', [ 'functions' filesep 'adminfunc' ]);
myaddpath( eeglabpath, 'eeg_checkset.m', [ 'functions' filesep 'adminfunc' ]);
myaddpath( eeglabpath, ['@mmo' filesep 'mmo.m'], 'functions');
@@ -276,8 +334,7 @@
myaddpath( eeglabpath, 'statcond.m', [ 'functions' filesep 'statistics' ]);
myaddpath( eeglabpath, 'timefreq.m', [ 'functions' filesep 'timefreqfunc' ]);
myaddpath( eeglabpath, 'icademo.m', [ 'functions' filesep 'miscfunc' ]);
- myaddpath( eeglabpath, 'eeglab1020.ced', [ 'functions' filesep 'resources' ]);
- myaddpath( eeglabpath, 'startpane.m', [ 'functions' filesep 'javachatfunc' ]);
+ myaddpath( eeglabpath, 'eeglab1020.ced', [ 'functions' filesep 'supportfiles' ]);
addpathifnotinlist(fullfile(eeglabpath, 'plugins'));
eeglab_options;
@@ -285,57 +342,49 @@
path_runica = fileparts(mywhich('runica'));
if length(path_runica) > 6 && strcmpi(path_runica(end-5:end), 'fmrlab')
rmpath(path_runica);
- end;
+ end
% add path if toolboxes are missing
% ---------------------------------
- signalpath = fullfile(eeglabpath, 'functions', 'octavefunc', 'signal');
- optimpath = fullfile(eeglabpath, 'functions', 'octavefunc', 'optim');
if option_donotusetoolboxes
p1 = fileparts(mywhich('ttest'));
p2 = fileparts(mywhich('filtfilt'));
p3 = fileparts(mywhich('optimtool'));
p4 = fileparts(mywhich('gray2ind'));
- if ~isempty(p1), rmpath(p1); end;
- if ~isempty(p2), rmpath(p2); end;
- if ~isempty(p3), rmpath(p3); end;
- if ~isempty(p4), rmpath(p4); end;
- end;
- if ~license('test','signal_toolbox') || exist('pwelch') ~= 2
- warning('off', 'MATLAB:dispatcher:nameConflict');
- addpath( signalpath );
- else
- warning('off', 'MATLAB:rmpath:DirNotFound');
- rmpathifpresent( signalpath );
- rmpathifpresent(optimpath);
- warning('on', 'MATLAB:rmpath:DirNotFound');
- end;
- if ~license('test','optim_toolbox') && ~ismatlab
- addpath( optimpath );
- else
- warning('off', 'MATLAB:rmpath:DirNotFound');
- rmpathifpresent( optimpath );
- warning('on', 'MATLAB:rmpath:DirNotFound');
- end;
+ if ~isempty(p1), rmpath(p1); end
+ if ~isempty(p2), rmpath(p2); end
+ if ~isempty(p3), rmpath(p3); end
+ if ~isempty(p4), rmpath(p4); end
+ end
+
+ % remove BIOSIG path which are not needed and might cause conflicts
+ biosigp{1} = fileparts(which('sopen.m'));
+ biosigp{2} = fileparts(which('regress_eog.m'));
+ biosigp{3} = fileparts(which('DecimalFactors.txt'));
+ removepath(fileparts(fileparts(biosigp{1})), biosigp{:})
else
eeglab_options;
-end;
+end
-if nargin == 1 && strcmp(onearg, 'redraw')
- if evalin('base', 'exist(''EEG'')', '0') == 1
- evalin('base', 'eeg_global;');
- end;
-end;
+% declare the variables as global
+evalin('base', 'eeg_global;');
eeg_global;
% remove empty datasets in ALLEEG
while ~isempty(ALLEEG) && isempty(ALLEEG(end).data)
ALLEEG(end) = [];
-end;
+end
+if isempty(CURRENTSET)
+ if isequal(CURRENTSTUDY, 0)
+ CURRENTSET = 1;
+ else
+ CURRENTSET = 1:length(ALLEEG);
+ end
+end
if ~isempty(ALLEEG) && max(CURRENTSET) > length(ALLEEG)
CURRENTSET = 1;
EEG = eeg_retrieve(ALLEEG, CURRENTSET);
-end;
+end
% for the history function
% ------------------------
@@ -344,55 +393,75 @@
evalin('caller', comtmp, '');
evalin('base', 'eeg_global;');
-if nargin < 1 | exist('EEG') ~= 1
- clear global EEG ALLEEG CURRENTSET ALLCOM LASTCOM STUDY;
+if nargin < 1 || exist('EEG') ~= 1
+ EEG = [];
+ ALLEEG = [];
+ CURRENTSET = [];
+ ALLCOM = [];
+ LASTCOM = [];
+ STUDY =[];
CURRENTSTUDY = 0;
- eeg_global;
EEG = eeg_emptyset;
eegh('[ALLEEG EEG CURRENTSET ALLCOM] = eeglab;');
if ismatlab && get(0, 'screendepth') <= 8
disp('Warning: screen color depth too low, some colors will be inaccurate in time-frequency plots');
- end;
-end;
+ end
+end
+if isempty(CURRENTSTUDY) CURRENTSTUDY = 0; end
+versL = ~option_allmenus;
if nargin == 1
if strcmp(onearg, 'versions')
disp( [ 'EEGLAB v' eeg_getversion ] );
elseif strcmp(onearg, 'nogui')
- if nargout < 1, clear ALLEEG; end; % do not return output var
- return;
+ if nargout < 1, clear ALLEEG; end % do not return output var
elseif strcmp(onearg, 'redraw')
- if ~ismatlab,return; end;
W_MAIN = findobj('tag', 'EEGLAB');
if ~isempty(W_MAIN)
updatemenu;
- if nargout < 1, clear ALLEEG; end; % do not return output var
+ if nargout < 1, clear ALLEEG; end % do not return output var
return;
else
eegh('eeglab(''redraw'');');
- end;
- elseif strcmp(onearg, 'rebuild')
- if ~ismatlab,return; end;
+ end
+ elseif strcmpi(onearg, 'continuous') || strcmpi(onearg, 'cont')
+ ALLEEG = []; CURRENTSET = 0; CURRENTSTUDY = 0; STUDY = [];
+ disp('Clearing all data and loading tutorial continuous data')
+ EEG = pop_loadset(fullfile(eeglabpath, 'sample_data', 'eeglab_data.set'));
+ eeglab redraw;
+ return
+ elseif strcmp(onearg, 'epoch')
+ ALLEEG = []; CURRENTSET = 0; CURRENTSTUDY = 0; STUDY = [];
+ disp('Clearing all data and loading tutorial epoched data')
+ EEG = pop_loadset(fullfile(eeglabpath, 'sample_data', 'eeglab_data_epochs_ica.set'));
+ eeglab redraw;
+ return
+ elseif strcmp(onearg, 'rebuild')
W_MAIN = findobj('tag', 'EEGLAB');
close(W_MAIN);
- eeglab;
+ eeglab redraw;
return;
+ elseif strcmp(onearg, 'full')
+ versL = false;
else
fprintf(2,['EEGLAB Warning: Invalid argument ''' onearg '''. Restarting EEGLAB interface instead.\n']);
eegh('[ALLEEG EEG CURRENTSET ALLCOM] = eeglab(''rebuild'');');
- end;
+ end
else
onearg = 'rebuild';
-end;
+end
ALLCOM = ALLCOM;
-try, eval('colordef white;'); catch end;
+try, colordef('white'); catch end
+if versL
+ disp('Some menus items hidden. Use Preference menu to show them all.');
+end
% default option folder
% ---------------------
-if ~iseeglabdeployed2
+if ~isdeployed
eeglab_options;
fprintf('eeglab: options file is %s%seeg_options.m\n', homefolder, filesep);
-end;
+end
% checking strings
% ----------------
@@ -419,32 +488,29 @@
' eegh(''[ALLEEG EEG] = eeg_store(ALLEEG, EEG, CURRENTSET, ''''savedata'''');'');' ...
'end;' ];
-storecall = '[ALLEEG EEG] = eeg_store(ALLEEG, EEG, CURRENTSET); eegh(''[ALLEEG EEG] = eeg_store(ALLEEG, EEG, CURRENTSET);'');';
-storenewcall = '[ALLEEG EEG CURRENTSET LASTCOM] = pop_newset(ALLEEG, EEG, CURRENTSET, ''study'', ~isempty(STUDY)+0); eegh(LASTCOM);';
-storeallcall = [ 'if ~isempty(ALLEEG) & ~isempty(ALLEEG(1).data), ALLEEG = eeg_checkset(ALLEEG);' ...
- 'EEG = eeg_retrieve(ALLEEG, CURRENTSET); eegh(''ALLEEG = eeg_checkset(ALLEEG); EEG = eeg_retrieve(ALLEEG, CURRENTSET);''); end;' ];
-
+storenewcall = 'EEG = eegh(LASTCOM, EEG); [ALLEEG EEG CURRENTSET LASTCOM] = pop_newset(ALLEEG, EEG, CURRENTSET, ''study'', ~isempty(STUDY)+0); eegh(LASTCOM);';
+storecall = 'EEG = eegh(LASTCOM, EEG); [ALLEEG, EEG] = eeg_store(ALLEEG, EEG, CURRENTSET); eegh(''[ALLEEG, EEG] = eeg_store(ALLEEG, EEG, CURRENTSET);'');';
+storecall = 'EEG = eegh(LASTCOM, EEG); [ALLEEG, EEG] = eeg_store(ALLEEG, EEG, CURRENTSET);';
testeegtmp = 'if exist(''EEGTMP'') == 1, EEG = EEGTMP; clear EEGTMP; end;'; % for backward compatibility
-ifeeg = 'if ~isempty(LASTCOM) & ~isempty(EEG),';
-ifeegnh = 'if ~isempty(LASTCOM) & ~isempty(EEG) & ~isempty(findstr(''='',LASTCOM)),';
+ifeeg = 'if ~isempty(LASTCOM) && ~isempty(EEG),';
% nh = no dataset history
% -----------------------
-e_storeall_nh = [e_catch 'eegh(LASTCOM);' ifeeg storeallcall 'disp(''Done.''); end; eeglab(''redraw'');'];
-e_hist_nh = [e_catch 'eegh(LASTCOM);'];
-
-% same as above but also save history in dataset
-% ----------------------------------------------
-e_newset = [e_catch 'EEG = eegh(LASTCOM, EEG);' testeegtmp ifeeg storenewcall 'disp(''Done.''); end; eeglab(''redraw'');'];
-e_store = [e_catch 'EEG = eegh(LASTCOM, EEG);' ifeegnh storecall 'disp(''Done.''); end; eeglab(''redraw'');'];
-e_hist = [e_catch 'EEG = eegh(LASTCOM, EEG);'];
-e_histdone = [e_catch 'EEG = eegh(LASTCOM, EEG); if ~isempty(LASTCOM), disp(''Done.''); end;' ];
+e_hist_noeegh = [e_catch 'eegh(LASTCOM);'];
% study checking
% --------------
+e_check_study = 'if length(EEG) > 1 && CURRENTSTUDY == 1, STUDY = std_checkset(STUDY, ALLEEG); eegh(''STUDY = std_checkset(STUDY, ALLEEG);''); end;';
e_load_study = [e_catch 'if ~isempty(LASTCOM), STUDY = STUDYTMP; STUDY = eegh(LASTCOM, STUDY); ALLEEG = ALLEEGTMP; EEG = ALLEEG; CURRENTSET = [1:length(EEG)]; eegh(''CURRENTSTUDY = 1; EEG = ALLEEG; CURRENTSET = [1:length(EEG)];''); CURRENTSTUDY = 1; disp(''Done.''); end; clear ALLEEGTMP STUDYTMP; eeglab(''redraw'');'];
e_plot_study = [e_catch 'if ~isempty(LASTCOM), STUDY = STUDYTMP; STUDY = eegh(LASTCOM, STUDY); disp(''Done.''); end; clear ALLEEGTMP STUDYTMP; eeglab(''redraw'');']; % ALLEEG not modified
+% same as above but also save history in dataset
+% ----------------------------------------------
+e_newset = [e_catch testeegtmp 'eeglab_new;' e_check_study ];
+e_store = [e_catch 'eeglab_new;' ];
+e_hist = [e_catch 'eeglab_new;' ];
+e_histdone = [e_catch 'eeglab_new; disp(''done'');' ];
+
% build structures for plugins
% ----------------------------
trystrs.no_check = e_try;
@@ -457,54 +523,51 @@
trystrs.check_chanlocs = checkplot;
trystrs.check_epoch_chanlocs = checkepochplot;
trystrs.check_epoch_ica_chanlocs = checkepochicaplot;
-catchstrs.add_to_hist = e_hist;
+trystrs.check_ica_chanlocs = checkicaplot;
+catchstrs.add_to_hist = e_store;
catchstrs.store_and_hist = e_store;
catchstrs.new_and_hist = e_newset;
catchstrs.new_non_empty = e_newset;
catchstrs.update_study = e_plot_study;
+catchstrs.load_study = e_load_study;
% create eeglab figure
% --------------------
-javaobj = eeg_mainfig(onearg);
+if ~strcmpi(onearg, 'nogui')
+ eeg_mainfig(onearg);
+end
% detecting icalab
% ----------------
if exist('icalab')
disp('ICALAB toolbox detected (algo. added to "run ICA" interface)');
-end;
+end
-if ~iseeglabdeployed2
+if ~isdeployed
% check for older version of Fieldtrip and presence of topoplot
% -------------------------------------------------------------
- if ismatlab
- ptopoplot = fileparts(mywhich('cbar'));
- ptopoplot2 = fileparts(mywhich('topoplot'));
- if ~strcmpi(ptopoplot, ptopoplot2),
- %disp(' Warning: duplicate function topoplot.m in Fieldtrip and EEGLAB');
- %disp(' EEGLAB function will prevail and call the Fieldtrip one when appropriate');
- addpath(ptopoplot);
- end;
- end;
-end;
+ ptopoplot = fileparts(mywhich('cbar'));
+ ptopoplot2 = fileparts(mywhich('topoplot'));
+ if ~strcmpi(ptopoplot, ptopoplot2),
+ %disp(' Warning: duplicate function topoplot.m in Fieldtrip and EEGLAB');
+ %disp(' EEGLAB function will prevail and call the Fieldtrip one when appropriate');
+ addpath(ptopoplot);
+ end
+ pcheck = fileparts(mywhich('finputcheck'));
+ if ~strfind(pcheck, 'guifunc')
+ rmpath(fileparts(pcheck));
+ end
+end
cb_importdata = [ nocheck '[EEG LASTCOM] = pop_importdata;' e_newset ];
-cb_readegi = [ nocheck '[EEG LASTCOM] = pop_readegi;' e_newset ];
-cb_readsegegi = [ nocheck '[EEG LASTCOM] = pop_readsegegi;' e_newset ];
-cb_readegiepo = [ nocheck '[EEG LASTCOM] = pop_importegimat;' e_newset ];
-cb_loadbci = [ nocheck '[EEG LASTCOM] = pop_loadbci;' e_newset ];
-cb_snapread = [ nocheck '[EEG LASTCOM] = pop_snapread;' e_newset ];
-cb_loadcnt = [ nocheck '[EEG LASTCOM] = pop_loadcnt;' e_newset ];
-cb_loadeeg = [ nocheck '[EEG LASTCOM] = pop_loadeeg;' e_newset ];
cb_biosig = [ nocheck '[EEG LASTCOM] = pop_biosig; ' e_newset ];
cb_fileio = [ nocheck '[EEG LASTCOM] = pop_fileio; ' e_newset ];
-cb_fileio2 = [ nocheck '[EEG LASTCOM] = pop_fileiodir;' e_newset ];
cb_importepoch = [ checkepoch '[EEG LASTCOM] = pop_importepoch(EEG);' e_store ];
-cb_loaddat = [ checkepoch '[EEG LASTCOM]= pop_loaddat(EEG);' e_store ];
cb_importevent = [ check '[EEG LASTCOM] = pop_importevent(EEG);' e_store ];
cb_chanevent = [ check '[EEG LASTCOM]= pop_chanevent(EEG);' e_store ];
cb_importpres = [ check '[EEG LASTCOM]= pop_importpres(EEG);' e_store ];
-cb_importev2 = [ check '[EEG LASTCOM]= pop_importev2(EEG);' e_store ];
+cb_importerplab= [ check '[EEG LASTCOM]= pop_importerplab(EEG);' e_store ];
cb_export = [ check 'LASTCOM = pop_export(EEG);' e_histdone ];
cb_expica1 = [ check 'LASTCOM = pop_expica(EEG, ''weights'');' e_histdone ];
cb_expica2 = [ check 'LASTCOM = pop_expica(EEG, ''inv'');' e_histdone ];
@@ -514,21 +577,20 @@
cb_loadset = [ nocheck '[EEG LASTCOM] = pop_loadset;' e_newset];
cb_saveset = [ check '[EEG LASTCOM] = pop_saveset(EEG, ''savemode'', ''resave'');' e_store ];
cb_savesetas = [ check '[EEG LASTCOM] = pop_saveset(EEG);' e_store ];
-cb_delset = [ nocheck '[ALLEEG LASTCOM] = pop_delset(ALLEEG, -CURRENTSET);' e_hist_nh 'eeglab redraw;' ];
+cb_delset = [ nocheck '[ALLEEG LASTCOM] = pop_delset(ALLEEG, -CURRENTSET);' e_hist_noeegh 'eeglab redraw;' ];
cb_study1 = [ nocheck 'pop_stdwarn; [STUDYTMP ALLEEGTMP LASTCOM] = pop_study([], ALLEEG , ''gui'', ''on'');' e_load_study];
cb_study2 = [ nocheck 'pop_stdwarn; [STUDYTMP ALLEEGTMP LASTCOM] = pop_study([], isempty(ALLEEG), ''gui'', ''on'');' e_load_study];
cb_studyerp = [ nocheck 'pop_stdwarn; [STUDYTMP ALLEEGTMP LASTCOM] = pop_studyerp;' e_load_study];
cb_loadstudy = [ nocheck 'pop_stdwarn; [STUDYTMP ALLEEGTMP LASTCOM] = pop_loadstudy; if ~isempty(LASTCOM), STUDYTMP = std_renamestudyfiles(STUDYTMP, ALLEEGTMP); end;' e_load_study];
-cb_savestudy1 = [ check '[STUDYTMP ALLEEGTMP LASTCOM] = pop_savestudy(STUDY, EEG, ''savemode'', ''resave'');' e_load_study];
+cb_savestudy1 = [ check '[STUDYTMP ALLEEGTMP LASTCOM] = pop_savestudy(STUDY, EEG, ''savemode'', ''resavegui'');' e_load_study];
cb_savestudy2 = [ check '[STUDYTMP ALLEEGTMP LASTCOM] = pop_savestudy(STUDY, EEG);' e_load_study];
cb_clearstudy = 'LASTCOM = ''STUDY = []; CURRENTSTUDY = 0; ALLEEG = []; EEG=[]; CURRENTSET=[];''; eval(LASTCOM); eegh( LASTCOM ); eeglab redraw;';
cb_editoptions = [ nocheck 'if isfield(ALLEEG, ''nbchan''), LASTCOM = pop_editoptions(length([ ALLEEG.nbchan ]) >1);' ...
- 'else LASTCOM = pop_editoptions(0); end;' e_storeall_nh];
-cb_plugin1 = [ nocheck 'if plugin_extract(''import'', PLUGINLIST) , close(findobj(''tag'', ''EEGLAB'')); eeglab redraw; end;' e_hist_nh ];
-cb_plugin2 = [ nocheck 'if plugin_extract(''process'', PLUGINLIST), close(findobj(''tag'', ''EEGLAB'')); eeglab redraw; end;' e_hist_nh ];
+ 'else LASTCOM = pop_editoptions(0); end;' e_hist_noeegh ];
+cb_plugin = [ nocheck 'if plugin_menu(PLUGINLIST) , close(findobj(''tag'', ''EEGLAB'')); eeglab redraw; end;' e_hist_noeegh ];
-cb_saveh1 = [ nocheck 'LASTCOM = pop_saveh(EEG.history);' e_hist_nh];
-cb_saveh2 = [ nocheck 'LASTCOM = pop_saveh(ALLCOM);' e_hist_nh];
+cb_saveh1 = [ nocheck 'LASTCOM = pop_saveh(EEG.history);' e_hist_noeegh];
+cb_saveh2 = [ nocheck 'LASTCOM = pop_saveh(ALLCOM);' e_hist_noeegh];
cb_runsc = [ nocheck 'LASTCOM = pop_runscript;' e_hist ];
cb_quit = [ 'close(gcf); disp(''To save the EEGLAB command history >> pop_saveh(ALLCOM);'');' ...
'clear global EEG ALLEEG LASTCOM CURRENTSET;'];
@@ -536,40 +598,42 @@
cb_editset = [ check '[EEG LASTCOM] = pop_editset(EEG);' e_store];
cb_editeventf = [ checkevent '[EEG LASTCOM] = pop_editeventfield(EEG);' e_store];
cb_editeventv = [ checkevent '[EEG LASTCOM] = pop_editeventvals(EEG);' e_store];
-cb_comments = [ check '[EEG.comments LASTCOM] =pop_comments(EEG.comments, ''About this dataset'');' e_store];
-cb_chanedit = [ 'disp(''IMPORTANT: After importing/modifying data channels, you must close'');' ...
+cb_adjustevents= [ checkevent '[EEG LASTCOM] = pop_adjustevents(EEG);' e_store];
+cb_comments = [ check '[EEG LASTCOM] =pop_comments(EEG, ''About this dataset'');' e_store];
+cb_chanedit = [ check 'disp(''IMPORTANT: After importing/modifying data channels, you must close'');' ...
'disp(''the channel editing window for the changes to take effect in EEGLAB.'');' ...
- 'disp(''TIP: Call this function directy from the prompt, ">> pop_chanedit([]);"'');' ...
+ 'disp(''TIP: Call this function directly from the prompt, ">> pop_chanedit([]);"'');' ...
'disp('' to convert between channel location file formats'');' ...
- '[EEG TMPINFO TMP LASTCOM] = pop_chanedit(EEG); if ~isempty(LASTCOM), EEG = eeg_checkset(EEG, ''chanlocsize'');' ...
- 'clear TMPINFO TMP; EEG = eegh(LASTCOM, EEG);' storecall 'end; eeglab(''redraw'');'];
+ '[EEG TMPINFO TMP LASTCOM] = pop_chanedit(EEG); clear TMPINFO TMP; if ~isempty(LASTCOM), EEG = eeg_checkset(EEG, ''chanlocsize''); end;' ...
+ e_store ];
+ %'clear TMPINFO TMP; EEG = eegh(LASTCOM, EEG);' storecall 'end; eeglab(''redraw'');'];
cb_select = [ check '[EEG LASTCOM] = pop_select(EEG);' e_newset];
cb_rmdat = [ checkevent '[EEG LASTCOM] = pop_rmdat(EEG);' e_newset];
cb_selectevent = [ checkevent '[EEG TMP LASTCOM] = pop_selectevent(EEG); clear TMP;' e_newset ];
-cb_copyset = [ check '[ALLEEG EEG CURRENTSET LASTCOM] = pop_copyset(ALLEEG, CURRENTSET); eeglab(''redraw'');' e_hist_nh];
+cb_copyset = [ check '[ALLEEG EEG CURRENTSET LASTCOM] = pop_copyset(ALLEEG, CURRENTSET); eeglab(''redraw'');' e_hist_noeegh];
cb_mergeset = [ check '[EEG LASTCOM] = pop_mergeset(ALLEEG);' e_newset];
cb_resample = [ check '[EEG LASTCOM] = pop_resample(EEG);' e_newset];
cb_eegfilt = [ check '[EEG LASTCOM] = pop_eegfilt(EEG);' e_newset];
cb_interp = [ check '[EEG LASTCOM] = pop_interp(EEG); ' e_newset];
cb_reref = [ check '[EEG LASTCOM] = pop_reref(EEG);' e_newset];
-cb_eegplot = [ checkcont '[LASTCOM] = pop_eegplot(EEG, 1);' e_hist];
-cb_epoch = [ check '[EEG tmp LASTCOM] = pop_epoch(EEG); clear tmp;' e_newset check '[EEG LASTCOM] = pop_rmbase(EEG);' e_newset];
-cb_rmbase = [ check '[EEG LASTCOM] = pop_rmbase(EEG);' e_store];
-cb_runica = [ check '[EEG LASTCOM] = pop_runica(EEG);' e_store];
+cb_eegplot = [ check '[LASTCOM] = pop_eegplot(EEG, 1);' e_hist];
+cb_epoch = [ check '[EEG,~,LASTCOM] = pop_epoch(EEG); clear tmp;' e_newset check '[EEG LASTCOM] = pop_rmbase(EEG);' e_newset e_check_study ];
+cb_rmbase = [ check '[EEG LASTCOM] = pop_rmbase(EEG);' e_newset];
+cb_runica = [ check '[EEG LASTCOM] = pop_runica(EEG);' e_store e_check_study];
cb_subcomp = [ checkica '[EEG LASTCOM] = pop_subcomp(EEG);' e_newset];
%cb_chanrej = [ check 'pop_rejchan(EEG); LASTCOM = '''';' e_hist];
-cb_chanrej = [ check '[EEG tmp1 tmp2 LASTCOM] = pop_rejchan(EEG); clear tmp1 tmp2;' e_hist];
-cb_autorej = [ checkepoch '[EEG tmpp LASTCOM] = pop_autorej(EEG); clear tmpp;' e_hist];
-cb_rejcont = [ check '[EEG tmp1 tmp2 LASTCOM] = pop_rejcont(EEG); clear tmp1 tmp2;' e_hist];
+cb_chanrej = [ check '[EEG ~ ~ LASTCOM] = pop_rejchan(EEG);' e_hist];
+cb_autorej = [ checkepoch '[EEG ~ LASTCOM] = pop_autorej(EEG);' e_hist];
+cb_rejcont = [ check '[EEG ~ ~ LASTCOM] = pop_rejcont(EEG);' e_hist];
cb_rejmenu1 = [ check 'pop_rejmenu(EEG, 1); LASTCOM = '''';' e_hist];
cb_eegplotrej1 = [ check '[LASTCOM] = pop_eegplot(EEG, 1);' e_hist];
-cb_eegthresh1 = [ checkepoch '[TMP LASTCOM] = pop_eegthresh(EEG, 1); clear TMP;' e_hist];
+cb_eegthresh1 = [ checkepoch '[~ LASTCOM] = pop_eegthresh(EEG, 1);' e_hist];
cb_rejtrend1 = [ checkepoch '[EEG LASTCOM] = pop_rejtrend(EEG, 1);' e_store];
cb_jointprob1 = [ checkepoch '[EEG LASTCOM] = pop_jointprob(EEG, 1);' e_store];
cb_rejkurt1 = [ checkepoch '[EEG LASTCOM] = pop_rejkurt(EEG, 1);' e_store];
-cb_rejspec1 = [ checkepoch '[EEG Itmp LASTCOM] = pop_rejspec(EEG, 1); clear Itmp;' e_store];
+cb_rejspec1 = [ checkepoch '[EEG ~ LASTCOM] = pop_rejspec(EEG, 1);' e_store];
cb_rejsup1 = [ checkepochica '[EEG LASTCOM] = eeg_rejsuperpose(EEG, 1,1,1,1,1,1,1,1); eegh(LASTCOM);' ...
'LASTCOM = ''EEG.reject.icarejmanual = EEG.reject.rejglobal;''; eval(LASTCOM);' e_store ];
cb_rejsup2 = [ checkepoch '[EEG LASTCOM] = eeg_rejsuperpose(EEG, 1,1,1,1,1,1,1,1); EEG = eegh(LASTCOM, EEG);' ...
@@ -608,8 +672,8 @@
cb_headplot2 = [ checkicaplot '[EEG LASTCOM] = pop_headplot(EEG, 0);' e_store];
cb_prop2 = [ checkicaplot 'LASTCOM = pop_prop(EEG,0);' e_hist];
cb_erpimage2 = [ checkepochica 'LASTCOM = pop_erpimage(EEG, 0, eegh(''find'',''pop_erpimage(EEG,0''));' e_hist];
-cb_envtopo1 = [ checkica 'LASTCOM = pop_envtopo(EEG);' e_hist];
-cb_envtopo2 = [ checkica 'if length(ALLEEG) == 1, error(''Need at least 2 datasets''); end; LASTCOM = pop_envtopo(ALLEEG);' e_hist];
+cb_envtopo1 = [ checkicaplot 'LASTCOM = pop_envtopo(EEG);' e_hist];
+cb_envtopo2 = [ checkicaplot 'if length(ALLEEG) == 1, error(''Need at least 2 datasets''); end; LASTCOM = pop_envtopo(ALLEEG);' e_hist];
cb_plotdata2 = [ checkepochica '[tmpeeg LASTCOM] = pop_plotdata(EEG, 0); clear tmpeeg;' e_hist];
cb_comperp2 = [ checkepochica 'LASTCOM = pop_comperp(ALLEEG, 0);' e_hist];
@@ -629,6 +693,7 @@
cb_preclust = [ nocheck '[STUDYTMP ALLEEGTMP LASTCOM] = pop_preclust(STUDY, ALLEEG);' e_plot_study];
cb_clust = [ nocheck '[STUDYTMP ALLEEGTMP LASTCOM] = pop_clust(STUDY, ALLEEG);' e_plot_study];
cb_clustedit = [ nocheck 'ALLEEGTMP = ALLEEG; [STUDYTMP LASTCOM] = pop_clustedit(STUDY, ALLEEG);' e_plot_study];
+
%
% % add STUDY plugin menus
% if exist('eegplugin_stderpimage')
@@ -642,403 +707,508 @@
% menu definition
% ---------------
-if ismatlab
- % defaults
- % --------
- % startup:on
- % study:off
- % chanloc:off
- % epoch:on
- % continuous:on
-
- on = 'study:on';
- onnostudy = '';
- ondata = 'startup:off';
- onepoch = 'startup:off;continuous:off';
- ondatastudy = 'startup:off;study:on';
- onchannel = 'startup:off;chanloc:on';
- onepochchan = 'startup:off;continuous:off;chanloc:on';
- onstudy = 'startup:off;epoch:off;continuous:off;study:on';
-
+% defaults
+% --------
+% startup:on
+% study:off
+% chanloc:off
+% epoch:on
+% continuous:on
+
+on = 'study:on';
+onnostudy = '';
+ondata = 'startup:off';
+ondatanoroi = 'startup:off;roi:off';
+onepoch = 'startup:off;continuous:off';
+onepochnoroi = 'startup:off;continuous:off;roi:off';
+ondatastudy = 'startup:off;study:on';
+ondatastudynoroi = 'startup:off;study:on;roi:off';
+onchannel = 'startup:off;chanloc:on';
+onchannelnoroi = 'startup:off;chanloc:on;roi:off';
+onepochchan = 'startup:off;continuous:off;chanloc:on';
+onstudy = 'startup:off;epoch:off;continuous:off;study:on';
+onstudynoroi = 'startup:off;epoch:off;continuous:off;study:on;roi:off';
+
+if ~strcmpi(onearg, 'nogui')
W_MAIN = findobj('tag', 'EEGLAB');
EEGUSERDAT = get(W_MAIN, 'userdata');
set(W_MAIN, 'MenuBar', 'none');
- file_m = uimenu( W_MAIN, 'Label', 'File' , 'userdata', on);
- import_m = uimenu( file_m, 'Label', 'Import data' , 'userdata', onnostudy);
- neuro_m = uimenu( import_m, 'Label', 'Using EEGLAB functions and plugins' , 'tag', 'import data' , 'userdata', onnostudy);
- epoch_m = uimenu( file_m, 'Label', 'Import epoch info', 'tag', 'import epoch', 'userdata', onepoch);
- event_m = uimenu( file_m, 'Label', 'Import event info', 'tag', 'import event', 'userdata', ondata);
- exportm = uimenu( file_m, 'Label', 'Export' , 'tag', 'export' , 'userdata', ondata);
- edit_m = uimenu( W_MAIN, 'Label', 'Edit' , 'userdata', ondata);
- tools_m = uimenu( W_MAIN, 'Label', 'Tools', 'tag', 'tools' , 'userdata', ondatastudy);
- plot_m = uimenu( W_MAIN, 'Label', 'Plot', 'tag', 'plot' , 'userdata', ondata);
- loc_m = uimenu( plot_m, 'Label', 'Channel locations' , 'userdata', onchannel);
- std_m = uimenu( W_MAIN, 'Label', 'Study', 'tag', 'study' , 'userdata', onstudy);
- set_m = uimenu( W_MAIN, 'Label', 'Datasets' , 'userdata', ondatastudy);
- help_m = uimenu( W_MAIN, 'Label', 'Help' , 'userdata', on);
-
- uimenu( neuro_m, 'Label', 'From ASCII/float file or Matlab array' , 'CallBack', cb_importdata);
- %uimenu( neuro_m, 'Label', 'From Netstation .mff (FILE-IO toolbox)', 'CallBack', cb_fileio2, 'Separator', 'on');
- uimenu( neuro_m, 'Label', 'From Netstation binary simple file' , 'CallBack', cb_readegi, 'Separator', 'on');
- uimenu( neuro_m, 'Label', 'From Multiple seg. Netstation files' , 'CallBack', cb_readsegegi);
- uimenu( neuro_m, 'Label', 'From Netstation Matlab files' , 'CallBack', cb_readegiepo);
- uimenu( neuro_m, 'Label', 'From BCI2000 ASCII file' , 'CallBack', cb_loadbci, 'Separator', 'on');
- uimenu( neuro_m, 'Label', 'From Snapmaster .SMA file' , 'CallBack', cb_snapread, 'Separator', 'on');
- uimenu( neuro_m, 'Label', 'From Neuroscan .CNT file' , 'CallBack', cb_loadcnt, 'Separator', 'on');
- uimenu( neuro_m, 'Label', 'From Neuroscan .EEG file' , 'CallBack', cb_loadeeg);
+ file_m = eegmenu( false, W_MAIN, 'Label', 'File' , 'userdata', on);
+ import_m = eegmenu( false, file_m, 'Label', 'Import data' , 'userdata', onnostudy);
+ neuro_m = eegmenu( false, import_m, 'Label', 'Using EEGLAB functions and plugins' , 'tag', 'import data' , 'userdata', onnostudy);
+ epoch_m = eegmenu( false, file_m, 'Label', 'Import epoch info', 'tag', 'import epoch', 'userdata', onepoch);
+ event_m = eegmenu( false, file_m, 'Label', 'Import event info', 'tag', 'import event', 'userdata', ondata);
+ exportm = eegmenu( false, file_m, 'Label', 'Export' , 'tag', 'export' , 'userdata', ondata);
+ edit_m = eegmenu( false, W_MAIN, 'Label', 'Edit' , 'userdata', ondatastudy);
+ tools_m = eegmenu( false, W_MAIN, 'Label', 'Tools', 'tag', 'tools' , 'userdata', ondatastudy);
+ plot_m = eegmenu( false, W_MAIN, 'Label', 'Plot', 'tag', 'plot' , 'userdata', ondata);
+ loc_m = eegmenu( false, plot_m, 'Label', 'Channel locations' , 'userdata', onchannel);
+ std_m = eegmenu( false, W_MAIN, 'Label', 'Study', 'tag', 'study' , 'userdata', onstudy);
+ set_m = eegmenu( false, W_MAIN, 'Label', 'Datasets' , 'userdata', ondatastudy);
+ help_m = eegmenu( false, W_MAIN, 'Label', 'Help' , 'userdata', on);
+
+ eegmenu( false, neuro_m, 'Label', '(for more use menu File > Manage EEGLAB extensions)', 'userdata', 'enable:off');
+ eegmenu( false, neuro_m, 'Label', 'From ASCII/float file or MATLAB array' , 'CallBack', cb_importdata, 'separator', 'on');
+ %eegmenu( false, neuro_m, 'Label', 'From Netstation .mff (FILE-IO toolbox)', 'CallBack', cb_fileio2, 'Separator', 'on');
% BIOSIG MENUS
% ------------
- uimenu( neuro_m, 'Label', 'From Biosemi BDF file (BIOSIG toolbox)', 'CallBack' , cb_biosig, 'Separator', 'on');
- uimenu( neuro_m, 'Label', 'From EDF/EDF+/GDF files (BIOSIG toolbox)', 'CallBack', cb_biosig);
-
- uimenu( epoch_m, 'Label', 'From Matlab array or ASCII file' , 'CallBack', cb_importepoch);
- uimenu( epoch_m, 'Label', 'From Neuroscan .DAT file' , 'CallBack', cb_loaddat);
- uimenu( event_m, 'Label', 'From Matlab array or ASCII file' , 'CallBack', cb_importevent);
- uimenu( event_m, 'Label', 'From data channel' , 'CallBack', cb_chanevent);
- uimenu( event_m, 'Label', 'From Presentation .LOG file' , 'CallBack', cb_importpres);
- uimenu( event_m, 'Label', 'From E-Prime ASCII (text) file' , 'CallBack', cb_importevent);
- uimenu( event_m, 'Label', 'From Neuroscan .ev2 file' , 'CallBack', cb_importev2);
- uimenu( exportm, 'Label', 'Data and ICA activity to text file' , 'CallBack', cb_export);
- uimenu( exportm, 'Label', 'Weight matrix to text file' , 'CallBack', cb_expica1);
- uimenu( exportm, 'Label', 'Inverse weight matrix to text file' , 'CallBack', cb_expica2);
- uimenu( exportm, 'Label', 'Events to text file' , 'CallBack', cb_expevents);
- uimenu( exportm, 'Label', 'Data to EDF/BDF/GDF file' , 'CallBack', cb_expdata, 'separator', 'on');
-
- uimenu( file_m, 'Label', 'Load existing dataset' , 'userdata', onnostudy, 'CallBack', cb_loadset, 'Separator', 'on');
- uimenu( file_m, 'Label', 'Save current dataset(s)' , 'userdata', ondatastudy, 'CallBack', cb_saveset);
- uimenu( file_m, 'Label', 'Save current dataset as' , 'userdata', ondata, 'CallBack', cb_savesetas);
- uimenu( file_m, 'Label', 'Clear dataset(s)' , 'userdata', ondata, 'CallBack', cb_delset);
-
- std2_m = uimenu( file_m, 'Label', 'Create study' , 'userdata', on , 'Separator', 'on');
- uimenu( std2_m, 'Label', 'Using all loaded datasets' , 'userdata', ondata , 'Callback', cb_study1);
- uimenu( std2_m, 'Label', 'Browse for datasets' , 'userdata', on , 'Callback', cb_study2);
- uimenu( std2_m, 'Label', 'Simple ERP STUDY' , 'userdata', on , 'Callback', cb_studyerp);
-
- uimenu( file_m, 'Label', 'Load existing study' , 'userdata', on , 'CallBack', cb_loadstudy,'Separator', 'on' );
- uimenu( file_m, 'Label', 'Save current study' , 'userdata', onstudy, 'CallBack', cb_savestudy1);
- uimenu( file_m, 'Label', 'Save current study as' , 'userdata', onstudy, 'CallBack', cb_savestudy2);
- uimenu( file_m, 'Label', 'Clear study / Clear all' , 'userdata', ondatastudy, 'CallBack', cb_clearstudy);
- uimenu( file_m, 'Label', 'Memory and other options' , 'userdata', on , 'CallBack', cb_editoptions, 'Separator', 'on');
-
- hist_m = uimenu( file_m, 'Label', 'History scripts' , 'userdata', on , 'Separator', 'on');
- uimenu( hist_m, 'Label', 'Save dataset history script' , 'userdata', ondata , 'CallBack', cb_saveh1);
- uimenu( hist_m, 'Label', 'Save session history script' , 'userdata', ondatastudy, 'CallBack', cb_saveh2);
- uimenu( hist_m, 'Label', 'Run script' , 'userdata', on , 'CallBack', cb_runsc);
-
- plugin_m = uimenu( file_m, 'Label', 'Manage EEGLAB extensions' , 'userdata', on);
- uimenu( plugin_m, 'Label', 'Data import extensions' , 'userdata', on , 'CallBack', cb_plugin1);
- uimenu( plugin_m, 'Label', 'Data processing extensions' , 'userdata', on , 'CallBack', cb_plugin2);
-
- uimenu( file_m, 'Label', 'Quit' , 'userdata', on , 'CallBack', cb_quit, 'Separator', 'on');
-
- uimenu( edit_m, 'Label', 'Dataset info' , 'userdata', ondata, 'CallBack', cb_editset);
- uimenu( edit_m, 'Label', 'Event fields' , 'userdata', ondata, 'CallBack', cb_editeventf);
- uimenu( edit_m, 'Label', 'Event values' , 'userdata', ondata, 'CallBack', cb_editeventv);
- uimenu( edit_m, 'Label', 'About this dataset' , 'userdata', ondata, 'CallBack', cb_comments);
- uimenu( edit_m, 'Label', 'Channel locations' , 'userdata', ondata, 'CallBack', cb_chanedit);
- uimenu( edit_m, 'Label', 'Select data' , 'userdata', ondata, 'CallBack', cb_select, 'Separator', 'on');
- uimenu( edit_m, 'Label', 'Select data using events' , 'userdata', ondata, 'CallBack', cb_rmdat);
- uimenu( edit_m, 'Label', 'Select epochs or events' , 'userdata', ondata, 'CallBack', cb_selectevent);
- uimenu( edit_m, 'Label', 'Copy current dataset' , 'userdata', ondata, 'CallBack', cb_copyset, 'Separator', 'on');
- uimenu( edit_m, 'Label', 'Append datasets' , 'userdata', ondata, 'CallBack', cb_mergeset);
- uimenu( edit_m, 'Label', 'Delete dataset(s) from memory' , 'userdata', ondata, 'CallBack', cb_delset);
-
- uimenu( tools_m, 'Label', 'Change sampling rate' , 'userdata', ondatastudy, 'CallBack', cb_resample);
-
- filter_m = uimenu( tools_m, 'Label', 'Filter the data' , 'userdata', ondatastudy, 'tag', 'filter');
- uimenu( filter_m, 'Label', 'Basic FIR filter (legacy)' , 'userdata', ondatastudy, 'CallBack', cb_eegfilt);
-
- uimenu( tools_m, 'Label', 'Re-reference' , 'userdata', ondata, 'CallBack', cb_reref);
- uimenu( tools_m, 'Label', 'Interpolate electrodes' , 'userdata', ondata, 'CallBack', cb_interp);
- uimenu( tools_m, 'Label', 'Reject continuous data by eye' , 'userdata', ondata, 'CallBack', cb_eegplot);
- uimenu( tools_m, 'Label', 'Extract epochs' , 'userdata', ondata, 'CallBack', cb_epoch, 'Separator', 'on');
- uimenu( tools_m, 'Label', 'Remove baseline' , 'userdata', ondatastudy, 'CallBack', cb_rmbase);
- uimenu( tools_m, 'Label', 'Run ICA' , 'userdata', ondatastudy, 'CallBack', cb_runica, 'foregroundcolor', 'b', 'Separator', 'on');
- uimenu( tools_m, 'Label', 'Remove components' , 'userdata', ondata, 'CallBack', cb_subcomp);
- uimenu( tools_m, 'Label', 'Automatic channel rejection' , 'userdata', ondata, 'CallBack', cb_chanrej, 'Separator', 'on');
- uimenu( tools_m, 'Label', 'Automatic continuous rejection' , 'userdata', ondata, 'CallBack', cb_rejcont);
- uimenu( tools_m, 'Label', 'Automatic epoch rejection' , 'userdata', onepoch, 'CallBack', cb_autorej);
- rej_m1 = uimenu( tools_m, 'Label', 'Reject data epochs' , 'userdata', onepoch);
- rej_m2 = uimenu( tools_m, 'Label', 'Reject data using ICA' , 'userdata', ondata );
-
- uimenu( rej_m1, 'Label', 'Reject data (all methods)' , 'userdata', onepoch, 'CallBack', cb_rejmenu1);
- uimenu( rej_m1, 'Label', 'Reject by inspection' , 'userdata', onepoch, 'CallBack', cb_eegplotrej1);
- uimenu( rej_m1, 'Label', 'Reject extreme values' , 'userdata', onepoch, 'CallBack', cb_eegthresh1);
- uimenu( rej_m1, 'Label', 'Reject by linear trend/variance' , 'userdata', onepoch, 'CallBack', cb_rejtrend1);
- uimenu( rej_m1, 'Label', 'Reject by probability' , 'userdata', onepoch, 'CallBack', cb_jointprob1);
- uimenu( rej_m1, 'Label', 'Reject by kurtosis' , 'userdata', onepoch, 'CallBack', cb_rejkurt1);
- uimenu( rej_m1, 'Label', 'Reject by spectra' , 'userdata', onepoch, 'CallBack', cb_rejspec1);
- uimenu( rej_m1, 'Label', 'Export marks to ICA reject' , 'userdata', onepoch, 'CallBack', cb_rejsup1, 'separator', 'on');
- uimenu( rej_m1, 'Label', 'Reject marked epochs' , 'userdata', onepoch, 'CallBack', cb_rejsup2, 'separator', 'on', 'foregroundcolor', 'b');
- uimenu( rej_m2, 'Label', 'Reject components by map' , 'userdata', ondata , 'CallBack', cb_selectcomps);
- uimenu( rej_m2, 'Label', 'Reject data (all methods)' , 'userdata', onepoch, 'CallBack', cb_rejmenu2, 'Separator', 'on');
- uimenu( rej_m2, 'Label', 'Reject by inspection' , 'userdata', onepoch, 'CallBack', cb_eegplotrej2);
- uimenu( rej_m2, 'Label', 'Reject extreme values' , 'userdata', onepoch, 'CallBack', cb_eegthresh2);
- uimenu( rej_m2, 'Label', 'Reject by linear trend/variance' , 'userdata', onepoch, 'CallBack', cb_rejtrend2);
- uimenu( rej_m2, 'Label', 'Reject by probability' , 'userdata', onepoch, 'CallBack', cb_jointprob2);
- uimenu( rej_m2, 'Label', 'Reject by kurtosis' , 'userdata', onepoch, 'CallBack', cb_rejkurt2);
- uimenu( rej_m2, 'Label', 'Reject by spectra' , 'userdata', onepoch, 'CallBack', cb_rejspec2);
- uimenu( rej_m2, 'Label', 'Export marks to data reject' , 'userdata', onepoch, 'CallBack', cb_rejsup3, 'separator', 'on');
- uimenu( rej_m2, 'Label', 'Reject marked epochs' , 'userdata', onepoch, 'CallBack', cb_rejsup4, 'separator', 'on', 'foregroundcolor', 'b');
-
- uimenu( loc_m, 'Label', 'By name' , 'userdata', onchannel, 'CallBack', cb_topoblank1);
- uimenu( loc_m, 'Label', 'By number' , 'userdata', onchannel, 'CallBack', cb_topoblank2);
- uimenu( plot_m, 'Label', 'Channel data (scroll)' , 'userdata', ondata , 'CallBack', cb_eegplot1, 'Separator', 'on');
- uimenu( plot_m, 'Label', 'Channel spectra and maps' , 'userdata', ondata , 'CallBack', cb_spectopo1);
- uimenu( plot_m, 'Label', 'Channel properties' , 'userdata', ondata , 'CallBack', cb_prop1);
- uimenu( plot_m, 'Label', 'Channel ERP image' , 'userdata', onepoch, 'CallBack', cb_erpimage1);
-
- ERP_m = uimenu( plot_m, 'Label', 'Channel ERPs' , 'userdata', onepoch);
- uimenu( ERP_m, 'Label', 'With scalp maps' , 'CallBack', cb_timtopo);
- uimenu( ERP_m, 'Label', 'In scalp/rect. array' , 'CallBack', cb_plottopo);
-
- topo_m = uimenu( plot_m, 'Label', 'ERP map series' , 'userdata', onepochchan);
- uimenu( topo_m, 'Label', 'In 2-D' , 'CallBack', cb_topoplot1);
- uimenu( topo_m, 'Label', 'In 3-D' , 'CallBack', cb_headplot1);
- uimenu( plot_m, 'Label', 'Sum/Compare ERPs' , 'userdata', onepoch, 'CallBack', cb_comperp1);
-
- uimenu( plot_m, 'Label', 'Component activations (scroll)' , 'userdata', ondata , 'CallBack', cb_eegplot2,'Separator', 'on');
- uimenu( plot_m, 'Label', 'Component spectra and maps' , 'userdata', ondata , 'CallBack', cb_spectopo2);
-
- tica_m = uimenu( plot_m, 'Label', 'Component maps' , 'userdata', onchannel);
- uimenu( tica_m, 'Label', 'In 2-D' , 'CallBack', cb_topoplot2);
- uimenu( tica_m, 'Label', 'In 3-D' , 'CallBack', cb_headplot2);
- uimenu( plot_m, 'Label', 'Component properties' , 'userdata', ondata , 'CallBack', cb_prop2);
- uimenu( plot_m, 'Label', 'Component ERP image' , 'userdata', onepoch, 'CallBack', cb_erpimage2);
-
- ERPC_m = uimenu( plot_m, 'Label', 'Component ERPs' , 'userdata', onepoch);
- uimenu( ERPC_m, 'Label', 'With component maps' , 'CallBack', cb_envtopo1);
- uimenu( ERPC_m, 'Label', 'With comp. maps (compare)' , 'CallBack', cb_envtopo2);
- uimenu( ERPC_m, 'Label', 'In rectangular array' , 'CallBack', cb_plotdata2);
- uimenu( plot_m, 'Label', 'Sum/Compare comp. ERPs' , 'userdata', onepoch, 'CallBack', cb_comperp2);
-
- stat_m = uimenu( plot_m, 'Label', 'Data statistics', 'Separator', 'on', 'userdata', ondata );
- uimenu( stat_m, 'Label', 'Channel statistics' , 'CallBack', cb_signalstat1);
- uimenu( stat_m, 'Label', 'Component statistics' , 'CallBack', cb_signalstat2);
- uimenu( stat_m, 'Label', 'Event statistics' , 'CallBack', cb_eventstat);
-
- spec_m = uimenu( plot_m, 'Label', 'Time-frequency transforms', 'Separator', 'on', 'userdata', ondata);
- uimenu( spec_m, 'Label', 'Channel time-frequency' , 'CallBack', cb_timef1);
- uimenu( spec_m, 'Label', 'Channel cross-coherence' , 'CallBack', cb_crossf1);
- uimenu( spec_m, 'Label', 'Component time-frequency' , 'CallBack', cb_timef2,'Separator', 'on');
- uimenu( spec_m, 'Label', 'Component cross-coherence' , 'CallBack', cb_crossf2);
-
- uimenu( std_m, 'Label', 'Edit study info' , 'userdata', onstudy, 'CallBack', cb_study3);
- uimenu( std_m, 'Label', 'Select/Edit study design(s)' , 'userdata', onstudy, 'CallBack', cb_studydesign);
- uimenu( std_m, 'Label', 'Precompute channel measures' , 'userdata', onstudy, 'CallBack', cb_precomp, 'separator', 'on');
- uimenu( std_m, 'Label', 'Plot channel measures' , 'userdata', onstudy, 'CallBack', cb_chanplot);
- uimenu( std_m, 'Label', 'Precompute component measures' , 'userdata', onstudy, 'CallBack', cb_precomp2, 'separator', 'on');
- clust_m = uimenu( std_m, 'Label', 'PCA clustering (original)' , 'userdata', onstudy);
- uimenu( clust_m, 'Label', 'Build preclustering array' , 'userdata', onstudy, 'CallBack', cb_preclust);
- uimenu( clust_m, 'Label', 'Cluster components' , 'userdata', onstudy, 'CallBack', cb_clust);
- uimenu( std_m, 'Label', 'Edit/plot clusters' , 'userdata', onstudy, 'CallBack', cb_clustedit);
-
- if ~iseeglabdeployed2
- %newerVersionMenu = uimenu( help_m, 'Label', 'Upgrade to the Latest Version' , 'userdata', on, 'ForegroundColor', [0.6 0 0]);
- uimenu( help_m, 'Label', 'About EEGLAB' , 'userdata', on, 'CallBack', 'pophelp(''eeglab'');');
- uimenu( help_m, 'Label', 'About EEGLAB help' , 'userdata', on, 'CallBack', 'pophelp(''eeg_helphelp'');');
- uimenu( help_m, 'Label', 'EEGLAB menus' , 'userdata', on, 'CallBack', 'pophelp(''eeg_helpmenu'');','separator','on');
-
- help_1 = uimenu( help_m, 'Label', 'EEGLAB functions', 'userdata', on);
- uimenu( help_1, 'Label', 'Admin. functions' , 'userdata', on, 'Callback', 'pophelp(''eeg_helpadmin'');');
- uimenu( help_1, 'Label', 'Interactive pop_ functions' , 'userdata', on, 'Callback', 'pophelp(''eeg_helppop'');');
- uimenu( help_1, 'Label', 'Signal processing functions' , 'userdata', on, 'Callback', 'pophelp(''eeg_helpsigproc'');');
- uimenu( help_1, 'Label', 'Group data (STUDY) functions' , 'userdata', on, 'Callback', 'pophelp(''eeg_helpstudy'');');
- uimenu( help_1, 'Label', 'Time-frequency functions' , 'userdata', on, 'Callback', 'pophelp(''eeg_helptimefreq'');');
- uimenu( help_1, 'Label', 'Statistical functions' , 'userdata', on, 'Callback', 'pophelp(''eeg_helpstatistics'');');
- uimenu( help_1, 'Label', 'Graphic interface builder functions' , 'userdata', on, 'Callback', 'pophelp(''eeg_helpgui'');');
- uimenu( help_1, 'Label', 'Misc. command line functions' , 'userdata', on, 'Callback', 'pophelp(''eeg_helpmisc'');');
-
- uimenu( help_m, 'Label', 'EEGLAB license' , 'userdata', on, 'CallBack', 'pophelp(''eeglablicense.txt'', 1);');
+ eegmenu( false, neuro_m, 'Label', 'From Biosemi BDF file (BIOSIG toolbox)', 'CallBack' , cb_biosig, 'Separator', 'on');
+ eegmenu( false, neuro_m, 'Label', 'From EDF/EDF+/GDF files (BIOSIG toolbox)', 'CallBack', cb_biosig);
+
+ eegmenu( false, epoch_m, 'Label', 'From MATLAB array or ASCII file' , 'CallBack', cb_importepoch);
+ eegmenu( false, event_m, 'Label', 'From MATLAB array or ASCII file' , 'CallBack', cb_importevent);
+ eegmenu( false, event_m, 'Label', 'From data channel' , 'CallBack', cb_chanevent);
+ eegmenu( false, event_m, 'Label', 'From Presentation .LOG file' , 'CallBack', cb_importpres);
+ eegmenu( false, event_m, 'Label', 'From E-Prime ASCII (text) file' , 'CallBack', cb_importevent);
+ eegmenu( false, event_m, 'Label', 'From ERPLAB text files' , 'CallBack', cb_importerplab);
+
+ eegmenu( false, exportm, 'Label', '(for more use menu File > Manage EEGLAB extensions)', 'userdata', 'enable:off');
+ eegmenu( false, exportm, 'Label', 'Data and ICA activity to text file' , 'CallBack', cb_export, 'separator', 'on');
+ eegmenu( false, exportm, 'Label', 'Weight matrix to text file' , 'CallBack', cb_expica1);
+ eegmenu( false, exportm, 'Label', 'Inverse weight matrix to text file' , 'CallBack', cb_expica2);
+ eegmenu( false, exportm, 'Label', 'Events to text file' , 'CallBack', cb_expevents);
+ eegmenu( false, exportm, 'Label', 'Data to EDF/BDF/GDF file' , 'CallBack', cb_expdata, 'separator', 'on');
+
+ eegmenu( false, file_m, 'Label', 'Load existing dataset' , 'userdata', onnostudy, 'CallBack', cb_loadset, 'Separator', 'on');
+ eegmenu( false, file_m, 'Label', 'Resave current dataset(s)' , 'userdata', ondatastudy, 'CallBack', cb_saveset);
+ eegmenu( false, file_m, 'Label', 'Save current dataset as' , 'userdata', ondata, 'CallBack', cb_savesetas);
+ eegmenu( false, file_m, 'Label', 'Clear dataset(s)' , 'userdata', ondata, 'CallBack', cb_delset);
+
+ std2_m = eegmenu( false, file_m, 'Label', 'Create study' , 'userdata', on , 'Separator', 'on');
+ eegmenu( false, std2_m, 'Label', 'Using all loaded datasets' , 'userdata', ondata , 'Callback', cb_study1);
+ eegmenu( false, std2_m, 'Label', 'Browse for datasets' , 'userdata', on , 'Callback', cb_study2);
+ eegmenu( false, std2_m, 'Label', 'Simple ERP STUDY' , 'userdata', on , 'Callback', cb_studyerp);
+
+ eegmenu( false, file_m, 'Label', 'Load existing study' , 'userdata', on , 'CallBack', cb_loadstudy,'Separator', 'on' );
+ eegmenu( false, file_m, 'Label', 'Save current study' , 'userdata', onstudy, 'CallBack', cb_savestudy1);
+ eegmenu( false, file_m, 'Label', 'Save current study as' , 'userdata', onstudy, 'CallBack', cb_savestudy2);
+ eegmenu( false, file_m, 'Label', 'Clear study / Clear all' , 'userdata', ondatastudy, 'CallBack', cb_clearstudy);
+ eegmenu( false, file_m, 'Label', 'Preferences' , 'userdata', on , 'CallBack', cb_editoptions, 'Separator', 'on');
+
+ hist_m = eegmenu( false, file_m, 'Label', 'History scripts' , 'userdata', on , 'Separator', 'on');
+ eegmenu( false, hist_m, 'Label', 'Save dataset history script' , 'userdata', ondata , 'CallBack', cb_saveh1);
+ eegmenu( false, hist_m, 'Label', 'Save session history script' , 'userdata', ondatastudy, 'CallBack', cb_saveh2);
+ eegmenu( false, hist_m, 'Label', 'Run script' , 'userdata', on , 'CallBack', cb_runsc);
+ if isdeployed
+ eegmenu( false, hist_m, 'Label', 'Test compiled version' , 'userdata', on , 'CallBack', @test_compiled_version);
+ end
+
+ if ~isdeployed
+ eegmenu( false, file_m, 'Label', 'Manage EEGLAB extensions' , 'userdata', on, 'CallBack', cb_plugin);
+ end
+ eegmenu( false, file_m, 'Label', 'Quit' , 'userdata', on , 'CallBack', cb_quit, 'Separator', 'on');
+
+ eegmenu( false, edit_m, 'Label', 'Dataset info' , 'userdata', ondata, 'CallBack', cb_editset);
+ eegmenu( versL, edit_m, 'Label', 'Event fields' , 'userdata', ondata, 'CallBack', cb_editeventf);
+ eegmenu( false, edit_m, 'Label', 'Event values' , 'userdata', ondata, 'CallBack', cb_editeventv);
+ eegmenu( versL, edit_m, 'Label', 'Adjust event latencies' , 'userdata', ondata, 'CallBack', cb_adjustevents);
+ eegmenu( false, edit_m, 'Label', 'About this dataset' , 'userdata', ondata, 'CallBack', cb_comments);
+ eegmenu( false, edit_m, 'Label', 'Channel locations' , 'userdata', ondatastudy, 'CallBack', cb_chanedit);
+ eegmenu( false, edit_m, 'Label', 'Select data' , 'userdata', ondatastudy, 'CallBack', cb_select, 'Separator', 'on');
+ eegmenu( false, edit_m, 'Label', 'Select data using events' , 'userdata', ondata, 'CallBack', cb_rmdat);
+ eegmenu( false, edit_m, 'Label', 'Select epochs or events' , 'userdata', ondata, 'CallBack', cb_selectevent);
+ eegmenu( false, edit_m, 'Label', 'Copy current dataset' , 'userdata', ondata, 'CallBack', cb_copyset, 'Separator', 'on');
+ eegmenu( false, edit_m, 'Label', 'Append datasets' , 'userdata', ondata, 'CallBack', cb_mergeset);
+ eegmenu( false, edit_m, 'Label', 'Delete dataset(s) from memory' , 'userdata', ondata, 'CallBack', cb_delset);
+
+ eegmenu(~versL, tools_m, 'Label', '(Expand tool choices via "File > Preferences")' , 'userdata', 'enable:off');
+ eegmenu( false, tools_m, 'Label', 'Change sampling rate' , 'userdata', ondatastudy, 'CallBack', cb_resample, 'Separator', 'on');
+
+ filter_m = eegmenu( false, tools_m, 'Label', 'Filter the data' , 'userdata', ondatastudy, 'tag', 'filter');
+ eegmenu( false, filter_m, 'Label', 'Basic FIR filter (legacy)' , 'userdata', ondatastudy, 'CallBack', cb_eegfilt);
+
+ eegmenu( false, tools_m, 'Label', 'Re-reference the data' , 'userdata', ondatastudy, 'CallBack', cb_reref);
+ eegmenu( false, tools_m, 'Label', 'Interpolate electrodes' , 'userdata', ondata, 'CallBack', cb_interp);
+ eegmenu( false, tools_m, 'Label', 'Inspect/reject data by eye' , 'userdata', ondata, 'CallBack', cb_eegplot, 'Separator', 'on');
+ eegmenu( versL, tools_m, 'Label', 'Automatic channel rejection' , 'userdata', ondata, 'CallBack', cb_chanrej);
+ eegmenu( versL, tools_m, 'Label', 'Automatic continuous rejection' , 'userdata', ondata, 'CallBack', cb_rejcont);
+ eegmenu( versL, tools_m, 'Label', 'Automatic epoch rejection' , 'userdata', onepoch, 'CallBack', cb_autorej);
+ eegmenu( false, tools_m, 'Label', 'Decompose data by ICA' , 'userdata', ondatastudynoroi, 'CallBack', cb_runica, 'Separator', 'on');
+ rej_m1 = eegmenu( versL, tools_m, 'Label', 'Reject data epochs' , 'userdata', onepoch);
+ rej_m2 = eegmenu( versL, tools_m, 'Label', 'Reject data using ICA' , 'userdata', ondata );
+
+ eegmenu( versL, rej_m1, 'Label', 'Reject data (all methods)' , 'userdata', onepoch, 'CallBack', cb_rejmenu1);
+ eegmenu( versL, rej_m1, 'Label', 'Reject by inspection' , 'userdata', onepoch, 'CallBack', cb_eegplotrej1);
+ eegmenu( versL, rej_m1, 'Label', 'Reject extreme values' , 'userdata', onepoch, 'CallBack', cb_eegthresh1);
+ eegmenu( versL, rej_m1, 'Label', 'Reject by linear trend/variance' , 'userdata', onepoch, 'CallBack', cb_rejtrend1);
+ eegmenu( versL, rej_m1, 'Label', 'Reject by probability' , 'userdata', onepoch, 'CallBack', cb_jointprob1);
+ eegmenu( versL, rej_m1, 'Label', 'Reject by kurtosis' , 'userdata', onepoch, 'CallBack', cb_rejkurt1);
+ eegmenu( versL, rej_m1, 'Label', 'Reject by spectra' , 'userdata', onepoch, 'CallBack', cb_rejspec1);
+ eegmenu( versL, rej_m1, 'Label', 'Export marks to ICA reject' , 'userdata', onepoch, 'CallBack', cb_rejsup1, 'separator', 'on');
+ eegmenu( versL, rej_m1, 'Label', 'Reject marked epochs' , 'userdata', onepoch, 'CallBack', cb_rejsup2, 'separator', 'on', 'foregroundcolor', 'b');
+ eegmenu(~versL, tools_m,'Label', 'Inspect/label components by map' , 'userdata', ondata , 'CallBack', cb_selectcomps);
+ eegmenu( versL, rej_m2, 'Label', 'Reject components by map' , 'userdata', ondata , 'CallBack', cb_selectcomps);
+ eegmenu( versL, rej_m2, 'Label', 'Reject data (all methods)' , 'userdata', onepoch, 'CallBack', cb_rejmenu2, 'Separator', 'on');
+ eegmenu( versL, rej_m2, 'Label', 'Reject by inspection' , 'userdata', onepoch, 'CallBack', cb_eegplotrej2);
+ eegmenu( versL, rej_m2, 'Label', 'Reject extreme values' , 'userdata', onepoch, 'CallBack', cb_eegthresh2);
+ eegmenu( versL, rej_m2, 'Label', 'Reject by linear trend/variance' , 'userdata', onepoch, 'CallBack', cb_rejtrend2);
+ eegmenu( versL, rej_m2, 'Label', 'Reject by probability' , 'userdata', onepoch, 'CallBack', cb_jointprob2);
+ eegmenu( versL, rej_m2, 'Label', 'Reject by kurtosis' , 'userdata', onepoch, 'CallBack', cb_rejkurt2);
+ eegmenu( versL, rej_m2, 'Label', 'Reject by spectra' , 'userdata', onepoch, 'CallBack', cb_rejspec2);
+ eegmenu( versL, rej_m2, 'Label', 'Export marks to data reject' , 'userdata', onepoch, 'CallBack', cb_rejsup3, 'separator', 'on');
+ eegmenu( versL, rej_m2, 'Label', 'Reject marked epochs' , 'userdata', onepoch, 'CallBack', cb_rejsup4, 'separator', 'on', 'foregroundcolor', 'b');
+
+ eegmenu( false, tools_m, 'Label', 'Remove components from data' , 'userdata', ondatastudy, 'CallBack', cb_subcomp );
+ eegmenu( false, tools_m, 'Label', 'Extract epochs' , 'userdata', ondatastudy , 'CallBack', cb_epoch, 'Separator', 'on');
+ eegmenu( false, tools_m, 'Label', 'Remove epoch baseline' , 'userdata', ondatastudy , 'CallBack', cb_rmbase);
+
+ eegmenu( false, loc_m, 'Label', 'By name' , 'userdata', onchannel, 'CallBack', cb_topoblank1);
+ eegmenu( false, loc_m, 'Label', 'By number' , 'userdata', onchannel, 'CallBack', cb_topoblank2);
+ eegmenu( false, plot_m, 'Label', 'Channel data (scroll)' , 'userdata', ondata , 'CallBack', cb_eegplot1, 'Separator', 'on');
+ eegmenu( false, plot_m, 'Label', 'Channel spectra and maps' , 'userdata', ondata , 'CallBack', cb_spectopo1);
+ eegmenu( false, plot_m, 'Label', 'Channel properties' , 'userdata', ondata , 'CallBack', cb_prop1);
+ eegmenu( false, plot_m, 'Label', 'Channel ERP image' , 'userdata', onepoch, 'CallBack', cb_erpimage1);
+
+ ERP_m = eegmenu( false, plot_m, 'Label', 'Channel ERPs' , 'userdata', onepoch);
+ eegmenu( false, ERP_m, 'Label', 'With scalp maps' , 'CallBack', cb_timtopo);
+ eegmenu( false, ERP_m, 'Label', 'In scalp/rect. array' , 'CallBack', cb_plottopo);
+
+ topo_m = eegmenu( false, plot_m, 'Label', 'ERP map series' , 'userdata', onepochchan);
+ eegmenu( false, topo_m, 'Label', 'In 2-D' , 'CallBack', cb_topoplot1);
+ eegmenu( false, topo_m, 'Label', 'In 3-D' , 'CallBack', cb_headplot1);
+ eegmenu( versL, plot_m, 'Label', 'Sum/Compare ERPs' , 'userdata', onepoch, 'CallBack', cb_comperp1);
+ eegmenu(~versL, plot_m, 'Label', 'Channel time-frequency' , 'CallBack', cb_timef1);
+
+ eegmenu( false, plot_m, 'Label', 'Component activations (scroll)' , 'userdata', ondata , 'CallBack', cb_eegplot2,'Separator', 'on');
+ eegmenu( false, plot_m, 'Label', 'Component spectra and maps' , 'userdata', ondatanoroi, 'CallBack', cb_spectopo2);
+
+ tica_m = eegmenu( false, plot_m, 'Label', 'Component maps' , 'userdata', onchannelnoroi);
+ eegmenu( false, tica_m, 'Label', 'In 2-D' , 'CallBack', cb_topoplot2);
+ eegmenu( false, tica_m, 'Label', 'In 3-D' , 'CallBack', cb_headplot2);
+ eegmenu( false, plot_m, 'Label', 'Component properties' , 'userdata', ondata , 'CallBack', cb_prop2);
+ eegmenu( false, plot_m, 'Label', 'Component ERP image' , 'userdata', onepoch, 'CallBack', cb_erpimage2);
+
+ ERPC_m = eegmenu( false, plot_m, 'Label', 'Component ERPs' , 'userdata', onepoch);
+ eegmenu( false, ERPC_m, 'Label', 'With component maps' , 'userdata', onepochnoroi, 'CallBack', cb_envtopo1);
+ eegmenu( false, ERPC_m, 'Label', 'With comp. maps (compare)' , 'userdata', onepochnoroi, 'CallBack', cb_envtopo2);
+ eegmenu( false, ERPC_m, 'Label', 'In rectangular array' , 'userdata', onepoch , 'CallBack', cb_plotdata2);
+ eegmenu( versL, plot_m, 'Label', 'Sum/Compare comp. ERPs' , 'userdata', onepochnoroi, 'userdata', onepoch, 'CallBack', cb_comperp2);
+
+ stat_m = eegmenu( versL, plot_m, 'Label', 'Data statistics', 'Separator', 'on', 'userdata', ondata );
+ eegmenu( versL, stat_m, 'Label', 'Channel statistics' , 'CallBack', cb_signalstat1);
+ eegmenu( versL, stat_m, 'Label', 'Component statistics' , 'CallBack', cb_signalstat2);
+ eegmenu( versL, stat_m, 'Label', 'Event statistics' , 'CallBack', cb_eventstat);
+
+ spec_m = eegmenu( versL, plot_m, 'Label', 'Time-frequency transforms', 'Separator', 'on', 'userdata', ondata);
+ eegmenu( versL, spec_m, 'Label', 'Channel time-frequency' , 'CallBack', cb_timef1);
+ eegmenu( versL, spec_m, 'Label', 'Channel cross-coherence' , 'CallBack', cb_crossf1);
+ eegmenu( versL, spec_m, 'Label', 'Component time-frequency' , 'CallBack', cb_timef2,'Separator', 'on');
+ eegmenu( versL, spec_m, 'Label', 'Component cross-coherence' , 'CallBack', cb_crossf2);
+ eegmenu(~versL, plot_m, 'Label', 'Component time-frequency' , 'CallBack', cb_timef2);
+
+ eegmenu( false, std_m, 'Label', 'Edit study info' , 'userdata', onstudy, 'CallBack', cb_study3);
+ eegmenu( false, std_m, 'Label', 'Select/Edit study design(s)' , 'userdata', onstudy, 'CallBack', cb_studydesign);
+ eegmenu( false, std_m, 'Label', 'Precompute channel measures' , 'userdata', onstudy, 'CallBack', cb_precomp, 'separator', 'on');
+ eegmenu( false, std_m, 'Label', 'Plot channel measures' , 'userdata', onstudy, 'CallBack', cb_chanplot);
+ eegmenu( false, std_m, 'Label', 'Precompute component measures' , 'userdata', onstudy, 'CallBack', cb_precomp2, 'separator', 'on');
+ clust_m = eegmenu( false, std_m, 'Label', 'PCA clustering (original)' , 'userdata', onstudynoroi);
+ eegmenu( false, clust_m, 'Label', 'Build preclustering array' , 'userdata', onstudynoroi, 'CallBack', cb_preclust);
+ eegmenu( false, clust_m, 'Label', 'Cluster components' , 'userdata', onstudynoroi, 'CallBack', cb_clust);
+ eegmenu( false, std_m, 'Label', 'Edit/plot component clusters' , 'userdata', onstudy, 'CallBack', cb_clustedit);
+
+ if ~isdeployed && ismatlab
+ %newerVersionMenu = eegmenu( false, help_m, 'Label', 'Upgrade to the Latest Version' , 'userdata', on, 'ForegroundColor', [0.6 0 0]);
+ eegmenu( false, help_m, 'Label', 'About EEGLAB' , 'userdata', on, 'CallBack', 'pophelp(''eeglab'');');
+ eegmenu( false, help_m, 'Label', 'Check for EEGLAB update' , 'userdata', on, 'CallBack', 'eeglab_update;');
+ eegmenu( false, help_m, 'Label', 'About EEGLAB help' , 'userdata', on, 'CallBack', 'pophelp(''eeg_helphelp'');');
+ eegmenu( false, help_m, 'Label', 'EEGLAB menus' , 'userdata', on, 'CallBack', 'pophelp(''eeg_helpmenu'');','separator','on');
+
+ help_1 = eegmenu( false, help_m, 'Label', 'EEGLAB functions', 'userdata', on);
+ eegmenu( false, help_1, 'Label', 'Admin. functions' , 'userdata', on, 'Callback', 'pophelp(''eeg_helpadmin'');');
+ eegmenu( false, help_1, 'Label', 'Interactive pop_ functions' , 'userdata', on, 'Callback', 'pophelp(''eeg_helppop'');');
+ eegmenu( false, help_1, 'Label', 'Signal processing functions' , 'userdata', on, 'Callback', 'pophelp(''eeg_helpsigproc'');');
+ eegmenu( false, help_1, 'Label', 'Group data (STUDY) functions' , 'userdata', on, 'Callback', 'pophelp(''eeg_helpstudy'');');
+ eegmenu( false, help_1, 'Label', 'Time-frequency functions' , 'userdata', on, 'Callback', 'pophelp(''eeg_helptimefreq'');');
+ eegmenu( false, help_1, 'Label', 'Statistical functions' , 'userdata', on, 'Callback', 'pophelp(''eeg_helpstatistics'');');
+ eegmenu( false, help_1, 'Label', 'Graphic interface builder functions' , 'userdata', on, 'Callback', 'pophelp(''eeg_helpgui'');');
+ eegmenu( false, help_1, 'Label', 'Misc. command line functions' , 'userdata', on, 'Callback', 'pophelp(''eeg_helpmisc'');');
+
+ eegmenu( false, help_m, 'Label', 'EEGLAB license' , 'userdata', on, 'CallBack', 'pophelp(''eeglablicense.txt'', 1);');
+ eegmenu( false, help_m, 'Label', 'EEGLAB tutorial' , 'userdata', on, 'CallBack', 'tutorial;', 'Separator', 'on');
+ eegmenu( false, help_m, 'Label', 'Email the EEGLAB team' , 'userdata', on, 'CallBack', 'web(''mailto:eeglab@sccn.ucsd.edu'');');
else
- uimenu( help_m, 'Label', 'About EEGLAB' , 'userdata', on, 'CallBack', 'abouteeglab;');
- uimenu( help_m, 'Label', 'EEGLAB license' , 'userdata', on, 'CallBack', 'pophelp(''eeglablicense.txt'', 1);');
- end;
-
- uimenu( help_m, 'Label', 'EEGLAB tutorial' , 'userdata', on, 'CallBack', 'tutorial;', 'Separator', 'on');
- uimenu( help_m, 'Label', 'Email the EEGLAB team' , 'userdata', on, 'CallBack', 'web(''mailto:eeglab@sccn.ucsd.edu'');');
-end;
-
-if iseeglabdeployed2
- disp('Adding FIELDTRIP toolbox functions');
- disp('Adding BIOSIG toolbox functions');
- disp('Adding FILE-IO toolbox functions');
- funcname = { 'eegplugin_VisEd' ...
- 'eegplugin_eepimport' ...
- 'eegplugin_bdfimport' ...
- 'eegplugin_brainmovie' ...
- 'eegplugin_bva_io' ...
- 'eegplugin_ctfimport' ...
- 'eegplugin_dipfit' ...
- 'eegplugin_erpssimport' ...
- 'eegplugin_fmrib' ...
- 'eegplugin_iirfilt' ...
- 'eegplugin_ascinstep' ...
- 'eegplugin_loreta' ...
- 'eegplugin_miclust' ...
- 'eegplugin_4dneuroimaging' };
+ eegmenu( false, help_m, 'Label', 'About EEGLAB' , 'userdata', on, 'CallBack', 'abouteeglab;');
+ eegmenu( false, help_m, 'Label', 'EEGLAB license' , 'userdata', on, 'CallBack', 'pophelp(''eeglablicense.txt'', 1);');
+ eegmenu( false, help_m, 'Label', 'EEGLAB tutorial' , 'userdata', on, 'CallBack', 'tutorial;', 'Separator', 'on');
+ end
+
+end
+
+statusconnection = 1;
+eeglabVersionStatus = [];
+if isdeployed || (exist('ismcc') && ismcc)
+ disp('Loading plugins');
+ funcname = { ...
+ @eegplugin_eepimport, ...
+ @eegplugin_iclabel, ...
+ @eegplugin_VisEd, ...
+ @eegplugin_bids, ...
+ @eegplugin_bva_io, ...
+ @eegplugin_clean_rawdata, ...
+ @eegplugin_dipfit, ...
+ @eegplugin_egilegacy, ...
+ @eegplugin_firfilt, ...
+ @eegplugin_iirfilt, ...
+ @eegplugin_musedirect, ...
+ @eegplugin_musemonitor, ...
+ @eegplugin_neuroscanio, ...
+ @eegplugin_scd, ...
+ @eegplugin_snapmaster, ...
+ @eegplugin_xdfimport, ...
+ @eegplugin_mffmatlabio, ...
+ };
for indf = 1:length(funcname)
- try
- vers = feval(funcname{indf}, gcf, trystrs, catchstrs);
- disp(['EEGLAB: adding "' vers '" plugin' ]);
- catch
- feval(funcname{indf}, gcf, trystrs, catchstrs);
- disp(['EEGLAB: adding plugin function "' funcname{indf} '"' ]);
- end;
- end;
+ pluginfun = funcname{indf};
+ pluginname = func2str(pluginfun);
+ try
+ outargs = nargout(pluginfun);
+ if outargs == 1
+ vers = feval(pluginfun, gcf, trystrs, catchstrs);
+ disp(['EEGLAB: adding "' vers '" plugin' ]);
+ else
+ feval(funcname{indf}, gcf, trystrs, catchstrs);
+ disp(['EEGLAB: adding plugin function "' pluginname '"' ]);
+ end
+ catch e
+ disp(['EEGLAB: Could not load "' pluginname '": ' e.message]);
+ end
+ end
else
pluginlist = [];
plugincount = 1;
- p = mywhich('eeglab.m');
- p = p(1:findstr(p,'eeglab.m')-1);
- if strcmpi(p, './') || strcmpi(p, '.\'), p = [ pwd filesep ]; end;
+ eeglabp = fileparts(mywhich('eeglab.m'));
+
+ % scan plugin folder
+ % ------------------
+ dircontent = dir(fullfile(eeglabp, 'plugins'));
+ if ~isfield(dircontent, 'folder')
+ [dircontent(:).folder] = deal(fullfile(eeglabp, 'plugins'));
+ end
- % scan deactivated plugin folder
- % ------------------------------
- dircontent = dir(fullfile(p, 'deactivatedplugins'));
- dircontent = { dircontent.name };
- for index = 1:length(dircontent)
- funcname = '';
- pluginVersion = '';
- if exist([p 'deactivatedplugins' filesep dircontent{index}]) == 7
- if ~strcmpi(dircontent{index}, '.') & ~strcmpi(dircontent{index}, '..')
- tmpdir = dir([ p 'deactivatedplugins' filesep dircontent{index} filesep 'eegplugin*.m' ]);
- [ pluginName pluginVersion ] = parsepluginname(dircontent{index});
- if ~isempty(tmpdir)
- funcname = tmpdir(1).name(1:end-2);
- end;
- end;
- else
- if ~isempty(findstr(dircontent{index}, 'eegplugin')) && dircontent{index}(end) == 'm'
- funcname = dircontent{index}(1:end-2); % remove .m
- [ pluginName pluginVersion ] = parsepluginname(dircontent{index}(10:end-2));
- end;
- end;
- if ~isempty(pluginVersion)
- pluginlist(plugincount).plugin = pluginName;
- pluginlist(plugincount).version = pluginVersion;
- pluginlist(plugincount).foldername = dircontent{index};
- if ~isempty(funcname)
- pluginlist(plugincount).funcname = funcname(10:end);
- else pluginlist(plugincount).funcname = '';
+ % scan local plugin folder
+ % ------------------------
+ if ~isequal(pwd, eeglabp)
+ dircontent2 = dir(fullfile(pwd, 'plugins'));
+ if ~isempty(dircontent2)
+ fprintf(2, 'WARNING: plugins in current folders may shadow plugins installed in EEGLAB plugins folder\n');
+ if ~isfield(dircontent2, 'folder')
+ [dircontent2(:).folder] = deal(fullfile(pwd, 'plugins'));
end
- if length(pluginlist(plugincount).funcname) > 1 && pluginlist(plugincount).funcname(1) == '_'
- pluginlist(plugincount).funcname(1) = [];
- end;
- pluginlist(plugincount).status = 'deactivated';
- plugincount = plugincount+1;
- end;
- end;
+ dircontent = [dircontent;dircontent2];
+ end
+ end
+
+ pluginstats = [];
+ if option_checkversion && ismatlab
+ disp('Retrieving plugin versions from server...');
+ try
+ [pluginTmp, eeglabVersionStatus] = plugin_getweb('startup', pluginlist);
+ catch
+ disp('Issue with retrieving statistics for extensions');
+ pluginTmp = [];
+ end
+ if ~isempty(pluginTmp) && isfield(pluginTmp, 'name') && isfield(pluginTmp, 'version')
+ pluginstats.name = { pluginTmp.name };
+ pluginstats.version = { pluginTmp.version };
+ end
+ end
- % scan plugin folder
- % ------------------
- dircontent = dir(fullfile(p, 'plugins'));
- dircontent = { dircontent.name };
for index = 1:length(dircontent)
% find function
% -------------
funcname = '';
pluginVersion = [];
- if exist([p 'plugins' filesep dircontent{index}]) == 7
- if ~strcmpi(dircontent{index}, '.') & ~strcmpi(dircontent{index}, '..')
- newpath = [ 'plugins' filesep dircontent{index} ];
- tmpdir = dir([ p 'plugins' filesep dircontent{index} filesep 'eegplugin*.m' ]);
+ if exist(fullfile(dircontent(index).folder, dircontent(index).name), 'dir')
+ if ~strcmpi(dircontent(index).name, '.') && ~strcmpi(dircontent(index).name, '..')
+ tmpdir = dir(fullfile(dircontent(index).folder, dircontent(index).name, 'eegplugin*.m'));
- addpathifnotinlist(fullfile(eeglabpath, newpath));
- [ pluginName pluginVersion ] = parsepluginname(dircontent{index});
if ~isempty(tmpdir)
%myaddpath(eeglabpath, tmpdir(1).name, newpath);
funcname = tmpdir(1).name(1:end-2);
- end;
+ end
+ addpathifnotinlist(fullfile(dircontent(index).folder, dircontent(index).name));
+ [ pluginName, pluginVersion ] = parsepluginname(dircontent(index).name, funcname(11:end));
% special case of subfolder for Fieldtrip
% ---------------------------------------
- if ~isempty(findstr(lower(dircontent{index}), 'fieldtrip'))
- addpathifnotexist( fullfile(eeglabpath, newpath, 'compat') , 'electrodenormalize' );
- addpathifnotexist( fullfile(eeglabpath, newpath, 'forward'), 'ft_sourcedepth.m');
- addpathifnotexist( fullfile(eeglabpath, newpath, 'utilities'), 'ft_datatype.m');
+ if ~isempty(findstr(lower(dircontent(index).name), 'fieldtrip')) && isempty(findstr(lower(dircontent(index).name), 'rest'))
+ addpathifnotexist( fullfile(dircontent(index).folder, dircontent(index).name, 'compat') , 'electrodenormalize' );
+ addpathifnotexist( fullfile(dircontent(index).folder, dircontent(index).name, 'forward'), 'ft_sourcedepth.m');
+ addpathifnotexist( fullfile(dircontent(index).folder, dircontent(index).name, 'utilities'), 'ft_datatype.m');
+ addpathifnotexist( fullfile(dircontent(index).folder, dircontent(index).name, 'plotting'), 'ft_plot_mesh.m');
ptopoplot = fileparts(mywhich('cbar'));
ptopoplot2 = fileparts(mywhich('topoplot'));
if ~isequal(ptopoplot, ptopoplot2)
addpath(ptopoplot);
- end;
- end;
+ end
+ end
% special case of subfolder for BIOSIG
% ------------------------------------
- if ~isempty(findstr(lower(dircontent{index}), 'biosig')) && isempty(findstr(lower(dircontent{index}), 'biosigplot'))
- addpathifnotexist( fullfile(eeglabpath, newpath, 'biosig', 't200_FileAccess'), 'sopen.m');
- addpathifnotexist( fullfile(eeglabpath, newpath, 'biosig', 't250_ArtifactPreProcessingQualityControl'), 'regress_eog.m' );
- addpathifnotexist( fullfile(eeglabpath, newpath, 'biosig', 'doc'), 'DecimalFactors.txt');
- end;
+ if ~isempty(findstr(lower(dircontent(index).name), 'biosig')) && isempty(strfind(lower(dircontent(index).name), 'biosigplot'))
+ addpathifnotexist( fullfile(dircontent(index).folder, dircontent(index).name, 'biosig', 't200_FileAccess'), 'sopen.m');
+ addpathifnotexist( fullfile(dircontent(index).folder, dircontent(index).name, 'biosig', 't250_ArtifactPreProcessingQualityControl'), 'regress_eog.m' );
+ addpathifnotexist( fullfile(dircontent(index).folder, dircontent(index).name, 'biosig', 'doc'), 'DecimalFactors.txt');
+ end
- end;
+ end
else
- if ~isempty(findstr(dircontent{index}, 'eegplugin')) && dircontent{index}(end) == 'm'
- funcname = dircontent{index}(1:end-2); % remove .m
- [ pluginName pluginVersion ] = parsepluginname(dircontent{index}(10:end-2));
- end;
- end;
+ if ~isempty(findstr(dircontent(index).name, 'eegplugin')) && dircontent(index).name(end) == 'm'
+ funcname = dircontent(index).name(1:end-2); % remove .m
+ [ pluginName, pluginVersion ] = parsepluginname(dircontent(index).name(10:end-2));
+ end
+ end
% execute function
% ----------------
if ~isempty(pluginVersion) || ~isempty(funcname)
if isempty(funcname)
- disp([ 'EEGLAB: adding "' pluginName '" to the path; subfolders (if any) might be missing from the path' ]);
+ fprintf([ 'EEGLAB: adding "' pluginName '" v' pluginVersion ' to the path' ]);
pluginlist(plugincount).plugin = pluginName;
pluginlist(plugincount).version = pluginVersion;
- pluginlist(plugincount).foldername = dircontent{index};
+ pluginlist(plugincount).foldername = dircontent(index).name;
pluginlist(plugincount).status = 'ok';
+ if ~isempty(pluginstats)
+ indPlugin = strmatch(lower(pluginlist(plugincount).plugin), lower(pluginstats.name), 'exact');
+ else
+ indPlugin = [];
+ end
+ if length(indPlugin) == 1
+ if ~strcmpi(pluginVersion, pluginstats.version{indPlugin})
+ fprintf(2, ' - new version %s available\n', pluginstats.version{indPlugin});
+ else
+ fprintf('\n');
+ end
+ else
+ fprintf('\n');
+ end
plugincount = plugincount+1;
else
pluginlist(plugincount).plugin = pluginName;
pluginlist(plugincount).version = pluginVersion;
- vers = pluginlist(plugincount).version; % version
vers2 = '';
status = 'ok';
- try,
- %eval( [ 'vers2 =' funcname '(gcf, trystrs, catchstrs);' ]);
- vers2 = feval(funcname, gcf, trystrs, catchstrs);
- catch
- try,
- eval( [ funcname '(gcf, trystrs, catchstrs)' ]);
+ if ~strcmpi(onearg, 'nogui')
+ try
+ %eval( [ 'vers2 =' funcname '(gcf, trystrs, catchstrs);' ]);
+ vers2 = feval(funcname, gcf, trystrs, catchstrs);
+ [~, vers2] = parsepluginname(vers2);
catch
- disp([ 'EEGLAB: error while adding plugin "' funcname '"' ] );
- disp([ ' ' lasterr] );
- status = 'error';
- end;
- end;
+ try
+ eval( [ funcname '(gcf, trystrs, catchstrs)' ]);
+ catch
+ disp([ 'EEGLAB: error while adding plugin "' funcname '"' ] );
+ disp([ ' ' lasterr] );
+ status = 'error';
+ end
+ end
+ end
+ if isempty(pluginlist(plugincount).version)
+ pluginlist(plugincount).version = vers2;
+ elseif ~isempty(vers2)
+ if ~isequal(pluginlist(plugincount).version, vers2)
+ fprintf('WARNING: for plugin "%s" version in the folder name "%s" and in the eegplugin_ file "%s" differ\n', pluginlist(plugincount).plugin, pluginlist(plugincount).version,vers2);
+ end
+ end
pluginlist(plugincount).funcname = funcname(10:end);
- pluginlist(plugincount).foldername = dircontent{index};
- [tmp pluginlist(plugincount).versionfunc] = parsepluginname(vers2);
+ pluginlist(plugincount).foldername = dircontent(index).name;
if length(pluginlist(plugincount).funcname) > 1 && pluginlist(plugincount).funcname(1) == '_'
pluginlist(plugincount).funcname(1) = [];
- end;
+ end
if strcmpi(status, 'ok')
- if isempty(vers), vers = pluginlist(plugincount).versionfunc; end;
- if isempty(vers), vers = '?'; end;
- fprintf('EEGLAB: adding "%s" v%s (see >> help %s)\n', ...
+ vers = pluginlist(plugincount).version; % version
+ if isempty(vers), vers = '?'; end
+ fprintf('EEGLAB: adding "%s" v%s (see >> help %s)', ...
pluginlist(plugincount).plugin, vers, funcname);
- end;
+ if ~isempty(pluginstats)
+ indPlugin = strmatch(lower(pluginlist(plugincount).plugin), lower(pluginstats.name), 'exact');
+ if length(indPlugin) == 1
+ if ~strcmpi(vers, pluginstats.version{indPlugin})
+ fprintf(2, ' - new version %s available\n', pluginstats.version{indPlugin});
+ else fprintf('\n');
+ end
+ else fprintf('\n');
+ end
+ else fprintf('\n');
+ end
+ end
pluginlist(plugincount).status = status;
plugincount = plugincount+1;
- end;
- end;
- end;
+ end
+ end
+ end
global PLUGINLIST;
PLUGINLIST = pluginlist;
-end; % iseeglabdeployed2
+
+ % add menus for plugins to install
+ % --------------------------------
+ if ismatlab && ~strcmpi(onearg, 'nogui')
+ if ~exist('mff_import', 'file')
+ neuro_m = findobj(W_MAIN, 'tag', 'import data');
+ cb_mff = [ 'if ~plugin_askinstall(''mffmatlabio'', ''mff_import''), return; end;' ...
+ 'eval(char(get(findobj(''label'', ''Import Magstim/EGI .mff file''), ''callback'')));' ];
+ eegmenu( false, neuro_m, 'Label', 'Import Magstim/EGI .mff file', 'CallBack', cb_mff, 'separator', 'on');
+ end
+ if ~exist('eegplugin_neuroscanio', 'file')
+ neuro_m = findobj(W_MAIN, 'tag', 'import data');
+ neuroscan_check = 'if ~plugin_askinstall(''neuroscanio'', ''eegplugin_neuroscanio''), return; end;';
+ cb_neuroscan1 = [ neuroscan_check 'eval(char(get(findobj(''label'', ''From Neuroscan .CNT file''), ''callback'')));' ];
+ cb_neuroscan2 = [ neuroscan_check 'eval(char(get(findobj(''label'', ''From Neuroscan .EEG file''), ''callback'')));' ];
+ eegmenu( false, neuro_m, 'Label', 'From Neuroscan .CNT file', 'CallBack', cb_neuroscan1, 'Separator', 'on');
+ eegmenu( false, neuro_m, 'Label', 'From Neuroscan .EEG file', 'CallBack', cb_neuroscan2);
+ end
+ if ~exist('eegplugin_firfilt', 'file')
+ neuro_m = findobj(W_MAIN, 'tag', 'filter');
+ cb_filter = [ 'if ~plugin_askinstall(''firfilt'', ''eegplugin_firfilt''), return; end;' ...
+ 'eval(char(get(findobj(''label'', ''Basic FIR filter (new, default)''), ''callback'')));' ];
+ eegmenu( false, neuro_m, 'Label', 'Basic FIR filter (new, default)', 'CallBack', cb_filter, 'separator', 'on');
+ end
+ if ~exist('eegplugin_iclabel', 'file')
+ fprintf(2, 'Warning: ICLabel default plugin missing (probably due to downloading zip file from Github). Install manually.\n');
+ end
+ if ~exist('eegplugin_clean_rawdata', 'file')
+ fprintf(2, 'Warning: Clean Rawdata plugin missing (probably due to downloading zip file from Github). Install manually.\n');
+ end
+ if ~exist('pop_dipfit_settings', 'file')
+ neuro_m = findobj(W_MAIN, 'tag', 'tools');
+ cb_dipfit = 'if ~plugin_askinstall(''dipfit'', ''pop_dipfit_settings''), return; end;' ;
+ eegmenu( false, neuro_m, 'Label', 'Locate dipoles using DIPFIT 2.x', 'CallBack', cb_dipfit, 'separator', 'on');
+ end
+ if ~exist('pop_loadbva', 'file')
+ neuro_m = findobj(W_MAIN, 'tag', 'import data');
+ cb_bva1 = [ 'if ~plugin_askinstall(''bva-io'', ''pop_loadbva''), return; end;' ...
+ 'eval(char(get(findobj(''label'', ''From Brain Vis. Rec. .vhdr file''), ''callback'')));' ];
+ cb_bva2 = [ 'if ~plugin_askinstall(''bva-io'', ''pop_loadbva''), return; end;' ...
+ 'eval(char(get(findobj(''label'', ''From Brain Vis. Anal. Matlab file''), ''callback'')));' ];
+ eegmenu( false, neuro_m, 'Label', 'From Brain Vis. Rec. .vhdr file', 'CallBack', cb_bva1, 'separator', 'on');
+ eegmenu( false, neuro_m, 'Label', 'From Brain Vis. Anal. Matlab file', 'CallBack', cb_bva2);
+ end
+ end
+end
+
+% Path exception for BIOSIG (sending BIOSIG down into the path)
+biosigpathlast; % fix str2double issue
+
+% push SIFT path last for dipplot
+dipplotpath = fileparts( which('dipplot') );
+dipfitpath = fileparts( which('dipfit_1_to_2') );
+if ~strcmp(dipplotpath,dipfitpath)
+ addpath(dipfitpath,'-begin');
+end
+
+if strcmpi(onearg, 'nogui')
+ return;
+end
-if ~ismatlab, return; end;
% add other import ...
% --------------------
cb_others = [ 'pophelp(''troubleshooting_data_formats'');' ];
-uimenu( import_m, 'Label', 'Using the FILE-IO interface', 'CallBack', cb_fileio, 'separator', 'on');
-uimenu( import_m, 'Label', 'Using the BIOSIG interface' , 'CallBack', cb_biosig);
-uimenu( import_m, 'Label', 'Troubleshooting data formats...', 'CallBack', cb_others);
+eegmenu( false, import_m, 'Label', 'Using the FILE-IO interface', 'CallBack', cb_fileio, 'separator', 'on');
+eegmenu( false, import_m, 'Label', 'Using the BIOSIG interface' , 'CallBack', cb_biosig);
+eegmenu( false, import_m, 'Label', 'Troubleshooting data formats...', 'CallBack', cb_others);
% changing plugin menu color
% --------------------------
@@ -1050,127 +1220,40 @@
editsub_m = findobj('parent', edit_m);
exportsub_m = findobj('parent', exportm);
filter_m = findobj('parent', filter_m);
+
icadefs; % containing PLUGINMENUCOLOR
-if length(fourthsub_m) > 11, set(fourthsub_m(1:end-11), 'foregroundcolor', PLUGINMENUCOLOR); end;
-if length(plotsub_m) > 17, set(plotsub_m (1:end-17), 'foregroundcolor', PLUGINMENUCOLOR); end;
-if length(importsub_m) > 9, set(importsub_m(1:end-9) , 'foregroundcolor', PLUGINMENUCOLOR); end;
-if length(epochsub_m ) > 3 , set(epochsub_m (1:end-3 ), 'foregroundcolor', PLUGINMENUCOLOR); end;
-if length(eventsub_m ) > 4 , set(eventsub_m (1:end-4 ), 'foregroundcolor', PLUGINMENUCOLOR); end;
-if length(exportsub_m) > 4 , set(exportsub_m(1:end-4 ), 'foregroundcolor', PLUGINMENUCOLOR); end;
-if length(editsub_m) > 10, set(editsub_m( 1:end-10), 'foregroundcolor', PLUGINMENUCOLOR); end;
-if length(filter_m) > 3 , set(filter_m (1:end-1 ), 'foregroundcolor', PLUGINMENUCOLOR); end;
-
-EEGMENU = uimenu( set_m, 'Label', '------', 'Enable', 'off');
-eval('set(W_MAIN, ''userdat'', { EEGUSERDAT{1} EEGMENU javaobj });');
+if versL, tm = 14; else tm = 16; end
+if length(fourthsub_m) > tm, set(fourthsub_m(1:end-tm), 'foregroundcolor', PLUGINMENUCOLOR); end
+if length(plotsub_m) > 17, set(plotsub_m (1:end-17), 'foregroundcolor', PLUGINMENUCOLOR); end
+if length(importsub_m) > 4, set(importsub_m(1:end-4) , 'foregroundcolor', PLUGINMENUCOLOR); end
+if length(epochsub_m ) > 3 , set(epochsub_m (1:end-3 ), 'foregroundcolor', PLUGINMENUCOLOR); end
+if length(eventsub_m ) > 4 , set(eventsub_m (1:end-4 ), 'foregroundcolor', PLUGINMENUCOLOR); end
+if length(exportsub_m) > 4 , set(exportsub_m(1:end-4 ), 'foregroundcolor', PLUGINMENUCOLOR); end
+if length(editsub_m) > 10, set(editsub_m( 1:end-10), 'foregroundcolor', PLUGINMENUCOLOR); end
+if length(filter_m) > 3 , set(filter_m (1:end-1 ), 'foregroundcolor', PLUGINMENUCOLOR); end
+
+EEGMENU = eegmenu( false, set_m, 'Label', '------', 'Enable', 'off');
+eval('set(W_MAIN, ''userdat'', { EEGUSERDAT{1} EEGMENU });');
eeglab('redraw');
if nargout < 1
clear ALLEEG;
-end;
+end
-%% automatic updater
-try
- [dummy eeglabVersionNumber currentReleaseDateString] = eeg_getversion;
- if isempty(eeglabVersionNumber)
- eeglabVersionNumber = 'dev';
- end;
- eeglabUpdater = up.updater(eeglabVersionNumber, 'http://sccn.ucsd.edu/eeglab/updater/latest_version.php', 'EEGLAB', currentReleaseDateString);
-
- % create a new GUI item (e.g. under Help)
- %newerVersionMenu = uimenu(help_m, 'Label', 'Upgrade to the Latest Version', 'visible', 'off', 'userdata', 'startup:on;study:on');
-
- % set the callback to bring up the updater GUI
- icadefs; % for getting background color
- eeglabFolder = fileparts(mywhich('eeglab.m'));
- %eeglabUpdater.menuItemHandle = []; %newerVersionMenu;
- %eeglabUpdater.menuItemCallback = {@command_on_update_menu_click, eeglabUpdater, eeglabFolder, true, BACKEEGLABCOLOR};
-
- % place it in the base workspace.
- assignin('base', 'eeglabUpdater', eeglabUpdater);
-
- % only start timer if the function is called from the command line
- % (which means that the stack should only contain one element)
- stackVar = dbstack;
- if length(stackVar) == 1
- if option_checkversion
- eeglabUpdater.checkForNewVersion({'eeglab_event' 'setup'});
- if strcmpi(eeglabVersionNumber, 'dev')
- return;
- end;
- newMajorRevision = 0;
- if ~isempty(eeglabUpdater.newMajorRevision)
- fprintf('\nA new major version of EEGLAB (EEGLAB%s - beta) is now available.\n', eeglabUpdater.newMajorRevision);
- newMajorRevision = 1;
- end;
- if eeglabUpdater.newerVersionIsAvailable
- eeglabv = num2str(eeglabUpdater.latestVersionNumber);
- posperiod = find(eeglabv == '.');
- if isempty(posperiod), posperiod = length(eeglabv)+1; eeglabv = [ eeglabv '.0' ]; end;
- if length(eeglabv(posperiod+1:end)) < 2, eeglabv = [ eeglabv '0' ]; end;
- %if length(eeglabv(posperiod+1:end)) < 3, eeglabv = [ eeglabv '0' ]; end;
- eeglabv = [ eeglabv(1:posperiod+1) '.' eeglabv(posperiod+2) ]; %'.' eeglabv(posperiod+3) ];
-
- stateWarning = warning('backtrace');
- warning('backtrace', 'off');
- if newMajorRevision
- fprintf('\n');
- warning( sprintf(['\nA critical revision of EEGLAB%d (%s) is also available here\n' ...
- 'See Release notes for more informations\n' ...
- 'You may disable this message using the Option menu\n' ], ...
- floor(eeglabVersionNumber), eeglabv, eeglabUpdater.downloadUrl, ...
- [ 'http://sccn.ucsd.edu/wiki/EEGLAB_revision_history_version_13' ]));
- else
- warning( sprintf(['\nA newer version of EEGLAB (%s) is available here\n' ...
- 'See Release notes for more informations\n' ...
- 'You may disable this message using the Option menu\n' ], ...
- eeglabv, eeglabUpdater.downloadUrl, ...
- [ 'http://sccn.ucsd.edu/wiki/EEGLAB_revision_history_version_13' ]));
- end;
- warning('backtrace', stateWarning.state);
-
- % make the Help menu item dark red
- set(help_m, 'foregroundColor', [0.6, 0 0]);
- elseif isempty(eeglabUpdater.lastTimeChecked)
- fprintf('Could not check for the latest EEGLAB version (internet may be disconnected).\n');
- fprintf('To prevent long startup time, disable checking for new EEGLAB version (FIle > Memory and other options).\n');
- else
- if ~newMajorRevision
- fprintf('You are using the latest version of EEGLAB.\n');
- else
- fprintf('You are currently using the latest revision of EEGLAB%d (no critical update available).\n', floor(eeglabVersionNumber));
- end;
- end;
- else
- eeglabtimers = timerfind('name', 'eeglabupdater');
- if ~isempty(eeglabtimers)
- stop(eeglabtimers);
- delete(eeglabtimers);
- end;
- % This is disabled because it cause Matlab to hang in case
- % there is no connection or the connection is available but not
- % usable
- % start(timer('TimerFcn','try, eeglabUpdater.checkForNewVersion({''eeglab_event'' ''setup''}); catch, end; clear eeglabUpdater;', 'name', 'eeglabupdater', 'StartDelay', 20.0));
- end;
- end;
-catch
- if option_checkversion
- fprintf('Updater could not be initialized.\n');
- end;
-end;
+% check if update is available
+if ismatlab
+ eeglab_update(eeglabVersionStatus);
+end
% REMOVED MENUS
- %uimenu( tools_m, 'Label', 'Automatic comp. reject', 'enable', 'off', 'CallBack', '[EEG LASTCOM] = pop_rejcomp(EEG); eegh(LASTCOM); if ~isempty(LASTCOM), eeg_store(CURRENTSET); end;');
- %uimenu( tools_m, 'Label', 'Reject (synthesis)' , 'Separator', 'on', 'CallBack', '[EEG LASTCOM] = pop_rejall(EEG); eegh(LASTCOM); if ~isempty(LASTCOM), eeg_store; end; eeglab(''redraw'');');
-
- function command_on_update_menu_click(callerHandle, tmp, eeglabUpdater, installDirectory, goOneFolderLevelIn, backGroundColor)
- postInstallCallbackString = 'clear all function functions; eeglab';
- eeglabUpdater.launchGui(installDirectory, goOneFolderLevelIn, backGroundColor, postInstallCallbackString);
-
+ %eegmenu( false, tools_m, 'Label', 'Automatic comp. reject', 'enable', 'off', 'CallBack', '[EEG LASTCOM] = pop_rejcomp(EEG); eegh(LASTCOM); if ~isempty(LASTCOM), eeg_store(CURRENTSET); end;');
+ %eegmenu( false, tools_m, 'Label', 'Reject (synthesis)' , 'Separator', 'on', 'CallBack', '[EEG LASTCOM] = pop_rejall(EEG); eegh(LASTCOM); if ~isempty(LASTCOM), eeg_store; end; eeglab(''redraw'');');
+
%
% --------------------
% draw the main figure
% --------------------
-function tb = eeg_mainfig(onearg);
+function eeg_mainfig(onearg);
icadefs;
COLOR = BACKEEGLABCOLOR;
@@ -1179,7 +1262,6 @@ function command_on_update_menu_click(callerHandle, tmp, eeglabUpdater, installD
WINYDEC = 13;
NBLINES = 16;
WINY = WINYDEC*NBLINES;
-javaChatFlag = 1;
BORDERINT = 4;
BORDEREXT = 10;
@@ -1196,19 +1278,36 @@ function command_on_update_menu_click(callerHandle, tmp, eeglabUpdater, installD
FONTSIZE = FONTSIZE+2;
WINMAXX = WINMAXX*1.3;
WINY = WINY*1.3;
- end;
+ end
else
FONTNAME = '';
FONTSIZE = 11;
-end;
+end
+if ~ismatlab
+ WINMAXX = WINMAXX*1.35;
+ WINY = WINY*1.4;
+end
hh = findobj('tag', 'EEGLAB');
if ~isempty(hh)
disp('EEGLAB warning: there can be only one EEGLAB window, closing old one');
close(hh);
-end;
+end
+
+% determine the text for the revision
+[txtVersion, numVersion ] = eeg_getversion;
+if ~isempty(numVersion)
+ txtVersion = [ 'EEGLAB v' txtVersion ];
+else
+ txtVersion = [ 'EEGLAB ' txtVersion ];
+end
+if ~ismatlab && ismac
+ txtVersion = [ txtVersion ' - menu is on the top bar' ];
+end
+
+% create figures
if strcmpi(onearg, 'remote')
- figure( 'name', [ 'EEGLAB v' eeg_getversion ], ...
+ figure( 'name', txtVersion, ...
'numbertitle', 'off', ...
'Position',[200 100 (WINMINX+WINMAXX+2*BORDERINT+2*BORDEREXT) 30 ], ...
'color', COLOR, ...
@@ -1216,13 +1315,13 @@ function command_on_update_menu_click(callerHandle, tmp, eeglabUpdater, installD
'Userdata', {[] []});
%'resize', 'off', ...
return;
-end;
+end
W_MAIN = figure('Units','points', ...
... % 'Colormap','gray', ...
'PaperPosition',[18 180 576 432], ...
'PaperUnits','points', ...
- 'name', [ 'EEGLAB v' eeg_getversion ], ...
+ 'name', txtVersion, ...
'numbertitle', 'off', ...
'Position',[200 100 (WINMINX+WINMAXX+2*BORDERINT+2*BORDEREXT) (WINY+2*BORDERINT+2*BORDEREXT) ], ...
'color', COLOR, ...
@@ -1233,231 +1332,172 @@ function command_on_update_menu_click(callerHandle, tmp, eeglabUpdater, installD
% java chat
eeglab_options;
-if option_chat == 1
- if is_sccn
- disp('Starting chat...');
- tmpp = fileparts(mywhich('startpane.m'));
- if isempty(tmpp) || ~ismatlab
- disp('Cannot start chat');
- tb = [];
- else
- disp(' ----------------------------------- ');
- disp('| EEGLAB chat 0.9 |');
- disp('| The chat currently only works |');
- disp('| at the University of CA San Diego |');
- disp(' ----------------------------------- ');
-
- javaaddpath(fullfile(tmpp, 'Chat_with_pane.jar'));
- eval('import client.EEGLABchat.*;');
- eval('import client.VisualToolbar;');
- eval('import java.awt.*;');
- eval('import javax.swing.*;');
-
- try
- tb = VisualToolbar('137.110.244.26');
- F = W_MAIN;
- tb.setPreferredSize(Dimension(0, 75));
-
- javacomponent(tb,'South',F);
- javaclose = ['userdat = get(gcbf, ''userdata'');' ...
- 'try,'...
- ' tb = userdat{3};' ...
- 'clear userdat; delete(gcbf); tb.close; clear tb;'...
- 'catch,end;'];
- set(gcf, 'CloseRequestFcn',javaclose);
-
- refresh(F);
- catch,
- tb = [];
- end;
- end;
- else
- tb = [];
- end;
-else
- tb = [];
-end;
-try,
+try
set(W_MAIN, 'NextPlot','new');
-catch, end;
-
-if ismatlab
- BackgroundColor = get(gcf, 'color'); %[0.701960784313725 0.701960784313725 0.701960784313725];
- H_MAIN(1) = uicontrol('Parent',W_MAIN, ...
- 'Units','points', ...
- 'BackgroundColor',COLOR, ...
- 'ListboxTop',0, ...
- 'HorizontalAlignment', 'left',...
- 'Position',[BORDEREXT BORDEREXT (WINMINX+WINMAXX+2*BORDERINT) (WINY)], ...
- 'Style','frame', ...
- 'Tag','Frame1');
- set(H_MAIN(1), 'unit', 'normalized');
- geometry = { [1] [1] [1] [1 1] [1 1] [1 1] [1 1] [1 1] [1 1] [1 1] [1 1] [1 1] [1 1] [1 1] [1] };
- listui = { { 'style', 'text', 'string', 'Parameters of the current set', 'tag', 'win0' } { } ...
- { 'style', 'text', 'tag', 'win1', 'string', ' ', 'userdata', 'datinfo' } ...
- { 'style', 'text', 'tag', 'win2', 'string', 'Channels per frame', 'userdata', 'datinfo'} ...
- { 'style', 'text', 'tag', 'val2', 'string', ' ', 'userdata', 'datinfo' } ...
- { 'style', 'text', 'tag', 'win3', 'string', 'Frames per epoch', 'userdata', 'datinfo'} ...
- { 'style', 'text', 'tag', 'val3', 'string', ' ', 'userdata', 'datinfo' } ...
- { 'style', 'text', 'tag', 'win4', 'string', 'Epochs', 'userdata', 'datinfo'} ...
- { 'style', 'text', 'tag', 'val4', 'string', ' ', 'userdata', 'datinfo' } ...
- { 'style', 'text', 'tag', 'win5', 'string', 'Events', 'userdata', 'datinfo'} ...
- { 'style', 'text', 'tag', 'val5', 'string', ' ', 'userdata', 'datinfo' } ...
- { 'style', 'text', 'tag', 'win6', 'string', 'Sampling rate (Hz)', 'userdata', 'datinfo' } ...
- { 'style', 'text', 'tag', 'val6', 'string', ' ', 'userdata', 'datinfo' } ...
- { 'style', 'text', 'tag', 'win7', 'string', 'Epoch start (sec)', 'userdata', 'datinfo' } ...
- { 'style', 'text', 'tag', 'val7', 'string', ' ', 'userdata', 'datinfo' } ...
- { 'style', 'text', 'tag', 'win8', 'string', 'Epoch end (sec)', 'userdata', 'datinfo' } ...
- { 'style', 'text', 'tag', 'val8', 'string', ' ', 'userdata', 'datinfo' } ...
- { 'style', 'text', 'tag', 'win9', 'string', 'Average reference', 'userdata', 'datinfo' } ...
- { 'style', 'text', 'tag', 'val9', 'string', ' ', 'userdata', 'datinfo' } ...
- { 'style', 'text', 'tag', 'win10', 'string', 'Channel locations', 'userdata', 'datinfo'} ...
- { 'style', 'text', 'tag', 'val10', 'string', ' ', 'userdata', 'datinfo' } ...
- { 'style', 'text', 'tag', 'win11', 'string', 'ICA weights', 'userdata', 'datinfo' } ...
- { 'style', 'text', 'tag', 'val11', 'string', ' ', 'userdata', 'datinfo' } ...
- { 'style', 'text', 'tag', 'win12', 'string', 'Dataset size (Mb)', 'userdata', 'datinfo' } ...
- { 'style', 'text', 'tag', 'val12', 'string', ' ', 'userdata', 'datinfo' } {} };
- supergui(gcf, geometry, [], listui{:});
- geometry = { [1] [1] [1] [1] [1] [1] [1] [1] [1] [1] [1] [1] [1] [1] [1] [1] };
- listui = { { } ...
- { } ...
- { 'style', 'text', 'tag', 'mainwin1', 'string', ' ', 'userdata', 'fullline' } ...
- { 'style', 'text', 'tag', 'mainwin2', 'string', ' ', 'userdata', 'fullline' } ...
- { 'style', 'text', 'tag', 'mainwin3', 'string', ' ', 'userdata', 'fullline' } ...
- { 'style', 'text', 'tag', 'mainwin4', 'string', ' ', 'userdata', 'fullline' } ...
- { 'style', 'text', 'tag', 'mainwin5', 'string', ' ', 'userdata', 'fullline' } ...
- { 'style', 'text', 'tag', 'mainwin6', 'string', ' ', 'userdata', 'fullline' } ...
- { 'style', 'text', 'tag', 'mainwin7', 'string', ' ', 'userdata', 'fullline' } ...
- { 'style', 'text', 'tag', 'mainwin8', 'string', ' ', 'userdata', 'fullline' } ...
- { 'style', 'text', 'tag', 'mainwin9', 'string', ' ', 'userdata', 'fullline' } ...
- { 'style', 'text', 'tag', 'mainwin10', 'string', ' ', 'userdata', 'fullline' } ...
- { 'style', 'text', 'tag', 'mainwin11', 'string', ' ', 'userdata', 'fullline' } ...
- { 'style', 'text', 'tag', 'mainwin12', 'string', ' ', 'userdata', 'fullline' } ...
- { 'style', 'text', 'tag', 'mainwin13', 'string', ' ', 'userdata', 'fullline' } {} };
- supergui(gcf, geometry, [], listui{:});
-
- titleh = findobj('parent', gcf, 'tag', 'win0');
- alltexth = findobj('parent', gcf, 'style', 'text');
- alltexth = setdiff_bc(alltexth, titleh);
-
- set(gcf, 'Position',[200 100 (WINMINX+WINMAXX+2*BORDERINT+2*BORDEREXT) (WINY+2*BORDERINT+2*BORDEREXT) ]);
- set(titleh, 'fontsize', TEXT_FONTSIZE_L, 'fontweight', 'bold');
- set(alltexth, 'fontname', FONTNAME, 'fontsize', FONTSIZE);
- set(W_MAIN, 'visible', 'on');
-end;
-
+catch, end
+
+BackgroundColor = get(gcf, 'color'); %[0.701960784313725 0.701960784313725 0.701960784313725];
+H_MAIN(1) = uicontrol('Parent',W_MAIN, ...
+ 'Units','points', ...
+ 'BackgroundColor',COLOR, ...
+ 'ListboxTop',0, ...
+ 'HorizontalAlignment', 'left',...
+ 'Position',[BORDEREXT BORDEREXT (WINMINX+WINMAXX+2*BORDERINT) (WINY)], ...
+ 'Style','frame', ...
+ 'Tag','Frame1');
+set(H_MAIN(1), 'unit', 'normalized');
+geometry = { [1] [1] [1] [1 1] [1 1] [1 1] [1 1] [1 1] [1 1] [1 1] [1 1] [1 1] [1 1] [1 1] [1] };
+listui = { { 'style', 'text', 'string', 'Parameters of the current set', 'tag', 'win0' } { } ...
+ { 'style', 'text', 'tag', 'win1', 'string', ' ', 'userdata', 'datinfo' } ...
+ { 'style', 'text', 'tag', 'win2', 'string', 'Channels per frame', 'userdata', 'datinfo'} ...
+ { 'style', 'text', 'tag', 'val2', 'string', ' ', 'userdata', 'datinfo' } ...
+ { 'style', 'text', 'tag', 'win3', 'string', 'Frames per epoch', 'userdata', 'datinfo'} ...
+ { 'style', 'text', 'tag', 'val3', 'string', ' ', 'userdata', 'datinfo' } ...
+ { 'style', 'text', 'tag', 'win4', 'string', 'Epochs', 'userdata', 'datinfo'} ...
+ { 'style', 'text', 'tag', 'val4', 'string', ' ', 'userdata', 'datinfo' } ...
+ { 'style', 'text', 'tag', 'win5', 'string', 'Events', 'userdata', 'datinfo'} ...
+ { 'style', 'text', 'tag', 'val5', 'string', ' ', 'userdata', 'datinfo' } ...
+ { 'style', 'text', 'tag', 'win6', 'string', 'Sampling rate (Hz)', 'userdata', 'datinfo' } ...
+ { 'style', 'text', 'tag', 'val6', 'string', ' ', 'userdata', 'datinfo' } ...
+ { 'style', 'text', 'tag', 'win7', 'string', 'Epoch start (sec)', 'userdata', 'datinfo' } ...
+ { 'style', 'text', 'tag', 'val7', 'string', ' ', 'userdata', 'datinfo' } ...
+ { 'style', 'text', 'tag', 'win8', 'string', 'Epoch end (sec)', 'userdata', 'datinfo' } ...
+ { 'style', 'text', 'tag', 'val8', 'string', ' ', 'userdata', 'datinfo' } ...
+ { 'style', 'text', 'tag', 'win9', 'string', 'Average reference', 'userdata', 'datinfo' } ...
+ { 'style', 'text', 'tag', 'val9', 'string', ' ', 'userdata', 'datinfo' } ...
+ { 'style', 'text', 'tag', 'win10', 'string', 'Channel locations', 'userdata', 'datinfo'} ...
+ { 'style', 'text', 'tag', 'val10', 'string', ' ', 'userdata', 'datinfo' } ...
+ { 'style', 'text', 'tag', 'win11', 'string', 'ICA weights', 'userdata', 'datinfo' } ...
+ { 'style', 'text', 'tag', 'val11', 'string', ' ', 'userdata', 'datinfo' } ...
+ { 'style', 'text', 'tag', 'win12', 'string', 'Dataset size (Mb)', 'userdata', 'datinfo' } ...
+ { 'style', 'text', 'tag', 'val12', 'string', ' ', 'userdata', 'datinfo' } {} };
+supergui(gcf, geometry, [], listui{:});
+geometry = { [1] [1 0.01] [1 0.01] [1 0.01] [1 0.01] [1 0.01] [1 0.01] [1 0.01] [1 0.01] [1 0.01] [1 0.01] [1 0.01] [1 0.01] [1 0.01] [1 0.01] [1] };
+listui = { { } ...
+ { 'style', 'text', 'tag', 'mainwin0', 'string', ' ', 'userdata', 'fullline' } { } ...
+ { 'style', 'text', 'tag', 'mainwin1', 'string', ' ', 'userdata', 'fullline' } { } ...
+ { 'style', 'text', 'tag', 'mainwin2', 'string', ' ', 'userdata', 'fullline' } { } ...
+ { 'style', 'text', 'tag', 'mainwin3', 'string', ' ', 'userdata', 'fullline' } { } ...
+ { 'style', 'text', 'tag', 'mainwin4', 'string', ' ', 'userdata', 'fullline' } { } ...
+ { 'style', 'text', 'tag', 'mainwin5', 'string', ' ', 'userdata', 'fullline' } { } ...
+ { 'style', 'text', 'tag', 'mainwin6', 'string', ' ', 'userdata', 'fullline' } { } ...
+ { 'style', 'text', 'tag', 'mainwin7', 'string', ' ', 'userdata', 'fullline' } { } ...
+ { 'style', 'text', 'tag', 'mainwin8', 'string', ' ', 'userdata', 'fullline' } { } ...
+ { 'style', 'text', 'tag', 'mainwin9', 'string', ' ', 'userdata', 'fullline' } { } ...
+ { 'style', 'text', 'tag', 'mainwin10', 'string', ' ', 'userdata', 'fullline' } { } ...
+ { 'style', 'text', 'tag', 'mainwin11', 'string', ' ', 'userdata', 'fullline' } { } ...
+ { 'style', 'text', 'tag', 'mainwin12', 'string', ' ', 'userdata', 'fullline' } { } ...
+ { 'style', 'text', 'tag', 'mainwin13', 'string', ' ', 'userdata', 'fullline' } { } {} };
+firstElemHeight = 1;
+if ispc, firstElemHeight = 1.7; end
+supergui(gcf, geometry, [firstElemHeight 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1], listui{:});
+
+titleh = findobj('parent', gcf, 'tag', 'win0');
+alltexth = findobj('parent', gcf, 'style', 'text');
+alltexth = setdiff_bc(alltexth, titleh);
+
+set(gcf, 'Position',[200 100 (WINMINX+WINMAXX+2*BORDERINT+2*BORDEREXT) (WINY+2*BORDERINT+2*BORDEREXT) ]);
+set(titleh, 'fontsize', TEXT_FONTSIZE_L, 'fontweight', 'bold');
+set(alltexth, 'fontname', FONTNAME, 'fontsize', FONTSIZE);
+
+set(W_MAIN, 'visible', 'on');
+
return;
-% eeglab(''redraw'')() - Update EEGLAB menus based on values of global variables.
-%
-% Usage: >> eeglab(''redraw'')( );
-%
-% Author: Arnaud Delorme, CNL / Salk Institute, 2001
-%
-% See also: eeg_global(), eeglab()
-
-% WHEN THIS FUNCTION WAS SEPARATED
-% Revision 1.21 2002/04/23 19:09:25 arno
-% adding automatic dataset search
-% Revision 1.20 2002/04/18 20:02:23 arno
-% retrIeve
-% Revision 1.18 2002/04/18 16:28:28 scott
-% EEG.averef printed as 'Yes' or 'No' -sm
-% Revision 1.16 2002/04/18 16:03:15 scott
-% editted "Events/epoch info (nb) -> Events -sm
-% Revision 1.14 2002/04/18 14:46:58 scott
-% editted main window help msg -sm
-% Revision 1.10 2002/04/18 03:02:17 scott
-% edited opening instructions -sm
-% Revision 1.9 2002/04/11 18:23:33 arno
-% Oups, typo which crashed EEGLAB
-% Revision 1.8 2002/04/11 18:07:59 arno
-% adding average reference variable
-% Revision 1.7 2002/04/11 17:49:40 arno
-% corrected operator precedence problem
-% Revision 1.6 2002/04/11 15:36:55 scott
-% added parentheses to final ( - & - ), line 84. ARNO PLEASE CHECK -sm
-% Revision 1.5 2002/04/11 15:34:50 scott
-% put isempty(CURRENTSET) first in line ~80 -sm
-% Revision 1.4 2002/04/11 15:31:47 scott
-% added test isempty(CURRENTSET) line 78 -sm
-% Revision 1.3 2002/04/11 01:41:27 arno
-% checking dataset ... and inteligent menu update
-% Revision 1.2 2002/04/09 20:47:41 arno
-% introducing event number into gui
-
-function updatemenu();
+% Update EEGLAB GUI (list of datasets)
+% -----------------
+function updatemenu()
eeg_global;
W_MAIN = findobj('tag', 'EEGLAB');
EEGUSERDAT = get(W_MAIN, 'userdata');
H_MAIN = EEGUSERDAT{1};
EEGMENU = EEGUSERDAT{2};
-if length(EEGUSERDAT) > 2
- tb = EEGUSERDAT{3};
-else tb = [];
-end;
-if ~isempty(tb) && ~isstr(tb)
- eval('tb.RefreshToolbar();');
-end;
-if exist('CURRENTSET') ~= 1, CURRENTSET = 0; end;
-if isempty(ALLEEG), ALLEEG = []; end;
-if isempty(EEG), EEG = []; end;
+if exist('CURRENTSET') ~= 1, CURRENTSET = 0; end
+if isempty(ALLEEG), ALLEEG = []; end
+if isempty(EEG), EEG = []; end
% test if the menu is present
try
figure(W_MAIN);
set_m = findobj( 'parent', W_MAIN, 'Label', 'Datasets');
-catch, return; end;
+catch, return; end
index = 1;
indexmenu = 1;
-MAX_SET = max(length( ALLEEG ), length(EEGMENU)-1);
+% check if EEG has changed
+% ------------------------
tmp = warning;
warning off;
clear functions;
warning(tmp);
eeglab_options;
-if isempty(ALLEEG) && ~isempty(EEG) && ~isempty(EEG.data)
+if isempty(ALLEEG) && ~isempty(EEG) && all(arrayfun(@(eeg) ~isempty(eeg.data), EEG))
ALLEEG = EEG;
-end;
+else
+ % check dataset
+ if ~isempty(EEG) && ~isempty(ALLEEG) && ~isequaln(EEG, ALLEEG(CURRENTSET))
+ if length(EEG) > 1
+ options = { 'EEG overwrites ALLEEG', 'ALLEEG overwrites EEG', 'Do nothing' };
+ res = questdlg2('In a STUDY, ALLEEG and EEG should be equal and they are not. How do you want EEGLAB to resolve this?', 'ALLEEG and EEG structure do not match', options{:}, options{1});
+ if isequal(res, options{1})
+ disp('Overwriting ALLEEG with EEG')
+ ALLEEG = EEG;
+ elseif isequal(res, options{2})
+ disp('Overwriting EEG with ALLEEG')
+ EEG = ALLEEG;
+ end
+ else
+ EEG.saved = 'no';
+ [ALLEEG, EEG, CURRENTSET] = pop_newset(ALLEEG, EEG, CURRENTSET, 'study', ~isempty(STUDY)+0, 'guistring', 'The EEG structure has changed, what do you want to do?');
+ end
+ end
+end
+
+% Maximum number of set
+% ---------------------
+MAX_SET = max(length( ALLEEG ), length(EEGMENU)-1);
+if MAX_SET > 200
+ disp('Updating menu, allowing selection of the first 200 datasets only to speed up display...')
+ MAX_SET = 200;
+end
% setting the dataset menu
% ------------------------
while( index <= MAX_SET)
try
set( EEGMENU(index), 'Label', '------', 'checked', 'off');
- catch,
+ catch
if mod(index, 30) == 0
tag = [ 'More (' int2str(index/30) ') ->' ];
tmp_m = findobj('label', tag);
if isempty(tmp_m)
- set_m = uimenu( set_m, 'Label', tag, 'userdata', 'study:on');
+ set_m = eegmenu( false, set_m, 'Label', tag, 'userdata', 'study:on');
else set_m = tmp_m;
- end;
- end;
+ end
+ end
try
set( EEGMENU(index), 'Label', '------', 'checked', 'off');
- catch, EEGMENU(index) = uimenu( set_m, 'Label', '------', 'Enable', 'on'); end;
- end;
+ catch, EEGMENU(index) = eegmenu( false, set_m, 'Label', '------', 'Enable', 'on'); end
+ end
set( EEGMENU(index), 'Enable', 'on', 'separator', 'off' );
try, ALLEEG(index).data;
if ~isempty( ALLEEG(index).data)
cb_retrieve = [ '[ALLEEG EEG CURRENTSET LASTCOM] = pop_newset(ALLEEG, EEG, CURRENTSET, ''retrieve'', ' int2str(index) ', ''study'', ~isempty(STUDY)+0);' ...
- 'if CURRENTSTUDY & ~isempty(LASTCOM), CURRENTSTUDY = 0; LASTCOM = [ ''CURRENTSTUDY = 0;'' LASTCOM ]; end; eegh(LASTCOM);' ...
+ 'if CURRENTSTUDY && ~isempty(LASTCOM), CURRENTSTUDY = 0; LASTCOM = [ ''CURRENTSTUDY = 0;'' LASTCOM ]; end; eegh(LASTCOM);' ...
'eeglab(''redraw'');' ];
menutitle = sprintf('Dataset %d:%s', index, ALLEEG(index).setname);
set( EEGMENU(index), 'Label', menutitle, 'userdata', 'study:on');
set( EEGMENU(index), 'CallBack', cb_retrieve );
set( EEGMENU(index), 'Enable', 'on' );
- if any(index == CURRENTSET), set( EEGMENU(index), 'checked', 'on' ); end;
- end;
- catch, end;
+ if any(index == CURRENTSET), set( EEGMENU(index), 'checked', 'on' ); end
+ end
+ catch, end
index = index+1;
-end;
+end
hh = findobj( 'parent', set_m, 'Label', '------');
set(hh, 'Enable', 'off');
@@ -1472,16 +1512,16 @@ function command_on_update_menu_click(callerHandle, tmp, eeglabUpdater, installD
' eeglab(''redraw'');' ...
'end;' ...
'clear tmpind nonempty;' ];
- if MAX_SET == length(EEGMENU), EEGMENU(end+1) = uimenu( set_m, 'Label', '------', 'Enable', 'on'); end;
+ if MAX_SET == length(EEGMENU), EEGMENU(end+1) = eegmenu( false, set_m, 'Label', '------', 'Enable', 'on'); end
set(EEGMENU(end), 'enable', 'on', 'Label', 'Select multiple datasets', ...
'callback', cb_select, 'separator', 'on', 'userdata', 'study:on');
-end;
+end
% STUDY consistency
% -----------------
exist_study = 0;
-if exist('STUDY') & exist('CURRENTSTUDY')
+if exist('STUDY') && exist('CURRENTSTUDY')
% if study present, check study consistency with loaded datasets
% --------------------------------------------------------------
@@ -1499,21 +1539,21 @@ function command_on_update_menu_click(callerHandle, tmp, eeglabUpdater, installD
pop_savestudy(STUDY, ALLEEG);
STUDY = [];
CURRENTSTUDY = 0;
- end;
+ end
else
warndlg2( strvcat('The study was not compatible any more with the datasets present in memory.', ...
'Since it had not changed since last saved, it was simply removed from', ...
'memory.') );
STUDY = [];
CURRENTSTUDY = 0;
- end;
- end;
- end;
+ end
+ end
+ end
if ~isempty(STUDY)
exist_study = 1;
- end;
-end;
+ end
+end
% menu for selecting STUDY set
% ----------------------------
@@ -1524,76 +1564,76 @@ function command_on_update_menu_click(callerHandle, tmp, eeglabUpdater, installD
'eeglab(''redraw'');' ];
tmp_m = findobj('label', 'Select the study set');
delete(tmp_m); % in case it is not at the end
- tmp_m = uimenu( set_m, 'Label', 'Select the study set', 'Enable', 'on', 'userdata', 'study:on');
+ tmp_m = eegmenu( false, set_m, 'Label', 'Select the study set', 'Enable', 'on', 'userdata', 'study:on');
set(tmp_m, 'enable', 'on', 'callback', cb_select, 'separator', 'on');
else
delete( findobj('label', 'Select the study set') );
-end;
+end
EEGUSERDAT{2} = EEGMENU;
set(W_MAIN, 'userdata', EEGUSERDAT);
-if (isempty(CURRENTSET) | length(ALLEEG) < CURRENTSET(1) | CURRENTSET(1) == 0 | isempty(ALLEEG(CURRENTSET(1)).data))
+if (isempty(CURRENTSET) || length(ALLEEG) < CURRENTSET(1) || CURRENTSET(1) == 0 || isempty(ALLEEG(CURRENTSET(1)).data))
CURRENTSET = 0;
for index = 1:length(ALLEEG)
if ~isempty(ALLEEG(index).data)
CURRENTSET = index;
break;
- end;
- end;
+ end
+ end
if CURRENTSET ~= 0
eegh([ '[EEG ALLEEG CURRENTSET] = eeg_retrieve(ALLEEG,' int2str(CURRENTSET) ');' ])
- [EEG ALLEEG] = eeg_retrieve(ALLEEG, CURRENTSET);
+ [EEG, ALLEEG] = eeg_retrieve(ALLEEG, CURRENTSET);
else
EEG = eeg_emptyset;
- end;
-end;
+ end
+end
-if (isempty(EEG) | isempty(EEG(1).data)) & CURRENTSET(1) ~= 0
+if (isempty(EEG) || isempty(EEG(1).data)) && CURRENTSET(1) ~= 0
eegh([ '[EEG ALLEEG CURRENTSET] = eeg_retrieve(ALLEEG,' int2str(CURRENTSET) ');' ])
- [EEG ALLEEG] = eeg_retrieve(ALLEEG, CURRENTSET);
-end;
+ [EEG, ALLEEG] = eeg_retrieve(ALLEEG, CURRENTSET);
+end
% test if dataset has changed
% ---------------------------
-if length(EEG) == 1
- if ~isempty(ALLEEG) & CURRENTSET~= 0 & ~isequal(EEG.data, ALLEEG(CURRENTSET).data) & ~isnan(EEG.data(1))
- % the above comparison does not work for ome structures
- %tmpanswer = questdlg2(strvcat('The current EEG dataset has changed. What should eeglab do with the changes?', ' '), ...
- % 'Dataset change detected', ...
- % 'Keep changes', 'Delete changes', 'New dataset', 'Make new dataset');
- disp('Warning: for some reason, the backup dataset in EEGLAB memory does not');
- disp(' match the current dataset. The dataset in memory has been overwritten');
- [ALLEEG EEG CURRENTSET] = eeg_store(ALLEEG, EEG, CURRENTSET);
- eegh('[ALLEEG EEG CURRENTSET] = eeg_store(ALLEEG, EEG, CURRENTSET);');
-
- %if tmpanswer(1) == 'D' % delete changes
- % [EEG ALLEEG] = eeg_retrieve(ALLEEG, CURRENTSET);
- % eegh('[EEG ALLEEG] = eeg_retrieve( ALLEEG, CURRENTSET);');
- %elseif tmpanswer(1) == 'K' % keep changes
- % [ALLEEG EEG CURRENTSET] = eeg_store(ALLEEG, EEG, CURRENTSET);
- % eegh('[ALLEEG EEG CURRENTSET] = eeg_store(ALLEEG, EEG, CURRENTSET);');
- %else % make new dataset
- % [ALLEEG EEG CURRENTSET LASTCOM] = pop_newset(ALLEEG, EEG, CURRENTSET);
- % eegh(LASTCOM);
- % MAX_SET = max(length( ALLEEG ), length(EEGMENU));
- %end;
- end;
-end;
+if length(EEG) == 1 && length(CURRENTSET) == 1
+ if ~isempty(ALLEEG) && CURRENTSET~= 0 && ~isequal(EEG.data, ALLEEG(CURRENTSET).data)
+ if exist('isequaln','builtin') ~= 5, isequalfunc = @isequal; else isequalfunc = @isequaln; end
+ if isequalfunc(EEG.data, ALLEEG(CURRENTSET).data)
+ disp('Warning: Your data contains NaNs.');
+ else
+ disp('Warning: The backup dataset in EEGLAB memory does not match the current dataset.');
+ disp(' The dataset in memory has been overwritten');
+ [ALLEEG, EEG, CURRENTSET] = eeg_store(ALLEEG, EEG, CURRENTSET);
+ eegh('[ALLEEG EEG CURRENTSET] = eeg_store(ALLEEG, EEG, CURRENTSET);');
+ end
+ end
+else
+ EEG = ALLEEG(CURRENTSET);
+end
% print some information on the main figure
% ------------------------------------------
g = myguihandles(gcf);
if ~isfield(g, 'win0') % no display
return;
-end;
+end
study_selected = 0;
-if exist('STUDY') & exist('CURRENTSTUDY')
- if CURRENTSTUDY == 1, study_selected = 1; end;
-end;
+if exist('STUDY') && exist('CURRENTSTUDY')
+ if CURRENTSTUDY == 1, study_selected = 1; end
+end
menustatus = {};
+try
+ curroiFlag = unique(cellfun(@(x)getfield(x, 'eeglab_using_roi'), { EEG(:).roi }));
+ if length(curroiFlag) == 1 && curroiFlag
+ menustatus = { menustatus{:} 'roi_connect' };
+ else
+ disp('Warning: different settings for using ROIs detected in different datasets');
+ end
+catch
+end
if study_selected
menustatus = { menustatus{:} 'study' };
@@ -1607,10 +1647,10 @@ function command_on_update_menu_click(callerHandle, tmp, eeglabUpdater, installD
% dataset type
% ------------
datasettype = unique_bc( [ EEG.trials ] );
- if datasettype(1) == 1 & length(datasettype) == 1, datasettype = 'continuous';
+ if datasettype(1) == 1 && length(datasettype) == 1, datasettype = 'continuous';
elseif datasettype(1) == 1, datasettype = 'epoched and continuous';
else datasettype = 'epoched';
- end;
+ end
% number of channels and channel locations
% ----------------------------------------
@@ -1620,7 +1660,7 @@ function command_on_update_menu_click(callerHandle, tmp, eeglabUpdater, installD
if length(anyempty) == 2, chanlocs = 'mixed, yes and no';
elseif anyempty == 0, chanlocs = 'yes';
else chanlocs = 'no';
- end;
+ end
% ica weights
% -----------
@@ -1628,17 +1668,17 @@ function command_on_update_menu_click(callerHandle, tmp, eeglabUpdater, installD
if length(anyempty) == 2, studystatus = 'Missing ICA dec.';
elseif anyempty == 0, studystatus = 'Ready to precluster';
else studystatus = 'Missing ICA dec.';
- end;
+ end
- % consistency & other parameters
+ % consistency && other parameters
% ------------------------------
- [EEG epochconsist] = eeg_checkset(EEG, 'epochconsist'); % epoch consistency
- [EEG chanconsist ] = eeg_checkset(EEG, 'chanconsist'); % channel consistency
- [EEG icaconsist ] = eeg_checkset(EEG, 'icaconsist'); % ICA consistency
+ [EEG, epochconsist] = eeg_checkset(EEG, 'epochconsist'); % epoch consistency
+ [EEG, chanconsist ] = eeg_checkset(EEG, 'chanconsist'); % channel consistency
+ [EEG, icaconsist ] = eeg_checkset(EEG, 'icaconsist'); % ICA consistency
totevents = num2str(sum( cellfun( 'length', { EEG.event }) )); % total number of events
totsize = whos('STUDY', 'ALLEEG'); % total size
- if isempty(STUDY.session), sessionstr = ''; else sessionstr = vararg2str(STUDY.session); end;
- if isempty(STUDY.condition), condstr = ''; else condstr = vararg2str(STUDY.condition); end;
+ if isempty(STUDY.session), sessionstr = ''; else sessionstr = vararg2str(STUDY.session); end
+ if isempty(STUDY.condition), condstr = ''; else condstr = vararg2str(STUDY.condition); end
% determine study status
% ----------------------
@@ -1647,10 +1687,10 @@ function command_on_update_menu_click(callerHandle, tmp, eeglabUpdater, installD
studystatus = 'Pre-clustered';
elseif length(STUDY.cluster) > 1
studystatus = 'Clustered';
- end;
+ end
elseif length(STUDY.cluster) > 1
studystatus = 'Clustered';
- end;
+ end
% text
% ----
@@ -1673,7 +1713,7 @@ function command_on_update_menu_click(callerHandle, tmp, eeglabUpdater, installD
set( g.win1, 'String', sprintf('Study filename: ...%s\n', fullfilename(max(1,length(fullfilename)-26):end) ));
else
set( g.win1, 'String', sprintf('Study filename: %s\n' , fullfilename));
- end;
+ end
condconsist = std_checkconsist(STUDY, 'uniform', 'condition');
groupconsist = std_checkconsist(STUDY, 'uniform', 'group');
sessconsist = std_checkconsist(STUDY, 'uniform', 'session');
@@ -1685,14 +1725,14 @@ function command_on_update_menu_click(callerHandle, tmp, eeglabUpdater, installD
set( g.val4, 'String', [ int2str(max(1, length(STUDY.condition))) txtcond ]);
set( g.val5, 'String', [ int2str(max(1, length(STUDY.session))) txtsess ]);
set( g.val6, 'String', [ int2str(max(1, length(STUDY.group))) txtgroup ]);
- set( g.val7, 'String', epochconsist);
- set( g.val8, 'String', chanlenstr);
- set( g.val9, 'String', chanlocs);
- set( g.val10, 'String', length(STUDY.cluster));
- set( g.val11, 'String', studystatus);
+ set( g.val7, 'String', char(epochconsist));
+ set( g.val8, 'String', char(chanlenstr));
+ set( g.val9, 'String', char(chanlocs));
+ set( g.val10, 'String', num2str(length(STUDY.cluster)));
+ set( g.val11, 'String', char(studystatus));
set( g.val12, 'String', num2str(round(sum( [ totsize.bytes] )/1E6*10)/10));
-elseif (exist('EEG') == 1) & ~isnumeric(EEG) & ~isempty(EEG(1).data)
+elseif (exist('EEG') == 1) && ~isnumeric(EEG) && ~isempty(EEG(1).data)
hh = findobj('parent', gcf, 'userdata', 'fullline'); set(hh, 'visible', 'off');
hh = findobj('parent', gcf, 'userdata', 'datinfo'); set(hh, 'visible', 'on');
@@ -1706,17 +1746,17 @@ function command_on_update_menu_click(callerHandle, tmp, eeglabUpdater, installD
strsetnum = 'Datasets ';
for i = CURRENTSET
strsetnum = [ strsetnum int2str(i) ',' ];
- end;
+ end
strsetnum = strsetnum(1:end-1);
set( g.win0, 'String', strsetnum);
% dataset type
% ------------
datasettype = unique_bc( [ EEG.trials ] );
- if datasettype(1) == 1 & length(datasettype) == 1, datasettype = 'continuous';
+ if datasettype(1) == 1 && length(datasettype) == 1, datasettype = 'continuous';
elseif datasettype(1) == 1, datasettype = 'epoched and continuous';
else datasettype = 'epoched';
- end;
+ end
% number of channels and channel locations
% ----------------------------------------
@@ -1726,7 +1766,7 @@ function command_on_update_menu_click(callerHandle, tmp, eeglabUpdater, installD
if length(anyempty) == 2, chanlocs = 'mixed, yes and no';
elseif anyempty == 0, chanlocs = 'yes';
else chanlocs = 'no';
- end;
+ end
% ica weights
% -----------
@@ -1734,13 +1774,13 @@ function command_on_update_menu_click(callerHandle, tmp, eeglabUpdater, installD
if length(anyempty) == 2, icaweights = 'mixed, yes and no';
elseif anyempty == 0, icaweights = 'yes';
else icaweights = 'no';
- end;
+ end
% consistency & other parameters
% ------------------------------
- [EEG epochconsist] = eeg_checkset(EEG, 'epochconsist'); % epoch consistency
- [EEG chanconsist ] = eeg_checkset(EEG, 'chanconsist'); % channel consistency
- [EEG icaconsist ] = eeg_checkset(EEG, 'icaconsist'); % ICA consistency
+ [EEG, epochconsist] = eeg_checkset(EEG, 'epochconsist'); % epoch consistency
+ [EEG, chanconsist ] = eeg_checkset(EEG, 'chanconsist'); % channel consistency
+ [EEG, icaconsist ] = eeg_checkset(EEG, 'icaconsist'); % ICA consistency
totevents = num2str(sum( cellfun( 'length', { EEG.event }) )); % total number of events
srate = vararg2str( mattocell( unique( [ EEG.srate ] ) )); % sampling rate
totsize = whos('EEG'); % total size
@@ -1763,18 +1803,18 @@ function command_on_update_menu_click(callerHandle, tmp, eeglabUpdater, installD
% ------
set( g.win1, 'String', sprintf('Groupname: -(soon)-\n'));
set( g.val2, 'String', int2str(length(EEG)));
- set( g.val3, 'String', datasettype);
- set( g.val4, 'String', epochconsist);
- set( g.val5, 'String', chanlenstr);
- set( g.val6, 'String', chanconsist);
- set( g.val7, 'String', chanlocs);
- set( g.val8, 'String', totevents);
- set( g.val9, 'String', srate);
- set( g.val10, 'String', icaweights);
- set( g.val11, 'String', icaconsist);
+ set( g.val3, 'String', char(datasettype));
+ set( g.val4, 'String', char(epochconsist));
+ set( g.val5, 'String', char(chanlenstr));
+ set( g.val6, 'String', char(chanconsist));
+ set( g.val7, 'String', char(chanlocs));
+ set( g.val8, 'String', char(totevents));
+ set( g.val9, 'String', char(srate));
+ set( g.val10, 'String', char(icaweights));
+ set( g.val11, 'String', char(icaconsist));
set( g.val12, 'String', num2str(round(totsize.bytes/1E6*10)/10));
- else % one continous dataset selected
+ else % one continuous dataset selected
menustatus = { menustatus{:} 'continuous_dataset' };
@@ -1794,16 +1834,16 @@ function command_on_update_menu_click(callerHandle, tmp, eeglabUpdater, installD
if CURRENTSET == 0, strsetnum = '';
else strsetnum = ['#' int2str(CURRENTSET) ': '];
- end;
+ end
maxchar = 28;
if ~isempty( EEG.setname )
if length(EEG.setname) > maxchar+2
set( g.win0, 'String', [strsetnum EEG.setname(1:min(maxchar,length(EEG.setname))) '...' ]);
else set( g.win0, 'String', [strsetnum EEG.setname ]);
- end;
+ end
else
set( g.win0, 'String', [strsetnum '(no dataset name)' ] );
- end;
+ end
fullfilename = fullfile(EEG.filepath, EEG.filename);
if ~isempty(fullfilename)
@@ -1811,47 +1851,47 @@ function command_on_update_menu_click(callerHandle, tmp, eeglabUpdater, installD
set( g.win1, 'String', sprintf('Filename: ...%s\n', fullfilename(max(1,length(fullfilename)-26):end) ));
else
set( g.win1, 'String', sprintf('Filename: %s\n', fullfilename));
- end;
+ end
else
set( g.win1, 'String', sprintf('Filename: none\n'));
- end;
+ end
set( g.val2, 'String', int2str(fastif(isempty(EEG.data), 0, size(EEG.data,1))));
set( g.val3, 'String', int2str(EEG.pnts));
set( g.val4, 'String', int2str(EEG.trials));
set( g.val5, 'String', fastif(isempty(EEG.event), 'none', int2str(length(EEG.event))));
set( g.val6, 'String', int2str( round(EEG.srate)) );
- if round(EEG.xmin) == EEG.xmin & round(EEG.xmax) == EEG.xmax
+ if round(EEG.xmin) == EEG.xmin && round(EEG.xmax) == EEG.xmax
set( g.val7, 'String', sprintf('%d\n', EEG.xmin));
set( g.val8, 'String', sprintf('%d\n', EEG.xmax));
else
set( g.val7, 'String', sprintf('%6.3f\n', EEG.xmin));
set( g.val8, 'String', sprintf('%6.3f\n', EEG.xmax));
- end;
+ end
% reference
if isfield(EEG(1).chanlocs, 'ref')
- [curref tmp allinds] = unique_bc( { EEG(1).chanlocs.ref });
+ [curref, ~, allinds] = unique_bc( { EEG(1).chanlocs.ref });
maxind = 1;
for ind = unique_bc(allinds)
if length(find(allinds == ind)) > length(find(allinds == maxind))
maxind = ind;
- end;
- end;
+ end
+ end
curref = curref{maxind};
- if isempty(curref), curref = 'unknown'; end;
+ if isempty(curref), curref = 'unknown'; end
else curref = 'unknown';
- end;
+ end
set( g.val9, 'String', curref);
if isempty(EEG.chanlocs)
set( g.val10, 'String', 'No');
else
- if ~isfield(EEG.chanlocs, 'theta') | all(cellfun('isempty', { EEG.chanlocs.theta }))
+ if ~isfield(EEG.chanlocs, 'theta') || all(cellfun('isempty', { EEG.chanlocs.theta }))
set( g.val10, 'String', 'No (labels only)');
else
set( g.val10, 'String', 'Yes');
- end;
- end;
+ end
+ end
set( g.val11, 'String', fastif(isempty(EEG.icasphere), 'No', 'Yes'));
tmp = whos('EEG');
@@ -1859,7 +1899,7 @@ function command_on_update_menu_click(callerHandle, tmp, eeglabUpdater, installD
set( g.val12, 'String', num2str(round(tmp.bytes/1E6*10)/10));
else
set( g.val12, 'String', [ num2str(round(tmp.bytes/1E6*10)/10) ' (file mapped)' ]);
- end;
+ end
if EEG.trials > 1 || EEG.xmin ~= 0
menustatus = { menustatus{:} 'epoched_dataset' };
@@ -1868,36 +1908,45 @@ function command_on_update_menu_click(callerHandle, tmp, eeglabUpdater, installD
end
if ~isfield(EEG.chanlocs, 'theta')
menustatus = { menustatus{:} 'chanloc_absent' };
- end;
+ end
if isempty(EEG.icaweights)
menustatus = { menustatus{:} 'ica_absent' };
- end;
- end;
+ end
+ end
else
- menustatus = { menustatus{:} 'startup' };
+ menustatus = { 'startup' };
hh = findobj('parent', gcf, 'userdata', 'fullline'); set(hh, 'visible', 'on');
hh = findobj('parent', gcf, 'userdata', 'datinfo'); set(hh, 'visible', 'off');
set( g.win0, 'String', 'No current dataset');
+ set( g.mainwin0, 'String', 'Suggested steps to get started', 'fontweight', 'bold');
set( g.mainwin1, 'String', '- Create a new or load an existing dataset:');
set( g.mainwin2, 'String', ' Use "File > Import data" (new)');
- set( g.mainwin3, 'String', ' Or "File > Load existing dataset" (old)');
- set( g.mainwin4, 'String', '- If new,');
- set( g.mainwin5, 'String', ' "File > Import epoch info" (data epochs) else');
- set( g.mainwin6, 'String', ' "File > Import event info" (continuous data)');
- set( g.mainwin7, 'String', ' "Edit > Dataset info" (add/edit dataset info)');
- set( g.mainwin8, 'String', ' "File > Save dataset" (save dataset)');
- set( g.mainwin9, 'String', '- Prune data: "Edit > Select data"');
- set( g.mainwin10,'String', '- Reject data: "Tools > Reject continuous data"');
- set( g.mainwin11,'String', '- Epoch data: "Tools > Extract epochs"');
- set( g.mainwin12,'String', '- Remove baseline: "Tools > Remove baseline"');
- set( g.mainwin13,'String', '- Run ICA: "Tools > Run ICA"');
-end;
+ set( g.mainwin3, 'String', ' Or "File > Load existing dataset" (load)');
+ set( g.mainwin4, 'String', ' (find tutorial data in sample_data folder)');
+ set( g.mainwin5, 'String', '- If newly imported raw dataset');
+ set( g.mainwin6, 'String', ' "Edit > Channel locations" (look up locations)');
+ set( g.mainwin7, 'String', ' "File > Import event info" (for continuous data)');
+ set( g.mainwin8, 'String', '- Filter data: "Tools > Filter data"');
+ set( g.mainwin9, 'String', '- Reject data: "Tools > Reject data by eye"');
+ set( g.mainwin10,'String', '- Run ICA: "Tools > Run ICA" (can take time)');
+ set( g.mainwin11,'String', '- Reject by ICA: "Tools > Reject data using ICA"');
+ set( g.mainwin12,'String', '- Epoch data: "Tools > Extract epochs"');
+ set( g.mainwin13,'String', '- Plot ERP: "Plot > Channel ERP > In scalp array"');
+end
% ERPLAB
if exist('ALLERP') == 1 && ~isempty(ALLERP)
menustatus = { menustatus{:} 'erp_dataset' };
-end;
+end
+
+if exist('ALLBEST') == 1 && ~isempty(ALLBEST)
+ menustatus = { menustatus{:} 'best_dataset' };
+end
+
+if exist('ALLMVPC') == 1 && ~isempty(ALLMVPC)
+ menustatus = { menustatus{:} 'mvpc_dataset'};
+end
% enable selected menu items
% --------------------------
@@ -1938,20 +1987,30 @@ function command_on_update_menu_click(callerHandle, tmp, eeglabUpdater, installD
set(allmenus(indmatchvar), 'enable', 'off');
-end;
+end
if any(strcmp(menustatus, 'chanloc_absent'))
eval('indmatchvar = cellfun(@(x)(~isempty(findstr(num2str(x), ''chanloc:on''))), allstrs);');
set(allmenus(indmatchvar), 'enable', 'off');
-end;
+end
if any(strcmp(menustatus, 'ica_absent'))
eval('indmatchvar = cellfun(@(x)(~isempty(findstr(num2str(x), ''ica:on''))), allstrs);');
set(allmenus(indmatchvar), 'enable', 'off');
-end;
+end
+if any(strcmp(menustatus, 'roi_connect'))
+
+ eval('indmatchvar = cellfun(@(x)(~isempty(findstr(num2str(x), ''roi:off''))), allstrs);');
+ set(allmenus(indmatchvar), 'enable', 'off');
+
+end
+% always off
+eval('indmatchvar = cellfun(@(x)(~isempty(findstr(num2str(x), ''enable:off''))), allstrs);');
+set(allmenus(indmatchvar), 'enable', 'off');
+
% --------------------------------
% Javier Lopez-Calderon for ERPLAB
if any(strcmp(menustatus, 'erp_dataset'))
@@ -1960,6 +2019,20 @@ function command_on_update_menu_click(callerHandle, tmp, eeglabUpdater, installD
end
% end, Javier Lopez-Calderon for ERPLAB
% --------------------------------
+% --------------------------------
+% Aaron Matthew Simmons for ERPLAB
+
+if any(strcmp(menustatus, 'best_dataset'))
+ set(allmenus, 'enable', 'on');
+ eval('indmatchvar = cellfun(@(x)(~isempty(findstr(num2str(x), ''bestset:off''))), allstrs);');
+ set(allmenus(indmatchvar), 'enable', 'off');
+end
+if any(strcmp(menustatus, 'mvpc_dataset'))
+ set(allmenus, 'enable', 'on');
+ eval('indmatchvar = cellfun(@(x)(~isempty(findstr(num2str(x), ''mvpcset:off''))), allstrs);');
+ set(allmenus(indmatchvar), 'enable', 'off');
+end
+% end, Aaron Matthew Simmons for ERPLAB
% adjust title extent
@@ -1970,15 +2043,16 @@ function command_on_update_menu_click(callerHandle, tmp, eeglabUpdater, installD
% adjust all font sizes (RMC fix MATLAB 2014 compatibility)
% -------------------
-handlesname = fieldnames(g);
-for i = 1:length(handlesname)
- if isprop(eval(['g.' handlesname{i}]),'Style') & ~strcmp(handlesname{i},'win0')
- propval = get(eval(['g.' handlesname{i}]), 'Style');
- if strcmp(propval,'text')
- set(eval(['g.' handlesname{i}]),'FontSize',TEXT_FONTSIZE);
- end
- end
-end
+% icadefs;
+% handlesname = fieldnames(g);
+% for i = 1:length(handlesname)
+% if isprop(eval(['g.' handlesname{i}]),'Style') && ~strcmp(handlesname{i},'win0')
+% propval = get(eval(['g.' handlesname{i}]), 'Style');
+% if strcmp(propval,'text')
+% set(eval(['g.' handlesname{i}]),'FontSize',TEXT_FONTSIZE);
+% end
+% end
+% end
return;
@@ -1988,7 +2062,7 @@ function command_on_update_menu_click(callerHandle, tmp, eeglabUpdater, installD
switch lower(ButtonName),
case 'cancel', num = 0;
case 'yes', num = 1;
- end;
+ end
function g = myguihandles(fig)
g = [];
@@ -1996,116 +2070,118 @@ function command_on_update_menu_click(callerHandle, tmp, eeglabUpdater, installD
for index = 1:length(hh)
if ~isempty(get(hh(index), 'tag'))
g = setfield(g, get(hh(index), 'tag'), hh(index));
- end;
- end;
+ end
+ end
-function rmpathifpresent(newpath);
+function rmpathifpresent(newpath)
comp = computer;
if strcmpi(comp(1:2), 'PC')
newpath = [ newpath ';' ];
else
newpath = [ newpath ':' ];
- end;
- if ismatlab
- p = matlabpath;
- else p = path;
- end;
+ end
+ p = path;
ind = strfind(p, newpath);
if ~isempty(ind)
rmpath(newpath);
- end;
+ end
% add path only if it is not already in the list
% ----------------------------------------------
-function addpathifnotinlist(newpath);
+function addpathifnotinlist(newpath)
comp = computer;
if strcmpi(comp(1:2), 'PC')
newpathtest = [ newpath ';' ];
else
newpathtest = [ newpath ':' ];
- end;
- if ismatlab
- p = matlabpath;
- else p = path;
- end;
+ end
+ p = path;
ind = strfind(p, newpathtest);
if isempty(ind)
if exist(newpath) == 7
addpath(newpath);
- end;
- end;
+ end
+ end
-function addpathifnotexist(newpath, functionname);
+function addpathifnotexist(newpath, functionname)
tmpp = mywhich(functionname);
if isempty(tmpp)
addpath(newpath);
- end;
+ end
% find a function path and add path if not present
% ------------------------------------------------
-function myaddpath(eeglabpath, functionname, pathtoadd);
+function myaddpath(eeglabpath, functionname, pathtoadd)
tmpp = mywhich(functionname);
tmpnewpath = [ eeglabpath pathtoadd ];
if ~isempty(tmpp)
tmpp = tmpp(1:end-length(functionname));
- if length(tmpp) > length(tmpnewpath), tmpp = tmpp(1:end-1); end; % remove trailing filesep
- if length(tmpp) > length(tmpnewpath), tmpp = tmpp(1:end-1); end; % remove trailing filesep
- %disp([ tmpp ' | ' tmpnewpath '(' num2str(~strcmpi(tmpnewpath, tmpp)) ')' ]);
+ if length(tmpp) > length(tmpnewpath), tmpp = tmpp(1:end-1); end % remove trailing filesep
+ if length(tmpp) > length(tmpnewpath), tmpp = tmpp(1:end-1); end % remove trailing filesep
+ %disp([ tmpp ' || ' tmpnewpath '(' num2str(~strcmpi(tmpnewpath, tmpp)) ')' ]);
if ~strcmpi(tmpnewpath, tmpp)
warning('off', 'MATLAB:dispatcher:nameConflict');
addpath(tmpnewpath);
warning('on', 'MATLAB:dispatcher:nameConflict');
- end;
+ end
else
%disp([ 'Adding new path ' tmpnewpath ]);
addpathifnotinlist(tmpnewpath);
- end;
-
-function val = iseeglabdeployed2;
-%val = 1; return;
-if exist('isdeployed')
- val = isdeployed;
-else val = 0;
-end;
-
-function buildhelpmenu;
+ end
% parse plugin function name
% --------------------------
-function [name, vers] = parsepluginname(dirName);
+function [name, vers] = parsepluginname(dirName, funcname)
ind = find( dirName >= '0' & dirName <= '9' );
if isempty(ind)
name = dirName;
vers = '';
else
ind = length(dirName);
- while ind > 0 && ((dirName(ind) >= '0' & dirName(ind) <= '9') || dirName(ind) == '.' || dirName(ind) == '_')
+ while ind > 0 && ((dirName(ind) >= '0' && dirName(ind) <= '9') || dirName(ind) == '.' || dirName(ind) == '_')
ind = ind - 1;
- end;
+ end
name = dirName(1:ind);
vers = dirName(ind+1:end);
- vers(find(vers == '_')) = '.';
- end;
-
+ vers(vers == '_') = '.';
+ if ~isempty(vers)
+ if vers(1) == '.', vers(1) = []; end
+ end
+ end
+
+ % check with function name and change version if necessary (for loadhdf5)
+ if nargin > 1 && ~isempty(strfind(dirName, funcname))
+ name1 = funcname;
+ vers2 = dirName(length(funcname)+1:end);
+ if ~isempty(vers2)
+ vers2(vers2 == '_') = '.';
+ if ~isequal(vers, vers2) ... % differebt versions
+ && (vers2(1) >= '0' && vers2(1) <= '9') % version 2 is numerical
+ vers = vers2;
+ end
+ end
+ end
+
% required here because path not added yet
% to the admin folder
-function res = ismatlab;
+function res = ismatlab
-v = version;
-if v(1) > '4'
- res = 1;
-else
- res = 0;
-end;
+res = exist('OCTAVE_VERSION', 'builtin') == 0;
-function res = mywhich(varargin);
+function res = mywhich(varargin)
try
res = which(varargin{:});
catch
- fprintf('Warning: permission error accesssing %s\n', varargin{1});
-end;
-
\ No newline at end of file
+ fprintf('Warning: permission error accessing %s\n', varargin{1});
+end
+
+function h = eegmenu( versL, varargin)
+ h = [];
+ if ~versL
+ h = uimenu(varargin{:});
+ end
+
diff --git a/eeglab.prj b/eeglab.prj
new file mode 100644
index 000000000..5bc802061
--- /dev/null
+++ b/eeglab.prj
@@ -0,0 +1,225 @@
+
', text1{:}); + tmp = tmp'; + tmp = tmp(:); + web( tmp' ); else pathHelpHTML = fileparts(which('help2html')); - if ~isempty(findstr('NFT', pathHelpHTML)), rmpath(pathHelpHTML); end; + if ~isempty(findstr('NFT', pathHelpHTML)), rmpath(pathHelpHTML); end text1 = help2html(funct); - if length(funct) > 4 & strcmpi(funct(1:4), 'pop_') + if length(funct) > 4 && strcmpi(funct(1:4), 'pop_') try, text2 = help2html(funct(5:end)); text1 = [text1 '___________________________________________________________________' 10 ... @@ -53,18 +72,27 @@ ' The ''pop'' function above calls the eponymous Matlab function below' 10 ... ' and could use some of its optional parameters' 10 ... '___________________________________________________________________
' text2 ]; - catch, end; - end; - - web([ 'text://' text1 ]); - end; + catch, end + end + if exist('OCTAVE_VERSION','builtin') == 0 + web([ 'text://' text1 ]); + else + disp(text1); + end + end else - if isempty(funct), return; end; + if exist('OCTAVE_VERSION','builtin') == 0 + doc(funct); + return; + end + + if isempty(funct), return; end doc1 = readfunc(funct, nonmatlab); - if length(funct) > 4 & strcmpi(funct(1:4), 'pop_') + if length(funct) > 4 && strcmpi(funct(1:4), 'pop_') try, doc2 = readfunc(funct(5:end), nonmatlab); - doc1 = { doc1{:} ' _________________________________________________________________ ' ... + doc1 = { doc1{:} ' ' ... + ' _________________________________________________________________ ' ... ' ' ... ' The ''pop'' function above calls the eponymous Matlab function below, ' ... ' which may contain more information for some parameters. '... @@ -72,31 +100,62 @@ ' _________________________________________________________________ ' ... ' ' ... doc2{:} }; - catch, end; - end; + catch, end + end + + if exist('OCTAVE_VERSION','builtin') ~= 0 + for iRow = 1:length(doc1) + disp(doc1{iRow}); + end + return + end + + % write file for help only + icadefs; + if ~isempty(EEGOPTION_PATH) % in icadefs above + homefolder = EEGOPTION_PATH; + elseif ispc + homefolder = getenv('USERPROFILE'); + else homefolder = '~'; + end + + [~,funct] = fileparts(funct); + fileTmp = fullfile(homefolder, [ funct '_doc.m' ]); + fid = fopen(fileTmp, 'w'); + if fid ~= -1 + for iDoc = 1:length(doc1) + fprintf(fid, '%%%s\n', doc1{iDoc}); + end + fclose(fid); + doc(fileTmp); + drawnow; pause(2); + delete(fileTmp); + else + textgui(doc1); + h = findobj('parent', gcf, 'style', 'slider'); + try + icadefs; + catch + GUIBUTTONCOLOR = [0.8 0.8 0.8]; + GUITEXTCOLOR = 'k'; + end + set(h, 'backgroundcolor', GUIBUTTONCOLOR); + h = findobj('parent', gcf, 'style', 'pushbutton'); + set(h, 'backgroundcolor', GUIBUTTONCOLOR); + h = findobj('parent', gca); + set(h, 'color', GUITEXTCOLOR); + set(gcf, 'color', BACKCOLOR); + end - textgui(doc1);1000 - h = findobj('parent', gcf, 'style', 'slider'); - try, icadefs; catch, - GUIBUTTONCOLOR = [0.8 0.8 0.8]; - GUITEXTCOLOR = 'k'; - end; - set(h, 'backgroundcolor', GUIBUTTONCOLOR); - h = findobj('parent', gcf, 'style', 'pushbutton'); - set(h, 'backgroundcolor', GUIBUTTONCOLOR); - h = findobj('parent', gca); - set(h, 'color', GUITEXTCOLOR); - set(gcf, 'color', BACKCOLOR); -end; +end return; function [doc] = readfunc(funct, nonmatlab) doc = {}; if iseeglabdeployed - if isempty(find(funct == '.')), funct = [ funct '.m' ]; end; - funct = fullfile(eeglabexefolder, 'help', funct); -end; + warndlg2([ 'Some help menus not available in compiled version.' 10 'Look up help online.' ] ); +end if nonmatlab fid = fopen( funct, 'r'); else @@ -104,17 +163,17 @@ fid = fopen( funct, 'r'); else fid = fopen( [funct '.m'], 'r'); - end; -end; + end +end if fid == -1 error('File not found'); -end; +end sub = 1; try, - if ~isunix, sub = 0; end; -catch, end; + if ~isunix, sub = 0; end +catch, end if nonmatlab str = fgets( fid ); @@ -122,13 +181,13 @@ str = deblank(str(1:end-sub)); doc = { doc{:} str(1:end) }; str = fgets( fid ); - end; + end else str = fgets( fid ); while (str(1) == '%') str = deblank(str(1:end-sub)); doc = { doc{:} str(2:end) }; str = fgets( fid ); - end; -end; + end +end fclose(fid); diff --git a/functions/guifunc/questdlg2.m b/functions/guifunc/questdlg2.m index f81647bed..ecdb96d0a 100644 --- a/functions/guifunc/questdlg2.m +++ b/functions/guifunc/questdlg2.m @@ -1,46 +1,56 @@ -% questdlg2() - questdlg function clone with coloring and help for -% eeglab(). +% QUESTDLG2 - questdlg function clone with coloring and help for +% EEGLAB. % -% Usage: same as questdlg() +% Usage: same as QUESTDLG % % Warning: % Case of button text and result might be changed by the function % % Author: Arnaud Delorme, CNL / Salk Institute, La Jolla, 11 August 2002 % -% See also: inputdlg2(), errordlg2(), supergui(), inputgui() +% See also: INPUTDLG2, ERRORDLG2, SUPERGUI, INPUTGUI % Copyright (C) Arnaud Delorme, CNL / Salk Institute, arno@salk.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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. -function [result] = questdlg2(Prompt,Title,varargin); +function [result] = questdlg2(Prompt,Title,varargin) result = ''; if nargin < 2 help questdlg2; return; -end; +end if isempty(varargin) varargin = { 'Yes' 'No' 'Cancel' 'Yes' }; -end; -result = varargin{end}; -if Prompt(end) == 10, Prompt(end) = []; end; -if Prompt(end) == 10, Prompt(end) = []; end; -if Prompt(end) == 10, Prompt(end) = []; end; -if Prompt(end) == 10, Prompt(end) = []; end; +end +if Prompt(end) == 10, Prompt(end) = []; end +if Prompt(end) == 10, Prompt(end) = []; end +if Prompt(end) == 10, Prompt(end) = []; end +if Prompt(end) == 10, Prompt(end) = []; end fig = figure('visible', 'off'); set(gcf, 'name', Title); @@ -49,43 +59,51 @@ geometry = {}; if ~isempty(find(Prompt == 10)) indlines = find(Prompt == 10); - if indlines(1) ~= 1, indlines = [ 0 indlines ]; end; - if indlines(end) ~= length(Prompt), indlines = [ indlines length(Prompt)+1 ]; end; + if indlines(1) ~= 1, indlines = [ 0 indlines ]; end + if indlines(end) ~= length(Prompt), indlines = [ indlines length(Prompt)+1 ]; end for index = 1:length(indlines)-1 geometry{index} = [1]; listui{index} = { 'Style', 'text', 'string' Prompt(indlines(index)+1:indlines(index+1)-1) }; - end; + end else for index = 1:size(Prompt,1) geometry{index} = [1]; listui{index} = { 'Style', 'text', 'string' Prompt(index,:) }; - end; -end; + end +end listui{end+1} = {}; +width = 80; geometry = { geometry{:} 1 ones(1,length(varargin)-1) }; for index = 1:length(varargin)-1 % ignoring default val - listui = {listui{:} { 'width',80,'align','center','Style', 'pushbutton', 'string', varargin{index}, 'callback', ['set(gcbf, ''userdata'', ''' varargin{index} ''');'] } }; + if index == 1 + if length(varargin{index}) > 15 + width = 160; + elseif length(varargin{index}) > 10 + width = 120; + end + end + listui = {listui{:} { 'width',width,'align','center','Style', 'pushbutton', 'string', varargin{index}, 'callback', ['set(gcbf, ''userdata'', ''' varargin{index} ''');'] } }; if strcmp(varargin{index}, varargin{end}) listui{end}{end+1} = 'fontweight'; listui{end}{end+1} = 'bold'; - end; -end; + end +end %cr = length(find(Prompt == char(10)))+1; %if cr == 1 % cr = size(Prompt,1); -%end; +%end %cr = cr^(7/); -%if cr >= 8, cr = cr-1; end; -%if cr >= 4, cr = cr-1; end; +%if cr >= 8, cr = cr-1; end +%if cr >= 4, cr = cr-1; end %[tmp tmp2 allobj] = supergui( 'fig', fig, 'geomhoriz', geometry, 'geomvert', [cr 1 1], 'uilist', listui, ... [tmp tmp2 allobj] = supergui( 'fig', fig, 'geomhoriz', geometry, 'uilist', listui, ... - 'borders', [0.02 0.015 0.08 0.06], 'spacing', [0 0], 'horizontalalignment', 'left', 'adjustbuttonwidth', 'on' ); + 'borders', [0.05 0.015 0.08 0.06], 'spacing', [0 0], 'horizontalalignment', 'left', 'adjustbuttonwidth', 'off' ); waitfor( fig, 'userdata'); try, result = get(fig, 'userdata'); close(fig); drawnow; -end; +end diff --git a/functions/guifunc/supergui.m b/functions/guifunc/supergui.m index 718ea0111..1971eb251 100644 --- a/functions/guifunc/supergui.m +++ b/functions/guifunc/supergui.m @@ -1,8 +1,8 @@ -% supergui() - a comprehensive gui automatic builder. This function help +% SUPERGUI - a comprehensive gui automatic builder. This function help % to create GUI very fast without bothering about the % positions of the elements. After creating a geometry, % elements just place themselves into the predefined -% locations. It is especially usefull for figure where you +% locations. It is especially useful for figure where you % intend to put text button and descriptions. % % Usage: @@ -34,7 +34,7 @@ % 'uilist' - list of uicontrol lists describing elements properties % { { ui1 }, { ui2 }... }, { 'uiX' } being GUI matlab % uicontrol arguments such as { 'style', 'radiobutton', -% 'String', 'hello' }. See Matlab function uicontrol() for details. +% 'String', 'hello' }. See Matlab function UICONTROL for details. % 'borders' - [left right top bottom] GUI internal borders in normalized % units (0 to 1). Default values are % 'title' - optional figure title @@ -44,7 +44,7 @@ % 'insetv' - vertical space between elements. Default is 2% % of window height. % 'spacing' - [horiz vert] spacing in normalized units. Default -% 'spacingtype' - ['absolute'|'proportional'] abolute means that the +% 'spacingtype' - ['absolute'|'proportional'] absolute means that the % spacing values are fixed. Proportional means that they % depend on the number of element in a line. % 'minwidth' - [integer] minimal width in pixels. Default is none. @@ -60,7 +60,7 @@ % Output: % handles - all the handles of the elements (in the same order as the % uilist input). -% height - adviced height for the figure (so the text look nice). +% height - advised height for the figure (so the text look nice). % allhandles - all the handles in object format % % Example: @@ -71,25 +71,36 @@ % % Author: Arnaud Delorme, CNL / Salk Institute, La Jolla, 2001- % -% See also: eeglab() +% See also: EEGLAB % Copyright (C) 2001 Arnaud Delorme, Salk Institute, arno@salk.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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. -function [handlers, outheight, allhandlers] = supergui( varargin); +function [handlers, outheight, allhandlers, alltags] = supergui( varargin); % handlers cell format % allhandlers linear format @@ -99,7 +110,7 @@ if nargin < 2 help supergui; return; -end; +end % get version and % set additional parameters @@ -110,13 +121,13 @@ if versnum >= 7.14 addParamFont = { 'fontsize' 12 }; else addParamFont = { }; -end; +end warning off MATLAB:hg:uicontrol:ParameterValuesMustBeValid % decoding input and backward compatibility % ----------------------------------------- -if isstr(varargin{1}) +if ischar(varargin{1}) options = varargin; else options = { 'fig' varargin{1} 'geomhoriz' varargin{2} ... @@ -137,25 +148,25 @@ 'spacing' 'real' [] [0.02 0.01]; 'inseth' 'real' [] 0.02; % x border absolute (5% of width) 'insetv' 'real' [] 0.02 }, 'supergui'); -if isstr(g), error(g); end +if ischar(g), error(g); end if ~isempty(g.geomhoriz) maxcount = sum(cellfun('length', g.geomhoriz)); if maxcount ~= length(g.uilist) warning('Wrong size for ''geomhoriz'' input'); - end; + end if ~isempty(g.geomvert) if length(g.geomvert) ~= length(g.geomhoriz) warning('Wrong size for ''geomvert'' input'); - end; - end; + end + end g.insetv = g.insetv/length(g.geomhoriz); -end; +end if ~isempty(g.geom) if length(g.geom) ~= length(g.uilist) warning('Wrong size for ''geom'' input'); - end; + end maxcount = length(g.geom); -end; +end % create new figure % ----------------- @@ -165,12 +176,12 @@ % converting the geometry formats % ------------------------------- -if ~isempty(g.geomhoriz) & ~iscell( g.geomhoriz ) +if ~isempty(g.geomhoriz) && ~iscell( g.geomhoriz ) oldgeom = g.geomhoriz; g.geomhoriz = {}; for row = 1:length(oldgeom) g.geomhoriz = { g.geomhoriz{:} ones(1, oldgeom(row)) }; - end; + end end if isempty(g.geomvert) g.geomvert = ones(1, length(g.geomhoriz)); @@ -191,14 +202,14 @@ g.geom{count} = { length(g.geomhoriz{row}) sumvert [incx incy] [g.geomhoriz{row}(column)*ratio g.geomvert(row)] }; incx = incx+g.geomhoriz{row}(column)*ratio; count = count+1; - end; + end incy = incy+g.geomvert(row); - end; + end g.borders(1:2) = g.borders(1:2)/maxhoriz*5; g.borders(3:4) = g.borders(3:4)/sumvert*10; g.spacing(1) = g.spacing(1)/maxhoriz*5; g.spacing(2) = g.spacing(2)/sumvert*10; -end; +end % disp new geometry % ----------------- @@ -207,9 +218,9 @@ for index = 1:length(g.geom) fprintf('{ %g %g [%g %g] [%g %g] } ...\n', g.geom{index}{1}, g.geom{index}{2}, ... g.geom{index}{3}(1), g.geom{index}{3}(2), g.geom{index}{4}(1), g.geom{index}{3}(2)); - end; + end fprintf('};\n'); -end; +end % get axis coordinates % -------------------- @@ -229,12 +240,17 @@ column = 1; % count the elements factmultx = 0; factmulty = 0; %zeros(length(g.geomhoriz)); +transformTextUIList = []; +alltags = []; for counter = 1:maxcount % init clear rowhandle; gm = g.geom{counter}; [posx posy width height] = getcoord(gm{1}, gm{2}, gm{3}, gm{4}, g.borders, g.spacing); +% str1 = sprintf('%d, %d, [%1.2f,%1.2f], [%1.2f,%1.2f]', gm{1}, gm{2}, gm{3}(1), gm{3}(2), gm{4}(1), gm{4}(2)); +% str2 = sprintf('%.4f, ', [posx posy width height]); +% fprintf('%s -> %s -> %s\n', str1, str2, g.uilist{ counter }{4}); try currentelem = g.uilist{ counter }; @@ -257,45 +273,63 @@ [posx posy+hf2*height 0.005 (hf1-hf2+0.1)*height].*s+q, 'style', 'pushbutton', 'string', ''); allhandlers{counter} = uicontrol(g.fig, 'unit', 'normalized', 'position', ... [posx posy+(hf1+hf2)/2*height width/2 0.005].*s+q, 'style', 'pushbutton', 'string', ''); - allhandlers{counter} = 0; + allhandlers{counter} = nan; else - if strcmpi(currentelem{1}, 'width'), + + if strcmpi(currentelem{1}, 'width') curwidth = currentelem{2}; currentelem(1:2) = []; else curwidth = 0; - end; - if strcmpi(currentelem{1}, 'align'), + end + if strcmpi(currentelem{1}, 'align') align = currentelem{2}; currentelem(1:2) = []; else align = 'right'; - end; - if strcmpi(currentelem{1}, 'stickto'), + end + transformText = false; + if strcmpi(currentelem{2}, 'text2') + transformTextUIList = [ transformTextUIList counter ]; + currentelem{2} = 'text'; + end + if strcmpi(currentelem{1}, 'stickto') stickto = currentelem{2}; currentelem(1:2) = []; else stickto = 'none'; - end; + end if strcmpi(currentelem{1}, 'vertshift'), currentelem(1) = []; addvert = -height/2; else addvert = 0; - end; + end if strcmpi(currentelem{1}, 'vertexpand'), heightfactor = currentelem{2}; addvert = -(heightfactor-1)*height; currentelem(1:2) = []; else heightfactor = 1; - end; + end % position adjustment depending on GUI type - if isstr(currentelem{2}) && strcmpi(currentelem{2}, 'popupmenu') - posy = posy-height/10; - end; - if isstr(currentelem{2}) && strcmpi(currentelem{2}, 'text') + if ischar(currentelem{2}) && strcmpi(currentelem{2}, 'popupmenu') + %posy = posy-height/5; + end + if ischar(currentelem{2}) && strcmpi(currentelem{2}, 'text') posy = posy+height/5; - end; + end - if strcmpi(currentelem{1}, 'function'), + if strcmpi(currentelem{1}, 'function') % property grid argument panel = uipanel('Title','','FontSize',12,'BackgroundColor','white','Position',[posx posy+addvert width height*heightfactor].*s+q); allhandlers{counter} = arg_guipanel(panel, currentelem{:}); + elseif strcmpi(currentelem{1}, 'panel') + % property grid argument + uipanel(currentelem{2:end},'FontSize',12,'Position',[posx posy+addvert width height*heightfactor].*s+q); + allhandlers{counter} = nan; + elseif strcmpi(currentelem{1}, 'uitable') + uitable(g.fig, currentelem{2:end}, 'unit', 'normalized', 'Position',[posx posy+addvert width height*heightfactor].*s+q); + allhandlers{counter} = nan; else - allhandlers{counter} = uicontrol(g.fig, 'unit', 'normalized', 'position', ... - [posx posy+addvert width height*heightfactor].*s+q, currentelem{:}, addParamFont{:}); + if ~isempty(strmatch('fontsize', currentelem(1:2:end))) + allhandlers{counter} = uicontrol(g.fig, 'unit', 'normalized', 'position', ... + [posx posy+addvert width height*heightfactor].*s+q, currentelem{:}); + else + allhandlers{counter} = uicontrol(g.fig, 'unit', 'normalized', 'position', ... + [posx posy+addvert width height*heightfactor].*s+q, currentelem{:}, addParamFont{:}); + end % this simply compute a factor so that all uicontrol will be visible % ------------------------------------------------------------------ @@ -309,54 +343,76 @@ curpos(1) = curpos(1)+curpos(3)-curwidth; elseif strcmpi(align, 'center') curpos(1) = curpos(1)+curpos(3)/2-curwidth/2; - end; + end set(allhandlers{counter}, 'position', [ curpos(1) curpos(2) curwidth curpos(4) ]); if strcmpi(stickto, 'on') set( allhandlers{counter-1}, 'units', 'pixels'); curpos2 = get(allhandlers{counter-1}, 'position'); set(allhandlers{counter-1}, 'position', [ curpos(1)-curpos2(3)-10 curpos2(2) curpos2(3) curpos2(4) ]); set( allhandlers{counter-1}, 'units', 'normalized'); - end; + end curext(3) = curwidth; - end; + end set( allhandlers{counter}, 'units', 'normalized'); - end; + end if ~strcmp(style, 'edit') && (~strcmp(style, 'pushbutton') || strcmpi(g.adjustbuttonwidth, 'on')) - %tmp = curext(3)/curpos(3); - %if tmp > 3*factmultx && factmultx > 0, adsfasd; end; - factmultx = max(factmultx, curext(3)/curpos(3)); - if strcmp(style, 'pushbutton'), factmultx = factmultx*1.1; end; - end; - if ~strcmp(style, 'listbox') + if strcmpi( currentelem{3}, 'string') && (~iscell(currentelem{4}) || ... + (~isempty(currentelem{4}) && isempty(findstr('html', currentelem{4}{1})))) + %tmp = curext(3)/curpos(3); + %if tmp > 3*factmultx && factmultx > 0, adsfasd; end + if exist('OCTAVE_VERSION','builtin') ~= 0 + curtxt = get(allhandlers{counter}, 'string'); + if ischar(curtxt) + nLines = length(find(curtxt == 10))+1; + curext(3) = curext(3)/nLines; + end + end + + if curext(3)/curpos(3) < 3 + factmultx = max(factmultx, curext(3)/curpos(3)); + end + tmptxt = get(allhandlers{counter}, 'string'); +% % text to get which UI modify horizontal size +% if iscell(tmptxt) fprintf('%s -> %f\n', 'cell', curext(3)/curpos(3)); +% else fprintf('%s -> %f\n', tmptxt, curext(3)/curpos(3)); +% end + if strcmp(style, 'pushbutton'), factmultx = factmultx*1.1; end + end + end + if ~strcmp(style, 'listbox') && ~strcmp(style, 'popupmenu') factmulty = max(factmulty, curext(4)/curpos(4)); - end; - - % Uniformize button text aspect (first letter must be upercase) + end + + % Uniformize button text aspect (first letter must be uppercase) % ----------------------------- - if strcmp(style, 'pushbutton') + if strcmp(style, 'pushbutton') && ishandle(allhandlers{counter}) tmptext = get(allhandlers{counter}, 'string'); if length(tmptext) > 1 if upper(tmptext(1)) ~= tmptext(1) || lower(tmptext(2)) ~= tmptext(2) && ~strcmpi(tmptext, 'STATS') tmptext = lower(tmptext); - try, tmptext(1) = upper(tmptext(1)); catch, end; - end; - end; + try, tmptext(1) = upper(tmptext(1)); catch, end + end + end set(allhandlers{counter}, 'string', tmptext); - end; - end; + end + + try + currentelemstruct = struct(currentelem{:}); + alltags.(currentelemstruct.tag) = allhandlers{counter}; + catch, end + end else - allhandlers{counter} = 0; - end; -end; + allhandlers{counter} = nan; + end +end % adjustments % ----------- -factmultx = factmultx*1.02;% because some text was still hidden -%factmultx = factmultx*1.2; +factmultx = factmultx*1.1;% because some text was still hidden if factmultx < 0.1 factmultx = 0.1; -end; +end % for MAC (magnify figures that have edit fields) % ------- @@ -367,9 +423,13 @@ factmulty = factmulty*1.5; elseif ~isunix % windows factmulty = factmulty*1.08; - end; -catch, end; -factmulty = factmulty*0.9; % global shinking + end +catch, end +if exist('OCTAVE_VERSION', 'builtin') == 0 + factmulty = factmulty*0.9; % global shinking +else + factmulty = factmulty*1.5; +end warning on; % scale and replace the figure in the screen @@ -377,8 +437,8 @@ pos = get(g.fig, 'position'); if factmulty > 1 pos(2) = max(0,pos(2)+pos(4)-pos(4)*factmulty); -end; -pos(1) = pos(1)+pos(3)*(1-factmultx)/2; +end +pos(1) = max(0,pos(1)+pos(3)*(1-factmultx)/2); pos(3) = max(pos(3)*factmultx, g.minwidth); pos(4) = pos(4)*factmulty; set(g.fig, 'position', pos); @@ -386,16 +446,16 @@ % vertical alignment to bottom for text (isnumeric by ishanlde was changed here) % --------------------------------------- for index = 1:length(allhandlers) - if allhandlers{index} ~= 0 && ishandle(allhandlers{index}) + if ishandle(allhandlers{index}) if strcmp(get(allhandlers{index}, 'style'), 'text') set(allhandlers{index}, 'unit', 'pixel'); curpos = get(allhandlers{index}, 'position'); curext = get(allhandlers{index}, 'extent'); set(allhandlers{index}, 'position', [curpos(1) curpos(2)-4 curpos(3) curext(4)]); set(allhandlers{index}, 'unit', 'normalized'); - end; - end; -end; + end + end +end % setting defaults colors %------------------------ @@ -404,11 +464,11 @@ GUIBACKCOLOR = [.8 .8 .8]; GUIPOPBUTTONCOLOR = [.8 .8 .8]; GUITEXTCOLOR = [0 0 0]; -end; +end numobjects = cellfun(@ishandle, allhandlers); % (isnumeric by ishanlde was changed here) allhandlersnum = [ allhandlers{numobjects} ]; -hh = findobj(allhandlersnum, 'parent', g.fig, 'style', 'text'); +hh = findobj(allhandlersnum,'flat', 'parent', g.fig, 'style', 'text'); %set(hh, 'BackgroundColor', get(g.fig, 'color'), 'horizontalalignment', 'left'); set(hh, 'Backgroundcolor', GUIBACKCOLOR); set(hh, 'foregroundcolor', GUITEXTCOLOR); @@ -418,25 +478,25 @@ end set(hh, 'horizontalalignment', g.horizontalalignment); -hh = findobj(allhandlersnum, 'style', 'edit'); +hh = findobj(allhandlersnum,'flat', 'style', 'edit'); set(hh, 'BackgroundColor', [1 1 1]); %, 'horizontalalignment', 'right'); -hh =findobj(allhandlersnum, 'parent', g.fig, 'style', 'pushbutton'); +hh =findobj(allhandlersnum,'flat', 'parent', g.fig, 'style', 'pushbutton'); comp = computer; if length(comp) < 3 || ~strcmpi(comp(1:3), 'MAC') % this puts the wrong background on macs set(hh, 'backgroundcolor', GUIPOPBUTTONCOLOR); set(hh, 'foregroundcolor', GUITEXTCOLOR); -end; -hh =findobj(allhandlersnum, 'parent', g.fig, 'style', 'popupmenu'); +end +hh =findobj(allhandlersnum,'flat', 'parent', g.fig, 'style', 'popupmenu'); set(hh, 'backgroundcolor', GUIPOPBUTTONCOLOR); set(hh, 'foregroundcolor', GUITEXTCOLOR); -hh =findobj(allhandlersnum, 'parent', g.fig, 'style', 'checkbox'); +hh =findobj(allhandlersnum,'flat', 'parent', g.fig, 'style', 'checkbox'); set(hh, 'backgroundcolor', GUIBACKCOLOR); set(hh, 'foregroundcolor', GUITEXTCOLOR); -hh =findobj(allhandlersnum, 'parent', g.fig, 'style', 'listbox'); +hh =findobj(allhandlersnum,'flat', 'parent', g.fig, 'style', 'listbox'); set(hh, 'backgroundcolor', GUIPOPBUTTONCOLOR); set(hh, 'foregroundcolor', GUITEXTCOLOR); -hh =findobj(allhandlersnum, 'parent', g.fig, 'style', 'radio'); +hh =findobj(allhandlersnum,'flat', 'parent', g.fig, 'style', 'radio'); set(hh, 'foregroundcolor', GUITEXTCOLOR); set(hh, 'backgroundcolor', GUIPOPBUTTONCOLOR); set(g.fig, 'visible', 'on'); @@ -452,13 +512,29 @@ pos(1) = (screenSize(3)-pos(3))/2; pos(2) = (screenSize(4)-pos(4))/2+pos(4); set(g.fig, 'position', pos); - end; + end end; % set userdata and title % ---------------------- -if ~isempty(g.userdata), set(g.fig, 'userdata', g.userdata); end; -if ~isempty(g.title ), set(g.fig, 'name', g.title ); end; +if ~isempty(g.userdata), set(g.fig, 'userdata', g.userdata); end +if ~isempty(g.title ), set(g.fig, 'name', g.title ); end + +% transform selected text UI +% -------------------------- +a = axes('position', [0 0 1 1]); +for iList = transformTextUIList + set(allhandlers{iList}, 'unit', 'normalized'); + sTmp = get(allhandlers{iList},'string'); + pTmp = get(allhandlers{iList},'position'); + eTmp = get(allhandlers{iList},'extent'); + tTmp = get(allhandlers{iList},'tag'); + % Remove the UICONTROL + delete(allhandlers{iList}); + % Replace it with a TEXT object + allhandlers{iList} = text(pTmp(1),pTmp(2),sTmp, 'interpreter','latex', 'tag', tTmp); +end +set(a, 'visible', 'off'); return; diff --git a/functions/guifunc/warndlg2.m b/functions/guifunc/warndlg2.m index 70f8f8aba..644f1a496 100644 --- a/functions/guifunc/warndlg2.m +++ b/functions/guifunc/warndlg2.m @@ -1,28 +1,43 @@ -% warndlg2() - same as warndlg for eeglab() +% WARNDLG2 - same as warndlg for EEGLAB % % Author: Arnaud Delorme, CNL / Salk Institute, 12 August 2002 % -% See also: inputdlg2(), questdlg2() +% See also: INPUTDLG2, QUESTDLG2 % Copyright (C) Arnaud Delorme, CNL / Salk Institute, arno@salk.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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. -function warndlg2(Prompt, Title); +function warndlg2(Prompt, Title, modal) if nargin <2 Title = 'Warning'; -end; -questdlg2(Prompt, Title, 'OK', 'OK'); +end +if nargin > 2 && ischar(modal) && strcmpi(modal, 'non-modal') + warndlg(Prompt, Title, 'non-modal') +else + questdlg2(Prompt, Title, 'OK', 'OK'); +end diff --git a/functions/javachatfunc/Chat_with_pane.jar b/functions/javachatfunc/Chat_with_pane.jar deleted file mode 100644 index 423fef359..000000000 Binary files a/functions/javachatfunc/Chat_with_pane.jar and /dev/null differ diff --git a/functions/javachatfunc/startpane.m b/functions/javachatfunc/startpane.m deleted file mode 100644 index 1bf214cd6..000000000 --- a/functions/javachatfunc/startpane.m +++ /dev/null @@ -1,12 +0,0 @@ -import client.EEGLABChat; -import client.VisualToolbar; -import java.awt.*; -import javax.swing.*; - -tb = VisualToolbar(); -F = gcf; -tb.setPreferredSize(Dimension(0, 75)); - -javacomponent(tb,'South',F); - -refresh(F); diff --git a/functions/javachatfunc/update.m b/functions/javachatfunc/update.m deleted file mode 100644 index ee78d1d93..000000000 --- a/functions/javachatfunc/update.m +++ /dev/null @@ -1 +0,0 @@ -tb.RefreshToolbar(); diff --git a/functions/miscfunc/abspeak.m b/functions/miscfunc/abspeak.m index be5ae149d..68b2b258a 100644 --- a/functions/miscfunc/abspeak.m +++ b/functions/miscfunc/abspeak.m @@ -1,4 +1,4 @@ -% abspeak() - find peak amps/latencies in each row of a single-epoch data matrix +% ABSPEAK - find peak amps/latencies in each row of a single-epoch data matrix % % Usage: % >> [amps,frames,signs] = abspeak(data); @@ -17,19 +17,30 @@ % Copyright (C) 1998 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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. % 3-9-98 added frames arg -sm % 01-25-02 reformated help & license -ad diff --git a/functions/miscfunc/arrow.m b/functions/miscfunc/arrow.m index bb16209d1..806a10ba3 100755 --- a/functions/miscfunc/arrow.m +++ b/functions/miscfunc/arrow.m @@ -1,1191 +1,6 @@ +function varargout = arrow( varargin ) -% arrow() - Draw a line with an arrowhead. -% -% Usage: -% >> arrow('Property1',PropVal1,'Property2',PropVal2,...) -% >> arrow(H,'Prop1',PropVal1,...) -% >> arrow(Start,Stop) -% >> arrow(Start,Stop,Length,BaseAngle,TipAngle,Width,Page,CrossDir) -% >> arrow demo %2-D demos of the capabilities of arrow() -% >> arrow demo2 %3-D demos of the capabilities of arrow() -% -% Inputs: -% H - vector of handles to previously created arrows and/or -% line objects, will update the previously-created -% arrows according to the current view and any specified -% properties, and will convert two-point line objects to -% corresponding arrows. Note that arrow(H) will update the -% arrows if the current view has changed. -% Start - vectors of length 2 or 3, or matrices with 2 or 3 columns -% Stop - same as Start -% 'Start' - The starting points. B -% 'Stop' - The end points. /|\ ^ -% 'Length' - Length of the arrowhead in pixels. /|||\ | -% 'BaseAngle' - Base angle in degrees (ADE). //|||\\ L| -% 'TipAngle' - Tip angle in degrees (ABC). ///|||\\\ e| -% 'Width' - Width of the base in pixels. ////|||\\\\ n| -% 'Page' - Use hardcopy proportions. /////|D|\\\\\ g| -% 'CrossDir' - Vector || to arrowhead plane. //// ||| \\\\ t| -% 'NormalDir' - Vector out of arrowhead plane. /// ||| \\\ h| -% 'Ends' - Which end has an arrowhead. //<----->|| \\ | -% 'ObjectHandles' - Vector of handles to update. / base ||| \ V -% 'LineStyle' - The linestyle of the arrow. E angle||<-------->C -% 'LineWidth' - Line thicknesses. |||tipangle -% 'FaceColor' - FaceColor of patch arrows. ||| -% 'EdgeColor' - EdgeColor/Color of patch/line arrows. ||| -% 'Color' - Set FaceColor & EdgeColor properties. -->|A|<-- width -% -% Notes: -% A property list can follow any specified normal argument list, e.g., -% ARROW([1 2 3],[0 0 0],36,'BaseAngle',60) creates an arrow from (1,2,3) to -% the origin, with an arrowhead of length 36 pixels and 60-degree base angle. -% -% The basic arguments or properties can generally be vectorized to create -% multiple arrows with the same call. This is done by passing a property -% with one row per arrow, or, if all arrows are to have the same property -% value, just one row may be specified. -% -% You may want to execute AXIS(AXIS) before calling ARROW so it doesn't change -% the axes on you; ARROW determines the sizes of arrow components BEFORE the -% arrow is plotted, so if ARROW changes axis limits, arrows may be malformed. -% -% ARROW uses features of Matlab 4.2c and later, so earlier versions may be -% incompatible; call ARROW VERSION for more details. -% -% Author: Erik A. Johnson, 1995 - -% Copyright (c)1995, Erik A. Johnson , 10/6/95 - -% Many thanks to Keith Rogers for his many excellent -% suggestions and beta testing. Check out his shareware package MATDRAW. -% He has permission to distribute ARROW with MATDRAW. - - -% $Log: arrow.m,v $ -% Revision 1.5 2009/10/20 22:19:56 dev -% -% added log to file -% - - -function [h,yy,zz] = arrow(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8, ... - arg9,arg10,arg11,arg12,arg13,arg14,arg15,arg16, ... - arg17,arg18,arg19,arg20,arg21,arg22,arg23,arg24) - -% Are we doing the demo? -c = sprintf('\n'); -if (nargin==1), - if (ischar(arg1)), - arg1 = lower([arg1 ' ']); - if (strcmp(arg1(1:4),'prop')), - disp([c ... - 'ARROW Properties: Default values are given in [square brackets], and other' c ... - ' acceptable equivalent property names are in (parenthesis).' c c ... - ' Start The starting points. For N arrows, B' c ... - ' this should be a Nx2 or Nx3 matrix. /|\ ^' c ... - ' Stop The end points. For N arrows, this /|||\ |' c ... - ' should be a Nx2 or Nx3 matrix. //|||\\ L|' c ... - ' Length Length of the arrowhead (in pixels on ///|||\\\ e|' c ... - ' screen, points on a page). [16] (Len) ////|||\\\\ n|' c ... - ' BaseAngle Angle (degrees) of the base angle /////|D|\\\\\ g|' c ... - ' ADE. For a simple stick arrow, use //// ||| \\\\ t|' c ... - ' BaseAngle=TipAngle. [90] (Base) /// ||| \\\ h|' c ... - ' TipAngle Angle (degrees) of tip angle ABC. //<----->|| \\ |' c ... - ' [16] (Tip) / base ||| \ V' c ... - ' Width Width of the base in pixels. Not E angle ||<-------->C' c ... - ' the ''LineWidth'' prop. [0] (Wid) |||tipangle' c ... - ' Page If provided, non-empty, and not NaN, |||' c ... - ' this causes ARROW to use hardcopy |||' c ... - ' rather than onscreen proportions. A' c ... - ' This is important if screen aspect --> <-- width' c ... - ' ratio and hardcopy aspect ratio are ----CrossDir---->' c ... - ' vastly different. []' c... - ' CrossDir A vector giving the direction towards which the fletches' c ... - ' on the arrow should go. [computed such that it is perpen-' c ... - ' dicular to both the arrow direction and the view direction' c ... - ' (i.e., as if it was pasted on a normal 2-D graph)] (Note' c ... - ' that CrossDir is a vector; if an axis is plotted on a log' c ... - ' scale, then the corresponding component of CrossDir must' c ... - ' also be set appropriately, i.e., to 1 for no change in' c ... - ' that direction, >1 for a positive change, >0 and <1 for' c ... - ' negative change.)' c ... - ' NormalDir A vector normal to the fletch direction (CrossDir is then' c ... - ' computed by the vector cross product {Line}x{NormalDir}). []' c ... - ' Ends Set which end has an arrowhead. Valid values are ''none'',' c ... - ' ''stop'', ''start'', and ''both''. [''stop''] (End)' c... - ' ObjectHandles Vector of handles to previously-created arrows to be' c ... - ' updated or line objects to be converted to arrows.' c ... - ' [] (Object,Handle)' c ... - ' LineStyle The linestyle of the arrow. If anything other than ''-'',' c ... - ' the arrow will be drawn with a line object, otherwise it' c ... - ' will be drawn with a patch. [''-''] (LineS)' c ... - ' LineWidth Same as used in SET commands, but may be passed a vector' c ... - ' for multiple arrows. [default of the line or patch]' c ... - ' FaceColor Set the FaceColor of patch arrows. May be one of' c ... - ' ''ymcrgbwkfn'' (f=flat,n=none) or a column-vector colorspec' c ... - ' (or Nx3 matrix for N arrows). [1 1 1] (FaceC)' c ... - ' EdgeColor Set the EdgeColor of patch arrows and Color of line' c ... - ' arrows. [1 1 1] (EdgeC)' c ... - ' Color Sets both FaceColor and EdgeColor properties.' c ... - ' Included for compatibility with line objects.' c c ... - ' ARROW(''Start'',P,''Stop'',[]) or ARROW(''Start'',[],''Stop'',P), with size(P)=[N 3]' c ... - ' will create N-1 arrows, just like ARROW(''Start'',P1,''Stop'',P2), where' c c ... - ' / x1 y1 z1 \ / x1 y1 z1 \ / x2 y2 z2 \' c ... - ' | . . . | | . . . | | . . . |' c ... - ' P = | . . . | P1 = | . . . | P2 = | . . . |' c ... - ' | . . . | | . . . | | . . . |' c ... - ' \ xN yN zN / \ xN-1 yN-1 zN-1 / \ xN yN zN /' c]); - elseif (strcmp(arg1(1:4),'vers')), - disp([c ... - 'ARROW Version: There are two compatibility problems for ARROW in Matlab' c ... - ' versions earlier than 4.2c:' c c c ... - ' 1) In Matlab <4.2, the ''Tag'' property does not exist. ARROW uses this' c ... - ' ''Tag'' to identify arrow objects for subsequent calls to ARROW.' c c ... - ' Solution: (a) delete all instances of the string' c c ... - ' ,''Tag'',ArrowTag' c c ... - ' (b) and replace all instances of the string' c c ... - ' strcmp(get(oh,''Tag''),ArrowTag)' c c ... - ' with the string' c c ... - ' all(size(ud)==[1 15])' c c c ... - ' 2) In Matlab <4.2c, FINDOBJ is buggy (it can cause Matlab to crash if' c ... - ' more than 100 objects are returned). ARROW uses FINDOBJ to make sure' c ... - ' that any handles it receives are truly handles to existing objects.' c c ... - ' Solution: replace the line' c c ... - ' objs = findobj;' c c ... - ' with the lines' c c ... - ' objs=0; k=1;' c ... - ' while (k<=length(objs)),' c ... - ' objs = [objs; get(objs(k),''Children'')];' c ... - ' if (strcmp(get(objs(k),''Type''),''axes'')),' c ... - ' objs=[objs;get(objs(k),''XLabel''); ...' c ... - ' get(objs(k),''YLabel''); ...' c ... - ' get(objs(k),''ZLabel''); ...' c ... - ' get(objs(k),''Title'')];' c ... - ' end;' c ... - ' k=k+1;' c ... - ' end;' c c]); - elseif (strcmp(arg1(1:4),'demo')), - % demo - % create the data - [x,y,z] = peaks; - [ddd,iii]=max(z(:)); - axlim = [min(x(:)) max(x(:)) min(y(:)) max(y(:)) min(z(:)) max(z(:))]; - - % modify it by inserting some NaN's - [m,n] = size(z); - m = floor(m/2); - n = floor(n/2); - z(1:m,1:n) = NaN*ones(m,n); - - % graph it - clf('reset'); - hs=surf(x,y,z); - xlabel('x'); ylabel('y'); - - if (~strcmp(arg1(1:5),'demo2')), - % set the view - axis(axlim); - zlabel('z'); - %shading('interp'); set(hs,'EdgeColor','k'); - view(viewmtx(-37.5,30,20)); - title('Demo of the capabilities of the ARROW function in 3-D'); - - % Normal yellow arrow - h1 = arrow([axlim(1) axlim(4) 4],[-.8 1.2 4], ... - 'EdgeColor','y','FaceColor','y'); - - % Normal white arrow, clipped by the surface - h2 = arrow(axlim([1 4 6]),[0 2 4]); - t=text(-2.4,2.7,7.7,'arrow clipped by surf'); - - % Baseangle<90 - h3 = arrow([3 .125 3.5],[1.375 0.125 3.5],30,50); - t2=text(3.1,.125,3.5,'local maximum'); - - % Baseangle<90, fill and edge colors different - h4 = arrow(axlim(1:2:5)*.5,[0 0 0],36,60,25, ... - 'EdgeColor','b','FaceColor','c'); - t3=text(axlim(1)*.5,axlim(3)*.5,axlim(5)*.5-.75,'origin'); - set(t3,'HorizontalAlignment','center'); - - % Baseangle>90, black fill - h5 = arrow([-2.9 2.9 3],[-1.3 .4 3.2],30,120,[],6, ... - 'EdgeColor','r','FaceColor','k','LineWidth',2); - - % Baseangle>90, no fill - h6 = arrow([-2.9 2.9 1.3],[-1.3 .4 1.5],30,120,[],6, ... - 'EdgeColor','r','FaceColor','none','LineWidth',2); - - % Stick arrow - h7 = arrow([-1.6 -1.65 -6.5],[0 -1.65 -6.5],[],16,16); - t4=text(-1.5,-1.65,-7.25,'global mininum'); - set(t4,'HorizontalAlignment','center'); - - % Normal, black fill - h8 = arrow([-1.4 0 -7.2],[-1.4 0 -3],'FaceColor','k'); - t5=text(-1.5,0,-7.75,'local minimum'); - set(t5,'HorizontalAlignment','center'); - - % Gray fill, crossdir specified - h9 = arrow([-3 2.2 -6],[-3 2.2 -.05],36,[],27,6,[],[0 -1 0], ... - 'EdgeColor','w','FaceColor',.2*[1 1 1]); - - % a series of normal arrows, linearly spaced, crossdir specified - h10y=(0:4)'/3; - h10 = arrow([-3*ones(size(h10y)) h10y -6.5*ones(size(h10y))], ... - [-3*ones(size(h10y)) h10y -.05*ones(size(h10y))], ... - 12,[],[],[],[],[0 -1 0]); - - % a series of normal arrows, linearly spaced - h11x=(1:.33:2.8)'; - h11 = arrow([h11x -3*ones(size(h11x)) 6.5*ones(size(h11x))], ... - [h11x -3*ones(size(h11x)) -.05*ones(size(h11x))]); - - % series of black-filled arrows, radially oriented, crossdir specified - h12x=2; h12y=-3; h12z=axlim(5)/2; h12xr=1; h12zr=h12z; ir=.15;or=.81; - h12t=(0:11)'/6*pi; - h12 = arrow([h12x+h12xr*cos(h12t)*ir h12y*ones(size(h12t)) ... - h12z+h12zr*sin(h12t)*ir],[h12x+h12xr*cos(h12t)*or ... - h12y*ones(size(h12t)) h12z+h12zr*sin(h12t)*or], ... - 10,[],[],[],[], ... - [-h12xr*sin(h12t) zeros(size(h12t)) h12zr*cos(h12t)],... - 'FaceColor','none','EdgeColor','m'); - - % series of normal arrows, tangentially oriented, crossdir specified - or13=.91; h13t=(0:.5:12)'/6*pi; - h13 = arrow([h12x+h12xr*cos(h13t)*or13 ... - h12y*ones(size(h13t)) ... - h12z+h12zr*sin(h13t)*or13],[],6); - - % arrow with no line ==> oriented upwards - h14 = arrow([3 3 3],[3 3 3],30); - t6=text(3,3,3.6,'no line'); set(t6,'HorizontalAlignment','center'); - - % arrow with -- linestyle - h15 = arrow([-.5 -3 -3],[1 -3 -3],'LineStyle','--','EdgeColor','g'); - - if (nargout>=1), h=[h1;h2;h3;h4;h5;h6;h7;h8;h9;h10;h11;h12;h13;h14;h15]; end; - else, - set(hs,'YData',10.^get(hs,'YData')); - shading('interp'); - view(2); - title('Demo of the capabilities of the ARROW function in 2-D'); - hold on; [C,H]=contour(x,y,z,20); hold off; - for k=H', set(k,'ZData',(axlim(6)+1)*ones(size(get(k,'XData'))),... - 'YData',10.^get(k,'YData'),'Color','k'); end; - set(gca,'YScale','log'); - axis([axlim(1:2) 10.^axlim(3:4)]); - - % Normal yellow arrow - h1 = arrow([axlim(1) 10^axlim(4) axlim(6)+2],[x(iii) 10^y(iii) axlim(6)+2], ... - 'EdgeColor','y','FaceColor','y'); - - % three arrows with varying fill, width, and baseangle - h2 = arrow([-3 10^(-3) 10; -3 10^(-1.5) 10; -1.5 10^(-3) 10], ... - [-.03 10^(-.03) 10; -.03 10^(-1.5) 10; -1.5 10^(-.03) 10], ... - 24,[90;60;120],[],[0;0;4]); - set(h2(2),'EdgeColor','g','FaceColor','c'); - set(h2(3),'EdgeColor','m','FaceColor','r'); - if (nargout>=1), h=[h1;h2]; end; - end; - else, - error(['ARROW got an unknown single-argument string ''' deblank(arg1) '''.']); - end; - return; - end; -end; - -% Check # of arguments -if (nargin==0), help arrow ; return; -elseif (nargout>3), error('ARROW produces at most 3 output arguments.'); -end; - -% find first property number -firstprop = nargin+1; -if (nargin<=3), % to speed things up a bit - if (nargin==1), - elseif (ischar(arg1)), firstprop=1; - elseif (ischar(arg2)), firstprop=2; - elseif (nargin==3), - if (ischar(arg3)), firstprop=3; end; - end; -else, - for k=1:nargin, - curarg = eval(['arg' num2str(k)]); - if (ischar(curarg)), - firstprop = k; - break; - end; - end; -end; - -% check property list -if (firstprop<=nargin), - for k=firstprop:2:nargin, - curarg = eval(['arg' num2str(k)]); - if ((~ischar(curarg))|(min(size(curarg))~=1)), - error('ARROW requires that a property name be a single string.'); - end; - end; - if (rem(nargin-firstprop,2)~=1), - error(['ARROW requires that the property ''' eval(['arg' num2str(nargin)]) ... - ''' be paired with a property value.']); - end; -end; - -% default output -if (nargout>0), h=[]; end; -if (nargout>1), yy=[]; end; -if (nargout>2), zz=[]; end; - -% set values to empty matrices -start = []; -stop = []; -len = []; -baseangle = []; -tipangle = []; -wid = []; -page = []; -crossdir = []; -ends = []; -linewidth = []; -linestyle = []; -edgecolor = []; -facecolor = []; -ax = []; -oldh = []; -defstart = [NaN NaN NaN]; -defstop = [NaN NaN NaN]; -deflen = 16; -defbaseangle = 90; -deftipangle = 16; -defwid = 0; -defpage = 0; -defcrossdir = [NaN NaN NaN]; -defends = 1; -deflinewidth = NaN; -deflinestyle = '- '; -defedgecolor = [1 1 1]; -deffacecolor = [1 1 1]; -defoldh = []; - -% The 'Tag' we'll put on our arrows -ArrowTag = 'Arrow'; - -% check for oldstyle arguments -if (firstprop>2), - % if old style arguments, get them - if (firstprop==3), start=arg1; stop=arg2; - elseif (firstprop==4), start=arg1; stop=arg2; len=arg3(:); - elseif (firstprop==5), start=arg1; stop=arg2; len=arg3(:); baseangle=arg4(:); - elseif (firstprop==6), start=arg1; stop=arg2; len=arg3(:); baseangle=arg4(:); tipangle=arg5(:); - elseif (firstprop==7), start=arg1; stop=arg2; len=arg3(:); baseangle=arg4(:); tipangle=arg5(:); wid=arg6(:); - elseif (firstprop==8), start=arg1; stop=arg2; len=arg3(:); baseangle=arg4(:); tipangle=arg5(:); wid=arg6(:); page=arg7(:); - elseif (firstprop==9), start=arg1; stop=arg2; len=arg3(:); baseangle=arg4(:); tipangle=arg5(:); wid=arg6(:); page=arg7(:); crossdir=arg8; - else, error('ARROW takes at most 8 non-property arguments.'); - end; -elseif (firstprop==2), - % assume arg1 is a set of handles - oldh = arg1(:); -end; - -% parse property pairs -extraprops=char([]); -for k=firstprop:2:nargin, - prop = eval(['arg' num2str(k)]); - val = eval(['arg' num2str(k+1)]); - prop = [lower(prop(:)') ' ']; - if (all(prop(1:5)=='start')), start = val; - elseif (all(prop(1:4)=='stop')), stop = val; - elseif (all(prop(1:3)=='len')), len = val(:); - elseif (all(prop(1:4)=='base')), baseangle = val(:); - elseif (all(prop(1:3)=='tip')), tipangle = val(:); - elseif (all(prop(1:3)=='wid')), wid = val(:); - elseif (all(prop(1:4)=='page')), page = val; - elseif (all(prop(1:5)=='cross')), crossdir = val; - elseif (all(prop(1:4)=='norm')), if (ischar(val)), crossdir=val; else, crossdir=val*sqrt(-1); end; - elseif (all(prop(1:3)=='end')), ends = val; - elseif (all(prop(1:5)=='linew')), linewidth = val(:); - elseif (all(prop(1:5)=='lines')), linestyle = val; - elseif (all(prop(1:5)=='color')), edgecolor = val; facecolor=val; - elseif (all(prop(1:5)=='edgec')), edgecolor = val; - elseif (all(prop(1:5)=='facec')), facecolor = val; - elseif (all(prop(1:6)=='object')), oldh = val(:); - elseif (all(prop(1:6)=='handle')), oldh = val(:); - elseif (all(prop(1:5)=='userd')), %ignore it - else, extraprops=[extraprops ',arg' num2str(k) ',arg' num2str(k+1)]; - end; -end; - -% Check if we got 'default' values -if (ischar(start )), s=lower([start(:)' ' ']); if (all(s(1:3)=='def')), start = defstart; else, error(['ARROW does not recognize ''' start(:)' ''' as a valid ''Start'' string.']); end; end; -if (ischar(stop )), s=lower([stop(:)' ' ']); if (all(s(1:3)=='def')), stop = defstop; else, error(['ARROW does not recognize ''' stop(:)' ''' as a valid ''Stop'' string.']); end; end; -if (ischar(len )), s=lower([len(:)' ' ']); if (all(s(1:3)=='def')), len = deflen; else, error(['ARROW does not recognize ''' len(:)' ''' as a valid ''Length'' string.']); end; end; -if (ischar(baseangle )), s=lower([baseangle(:)' ' ']); if (all(s(1:3)=='def')), baseangle = defbaseangle; else, error(['ARROW does not recognize ''' baseangle(:)' ''' as a valid ''BaseAngle'' string.']); end; end; -if (ischar(tipangle )), s=lower([tipangle(:)' ' ']); if (all(s(1:3)=='def')), tipangle = deftipangle; else, error(['ARROW does not recognize ''' tipangle(:)' ''' as a valid ''TipAngle'' string.']); end; end; -if (ischar(wid )), s=lower([wid(:)' ' ']); if (all(s(1:3)=='def')), wid = defwid; else, error(['ARROW does not recognize ''' wid(:)' ''' as a valid ''Width'' string.']); end; end; -if (ischar(crossdir )), s=lower([crossdir(:)' ' ']); if (all(s(1:3)=='def')), crossdir = defcrossdir; else, error(['ARROW does not recognize ''' crossdir(:)' ''' as a valid ''CrossDir'' or ''NormalDir'' string.']); end; end; -if (ischar(page )), s=lower([page(:)' ' ']); if (all(s(1:3)=='def')), page = defpage; else, error(['ARROW does not recognize ''' page(:)' ''' as a valid ''Page'' string.']); end; end; -if (ischar(ends )), s=lower([ends(:)' ' ']); if (all(s(1:3)=='def')), ends = defends; end; end; -if (ischar(linewidth )), s=lower([linewidth(:)' ' ']); if (all(s(1:3)=='def')), linewidth = deflinewidth; else, error(['ARROW does not recognize ''' linewidth(:)' ''' as a valid ''LineWidth'' string.']); end; end; -if (ischar(linestyle )), s=lower([linestyle(:)' ' ']); if (all(s(1:3)=='def')), linestyle = deflinestyle; end; end; -if (ischar(edgecolor )), s=lower([edgecolor(:)' ' ']); if (all(s(1:3)=='def')), edgecolor = defedgecolor; end; end; -if (ischar(facecolor )), s=lower([facecolor(:)' ' ']); if (all(s(1:3)=='def')), facecolor = deffacecolor; end; end; -if (ischar(oldh )), s=lower([oldh(:)' ' ']); if (all(s(1:3)=='def')), oldh = []; else, error(['ARROW does not recognize ''' oldh(:)' ''' as a valid ''ObjectHandles'' string.']); end; end; - -% check transpose on arguments; convert strings to numbers -if (((size(start ,1)==2)|(size(start ,1)==3))&((size(start ,2)==1)|(size(start ,2)>3))), start = start'; end; -if (((size(stop ,1)==2)|(size(stop ,1)==3))&((size(stop ,2)==1)|(size(stop ,2)>3))), stop = stop'; end; -if (((size(crossdir,1)==2)|(size(crossdir,1)==3))&((size(crossdir,2)==1)|(size(crossdir,2)>3))), crossdir = crossdir'; end; -if ((size(linestyle,2)>2)&(size(linestyle,1)<=2)), linestyle=linestyle'; end; -if (all(size(edgecolor))), - if (ischar(edgecolor)), - col = lower(edgecolor(:,1)); - edgecolor = zeros(length(col),3); - ii=find(col=='y'); if (all(size(ii))), edgecolor(ii,:)=ones(length(ii),1)*[1 1 0]; end; - ii=find(col=='m'); if (all(size(ii))), edgecolor(ii,:)=ones(length(ii),1)*[1 0 1]; end; - ii=find(col=='c'); if (all(size(ii))), edgecolor(ii,:)=ones(length(ii),1)*[0 1 1]; end; - ii=find(col=='r'); if (all(size(ii))), edgecolor(ii,:)=ones(length(ii),1)*[1 0 0]; end; - ii=find(col=='g'); if (all(size(ii))), edgecolor(ii,:)=ones(length(ii),1)*[0 1 0]; end; - ii=find(col=='b'); if (all(size(ii))), edgecolor(ii,:)=ones(length(ii),1)*[0 0 1]; end; - ii=find(col=='w'); if (all(size(ii))), edgecolor(ii,:)=ones(length(ii),1)*[1 1 1]; end; - ii=find(col=='k'); if (all(size(ii))), edgecolor(ii,:)=ones(length(ii),1)*[0 0 0]; end; - ii=find(col=='f'); if (all(size(ii))), edgecolor(ii,:)=ones(length(ii),1)*[1 1 1]*inf; end; - ii=find(col=='n'); if (all(size(ii))), edgecolor(ii,:)=ones(length(ii),1)*[1 1 1]*(-inf); end; - elseif ((size(edgecolor,2)~=3)&(size(edgecolor,1)==3)), - edgecolor=edgecolor'; - elseif (size(edgecolor,2)~=3), - error('ARROW requires that color specifications must be a ?x3 RGB matrix.'); - end; -end; -if (all(size(facecolor))), - if (ischar(facecolor)), - col = lower(facecolor(:,1)); - facecolor = zeros(length(col),3); - ii=find(col=='y'); if (all(size(ii))), facecolor(ii,:)=ones(length(ii),1)*[1 1 0]; end; - ii=find(col=='m'); if (all(size(ii))), facecolor(ii,:)=ones(length(ii),1)*[1 0 1]; end; - ii=find(col=='c'); if (all(size(ii))), facecolor(ii,:)=ones(length(ii),1)*[0 1 1]; end; - ii=find(col=='r'); if (all(size(ii))), facecolor(ii,:)=ones(length(ii),1)*[1 0 0]; end; - ii=find(col=='g'); if (all(size(ii))), facecolor(ii,:)=ones(length(ii),1)*[0 1 0]; end; - ii=find(col=='b'); if (all(size(ii))), facecolor(ii,:)=ones(length(ii),1)*[0 0 1]; end; - ii=find(col=='w'); if (all(size(ii))), facecolor(ii,:)=ones(length(ii),1)*[1 1 1]; end; - ii=find(col=='k'); if (all(size(ii))), facecolor(ii,:)=ones(length(ii),1)*[0 0 0]; end; - ii=find(col=='f'); if (all(size(ii))), facecolor(ii,:)=ones(length(ii),1)*[1 1 1]*inf; end; - ii=find(col=='n'); if (all(size(ii))), facecolor(ii,:)=ones(length(ii),1)*[1 1 1]*(-inf); end; - elseif ((size(facecolor,2)~=3)&(size(facecolor,1)==3)), - facecolor=facecolor'; - elseif (size(facecolor,2)~=3), - error('ARROW requires that color specifications must be a ?x3 RGB matrix.'); - end; -end; -if (all(size(ends))), - if (ischar(ends)), - endsorig = ends; - col = lower([ends(:,1:min(3,size(ends,2))) ones(size(ends,1),max(0,3-size(ends,2)))*' ']); - ends = NaN*ones(size(ends,1),1); - oo = ones(1,size(ends,1)); - ii=find(all(col'==['non']'*oo)'); if (all(size(ii))), ends(ii)=ones(length(ii),1)*0; end; - ii=find(all(col'==['sto']'*oo)'); if (all(size(ii))), ends(ii)=ones(length(ii),1)*1; end; - ii=find(all(col'==['sta']'*oo)'); if (all(size(ii))), ends(ii)=ones(length(ii),1)*2; end; - ii=find(all(col'==['bot']'*oo)'); if (all(size(ii))), ends(ii)=ones(length(ii),1)*3; end; - if (any(isnan(ends))), - ii = min(find(isnan(ends))); - error(['ARROW does not recognize ''' deblank(endsorig(ii,:)) ''' as a valid ''Ends'' value.']); - end; - else, - ends = ends(:); - end; -end; -oldh = oldh(:); - -% check object handles -if (all(size(oldh))), - oldh = oldh.'; - objs = findobj; - if (length(objs)==0), error('ARROW found no graphics handles.'); - elseif (length(objs)==1), objs=[objs;objs]; end; - if (~all(any(objs(:,ones(1,length(oldh)))==oldh(ones(length(objs),1),:)))), - error('ARROW got invalid object handles.'); - end; - oldh = oldh.'; -end; - -% Check for an empty Start or Stop (but not both) with no object handles -if ((~all(size(oldh)))&(all(size(start))~=all(size(stop)))), - if (~all(size(start))), start=stop; end; - ii = find(all(diff(start)'==0)'); - if (size(start,1)==1), - stop = start; - elseif (length(ii)==size(start,1)-1) - stop = start(1,:); - start = stop; - else, - if (all(size(ii))), - jj = (1:size(start,1))'; - jj(ii) = zeros(length(ii),1); - jj = jj(find(jj>0)); - start = start(jj,:); - end; - stop = start(2:size(start,1),:); - start = start(1:size(start,1)-1,:); - end; -end; - -% largest argument length -argsizes = [length(oldh) size(start,1) size(stop,1) ... - length(len) length(baseangle) length(tipangle) ... - length(wid) length(page) size(crossdir,1) length(ends) ... - length(linewidth) size(edgecolor,1) size(facecolor,1)]; -args=['length(ObjectHandle) '; ... - '#rows(Start) '; ... - '#rows(Stop) '; ... - 'length(Length) '; ... - 'length(BaseAngle) '; ... - 'length(TipAngle) '; ... - 'length(Width) '; ... - 'length(Page) '; ... - '#rows(CrossDir) '; ... - '#rows(Ends) '; ... - 'length(LineWidth) '; ... - '#colors in EdgeColor '; ... - '#colors in FaceColor ']; -if (any(imag(crossdir(:))~=0)), - args(9,:) = '#rows(NormalDir) '; -end; -if (~all(size(oldh))), - narrows = max(argsizes); -else, - narrows = length(oldh); -end; - -% Check size of arguments -ii = find((argsizes~=0)&(argsizes~=1)&(argsizes~=narrows)); -if (all(size(ii))), - s = args(ii',:); - while ((size(s,2)>1)&((abs(s(:,size(s,2)))==0)|(abs(s(:,size(s,2)))==abs(' ')))), - s = s(:,1:size(s,2)-1); - end; - s = [ones(length(ii),1)*'ARROW requires that ' s ... - ones(length(ii),1)*[' equal the # of arrows (' num2str(narrows) ').' c]]; - s = s'; - s = s(:)'; - s = s(1:length(s)-1); - error(char(s)); -end; - -% check element length in Start, Stop, and CrossDir -if (all(size(start))), - if (size(start,2)==2), - start = [start NaN*ones(size(start,1),1)]; - elseif (size(start,2)~=3), - error('ARROW requires 2- or 3-element Start points.'); - end; -end; -if (all(size(stop))), - if (size(stop,2)==2), - stop = [stop NaN*ones(size(stop,1),1)]; - elseif (size(stop,2)~=3), - error('ARROW requires 2- or 3-element Stop points.'); - end; -end; -if (all(size(crossdir))), - if (size(crossdir,2)<3), - crossdir = [crossdir NaN*ones(size(crossdir,1),3-size(crossdir,2))]; - elseif (size(crossdir,2)~=3), - if (all(imag(crossdir(:))==0)), - error('ARROW requires 2- or 3-element CrossDir vectors.'); - else, - error('ARROW requires 2- or 3-element NormalDir vectors.'); - end; - end; -end; - -% fill empty arguments -if (~all(size(start ))), start = [NaN NaN NaN]; end; -if (~all(size(stop ))), stop = [NaN NaN NaN]; end; -if (~all(size(len ))), len = NaN; end; -if (~all(size(baseangle ))), baseangle = NaN; end; -if (~all(size(tipangle ))), tipangle = NaN; end; -if (~all(size(wid ))), wid = NaN; end; -if (~all(size(page ))), page = NaN; end; -if (~all(size(crossdir ))), crossdir = [NaN NaN NaN]; end; -if (~all(size(ends ))), ends = NaN; end; -if (~all(size(linewidth ))), linewidth = NaN; end; -if (~all(size(linestyle ))), linestyle = char(['-']); end; % was NaN -if (~all(size(edgecolor ))), edgecolor = [NaN NaN NaN]; end; -if (~all(size(facecolor ))), facecolor = [NaN NaN NaN]; end; - -% expand single-column arguments -o = ones(narrows,1); -if (size(start ,1)==1), start = o * start ; end; -if (size(stop ,1)==1), stop = o * stop ; end; -if (length(len )==1), len = o * len ; end; -if (length(baseangle )==1), baseangle = o * baseangle ; end; -if (length(tipangle )==1), tipangle = o * tipangle ; end; -if (length(wid )==1), wid = o * wid ; end; -if (length(page )==1), page = o * page ; end; -if (size(crossdir ,1)==1), crossdir = o * crossdir ; end; -if (length(ends )==1), ends = o * ends ; end; -if (length(linewidth )==1), linewidth = o * linewidth ; end; -if (size(linestyle ,1)==1), linestyle = o * linestyle ; end; -if (size(edgecolor ,1)==1), edgecolor = o * edgecolor ; end; -if (size(facecolor ,1)==1), facecolor = o * facecolor ; end; -ax = o * gca; -if (size(linestyle ,2)==1), linestyle = char([linestyle o*' ']); end; -linestyle = char(linestyle); - -% if we've got handles, get the defaults from the handles -oldlinewidth = NaN*ones(narrows,1); -oldlinestyle = char(zeros(narrows,2)); -oldedgecolor = NaN*ones(narrows,3); -oldfacecolor = NaN*ones(narrows,3); -if (all(size(oldh))), - fromline = zeros(narrows,1); - for k=1:narrows, - oh = oldh(k); - ud = get(oh,'UserData'); - isarrow = strcmp(get(oh,'Tag'),ArrowTag); - ohtype = get(oh,'Type'); - ispatch = strcmp(ohtype,'patch'); - isline = strcmp(ohtype,'line'); - if (isarrow|isline), - % arrow UserData format: [start' stop' len base tip wid page crossdir' ends] - if (isarrow), - start0 = ud(1:3); - stop0 = ud(4:6); - if (isnan(len(k))), len(k) = ud( 7); end; - if (isnan(baseangle(k))), baseangle(k) = ud( 8); end; - if (isnan(tipangle(k))), tipangle(k) = ud( 9); end; - if (isnan(wid(k))), wid(k) = ud(10); end; - if (isnan(page(k))), page(k) = ud(11); end; - if (isnan(crossdir(k,1))), crossdir(k,1) = ud(12); end; - if (isnan(crossdir(k,2))), crossdir(k,2) = ud(13); end; - if (isnan(crossdir(k,3))), crossdir(k,3) = ud(14); end; - if (isnan(ends(k))), ends(k) = ud(15); end; - end; - if (isline), - fromline(k) = 1; - if (isarrow), - fc = -inf*[1 1 1]; - else, - fc = get(oh,'Color'); - x = get(oh,'XData'); - y = get(oh,'YData'); - z = get(oh,'ZData'); - if (any(size(x)~=[1 2])|any(size(y)~=[1 2])), - error('ARROW only converts two-point lines.'); - end; - if (~all(size(z))), z=NaN*ones(size(x)); end; - start0 = [x(1) y(1) z(1)]; - stop0 = [x(2) y(2) z(2)]; - end; - ec = get(oh,'Color'); - ls = [get(oh,'LineStyle') ' ']; ls=char(ls(1:2)); - lw = get(oh,'LineWidth'); - else, % an arrow patch - fc = get(oh,'FaceColor');if (ischar(fc)), - if (strcmp(fc,'none')), fc=-inf*[1 1 1]; - elseif (strcmp(fc,'flat')), fc=inf*[1 1 1]; - else, fc=[1 1 1]; end; - end; - ec = get(oh,'EdgeColor');if (ischar(ec)), - if (strcmp(ec,'none')), ec=-inf*[1 1 1]; - elseif (strcmp(ec,'flat')), ec=inf*[1 1 1]; - else, ec=[1 1 1]; end; - end; - ls = char('- '); - lw = get(oh,'LineWidth'); - end; - ax(k) = get(oh,'Parent'); - else, - error(['ARROW cannot convert ' ohtype ' objects.']); - end; - oldlinewidth(k) = lw; - oldlinestyle(k,:) = ls; - oldedgecolor(k,:) = ec; - oldfacecolor(k,:) = fc; - ii=find(isnan(start(k,:))); if (all(size(ii))), start(k,ii)=start0(ii); end; - ii=find(isnan(stop( k,:))); if (all(size(ii))), stop( k,ii)=stop0( ii); end; - if (isnan(linewidth(k))), linewidth(k) = lw; end; - if (isnan(linestyle(k,1))), linestyle(k,1:2) = ls; end; - if (any(isnan(facecolor(k,:)))), facecolor(k,:) = fc; end; - if (any(isnan(edgecolor(k,:)))), edgecolor(k,:) = ec; end; - end; -else - fromline = []; -end; - -% set up the UserData data -% (do it here so it is not corrupted by log10's and such) -ud = [start stop len baseangle tipangle wid page crossdir ends]; - -% Set Page defaults -if isnan(page) - page = ~isnan(page); -end; - -% Get axes limits, range, min; correct for aspect ratio and log scale -axm = zeros(3,narrows); -axr = zeros(3,narrows); -ap = zeros(2,narrows); -xyzlog = zeros(3,narrows); -limmin = zeros(2,narrows); -limrange = zeros(2,narrows); -oneax = all(ax==ax(1)); -if (oneax), - T = zeros(4,4); - invT = zeros(4,4); -else, - T = zeros(16,narrows); - invT = zeros(16,narrows); -end; -axnotdone = ones(size(ax)); -while (any(axnotdone)), - ii = min(find(axnotdone)); - curax = ax(ii); - curpage = page(ii); - % get axes limits and aspect ratio - axl = [get(curax,'XLim'); get(curax,'YLim'); get(curax,'ZLim')]; - ar = get(curax,'DataAspectRatio'); - % get axes size in pixels (points) - u = get(curax,'Units'); - axposoldunits = get(curax,'Position'); - if (curpage), - curfig = get(curax,'Parent'); - pu = get(curfig,'PaperUnits'); - set(curfig,'PaperUnits','points'); - pp = get(curfig,'PaperPosition'); - set(curfig,'PaperUnits',pu); - set(curax,'Units','normalized'); - curap = get(curax,'Position'); - curap = pp.*curap; - else, - set(curax,'Units','pixels'); - curap = get(curax,'Position'); - end; - set(curax,'Units',u); - set(curax,'Position',axposoldunits); - % adjust limits for log scale on axes - curxyzlog = [strcmp(get(curax,'XScale'),'log'); ... - strcmp(get(curax,'YScale'),'log'); ... - strcmp(get(curax,'ZScale'),'log')]; - if (any(curxyzlog)), - ii = find([curxyzlog;curxyzlog]); - if (any(axl(ii)<=0)), - error('ARROW does not support non-positive limits on log-scaled axes.'); - else, - axl(ii) = log10(axl(ii)); - end; - end; - % correct for aspect ratio - if (~isnan(ar(1))), - if (curap(3) < ar(1)*curap(4)), - curap(2) = curap(2) + (curap(4)-curap(3)/ar(1))/2; - curap(4) = curap(3)/ar(1); - else, - curap(1) = curap(1) + (curap(3)-curap(4)*ar(1))/2; - curap(3) = curap(4)*ar(1); - end; - end; - % correct for 'equal' - % may only want to do this for 2-D views, but seems right for 3-D also - if (~isnan(ar(2))), - if ((curap(3)/(axl(1,2)-axl(1,1)))/(curap(4)/(axl(2,2)-axl(2,1)))>ar(2)), - incr = curap(3)*(axl(2,2)-axl(2,1))/(curap(4)*ar(2)) - (axl(1,2)-axl(1,1)); - axl(1,:) = axl(1,:) + incr/2*[-1 1]; - else, - incr = ar(2)*(axl(1,2)-axl(1,1))*curap(4)/curap(3) - (axl(2,2)-axl(2,1)); - axl(2,:) = axl(2,:) + incr/2*[-1 1]; - end; - end; - % compute the range of 2-D values - curT = get(curax,'Xform'); - lim = curT*[0 1 0 1 0 1 0 1;0 0 1 1 0 0 1 1;0 0 0 0 1 1 1 1;1 1 1 1 1 1 1 1]; - lim = lim(1:2,:)./([1;1]*lim(4,:)); - curlimmin = min(lim')'; - curlimrange = max(lim')' - curlimmin; - curinvT = inv(curT); - if (~oneax), - curT = curT.'; - curinvT = curinvT.'; - curT = curT(:); - curinvT = curinvT(:); - end; - % check which arrows to which cur corresponds - ii = find((ax==curax)&(page==curpage)); - oo = ones(1,length(ii)); - axr(:,ii) = diff(axl')' * oo; - axm(:,ii) = axl(:,1) * oo; - ap(:,ii) = curap(3:4)' * oo; - xyzlog(:,ii) = curxyzlog * oo; - limmin(:,ii) = curlimmin * oo; - limrange(:,ii) = curlimrange * oo; - if (oneax), - T = curT; - invT = curinvT; - else, - T(:,ii) = curT * oo; - invT(:,ii) = curinvT * oo; - end; - axnotdone(ii) = zeros(1,length(ii)); -end; - -% correct for log scales -curxyzlog = xyzlog.'; -ii = find(curxyzlog(:)); -if (all(size(ii))), - start( ii) = real(log10(start( ii))); - stop( ii) = real(log10(stop( ii))); - if (all(imag(crossdir(ii))==0)), - crossdir(ii) = real(log10(crossdir(ii))); - else, - jj = find(imag(crossdir(ii))==0); - if (all(size(jj))), crossdir(jj) = real(log10(crossdir(jj))); end; - jj = find(imag(crossdir(ii))~=0); - if (all(size(jj))), crossdir(jj) = real(log10(imag(crossdir(jj))))*sqrt(-1); end; - end; -end; - -% take care of defaults, page was done above -ii=find(isnan(start(:) )); if (all(size(ii))), start(ii) = axm(ii)+axr(ii)/2; end; -ii=find(isnan(stop(:) )); if (all(size(ii))), stop(ii) = axm(ii)+axr(ii)/2; end; -ii=find(isnan(crossdir(:) )); if (all(size(ii))), crossdir(ii) = zeros(length(ii),1); end; -ii=find(isnan(len )); if (all(size(ii))), len(ii) = ones(length(ii),1)*deflen; end; -ii=find(isnan(baseangle )); if (all(size(ii))), baseangle(ii) = ones(length(ii),1)*defbaseangle; end; -ii=find(isnan(tipangle )); if (all(size(ii))), tipangle(ii) = ones(length(ii),1)*deftipangle; end; -ii=find(isnan(wid )); if (all(size(ii))), wid(ii) = ones(length(ii),1)*defwid; end; -ii=find(isnan(ends )); if (all(size(ii))), ends(ii) = ones(length(ii),1)*defends; end; -ii=find(isnan(linewidth )); if (all(size(ii))), linewidth(ii) = ones(length(ii),1)*deflinewidth; end; -ii=find(any(isnan(edgecolor'))); if (all(size(ii))), edgecolor(ii,:) = ones(length(ii),1)*defedgecolor; end; -ii=find(any(isnan(facecolor'))); if (all(size(ii))), facecolor(ii,:) = ones(length(ii),1)*deffacecolor; end; -ii=find(isnan(linestyle(:,1) )); if (all(size(ii))), linestyle(ii,:) = ones(length(ii),1)*deflinestyle; end; -ii=find(isnan(linestyle(:,2) )); if (all(size(ii))), linestyle(ii,2) = ones(length(ii),1)*' '; end; %just in case - -% transpose all values -start = start.'; -stop = stop.'; -len = len.'; -baseangle = baseangle.'; -tipangle = tipangle.'; -wid = wid.'; -page = page.'; -crossdir = crossdir.'; -ends = ends.'; -linewidth = linewidth.'; -linestyle = linestyle.'; -facecolor = facecolor.'; -edgecolor = edgecolor.'; -fromline = fromline.'; -ax = ax.'; -oldlinewidth = oldlinewidth.'; -oldlinestyle = oldlinestyle.'; -oldedgecolor = oldedgecolor.'; -oldfacecolor = oldfacecolor.'; - -% given x, a 3xN matrix of points in 3-space; -% want to convert to X, the corresponding 4xN 2-space matrix -% -% tmp1=[(x-axm)./axr; ones(1,size(x,1))]; -% if (oneax), X=T*tmp1; -% else, tmp1=[tmp1;tmp1;tmp1;tmp1]; tmp1=T.*tmp1; -% tmp2=zeros(4,4*N); tmp2(:)=tmp1(:); -% X=zeros(4,N); X(:)=sum(tmp2)'; end; -% X = X ./ (X(:,4)*ones(1,4)); - -% for all points with start==stop, start=stop-(verysmallvalue)*(up-direction); -ii = find(all(start==stop)); -if (all(size(ii))), - % find an arrowdir vertical on screen and perpendicular to viewer - % transform to 2-D - tmp1 = [(stop(:,ii)-axm(:,ii))./axr(:,ii);ones(1,length(ii))]; - if (oneax), twoD=T*tmp1; - else, tmp1=[tmp1;tmp1;tmp1;tmp1]; tmp1=T(:,ii).*tmp1; - tmp2=zeros(4,4*length(ii)); tmp2(:)=tmp1(:); - twoD=zeros(4,length(ii)); twoD(:)=sum(tmp2)'; end; - twoD=twoD./(ones(4,1)*twoD(4,:)); - % move the start point down just slightly - tmp1 = twoD + [0;-1/1000;0;0]*(limrange(2,ii)./ap(2,ii)); - % transform back to 3-D - if (oneax), threeD=invT*tmp1; - else, tmp1=[tmp1;tmp1;tmp1;tmp1]; tmp1=invT(:,ii).*tmp1; - tmp2=zeros(4,4*length(ii)); tmp2(:)=tmp1(:); - threeD=zeros(4,length(ii)); threeD(:)=sum(tmp2)'; end; - start(:,ii) = (threeD(1:3,:)./(ones(3,1)*threeD(4,:))).*axr(:,ii)+axm(:,ii); -end; - -% compute along-arrow points -% transform Start points - tmp1=[(start-axm)./axr;ones(1,narrows)]; - if (oneax), X0=T*tmp1; - else, tmp1=[tmp1;tmp1;tmp1;tmp1]; tmp1=T.*tmp1; - tmp2=zeros(4,4*narrows); tmp2(:)=tmp1(:); - X0=zeros(4,narrows); X0(:)=sum(tmp2)'; end; - X0=X0./(ones(4,1)*X0(4,:)); -% transform Stop points - tmp1=[(stop-axm)./axr;ones(1,narrows)]; - if (oneax), Xf=T*tmp1; - else, tmp1=[tmp1;tmp1;tmp1;tmp1]; tmp1=T.*tmp1; - tmp2=zeros(4,4*narrows); tmp2(:)=tmp1(:); - Xf=zeros(4,narrows); Xf(:)=sum(tmp2)'; end; - Xf=Xf./(ones(4,1)*Xf(4,:)); -% compute pixel distance between points - D = sqrt(sum(((Xf(1:2,:)-X0(1:2,:)).*(ap./limrange)).^2)); -% compute and modify along-arrow distances - len1 = len; - len2 = len - (len.*tan(tipangle/180*pi)-wid/2).*tan((90-baseangle)/180*pi); - slen0 = zeros(1,narrows); - slen1 = len1 .* ((ends==2)|(ends==3)); - slen2 = len2 .* ((ends==2)|(ends==3)); - len0 = zeros(1,narrows); - len1 = len1 .* ((ends==1)|(ends==3)); - len2 = len2 .* ((ends==1)|(ends==3)); - % for no start arrowhead - ii=find((ends==1)&(D 0), h=H; end; -else, - % don't create the patch, just return the data - h=x; - yy=y; - zz=z; -end; +disp('The arrow function was removed from EEGLAB') +disp('because of lack of compatibility with Matlab 2019') +disp('An updated version of the function is available at') +disp('https://www.mathworks.com/matlabcentral/fileexchange/278-arrow') diff --git a/functions/miscfunc/averef.m b/functions/miscfunc/averef.m index f6d6cbfec..b68d0881c 100644 --- a/functions/miscfunc/averef.m +++ b/functions/miscfunc/averef.m @@ -1,6 +1,6 @@ -% averef() - convert common-reference EEG data to average reference +% AVEREF - convert common-reference EEG data to average reference % Note that this old function is not being used in EEGLAB. The -% function used by EEGLAB is reref(). +% function used by EEGLAB is REREF. % % Usage: % >> data = averef(data); @@ -13,7 +13,7 @@ % Outputs: % data_out - Input data converted to average reference. % W_out - ICA weight matrix converted to average reference -% S_out - ICA sphere matrix converted to eye() +% S_out - ICA sphere matrix converted to EYE % meandata - (1,dataframes) mean removed from each data frame (point) % % Note: If 2 args, also converts the weight matrix W to average reference: @@ -24,23 +24,34 @@ % % Authors: Scott Makeig and Arnaud Delorme, SCCN/INC/UCSD, La Jolla, 1999 % -% See also: reref() +% See also: REREF % Copyright (C) 1999 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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. % 12/16/99 Corrected denomiator on the suggestion of Ian Nimmo-Smith, Cambridge UK % 01-25-02 reformated help & license -ad @@ -70,11 +81,11 @@ size1 = size(winv,1); avematrix = eye(size1)-ones(size1)*1/size1; W = pinv(avematrix*winv); -end; +end if nargin >= 3 winv = pinv(W*S); size1 = size(winv,1); avematrix = eye(size1)-ones(size1)*1/size1; W = pinv(avematrix*winv); S = eye(chans); -end; +end diff --git a/functions/miscfunc/brainstorm2eeglab.m b/functions/miscfunc/brainstorm2eeglab.m new file mode 100644 index 000000000..45cc0619b --- /dev/null +++ b/functions/miscfunc/brainstorm2eeglab.m @@ -0,0 +1,139 @@ +% brainstorm2eeglab - convert Brainstorm structures to EEGLAB dataset +% +% EEG = brainstorm2eeglab(bst, epochType); +% +% Inputs: +% bst - Brainstorm string for a folder containing data epoch files or Brainstorm +% data epoch structure +% epochType - [string] epoch type. Only import these epochs which +% Comment field contains this string +% +% Limitations: +% - Only import data epochs +% - Cannot import linked file +% +% Output: +% EEG - EEGLAB structure +% +% Author: Arnaud Delorme, UCSD + +% Copyright (C) Arnaud Delorme, UCSD 2022 +% +% This file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. + +function EEG = brainstorm2eeglab(bst, epochType) + +if nargin < 1 + help brainstorm2eeglab; + return; +end +if nargin < 2 + epochType = ''; +end + +if ischar(bst) + oriBst = bst; + bst = dir(fullfile(bst, '*.mat')); + if isempty(bst) + error('Files not found') + end +else + oriBst = ''; + % Need brainstrorm + try + prot = bst_get('ProtocolInfo'); + catch + brainstorm nogui + try + prot = bst_get('ProtocolInfo'); + catch + error('Brainstorm not found. Brainstorm must be installed and running.') + end + end + brainstorm_path = bst_get('BrainstormDbDir'); + protocol = prot.Comment; + + for iEpoch = 1:length(bst) + bst(iEpoch).name = bst(iEpoch).FileName; + bst(iEpoch).folder = fullfile(brainstorm_path, protocol, 'data'); + end +end + +disp('Reading data epochs...'); +allEpochs = {}; +for iEpoch = 1:length(bst) + if ~isequal(bst(iEpoch).name, 'brainstormstudy.mat') + epochStruct = load('-mat', fullfile(bst(iEpoch).folder, bst(iEpoch).name)); + % epochStruct.Comment(1) contain the type of event + % events not imported (in epochStruct.event) + if ~isempty(epochType) + if contains(epochStruct.Comment, epochType) + allEpochs{end+1} = epochStruct.F; + end + else + allEpochs{end+1} = epochStruct.F; + end + end +end +data = reshape([allEpochs{:}], size(allEpochs{1},1), size(allEpochs{1},2), length(allEpochs)); + +% create EEG structure +EEG = eeg_emptyset; +EEG.srate = mean(1./diff(epochStruct.Time)); +EEG.data = data; % microvolts +EEG.xmin = epochStruct.Time(1); + +% channel locations +if isempty(oriBst) + chanFile = fullfile(bst(1).folder, bst(1).ChannelFile); +else + chanFile = fullfile(oriBst, '..', '@default_study', 'channel.mat'); +end +if exist(chanFile, 'file') + chans = load('-mat', chanFile); + for iChan = 1:length(chans.Channel) + EEG.chanlocs(iChan).labels = chans.Channel(iChan).Name; + if ~isempty(chans.Channel(iChan).Loc) + EEG.chanlocs(iChan).X = chans.Channel(iChan).Loc(1); + EEG.chanlocs(iChan).Y = chans.Channel(iChan).Loc(2); + EEG.chanlocs(iChan).Z = chans.Channel(iChan).Loc(3); + end + EEG.chanlocs(iChan).type = chans.Channel(iChan).Type; + end + EEG.chanlocs = convertlocs(EEG.chanlocs, 'cart2all'); +end +EEG = eeg_checkset(EEG); + +% rescale data to microvolts +if ~isempty(EEG.chanlocs) + chanTypes = strmatch('EEG', { EEG.chanlocs.type }); + if ~isempty(chanTypes) + EEG.data(chanTypes,:,:) = EEG.data(chanTypes,:,:)*1e6; % assumes volt (this code should not be reached as channel types should always be defined) + end +else + EEG.data = EEG.data*1e6; % assumes volt (this code should not be reached as channel types should always be defined) +end + diff --git a/functions/miscfunc/caliper.m b/functions/miscfunc/caliper.m index 8087c9dc5..727b51213 100644 --- a/functions/miscfunc/caliper.m +++ b/functions/miscfunc/caliper.m @@ -1,4 +1,4 @@ -% caliper() - Measure a set of spatial components of a given data epoch relative to +% CALIPER - Measure a set of spatial components of a given data epoch relative to % a reference epoch and decomposition. % Usage: % >> [amp,window]=caliper(newepoch,refepoch,weights,compnums,filtnums,times,'noplot'); @@ -17,7 +17,7 @@ % windows = (length(compnums)),length(times)) matrix of tapering windows used % % Notes: -% Function caliper() works as follows: First the reference epoch is decomposed using +% Function CALIPER works as follows: First the reference epoch is decomposed using % the given weight matrix (may be ICA, PCA, or etc). Next, the time course of the % main lobe of the activation in the reference epoch (from max to 1st min, forward % and backward in time from abs max, optionally after bandpass filtering) is used @@ -33,23 +33,34 @@ % Copyright (C) 11/2000 Scott Makeig & Marissa Westerfield,, SCCN/INC/UCSD % -% 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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. % Edit History: % 12/05/00 -- added fig showing data, ref activation, and window vector -mw -% 12/19/00 -- adjusted new icaproj() args -sm +% 12/19/00 -- adjusted new ICAPROJ args -sm % 01-25-02 reformated help & license -ad function [amps,windows] = caliper(newepoch,refepoch,weights,compnums,filtnums,times,noplot) @@ -66,11 +77,11 @@ nchans = size(newepoch,1); ntimes = size(newepoch,2); -if compnums(1) == 0 | isempty(compnums(1)) +if compnums(1) == 0 || isempty(compnums(1)) compnums = 1:nchans; end -if min(compnums) < 1 | max(compnums) > size(weights,2) +if min(compnums) < 1 || max(compnums) > size(weights,2) help caliper return end @@ -80,7 +91,7 @@ else if isempty(filtnums) filtnums = []; - elseif length(filtnums)==1 & filtnums(1)==0 + elseif length(filtnums)==1 && filtnums(1)==0 filtnums = []; elseif length(filtnums) ~= 3 fprintf('\ncaliper(): filter parameters (filtnums) must have length 3.\n') @@ -88,7 +99,7 @@ end end -if nargin< 6 | isempty(times) | (length(times)==1 & times(1)==0) +if nargin< 6 || isempty(times) || (length(times)==1 && times(1)==0) times = 0:ntimes-1; else if length(times) ~= ntimes @@ -171,7 +182,7 @@ amps = [amps winvrms(c)*sum(refact(n,:).*newact(n,:))]; end n = n+1; - if ~noplot & n <= 4 %%% only plot out at most the first 3 components + if ~noplot && n <= 4 %%% only plot out at most the first 3 components refproj = icaproj(refepoch,weights,c); refproj = env(refproj); windproj = winv(:,c)*(refact(n-1,:)*refnorm); diff --git a/functions/miscfunc/chanproj.m b/functions/miscfunc/chanproj.m index 5b31811ea..2d797c069 100644 --- a/functions/miscfunc/chanproj.m +++ b/functions/miscfunc/chanproj.m @@ -1,11 +1,11 @@ -% chanproj() - make a detailed plot of data returned from plotproj() +% CHANPROJ - make a detailed plot of data returned from PLOTPROJ % for given channel. Returns the data plotted. % Usage: % >> [chandata] = chanproj(projdata,chan); % >> [chandata] = chanproj(projdata,chan,ncomps,framelist,limits,title,colors); % % Inputs: -% projdata = data returned from plotproj() +% projdata = data returned from PLOTPROJ % chan = single channel to plot % ncomps = number of component projections in projdata % @@ -21,26 +21,37 @@ % Copyright (C) 1996 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 +% This file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. % 11-30-96 Scott Makeig CNL / Salk Institute, La Jolla as plotprojchan.m -% 03-19-97 changed var() to diag(cov()) -sm +% 03-19-97 changed VAR to diag(COV) -sm % 03-26-97 fix (== -> =) -sm % 04-03-97 allow framelist to be a col vector, allow 32 traces, fix pvaf, made % ncomps mandatory -sm -% 04-04-97 shortened name to chanproj() -sm +% 04-04-97 shortened name to CHANPROJ -sm % 05-20-97 added read of icadefs.m -sm % 11-05-97 disallowed white traces unless default axis color is white -sm & ch % 11-13-97 rm'ed errcode variable -sm @@ -73,12 +84,12 @@ [chans,framestot] = size(projdata); frames = fix(framestot/(ncomps+1)); -if ncomps < 1 | frames*(ncomps+1) ~= framestot, +if ncomps < 1 || frames*(ncomps+1) ~= framestot, fprintf(... 'chanproj(): data length (%d) not a multiple of ncomps (%d).\n',... framestot,ncomps); return -end; +end if chan> chans, fprintf(... @@ -88,7 +99,7 @@ else chandata = projdata(chan,:); epochs = fix(length(chandata)/frames); -end; +end if epochs > MAXPLOTDATACHANS fprintf(... 'chanproj(): maximum number of traces to plot is %d\n',... @@ -110,23 +121,23 @@ fprintf( ... 'chanproj():^G limits should be 0 or an array [xmin xmax ymin ymax].\n'); return - end; + end xmin = limits(1); xmax = limits(2); ymin = limits(3); ymax = limits(4); -end; +end -if xmin == 0 & xmax == 0, +if xmin == 0 && xmax == 0, x = [0:frames-1]; xmin = 0; xmax = frames-1; else dx = (xmax-xmin)/(frames-1); x=xmin*ones(1,frames)+dx*(0:frames-1); % construct x-values -end; +end -if ymax == 0 & ymin == 0, +if ymax == 0 && ymin == 0, ymax=max(max(projdata(chan,:))); ymin=min(min(projdata(chan,:))); end @@ -149,7 +160,7 @@ end end -if framelist(1)<1 | framelist(length(framelist))>frames, +if framelist(1)<1 || framelist(length(framelist))>frames, fprintf('chanproj(): framelist values must be between 1-%d.\n',frames); return else @@ -167,7 +178,7 @@ if cid <3, fprintf('chanproj(): cannot open file %s.\n',colorfile); return - end; + end colors = fscanf(cid,'%s',[3 MAXPLOTDATACHANS]); colors = colors'; [r c] = size(colors); @@ -175,12 +186,12 @@ for j=1:c if colors(i,j)=='.', colors(i,j)=' '; - end; - end; - end; + end + end + end else % default color order - no yellow colors =['w ';'r ';'b ';'g ';'c ';'m ';'r ';'b ';'g ';'c ';'m ';'r ';'b ';'g ';'c ';'m ';'r ';'b ';'g ';'c ';'m ';'r ';'b ';'g ';'c ';'m ';'r ';'b ';'g ';'c ';'m ';'r ']; -end; +end % % Make vector of x-values % @@ -215,7 +226,7 @@ plot(x,chandata(e,:),colors(e),'LineWidth',1); % plot it! end hold on; -end; +end fprintf('\n'); % %%%%%%%%%%%%%%%%%%%% Fix axis limits %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/functions/miscfunc/cleanvarname.m b/functions/miscfunc/cleanvarname.m new file mode 100644 index 000000000..993325d14 --- /dev/null +++ b/functions/miscfunc/cleanvarname.m @@ -0,0 +1,62 @@ +function nameout = cleanvarname(namein) + +% Routine to remove unallowed characters from strings +% nameout can be use as a variable or field in a structure +% Cyril Pernet & Arnaud Delorme + +% custom change +if strcmp(namein,'#') + namein = 'nb'; +end + +% 1st change space to underscore (keeps readability) +for l=1:length(namein) + if isspace(namein(l)) + namein(l) = '_'; + end +end + +% keep letters, numbers and underscore +keep = isstrprop(namein, 'alpha') + isstrprop(namein, 'digit'); +underscores = zeros(1,size(namein,2)); +underscores(strfind(namein,'_')) = 1; +keep = keep + underscores; +nameout = namein(logical(keep)); + +% remove usual suspects JIC isstrprop did not work +stringcheck = [strfind(nameout,'('), ... + strfind(nameout,')') ... + strfind(nameout,'[') ... + strfind(nameout,']') ... + strfind(nameout,'{') ... + strfind(nameout,'}') ... + strfind(nameout,'-') ... + strfind(nameout,'+') ... + strfind(nameout,'*') ... + strfind(nameout,'/') ... + strfind(nameout,'#') ... + strfind(nameout,'%') ... + strfind(nameout,'&') ... + strfind(nameout,'@') ... + ]; + +if ~isempty(stringcheck) + nameout(stringcheck) = []; +end + +% No number in position 1 +nb_check = 1; +while nb_check + if isletter(nameout(1)) + nb_check = 0; + elseif strcmp(nameout(1),'_') + nameout(1) = []; + elseif isnumeric(eval(nameout(1))) + nameout(1) = []; + end +end + +% last check +if ~isvarname(nameout) + error('the variable name to use is still invalid, check chars to remove') +end diff --git a/functions/miscfunc/compareeeglabdistrib.m b/functions/miscfunc/compareeeglabdistrib.m new file mode 100644 index 000000000..62fa5f440 --- /dev/null +++ b/functions/miscfunc/compareeeglabdistrib.m @@ -0,0 +1,67 @@ +% compare EEGLAB distributions + +% Copyright (C) 2006 Arnaud Delorme +% +% This file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. + +function compareeeglabdistrib(folder1, folder2) + +fileList1 = getmfilelist(folder1); +fileList2 = getmfilelist(folder2); + +% strip list from folders +for iFile = 1:length(fileList1), fileList1{iFile} = fileList1{iFile}(length(folder1)+1:end); end +for iFile = 1:length(fileList2), fileList2{iFile} = fileList2{iFile}(length(folder2)+1:end); end + +for iFile1 = 1:length(fileList1) + iFile2 = strmatch(fileList1{iFile1}, fileList2, 'exact'); + if isempty(iFile2) + fprintf('Missing file %s in folder %s\n', fileList1{iFile1}, folder2); + else + dir1 = dir(fullfile(folder1, fileList1{iFile1})); + dir2 = dir(fullfile(folder2, fileList2{iFile2})); + if length(dir1) ~= 1 || length(dir2) ~= 1 + error('Size error'); + end + if dir1.bytes ~= dir2.bytes + fprintf('Files %s differ\n', fileList2{iFile2}); + %fprintf('---------------------\n'); + %system([ '/usr/bin/diff ' fullfile(folder1, fileList1{iFile1}) ' ' fullfile(folder2, fileList2{iFile2}) ]); + end + fileList2(iFile2) = []; + end +end + +for iFile2 = 1:length(fileList2) + fprintf('Missing file %s in folder %s\n', fileList2{iFile2}, folder1); +end + + + + + + + diff --git a/functions/miscfunc/compdsp.m b/functions/miscfunc/compdsp.m index a2863844d..accc2c9a7 100644 --- a/functions/miscfunc/compdsp.m +++ b/functions/miscfunc/compdsp.m @@ -1,4 +1,4 @@ -% compdsp() - Display standard info figures for a data decomposition +% COMPDSP - Display standard info figures for a data decomposition % Creates four figure windows showing: Component amplitudes, % scalp maps, activations and activation spectra. % Usage: @@ -6,7 +6,7 @@ % % Inputs: % data = data matrix used to train the decomposition -% weights = the unmixing matrix (e.g., weights*sphere from runica()) +% weights = the unmixing matrix (e.g., weights*sphere from RUNICA) % % Optional: % locfile = 2-d electrode locations file (as in >> topoplot example) @@ -16,30 +16,41 @@ % {default|'': none} % compnums = optional vector of component numbers to display % {default|[] -> all} -% amps = all component amplitudes (from runica()) +% amps = all component amplitudes (from RUNICA) % {default|[]->recompute} -% act = activations matrix (from runica()) +% act = activations matrix (from RUNICA) % {default|[]->recompute} % % Author: Scott Makeig, SCCN/INC/UCSD, La Jolla, 2000 % Copyright (C) 12/16/00 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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. -% 02-01-01 replaced std() with rms() -sm +% 02-01-01 replaced STD with RMS -sm % 02-10-01 made srate optional -sm % 01-25-02 reformated help & license -ad @@ -88,7 +99,7 @@ function compdsp(data,unmix,locfile,srate,titl,compnums,amps,act) if nargin<4 srate = 0; % from icadefs end -if isempty(srate) | srate==0 +if isempty(srate) || srate==0 srate = DEFAULT_SRATE; % from icadefs end if nargin<5 @@ -109,7 +120,7 @@ function compdsp(data,unmix,locfile,srate,titl,compnums,amps,act) if isempty(amps) amps = NaN; end -if ~isnan(amps) & length(amps) ~= ncomps +if ~isnan(amps) && length(amps) ~= ncomps error('Supplied amps does not match the number of unmixed components'); end @@ -145,7 +156,7 @@ function compdsp(data,unmix,locfile,srate,titl,compnums,amps,act) fprintf('\n'); elseif size(act,2) ~= frames error('Supplied activations do not match data length'); -elseif size(act,1) ~= ncomps & size(act,1) ~= length(compnums) +elseif size(act,1) ~= ncomps && size(act,1) ~= length(compnums) error('Number of supplied activations matrix does not match data or weights'); elseif size(act,1) == ncomps act = act(compnums,:); % cut down matrix to desired components @@ -185,7 +196,7 @@ function compdsp(data,unmix,locfile,srate,titl,compnums,amps,act) fprintf('\n'); % -%%%%%%%%%%%%%%%%%%%%%% III. eegplot() activations %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%% III. EEGPLOT activations %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % if frames/srate < 10 dispsecs = ceil(frames/srate); @@ -214,7 +225,7 @@ function compdsp(data,unmix,locfile,srate,titl,compnums,amps,act) end % -%%%%%%%%%%%%%%%%%%%%%%% IV. plotdata() spectra %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%% IV. PLOTDATA spectra %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % pos = [620,40,550,400]; figure('Position',pos); diff --git a/functions/miscfunc/compheads.m b/functions/miscfunc/compheads.m index 899e91b13..ee1a5f09d 100644 --- a/functions/miscfunc/compheads.m +++ b/functions/miscfunc/compheads.m @@ -1,4 +1,4 @@ -% compheads() - plot multiple topoplot() maps of ICA component topographies +% COMPHEADS - plot multiple TOPOPLOT maps of ICA component topographies % % Usage: % >> compheads(winv,'spline_file',compnos,'title',rowscols,labels,view) @@ -9,7 +9,7 @@ % defined in the eloc_file. Normally, winv = inv(weights*sphere). % spline_file - Name of the eloctrode position file in BESA spherical coords. % compnos - Vector telling which (order of) component maps to show -% Indices <0 tell compheads() to invert a map; = 0 leave blank subplot +% Indices <0 tell COMPHEADS to invert a map; = 0 leave blank subplot % Example [1 0 -2 3 0 -6] {default|0 -> 1:columns_in_winv} % 'title' - Title string for each page {default|0 -> 'ICA Component Maps'} % rowscols - Vector of the form [m,n] where m is total vertical tiles and n @@ -17,30 +17,41 @@ % multiple figures will be produced {def|0 -> one near-square page}. % labels - Vector of numbers or a matrix of strings to use as labels for % each map {default|0 -> 1:ncolumns_in_winv} -% view - topoplot() view, either [az el] or keyword ('top',...) -% See >> help topoplot() for options. +% view - TOPOPLOT view, either [az el] or keyword ('top',...) +% See >> help TOPOPLOT for options. % % Note: Map scaling is to +/-max(abs(data); green = 0 % % Author: Scott Makeig, SCCN/INC/UCSD, La Jolla, 4-28-1998 % -% See also: topoplot() +% See also: TOPOPLOT % Copyright (C) 4-28-98 from compmap.m 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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. % 01-25-02 reformated help & license, added links -ad diff --git a/functions/miscfunc/compile_eeglab.m b/functions/miscfunc/compile_eeglab.m index 908d12c14..fa15626e9 100644 --- a/functions/miscfunc/compile_eeglab.m +++ b/functions/miscfunc/compile_eeglab.m @@ -6,19 +6,30 @@ % Copyright (C) 2009 Arnaud Delorme % -% 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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. disp('This function will compile EEGLAB in the output folder'); disp('provided below. You may also enter a path relative to the EEGLAB'); @@ -32,24 +43,24 @@ % deal with VisEd plugin (VisEd is both the name of the folder and the % function inside and this creates a problem path_vised = fileparts(which('VisEd')) -try, movefile( path_vised, [ path_vised '2' ]); catch, end; +try, movefile( path_vised, [ path_vised '2' ]); catch, end addpath([ path_vised '2' ]); path_fileio = fileparts(which('chantype')); -try, movefile( fullfile(path_fileio, '@uint64'), fullfile(path_fileio, 'uint64') ); catch, end; -try, movefile( fullfile(path_fileio, 'private', 'buffer.m') , fullfile(path_fileio, 'private', 'bufferold.m') ); catch, end; -try, movefile( fullfile(path_fileio, 'private', 'read_24bit.m') , fullfile(path_fileio, 'private', 'read_24bitold.m')); catch, end; -try, movefile( fullfile(path_fileio, 'private', 'read_ctf_shm.m'), fullfile(path_fileio, 'private', 'read_ctf_shmold.m')); catch, end; -try, movefile( fullfile(path_fileio, 'private', 'write_ctf_shm.m'), fullfile(path_fileio, 'private', 'write_ctf_shmold.m')); catch, end; +try, movefile( fullfile(path_fileio, '@uint64'), fullfile(path_fileio, 'uint64') ); catch, end +try, movefile( fullfile(path_fileio, 'private', 'buffer.m') , fullfile(path_fileio, 'private', 'bufferold.m') ); catch, end +try, movefile( fullfile(path_fileio, 'private', 'read_24bit.m') , fullfile(path_fileio, 'private', 'read_24bitold.m')); catch, end +try, movefile( fullfile(path_fileio, 'private', 'read_ctf_shm.m'), fullfile(path_fileio, 'private', 'read_ctf_shmold.m')); catch, end +try, movefile( fullfile(path_fileio, 'private', 'write_ctf_shm.m'), fullfile(path_fileio, 'private', 'write_ctf_shmold.m')); catch, end path_fileio = path_fileio(length(path_eeglab)+2:end); files_fileio = fullfile(path_fileio, '*.m'); files_fileio_private = fullfile(path_fileio, 'private', '*.m'); path_fieldtrip = fileparts(which('electroderealign')); addpath(fullfile(path_fieldtrip, 'public')); -try, movefile( fullfile(path_fieldtrip, 'fileio', '@uint64'), fullfile(path_fieldtrip, 'fileio', 'uint64') ); catch, end; -try, movefile( fullfile(path_fieldtrip, '@uint64'), fullfile(path_fieldtrip, 'uint64') ); catch, end; -try, movefile( fullfile(path_fieldtrip, 'topoplot.m'), fullfile(path_fieldtrip, 'topoplotold.m') ); catch, end; +try, movefile( fullfile(path_fieldtrip, 'fileio', '@uint64'), fullfile(path_fieldtrip, 'fileio', 'uint64') ); catch, end +try, movefile( fullfile(path_fieldtrip, '@uint64'), fullfile(path_fieldtrip, 'uint64') ); catch, end +try, movefile( fullfile(path_fieldtrip, 'topoplot.m'), fullfile(path_fieldtrip, 'topoplotold.m') ); catch, end path_fieldtrip = path_fieldtrip(length(path_eeglab)+2:end); files_fieldtrip = fullfile(path_fieldtrip, '*.m'); files_public = fullfile(path_fieldtrip, 'public', '*.m'); @@ -62,7 +73,7 @@ try rmpath('C:\Documents and Settings\delorme\My Documents\eeglab\plugins\editevents_arno'); -catch, end; +catch, end path_biosig = fileparts(which('install')); path_biosig = path_biosig(length(path_eeglab)+2:end); biosig = ' sopen.m sclose.m sread.m '; @@ -100,7 +111,7 @@ copyfile( 'eeglab', fullfile(outputfolder, 'eeglab'), 'f'); copyfile( 'eeglab', fullfile(outputfolder, 'eeglab'), 'f'); copyfile( 'eeglab.ctf', fullfile(outputfolder, 'eeglab.ctf'), 'f'); -end; +end % copy BESA files etc % ------------------- @@ -136,9 +147,9 @@ for index = 1:length(allfiles) tmpp = which(allfiles{index}); copyfile(tmpp, fullfile(outputfolder, 'help', allfiles{index})); -end; +end -% copy MCR file and visual C++ librairies +% copy MCR file and visual C++ libraries % --------------------------------------- if strcmpi(comp(1:2), 'PC') copyfile(fullfile(matlabroot, 'toolbox', 'compiler', 'deploy', 'win32', 'MCRInstaller.exe'), fullfile(outputfolder, 'MCRInstaller.exe')); @@ -160,7 +171,7 @@ fprintf(fid, 'echo To start EEGLAB in the future, simply click on the EEGLAB.EXE file\r\n'); fprintf(fid, 'eeglab.exe\r\n'); fclose(fid); - end; + end fid = fopen(fullfile(outputfolder, 'eeglab.exe.manifest'), 'w'); if fid == -1, disp('Error: cannot create manifest file'); else @@ -173,25 +184,25 @@ fprintf(fid, ' \r\n'); fprintf(fid, '\r\n'); fclose(fid); - end; -end; + end +end % cleaning up % ----------- -try, movefile( [ path_vised '2' ], path_vised); catch, end; -try, movefile( fullfile(path_fileio, 'uint64'), fullfile(path_fileio, '@uint64') ); catch, end; -try, movefile( fullfile(path_fileio, 'private', 'bufferold.m') , fullfile(path_fileio, 'private', 'buffer.m') ); catch, end; -try, movefile( fullfile(path_fileio, 'private', 'read_24bitold.m') , fullfile(path_fileio, 'private', 'read_24bit.m')); catch, end; -try, movefile( fullfile(path_fileio, 'private', 'read_ctf_shmold.m'), fullfile(path_fileio, 'private', 'read_ctf_shm.m')); catch, end; -try, movefile( fullfile(path_fileio, 'private', 'write_ctf_shmold.m'), fullfile(path_fileio, 'private', 'write_ctf_shm.m')); catch, end; -try, movefile( fullfile(path_fieldtrip, 'fileio', 'uint64'), fullfile(path_fieldtrip, 'fileio', '@uint64') ); catch, end; -try, movefile( fullfile(path_fieldtrip, 'uint64'), fullfile(path_fieldtrip, '@uint64') ); catch, end; -try, movefile( fullfile(path_fieldtrip, 'topoplotold.m'), fullfile(path_fieldtrip, 'topoplot.m') ); catch, end; +try, movefile( [ path_vised '2' ], path_vised); catch, end +try, movefile( fullfile(path_fileio, 'uint64'), fullfile(path_fileio, '@uint64') ); catch, end +try, movefile( fullfile(path_fileio, 'private', 'bufferold.m') , fullfile(path_fileio, 'private', 'buffer.m') ); catch, end +try, movefile( fullfile(path_fileio, 'private', 'read_24bitold.m') , fullfile(path_fileio, 'private', 'read_24bit.m')); catch, end +try, movefile( fullfile(path_fileio, 'private', 'read_ctf_shmold.m'), fullfile(path_fileio, 'private', 'read_ctf_shm.m')); catch, end +try, movefile( fullfile(path_fileio, 'private', 'write_ctf_shmold.m'), fullfile(path_fileio, 'private', 'write_ctf_shm.m')); catch, end +try, movefile( fullfile(path_fieldtrip, 'fileio', 'uint64'), fullfile(path_fieldtrip, 'fileio', '@uint64') ); catch, end +try, movefile( fullfile(path_fieldtrip, 'uint64'), fullfile(path_fieldtrip, '@uint64') ); catch, end +try, movefile( fullfile(path_fieldtrip, 'topoplotold.m'), fullfile(path_fieldtrip, 'topoplot.m') ); catch, end return %histforexe(allfiles1, 'help'); -% help for lisence +% help for license % diff --git a/functions/miscfunc/compmap.m b/functions/miscfunc/compmap.m index b791af4fc..329326b4c 100644 --- a/functions/miscfunc/compmap.m +++ b/functions/miscfunc/compmap.m @@ -1,4 +1,4 @@ -% compmap() - Plot multiple topoplot() maps of ICA component topographies +% COMPMAP - Plot multiple TOPOPLOT maps of ICA component topographies % Click on an individual map to view separately. % Usage: % >> compmap (winv,'eloc_file',compnos,'title',rowscols,labels,printflag) @@ -25,25 +25,36 @@ % % Author: Colin Humphries, CNL / Salk Institute, Aug, 1996 % -% See also: topoplot() +% See also: TOPOPLOT -% This function calls topoplot(). and cbar(). +% This function calls TOPOPLOT. and CBAR. % Copyright (C) Colin Humphries & Scott Makeig, CNL / Salk Institute, Aug, 1996 % -% 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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. % Colin Humphries, CNL / Salk Institute, Aug, 1996 % 03-97 revised -CH @@ -51,19 +62,19 @@ % improved help msg; added figure offsets -Scott Makeig & CH % 11-13-97 fixed compnos<0 bug -sm % 11-18-97 added test for labels=comps -sm -% 12-08-97 added test for colorbar_tp() -sm +% 12-08-97 added test for COLORBAR_TP -sm % 12-15-97 added axis('square'), see SQUARE below -sm % 03-09-98 added test for eloc_file, fixed size checking for labels -sm % 02-09-00 added test for ' ' for srclabels(1,1) -sm % 02-23-00 added srclabels==' ' -> no labels -sm -% 03-16-00 added axcopy() -sm & tpj +% 03-16-00 added AXCOPY -sm & tpj % 02-25-01 added test for max(compnos) -sm % 05-24-01 added HEADPLOT logical flag below -sm % 01-25-02 reformated help & license -ad % NOTE: -% There is a minor problem with the Matlab function colorbar(). -% Use the toolbox cbar() instead. +% There is a minor problem with the Matlab function COLORBAR. +% Use the toolbox CBAR instead. function compmap(Winv,eloc_file,compnos,titleval,pagesize,srclabels,printlabel,caxis) @@ -171,12 +182,12 @@ function compmap(Winv,eloc_file,compnos,titleval,pagesize,srclabels,printlabel,c totalsources = length(compnos); if ~isempty(srclabels) - if ~ischar(srclabels(1,1)) | srclabels(1,1)==' ' % if numbers + if ~ischar(srclabels(1,1)) || srclabels(1,1)==' ' % if numbers if size(srclabels,1) == 1 srclabels = srclabels'; end end - if size(srclabels,1)==1 & size(srclabels,2)==1 & srclabels==' ' + if size(srclabels,1)==1 && size(srclabels,2)==1 && srclabels==' ' srclabels = repmat(srclabels,totalsources,1); end if size(srclabels,1) ~= totalsources, diff --git a/functions/miscfunc/compplot.m b/functions/miscfunc/compplot.m index 4e296e21b..bf990c0ab 100644 --- a/functions/miscfunc/compplot.m +++ b/functions/miscfunc/compplot.m @@ -1,4 +1,4 @@ -% compplot() - plot a data epoch and maps its scalp topography at a given time +% COMPPLOT - plot a data epoch and maps its scalp topography at a given time % % Usage: To plot the projection of an ICA component onto the scalp % >> projdata = icaproj(data,weights,compindex); @@ -9,8 +9,8 @@ % >> compplot(data,plotframe,chan_file,xstart,srate,title, splinefile); % % Inputs: -% data = data returned from icaproj() *ELSE* any EEG/ERP data epoch -% plotframe = frame to plot topographically {default|0 -> frame of max(var())} +% data = data returned from ICAPROJ *ELSE* any EEG/ERP data epoch +% plotframe = frame to plot topographically {default|0 -> frame of max(VAR)} % 'chan_file' = chan file, see >> topoplot example {def|0 -> 'chan_file'} % xstart = start time in seconds {default|0 -> 0} % srate = data sampling rate in Hz {default|0 -> 256 Hz} @@ -19,31 +19,42 @@ % % Authors: Colin Humphries & Scott Makeig, SCCN/INC/UCSD, CNL / Salk Institute, 1997 % -% See also: icaproj() +% See also: ICAPROJ % Copyright (C) 2000 Colin Humphries & Scott Makeig, SCCN/INC/UCSD % -% 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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. % 6-07-97 changed order of args in icaproj above -sm % Revised for Matlab 5.0.0.4064 11/97 -ch & sm -% 2-18-98 added undocumented headplot() option -sm +% 2-18-98 added undocumented HEADPLOT option -sm % 3-09-98 added check for chan_file -sm % 3-18-98 use new eegplot('noui') -sm % 7-25-98 make sure length(hkids) >= 3 on line 122 ff -sm -% 12-19-00 updated icaproj() call in help msg -sm +% 12-19-00 updated ICAPROJ call in help msg -sm % 1-24-01 corrected input error in header -ad % 01-25-02 reformated help & license, added links -ad diff --git a/functions/miscfunc/compsort.m b/functions/miscfunc/compsort.m index c96b07be2..d1381da26 100644 --- a/functions/miscfunc/compsort.m +++ b/functions/miscfunc/compsort.m @@ -1,4 +1,4 @@ -% compsort() - reorder ICA components, first largest to smallest by the size +% COMPSORT - reorder ICA components, first largest to smallest by the size % of their maximum variance in the single-component projections, % then (if specified) the nlargest component projections are % reordered by the (within-epoch) time point at which they reach @@ -9,12 +9,12 @@ % = compsort(data,weights,sphere,datamean, ... % frames,nlargest,chanlist); % Inputs: -% data = (chans,frames*epochs) the input data set decomposed by runica() -% weights = ica weight matrix returned by runica() -% sphere = sphering matrix returned by runica() +% data = (chans,frames*epochs) the input data set decomposed by RUNICA +% weights = ica weight matrix returned by RUNICA +% sphere = sphering matrix returned by RUNICA % % Optional: -% datamean = means removed from each row*epoch in runica() +% datamean = means removed from each row*epoch in RUNICA % (Note: 0 -> input data means are distributed among components % : 1 -> input data means are removed from the components (default)) % frames = frames per epoch in data (0 -> all) @@ -31,31 +31,42 @@ % % Authors: Scott Makeig, SCCN/INC/UCSD, La Jolla, 1996 % -% See also: runica() +% See also: RUNICA % Copyright (C) 1996 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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. % 11-30-96 as compsort.m % 12-19-96 moved def of epochs below default frames def -sm % 02-18-97 added chanlist -sm -% 03-11-97 added default chanlist=0 -> all chans, fixed datamean and var() -sm +% 03-11-97 added default chanlist=0 -> all chans, fixed datamean and VAR -sm % 03-17-97 made nlargest default -> nlargest=0 -sm % 04-03-97 fixed problems and removed permweights, permcomps outputs -sm -% 04-04-97 shortened name to compsort() -sm +% 04-04-97 shortened name to COMPSORT -sm % 06-05-97 corrected variance computation -sm % 06-07-97 changed order of args to conform to runica -sm % 06-10-97 fixed recent bug in maxvar order -sm @@ -75,7 +86,7 @@ if framestot==0, fprintf('Gcompsort(): cannot process an empty data array.\n'); return -end; +end [srows,scols] = size(sphere); [wrows,wcols] = size(weights); @@ -85,7 +96,7 @@ if chanlist==0, chanlist = [1:chans]; end -if length(chanlist)~=chans & wrows 0 & indexA <= length(A) + if indexA > 0 && indexA <= length(A) R(index) = R(index) + B(indexB)*A(indexA); sumconvo = sumconvo + B(indexB); - end; - end; + end + end R(index) = R(index) / sumconvo; -end; +end return; diff --git a/functions/miscfunc/corrimage.m b/functions/miscfunc/corrimage.m index 3562c5f76..7f4f685ac 100755 --- a/functions/miscfunc/corrimage.m +++ b/functions/miscfunc/corrimage.m @@ -1,4 +1,4 @@ -% corrimage() - compute correlation image between an event and amplitude +% CORRIMAGE - compute correlation image between an event and amplitude % and phase in the time-frequency domain. % % Usage: @@ -32,14 +32,14 @@ % to retain. i.e. [5 95] remove the 5 lowest and highest % percentile of sortvar values (and associated data) before % computing statistics. Default is [0 100]. -% 'align' - [float] same as 'align' parameter of erpimage(). This -% parameter is used to contrain the 'times' parameter so +% 'align' - [float] same as 'align' parameter of ERPIMAGE. This +% parameter is used to constrain the 'times' parameter so % correlation with data trials containing 0-values (as a % result of data alignment) are avoided: computing these % correlations would produce spurious significant results. % Default is no alignment. -% 'method' - ['erpimage'|timefreq'] use either the erpimage() function -% of the timefreq() function to compute spectral decomposition. +% 'method' - ['erpimage'|timefreq'] use either the ERPIMAGE function +% of the TIMEFREQ function to compute spectral decomposition. % Default is 'timefreq' for speed reasons (note that both % methods should return the same results). % 'erpout' - [min max] regress out ERP using the selected time-window [min @@ -85,34 +85,45 @@ % Author: Arnaud Delorme & Scott Makeig, SCCN UCSD, % and CNL Salk Institute, 18 April 2003 % -% See also: erpimage() +% See also: ERPIMAGE %123456789012345678901234567890123456789012345678901234567890123456789012 % Copyright (C) 2002 Arnaud Delorme % -% 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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. function [time, freq, alpha, sigout, limits, tf, sortvar] = corrimage(data, sortvar, timevect, varargin) if nargin < 3 help corrimage; return; -end; +end -if isempty(timevect), timevect = [1 2]; end; +if isempty(timevect), timevect = [1 2]; end % check inputs % ------------ @@ -134,7 +145,7 @@ 'erpout' 'real' [] []; 'tfopt' 'cell' [] {}; 'erpimopt' 'cell' [] {} }); -if isstr(g), error(g); end; +if ischar(g), error(g); end fprintf('Generating %d frequencies in log scale (ignore message on linear scale)\n', g.freqs(2)); g.freqs = logscale(g.freqs(1), g.freqs(3), g.freqs(2)); @@ -142,7 +153,7 @@ frames = length(timevect); if size(data,1) == 1 data = reshape(data, frames, size(data,2)*size(data,3)/frames); -end; +end % trim sortvar values % ------------------- @@ -153,10 +164,10 @@ highindex = round(len*g.trim(2)/100); sortvar = sortvar(lowindex:highindex); data = data(:, lowindex:highindex); -if lowindex ~=1 | highindex ~= length(sortorder) +if lowindex ~=1 || highindex ~= length(sortorder) fprintf('Actual percentiles %1.2f-%1.2f (indices 1-%d -> %d-%d): event vals min %3.2f; max %3.2f\n', ... 100*(lowindex-1)/len, 100*highindex/len, len, lowindex, highindex, min(sortvar), max(sortvar)); -end; +end % assign subject number for each trial % ------------------------------------ @@ -164,10 +175,10 @@ alltrials = zeros(1,len); for index = 1:length(g.triallimit)-1 alltrials([g.triallimit(index):g.triallimit(index+1)-1]) = index; - end; + end alltrials = alltrials(sortorder); alltrials = alltrials(lowindex:highindex); -end; +end %figure; hist(sortvar) @@ -189,13 +200,13 @@ % compute shifts % -------------- shifts = round((g.align-sortvar)*srate/1000); % shifts can be positive or negative - end; + end %figure; hist(shifts) minshift = min(shifts); % negative maxshift = max(shifts); % positive - if minshift > 0, error('minshift has to be negative'); end; - if maxshift < 0, error('maxshift has to be positive'); end; + if minshift > 0, error('minshift has to be negative'); end + if maxshift < 0, error('maxshift has to be positive'); end % realign data for all trials % --------------------------- @@ -211,7 +222,7 @@ end end % end trial data = aligndata(maxshift+1:frames+minshift,:); - if any(any(isnan(data))), error('NaNs remaining after data alignment'); end; + if any(any(isnan(data))), error('NaNs remaining after data alignment'); end timevect = timevect(maxshift+1:frames+minshift); % take the time vector subset @@ -220,7 +231,7 @@ else fprintf('Time vector truncated for data alignment between %1.0f and %1.0f\n', ... min(timevect), max(timevect)); end; -end; +end % regress out the ERP from the data (4 times to have residual ERP close to 0) % --------------------------------------------------------------------------- @@ -243,8 +254,8 @@ fprintf([ '***********************************************\n' ... 'Ratio in ERP after regression (compare to before) is %3.2f\n' ... '***********************************************\n' ], mean(erpend./erpstart)); - end; - end; + end + end erpend = mean(data,2); fprintf([ '***********************************************\n' ... 'Ratio in grand ERP after regression (compare to before) is %3.2f\n' ... @@ -273,7 +284,7 @@ subplot(3,5,index); trials = find(alltrials == index); erpimage(data(:,trials), sortvar(trials), timevect, '', 50, 100, 'erp'); - end; + end disp('Regressing out ERP'); if ~isempty(g.triallimit) @@ -295,12 +306,12 @@ %data(:,trials) = erpregout(data(:,trials), [timevect(1) timevect(end)], g.erpout); %data(:,trials) = erpregout(data(:,trials), [timevect(1) timevect(end)], g.erpout); %data(:,trials) = erpregout(data(:,trials), [timevect(1) timevect(end)], g.erpout); - end; + end else %data = erpregout(data, [timevect(1) timevect(end)], g.erpout); - end; - end; -end; + end + end +end % generate time points % -------------------- @@ -309,16 +320,16 @@ % time frequency decomposition % ---------------------------- -if strcmpi(g.method, 'timefreq') & isempty(g.plotvals) +if strcmpi(g.method, 'timefreq') && isempty(g.plotvals) data = reshape(data, length(data)/length(sortvar), length(sortvar)); [tf, g.freqs, g.times] = timefreq(data, srate, 'freqs', g.freqs, 'timesout', g.times, ... 'tlimits', [min(timevect) max(timevect)], 'wavelet', 3); outvar = sortvar; -end; +end % compute correlation % ------------------- -if strcmpi(g.mode, 'phase') & isempty(g.plotvals) +if strcmpi(g.mode, 'phase') && isempty(g.plotvals) for freq = 1:length(g.freqs) fprintf('Computing correlation with phase %3.2f Hz ----------------------\n', g.freqs(freq)); for time = 1:length(g.times) @@ -328,7 +339,7 @@ '', 0,0,g.erpimopt{:}, 'phasesort', [g.times(time) 0 g.freqs(freq)], 'noshow', 'yes'); else phsangls = angle( squeeze(tf(freq, time, :))' ); - end; + end % computing ITCs [ ITC(freq, time) alpha(freq, time) ] = ... @@ -340,8 +351,8 @@ %ITC(freq, time) = mean(cmplx); %alpha(freq,time) = bootstat(outvar/mean(outvar), exp(j*phsangls), 'res = mean(arg1 .* arg2)', ... % 'naccu', 100, 'vals', abs(ITC(freq, time)), 'distfit', 'norm'); - end; - end; + end + end sigout = ITC; elseif isempty(g.plotvals) for freq = 1:length(g.freqs) @@ -353,11 +364,11 @@ '', 0,0,g.erpimopt{:}, 'ampsort', [g.times(time) 0 g.freqs(freq)], 'noshow', 'yes'); else phsamp = abs(squeeze(tf(freq, time, :)))'; - end; + end % computing ITCs [ypred alpha(freq, time) Rsq slope(freq, time)] = myregress(outvar, 20*log10(phsamp)); - end; + end end; sigout = slope; else @@ -365,7 +376,7 @@ g.freqs = g.plotvals{2}; alpha = g.plotvals{3}; sigout = g.plotvals{4}; -end; +end % plot correlation % ---------------- @@ -375,15 +386,15 @@ sigoutplot = angle(sigout); else sigoutplot = abs(sigout); - end; + end else sigoutplot = sigout; - end; + end sigouttmp = sigoutplot; if strcmpi(g.smooth, 'on') tmpfilt = gauss2d(3,3,.3,.3); tmpfilt = tmpfilt/sum(sum(tmpfilt)); alpha = conv2(alpha, tmpfilt, 'same'); - end; + end % mask signal out if g.pmask > 0.5 @@ -398,17 +409,17 @@ sigouttmp = sigoutplot; indices = find( alpha(:) > g.pmask); sigouttmp(indices) = 0; - end; + end - if strcmpi(g.nofig, 'off'), figure; end; + if strcmpi(g.nofig, 'off'), figure; end switch g.plot case 'alpha', limits = plotfig(g.times, g.freqs, -log10(alpha), g); case 'sigout', limits = plotfigsim(g.times, g.freqs, sigoutplot, g); case { 'sigoutm' 'sigoutp' }, limits = plotfigsim(g.times, g.freqs, sigouttmp, g); case 'sigoutm2', limits = subplot(1,2,1); plotfigsim(g.times, g.freqs, sigoutplot, g); limits = subplot(1,2,2); plotfigsim(g.times, g.freqs, sigouttmp, g); - end; -end; + end +end time = g.times; freq = g.freqs; @@ -433,7 +444,7 @@ trim = timevar(2); if length(timevect)-2*round(trim/100*length(timevect)) < npoints npoints = length(timevect)-round(trim/100*length(timevect)); - end; + end fprintf('Generating %d times points trimmed by %1.1f percent\n', npoints, trim); timer = max(timevect) - min(timevect); maxt = max(timevect)-timer*trim/100; @@ -446,9 +457,9 @@ trim = timevar(2); len = length(timevect); trimtimevect = timevect(round(trim/100*len)+1:len-round(trim/100*len)); - fprintf('Subsampling by %d and triming data by %1.1f percent (%d points)\n', nsub, trim, round(trim/100*len)); + fprintf('Subsampling by %d and trimming data by %1.1f percent (%d points)\n', nsub, trim, round(trim/100*len)); val = trimtimevect(1:nsub:end); - end; + end else val = timevar; end; @@ -458,10 +469,10 @@ for index = 1:length(val) [dum ind] = min(abs(timevect-val(index))); val(index) = timevect(ind); - end; + end if length(val) < length(unique(val)) disp('Warning: duplicate times, reduce the number of output times'); - end; + end if all(oldval == val) disp('Debug msg: Time value unchanged by finding closest in data'); end; @@ -486,18 +497,18 @@ set(gca, 'yticklabel', num2str(freqs(1:4:end)', 3)) xlabel('Time (ms)'); ylabel('Freq (Hz)'); - if ~isempty(g.limits), caxis(g.limits); end; + if ~isempty(g.limits), caxis(g.limits); end limits = caxis; if ~isempty(g.vert) for vert = g.vert(:)' hold on; plot([vert vert], [0.001 500], 'k', 'linewidth', 2); - end; - end; + end + end if strcmpi(g.cbar,'on') cbar; - end; + end -% plot figure with symetrical phase +% plot figure with symmetrical phase % --------------------------------- function limits = plotfigsim(times, freqs, vals, g) icadefs; @@ -516,16 +527,16 @@ clim = max(abs(caxis)); limits = [-clim clim]; caxis(limits); - end; + end xlabel('Time (ms)'); ylabel('Freq (Hz)'); if ~isempty(g.vert) for vert = g.vert(:)' hold on; plot([vert vert], [0.01 500], 'k', 'linewidth', 2); - end; - end; + end + end if strcmpi(g.cbar,'on') cbar; - end; + end return; @@ -561,7 +572,7 @@ % accumulate 200 values % --------------------- alpha = 0.05; -if exist('accarray') ~= 1, accarray = NaN; end; +if exist('accarray') ~= 1, accarray = NaN; end [sigval accarray] = bootstat(outvar/mean(outvar), phsangls, 'res = mean(arg1 .* exp(arg2*complex(0,1)))', ... 'accarray', accarray, 'bootside', 'upper', 'alpha', alpha); text(-1300,-1600,sprintf('Threshold for significance at %d percent(naccu=200): %3.4f\n', alpha*100, sigval)); diff --git a/functions/miscfunc/covary.m b/functions/miscfunc/covary.m index be1053d0c..1de9cd6f7 100644 --- a/functions/miscfunc/covary.m +++ b/functions/miscfunc/covary.m @@ -1,4 +1,4 @@ -% covary() - For vectors, covary(X) returns the variance of X. +% COVARY - For vectors, covary(X) returns the variance of X. % For matrices, covary(X)is a row vector containing the % variance of each column of X. % @@ -12,19 +12,30 @@ % Copyright (C) 2000 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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. % 01-25-02 reformated help & license -ad diff --git a/functions/miscfunc/crossfold.m b/functions/miscfunc/crossfold.m index b4b94a9c0..80e9de45f 100644 --- a/functions/miscfunc/crossfold.m +++ b/functions/miscfunc/crossfold.m @@ -1,4 +1,4 @@ -% crossf() - Returns estimates and plot of event-related coherence (ERC) changes +% CROSSF - Returns estimates and plot of event-related coherence (ERC) changes % between data from two input channels. The lower panel gives the % coherent phase difference between the processes. In this panel, for Ex. % -90 degrees (blue) means xdata leads ydata by a quarter cycle. @@ -60,32 +60,43 @@ % % Authors: Sigurd Enghoff & Scott Makeig, SCCN/INC/UCSD, La Jolla, 1998 % -% See also: timef() +% See also: TIMEF % Copyright (C) 8/1/98 Sigurd Enghoff & Scott Makeig, SCCN/INC/UCSD % -% 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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. % 11-20-98 defined LINEWIDTH constant -sm % 04-01-99 made number of frequencies consistent -se % 06-29-99 fixed constant-Q freq indexing -se % 08-13-99 added cohangle plotting -sm % 08-20-99 made bootstrap more efficient -sm -% 08-24-99 allow nan values introduced by possible eventlock() preproc. -sm +% 08-24-99 allow nan values introduced by possible EVENTLOCK preproc. -sm % 03-16-00 added lead/lag interpretation to help msg - sm & eric visser -% 03-16-00 added axcopy() feature -sm & tpj +% 03-16-00 added AXCOPY feature -sm & tpj % 04-20-00 fixed Rangle sign for wavelets, added verts array -sm % 01-22-01 corrected help msg when nargin<2 -sm & arno delorme % 01-25-02 reformated help & license, added links -ad @@ -128,10 +139,10 @@ return end -if (min(size(X))~=1 | length(X)<2) +if (min(size(X))~=1 || length(X)<2) fprintf('crossf(): xdata must be a row or column vector.\n'); return -elseif (min(size(Y))~=1 | length(Y)<2) +elseif (min(size(Y))~=1 || length(Y)<2) fprintf('crossf(): ydata must be a row or column vector.\n'); return elseif (length(X) ~= length(Y)) @@ -141,7 +152,7 @@ if (nargin < 3) epoch = DEFAULT_EPOCH; -elseif (~isnumeric(epoch) | length(epoch)~=1 | epoch~=round(epoch)) +elseif (~isnumeric(epoch) || length(epoch)~=1 || epoch~=round(epoch)) fprintf('crossf(): Value of frames must be an integer.\n'); return elseif (epoch <= 0) @@ -154,7 +165,7 @@ if (nargin < 4) timelim = DEFAULT_TIMELIM; -elseif (~isnumeric(timelim) | sum(size(timelim))~=3) +elseif (~isnumeric(timelim) || sum(size(timelim))~=3) error('crossf(): Value of tlimits must be a vector containing two numbers.'); elseif (timelim(1) >= timelim(2)) error('crossf(): tlimits interval must be [min,max].'); @@ -168,7 +179,7 @@ if (nargin < 6) Fs = DEFAULT_FS; -elseif (~isnumeric(Fs) | length(Fs)~=1) +elseif (~isnumeric(Fs) || length(Fs)~=1) error('crossf(): Value of srate must be a number.'); elseif (Fs <= 0) error('crossf(): Value of srate must be positive.'); @@ -176,7 +187,7 @@ if (nargin < 7) varwin = DEFAULT_VARWIN; -elseif (~isnumeric(varwin) | length(varwin)~=1) +elseif (~isnumeric(varwin) || length(varwin)~=1) error('crossf(): Value of cycles must be a number.'); elseif (varwin < MAX_BASELN) error('crossf(): Value of cycles must be either zero or positive.'); @@ -184,11 +195,11 @@ if (nargin < 8) winsize = max(pow2(nextpow2(epoch)-3),4); -elseif (~isnumeric(winsize) | length(winsize)~=1 | winsize~=round(winsize)) +elseif (~isnumeric(winsize) || length(winsize)~=1 || winsize~=round(winsize)) error('crossf(): Value of winsize must be an integer number.'); elseif (winsize <= 0) error('crossf(): Value of winsize must be positive.'); -elseif (varwin == 0 & pow2(nextpow2(winsize)) ~= winsize) +elseif (varwin == 0 && pow2(nextpow2(winsize)) ~= winsize) error('crossf(): Value of winsize must be an integer power of two [1,2,4,8,16,...]'); elseif (winsize > epoch) error('crossf(): Value of winsize must be less than epoch length.'); @@ -196,7 +207,7 @@ if (nargin < 9) nwin = DEFAULT_NWIN; -elseif (~isnumeric(nwin) | length(nwin)~=1 | nwin~=round(nwin)) +elseif (~isnumeric(nwin) || length(nwin)~=1 || nwin~=round(nwin)) error('crossf(): Value of nwin must be an integer number.'); elseif (nwin <= 0) error('crossf(): Value of nwin must be positive.'); @@ -207,7 +218,7 @@ if (nargin < 10) oversmp = DEFAULT_OVERSMP; -elseif (~isnumeric(oversmp) | length(oversmp)~=1 | oversmp~=round(oversmp)) +elseif (~isnumeric(oversmp) || length(oversmp)~=1 || oversmp~=round(oversmp)) error('crossf(): Value of oversmp must be an integer number.'); elseif (oversmp <= 0) error('crossf(): Value of oversmp must be positive.'); @@ -217,7 +228,7 @@ if (nargin < 11) maxfreq = DEFAULT_MAXFREQ; -elseif (~isnumeric(maxfreq) | length(maxfreq)~=1) +elseif (~isnumeric(maxfreq) || length(maxfreq)~=1) error('crossf(): Value of maxfreq must be a number.'); elseif (maxfreq <= 0) error('crossf(): Value of maxfreq must be positive.'); @@ -225,9 +236,9 @@ if (nargin < 12) alpha = DEFAULT_ALPHA; -elseif (~isnumeric(alpha) | length(alpha)~=1) +elseif (~isnumeric(alpha) || length(alpha)~=1) error('crossf(): Value of alpha must be a number.'); -elseif (round(NACCU*alpha) < 2 | alpha > .5) +elseif (round(NACCU*alpha) < 2 || alpha > .5) fprintf('crossf(): Value of alpha must be in the range (~0,0.5]'); return else @@ -349,7 +360,7 @@ s = ceil(rand([1 2])*nwin); % random ints [1,nwin] tmpX = tmpsX(:,s(1)); tmpY = tmpsY(:,s(2)); - if ~any(isnan(tmpX)) & ~any(isnan(tmpY)) + if ~any(isnan(tmpX)) && ~any(isnan(tmpY)) RR = tmpX.*conj(tmpY) ./ (abs(tmpX).*abs(tmpY)); % complex coher. Rboot(:,j) = Rboot(:,j) + RR; j = j+1; @@ -431,7 +442,7 @@ plot([0 0],[0 freqs(max(dispf))],'--m','LineWidth',LINEWIDTH) for i=1:length(verts) plot([verts(i) verts(i)],[0 freqs(max(dispf))],'--m','LineWidth',LINEWIDTH); -end; +end hold off set(h(6),'YTickLabel',[],'YTick',[]) set(h(6),'XTickLabel',[],'XTick',[]) @@ -452,7 +463,7 @@ plot([0 0],[-500 500],'--m','LineWidth',LINEWIDTH); for i=1:length(verts) plot([verts(i) verts(i)],[-500 500],'--m','LineWidth',LINEWIDTH); -end; +end axis([min(times) max(times) 0 max(Emax)*1.2]) tick = get(h(10),'YTick'); set(h(10),'YTick',[tick(1) ; tick(length(tick))]) @@ -516,7 +527,7 @@ plot([0 0],[0 freqs(max(dispf))],'--m','LineWidth',LINEWIDTH); % zero-time line for i=1:length(verts) plot([verts(i) verts(i)],[0 freqs(max(dispf))],'--m','LineWidth',LINEWIDTH); - end; + end pos13 = get(h(13),'Position'); set(h(13),'Position',[pos13(1) pos13(2) midpos(3) pos13(4)]); diff --git a/functions/miscfunc/crossfreq.m b/functions/miscfunc/crossfreq.m index b236f9122..b29019d19 100644 --- a/functions/miscfunc/crossfreq.m +++ b/functions/miscfunc/crossfreq.m @@ -1,4 +1,4 @@ -% crossfreq() - compute cross-frequency coherences. Power of first input +% CROSSFREQ - compute cross-frequency coherences. Power of first input % correlation with phase of second. % % Usage: @@ -41,7 +41,7 @@ % 'wavelet2' = same as 'wavelet' for the second argument. Default is % same as cycles. Note that if the lowest frequency for X % and Y are different and cycle is [cycles expfactor], it -% may result in discrepencies in the number of cycles at +% may result in discrepancies in the number of cycles at % the same frequencies for X and Y. % 'ntimesout' = Number of output times (int > limits_vector = datlim(data); @@ -10,6 +10,33 @@ % % Author: Scott Makeig, SCCN/INC/UCSD, May 28, 2005 +% Copyright (C) Scott Makeig, SCCN/INC/UCSD, May 28, 2005 +% +% This file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. + function [limits_vector] = datlim(data) if ~isnumeric(data) diff --git a/functions/miscfunc/del2map.m b/functions/miscfunc/del2map.m index ce3fd8726..4436ae6ec 100644 --- a/functions/miscfunc/del2map.m +++ b/functions/miscfunc/del2map.m @@ -1,4 +1,4 @@ -% del2map() - compute the discrete laplacian of an EEG distribution. +% DEL2MAP - compute the discrete laplacian of an EEG distribution. % % Usage: % >> [ laplac ] = del2map( map, filename, draw ); @@ -23,55 +23,66 @@ % Copyright (C) 2001 Arnaud Delorme, Salk Institute, arno@salk.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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. function [ laplac, sumLaplac2D ] = del2map( map, filename, draw ) if nargin < 2 help del2map; return; -end; +end % process several maps if size(map,2) > 1 if size(map,1) > 1 for index = 1:size(map,2) laplac(:,index) = del2map( map(:,index), filename); - end; + end return; else map = map'; - end; -end; + end +end MAXCHANS = size(map,1); GRID_SCALE = 2*MAXCHANS+5; % Read the channel file % --------------------- -if ischar( filename ) | isstruct( filename ) +if ischar( filename ) || isstruct( filename ) [tmp lb Th Rd] = readlocs(filename); Th = pi/180*Th; % convert degrees to rads [x,y] = pol2cart(Th,Rd); else x = real(filename); y = imag(filename); - if exist('draw') == 1 & draw ~= 0 + if exist('draw') == 1 && draw ~= 0 line( [(x-0.01)' (x+0.01)']', [(y-0.01)' (y+0.01)']'); line( [(x+0.01)' (x-0.01)']', [(y-0.01)' (y+0.01)']'); - end; + end end; % locates nearest position of electrod in the grid @@ -81,7 +92,7 @@ for i=1:MAXCHANS [useless_var horizidx(i)] = min(abs(x(i) - xi)); % find pointers to electrode [useless_var vertidx(i)] = min(abs(y(i) - yi)); % positions in Zi -end; +end % Compute gradient % ---------------- @@ -96,16 +107,16 @@ % Draw gradient % ------------- - if exist('draw') == 1 & draw ~= 0 + if exist('draw') == 1 && draw ~= 0 if size(map,2) > 1 subplot(ceil(sqrt(size(map,2))), ceil(sqrt(size(map,2))), i); - end; + end plot(y, x, 'x', 'Color', 'black', 'markersize', 5); hold on contour(Xi, Yi, laplac2D); hold off; %line( [(x-0.01)' (x+0.01)']', [(y-0.01)' (y+0.01)']', 'Color','black'); %line( [(x+0.01)' (x-0.01)']', [(y-0.01)' (y+0.01)']', 'Color','black'); title( int2str(i) ); - end; + end end; % return; diff --git a/functions/miscfunc/dendhier.m b/functions/miscfunc/dendhier.m index d86ff87ed..cef7cef32 100644 --- a/functions/miscfunc/dendhier.m +++ b/functions/miscfunc/dendhier.m @@ -1,3 +1,4 @@ +function [links,topology,node] = dendhier(links,topology,node) % DENDHIER: Recursive algorithm to find links and distance coordinates on a % dendrogram, given the topology matrix. % @@ -12,7 +13,6 @@ % RE Strauss, 7/13/95 -function [links,topology,node] = dendhier(links,topology,node) n = size(topology,1)+1; % Number of OTUs c1 = topology(node,1); @@ -27,7 +27,7 @@ prevdist = topology(prevnode,4); links = [links; c1 clst prevdist dist]; [links,topology,node] = dendhier(links,topology,prevnode); - end; + end if (c2 <= n) links = [links; c2 clst 0 dist]; @@ -36,6 +36,6 @@ prevdist = topology(prevnode,4); links = [links; c2 clst prevdist dist]; [links,topology,node] = dendhier(links,topology,prevnode); - end; + end return; diff --git a/functions/miscfunc/dendplot.m b/functions/miscfunc/dendplot.m index 0283eed4a..1510d981b 100644 --- a/functions/miscfunc/dendplot.m +++ b/functions/miscfunc/dendplot.m @@ -1,3 +1,4 @@ +function dendplot(topology,labels,fontsize) % DENDPLOT: Plots a dendrogram given a topology matrix. % % Usage: dendplot(topology,{labels},{fontsize}) @@ -14,17 +15,16 @@ % RE Strauss, 5/27/98 % 8/20/99 - miscellaneous changes for Matlab v5 -function dendplot(topology,labels,fontsize) if (nargin<2) labels = []; - end; + end if (nargin < 3) fontsize = []; - end; + end if (isempty(fontsize)) % Default font size for labels fontsize = 10; - end; + end r = size(topology,1); n = r+1; % Number of taxa @@ -36,7 +36,7 @@ function dendplot(topology,labels,fontsize) y(otus) = 0.5:(n-0.5); for i = 1:(n-1) y(topology(i,3)) = mean([y(topology(i,1)),y(topology(i,2))]); - end; + end clf; % Begin plot hold on; @@ -47,14 +47,14 @@ function dendplot(topology,labels,fontsize) X = [links(i,3) links(i,4)]; Y = [y(desc) y(desc)]; plot(X,Y,'k'); - end; + end for i = (n+1):(2*n-1) % Vertical lines indx = find(links(:,2)==i); X = [links(indx,4)]; Y = [y(links(indx(1),1)) y(links(indx(2),1))]; plot(X,Y,'k'); - end; + end maxdist = max(links(:,4)); for i = 1:n % OTU labels @@ -65,8 +65,8 @@ function dendplot(topology,labels,fontsize) h = text(-.02*maxdist,y(i),num2str(i)); % For OTUs on right set(h,'fontsize',fontsize); % text(-.06*maxdist,y(i),num2str(i)); % For UTOs on left - end; - end; + end + end axis([0 maxdist+0.03*maxdist 0 n]); % Axes axis('square'); diff --git a/functions/miscfunc/detectmalware.m b/functions/miscfunc/detectmalware.m index 2fd0b3ef6..a758478c5 100644 --- a/functions/miscfunc/detectmalware.m +++ b/functions/miscfunc/detectmalware.m @@ -1,12 +1,39 @@ % this function detects potential malware in the current folder and subfolders % -% Author: A. Delorme, Cotober 2013 +% Author: A. Delorme, October 2013 + +% Copyright (C) Author: A. Delorme, October 2013 +% +% This file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. function detectmalware(currentFolder); if nargin < 1 currentFolder = pwd; -end; +end folderContent = dir(currentFolder); folderContent = { folderContent.name }; @@ -27,21 +54,21 @@ if length(str) > 1 && str(1) ~= '%' res = cellfun(@(x)~isempty(findstr(x, str)), malwareStrings(1:end-1)); - if str(1) == '!', res(end+1) = 1; end; + if str(1) == '!', res(end+1) = 1; end if any(res) pos = find(res); pos = pos(1); disp('************************************') fprintf('Potential malware command detected containing "%s" in\n %s line %d\n', malwareStrings{pos}, fullfile(currentFolder, currentFile), countLine); fprintf('%d: %s\n%d: %s\n%d: %s\n', countLine-1, prevstr, countLine, str, countLine+1, fgetl(fid)); countLine = countLine+1; - end; - end; + end + end prevstr = str; - end; + end fclose(fid); elseif exist(currentFile) == 7 && ~strcmpi(currentFile, '..') && ~strcmpi(currentFile, '.') detectmalware(fullfile(currentFolder, currentFile)); - end; -end; + end +end diff --git a/functions/miscfunc/difftopo.m b/functions/miscfunc/difftopo.m index 0486381d0..dba229881 100644 --- a/functions/miscfunc/difftopo.m +++ b/functions/miscfunc/difftopo.m @@ -19,30 +19,41 @@ % Copyright (C) Scott Makeig, SCCN/INC/UCSD 3/28/05 % -% 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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. function difftopo(ALLEEG,eeg1,eeg2,interval,limits,subcomps); if nargin < 3 help difftopo return end -if eeg1 < 1 | eeg1 > length(ALLEEG) +if eeg1 < 1 || eeg1 > length(ALLEEG) help difftopo return end -if eeg2 < 1 | eeg2 > length(ALLEEG) +if eeg2 < 1 || eeg2 > length(ALLEEG) help difftopo return end @@ -50,7 +61,7 @@ help difftopo return end -if ndims(ALLEEG(eeg1).data) ~=3 | ndims(ALLEEG(eeg2).data) ~=3 +if ndims(ALLEEG(eeg1).data) ~=3 || ndims(ALLEEG(eeg2).data) ~=3 error('EEG datasets must be epoched data'); end diff --git a/functions/miscfunc/dprime.m b/functions/miscfunc/dprime.m deleted file mode 100644 index fd8a47c2d..000000000 --- a/functions/miscfunc/dprime.m +++ /dev/null @@ -1,433 +0,0 @@ -% DPRIME - Signal-detection theory sensitivity measure. -% -% d = dprime(pHit,pFA) -% [d,beta] = dprime(pHit,pFA) -% -% PHIT and PFA are numerical arrays of the same shape. -% PHIT is the proportion of "Hits": P(Yes|Signal) -% PFA is the proportion of "False Alarms": P(Yes|Noise) -% All numbers involved must be between 0 and 1. -% The function calculates the d-prime measure for each pair. -% The criterion value BETA can also be requested. -% Requires MATLAB's Statistical Toolbox. -% -% References: -% * Green, D. M. & Swets, J. A. (1974). Signal Detection Theory and -% Psychophysics (2nd Ed.). Huntington, NY: Robert Krieger Publ.Co. -% * Macmillan, Neil A. & Creelman, C. Douglas (2005). Detection Theory: -% A User's Guide (2nd Ed.). Lawrence Erlbaum Associates. -% -% See also NORMINV, NORMPDF. - -% Original coding by Alexander Petrov, Ohio State University. -% $Revision: 1.2 $ $Date: 2009-02-09 10:49:29 $ -% -% Part of the utils toolbox version 1.1 for MATLAB version 5 and up. -% http://alexpetrov.com/softw/utils/ -% Copyright (c) Alexander Petrov 1999-2006, http://alexpetrov.com -% Please read the LICENSE and NO WARRANTY statement: - -% GNU Public License for the UTILS Toolbox -% -% ============================================================================== -% -% IN BRIEF -% ======== -% -% This document refers to all Matlab scripts and documentation (referred -% to collectively here as "the software") contained in the "utils toolbox" -% by Alexander Petrov 1999-2006, http://alexpetrov.com/softw/utils/ -% -% The software is freely available and freely redistributable, according -% to the conditions of the Gnu General Public License (below). You may not -% distribute the software, in whole or in part, in conjunction with -% proprietary code. That means you ONLY have my permission to distribute a -% program that uses my code IF you also make freely available (under the -% terms of the Gnu GPL) the source code for your whole project. You may -% not pass on the software to another party in its current form or any -% altered, embellished or reduced form, without acknowledging the author -% and including a copy of this license. -% -% The software 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 (reproduced below), and the Free Software Foundation -% website (http://www.fsf.org) for more details. -% -% Please notify the author, via the website, of any bugs, notes, comments -% or suggested changes, particularly of any useful changes you may have -% made to your own copy of the software. -% -% Alex Petrov, December 2006 -% -% ============================================================================== -% -% GNU GENERAL PUBLIC LICENSE -% ========================== -% -% Version 2, June 1991 -% Copyright (C) 1989, 1991 Free Software Foundation, Inc. -% 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -% Everyone is permitted to copy and distribute verbatim copies -% of this license document, but changing it is not allowed. -% -% -% Preamble -% ======== -% -% The licenses for most software are designed to take away your -% freedom to share and change it. By contrast, the GNU General Public -% License is intended to guarantee your freedom to share and change free -% software--to make sure the software is free for all its users. This -% General Public License applies to most of the Free Software -% Foundation's software and to any other program whose authors commit to -% using it. (Some other Free Software Foundation software is covered by -% the GNU Library General Public License instead.) You can apply it to -% your programs, too. -% -% When we speak of free software, we are referring to freedom, not -% price. Our General Public Licenses are designed to make sure that you -% have the freedom to distribute copies of free software (and charge for -% this service if you wish), that you receive source code or can get it -% if you want it, that you can change the software or use pieces of it -% in new free programs; and that you know you can do these things. -% -% To protect your rights, we need to make restrictions that forbid -% anyone to deny you these rights or to ask you to surrender the rights. -% These restrictions translate to certain responsibilities for you if you -% distribute copies of the software, or if you modify it. -% -% For example, if you distribute copies of such a program, whether -% gratis or for a fee, you must give the recipients all the rights that -% you have. You must make sure that they, too, receive or can get the -% source code. And you must show them these terms so they know their -% rights. -% -% We protect your rights with two steps: (1) copyright the software, and -% (2) offer you this license which gives you legal permission to copy, -% distribute and/or modify the software. -% -% Also, for each author's protection and ours, we want to make certain -% that everyone understands that there is no warranty for this free -% software. If the software is modified by someone else and passed on, we -% want its recipients to know that what they have is not the original, so -% that any problems introduced by others will not reflect on the original -% authors' reputations. -% -% Finally, any free program is threatened constantly by software -% patents. We wish to avoid the danger that redistributors of a free -% program will individually obtain patent licenses, in effect making the -% program proprietary. To prevent this, we have made it clear that any -% patent must be licensed for everyone's free use or not licensed at all. -% -% The precise terms and conditions for copying, distribution and -% modification follow. -% -% -% GNU GENERAL PUBLIC LICENSE -% ========================== -% TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION -% =============================================================== -% -% 0. This License applies to any program or other work which contains -% a notice placed by the copyright holder saying it may be distributed -% under the terms of this General Public License. The "Program", below, -% refers to any such program or work, and a "work based on the Program" -% means either the Program or any derivative work under copyright law: -% that is to say, a work containing the Program or a portion of it, -% either verbatim or with modifications and/or translated into another -% language. (Hereinafter, translation is included without limitation in -% the term "modification".) Each licensee is addressed as "you". -% -% Activities other than copying, distribution and modification are not -% covered by this License; they are outside its scope. The act of -% running the Program is not restricted, and the output from the Program -% is covered only if its contents constitute a work based on the -% Program (independent of having been made by running the Program). -% Whether that is true depends on what the Program does. -% -% 1. You may copy and distribute verbatim copies of the Program's -% source code as you receive it, in any medium, provided that you -% conspicuously and appropriately publish on each copy an appropriate -% copyright notice and disclaimer of warranty; keep intact all the -% notices that refer to this License and to the absence of any warranty; -% and give any other recipients of the Program a copy of this License -% along with the Program. -% -% You may charge a fee for the physical act of transferring a copy, and -% you may at your option offer warranty protection in exchange for a fee. -% -% 2. You may modify your copy or copies of the Program or any portion -% of it, thus forming a work based on the Program, and copy and -% distribute such modifications or work under the terms of Section 1 -% above, provided that you also meet all of these conditions: -% -% a) You must cause the modified files to carry prominent notices -% stating that you changed the files and the date of any change. -% -% b) You must cause any work that you distribute or publish, that in -% whole or in part contains or is derived from the Program or any -% part thereof, to be licensed as a whole at no charge to all third -% parties under the terms of this License. -% -% c) If the modified program normally reads commands interactively -% when run, you must cause it, when started running for such -% interactive use in the most ordinary way, to print or display an -% announcement including an appropriate copyright notice and a -% notice that there is no warranty (or else, saying that you provide -% a warranty) and that users may redistribute the program under -% these conditions, and telling the user how to view a copy of this -% License. (Exception: if the Program itself is interactive but -% does not normally print such an announcement, your work based on -% the Program is not required to print an announcement.) -% -% These requirements apply to the modified work as a whole. If -% identifiable sections of that work are not derived from the Program, -% and can be reasonably considered independent and separate works in -% themselves, then this License, and its terms, do not apply to those -% sections when you distribute them as separate works. But when you -% distribute the same sections as part of a whole which is a work based -% on the Program, the distribution of the whole must be on the terms of -% this License, whose permissions for other licensees extend to the -% entire whole, and thus to each and every part regardless of who wrote it. -% -% Thus, it is not the intent of this section to claim rights or contest -% your rights to work written entirely by you; rather, the intent is to -% exercise the right to control the distribution of derivative or -% collective works based on the Program. -% -% In addition, mere aggregation of another work not based on the Program -% with the Program (or with a work based on the Program) on a volume of -% a storage or distribution medium does not bring the other work under -% the scope of this License. -% -% 3. You may copy and distribute the Program (or a work based on it, -% under Section 2) in object code or executable form under the terms of -% Sections 1 and 2 above provided that you also do one of the following: -% -% a) Accompany it with the complete corresponding machine-readable -% source code, which must be distributed under the terms of Sections -% 1 and 2 above on a medium customarily used for software interchange; or, -% -% b) Accompany it with a written offer, valid for at least three -% years, to give any third party, for a charge no more than your -% cost of physically performing source distribution, a complete -% machine-readable copy of the corresponding source code, to be -% distributed under the terms of Sections 1 and 2 above on a medium -% customarily used for software interchange; or, -% -% c) Accompany it with the information you received as to the offer -% to distribute corresponding source code. (This alternative is -% allowed only for noncommercial distribution and only if you -% received the program in object code or executable form with such -% an offer, in accord with Subsection b above.) -% -% The source code for a work means the preferred form of the work for -% making modifications to it. For an executable work, complete source -% code means all the source code for all modules it contains, plus any -% associated interface definition files, plus the scripts used to -% control compilation and installation of the executable. However, as a -% special exception, the source code distributed need not include -% anything that is normally distributed (in either source or binary -% form) with the major components (compiler, kernel, and so on) of the -% operating system on which the executable runs, unless that component -% itself accompanies the executable. -% -% If distribution of executable or object code is made by offering -% access to copy from a designated place, then offering equivalent -% access to copy the source code from the same place counts as -% distribution of the source code, even though third parties are not -% compelled to copy the source along with the object code. -% -% 4. You may not copy, modify, sublicense, or distribute the Program -% except as expressly provided under this License. Any attempt -% otherwise to copy, modify, sublicense or distribute the Program is -% void, and will automatically terminate your rights under this License. -% However, parties who have received copies, or rights, from you under -% this License will not have their licenses terminated so long as such -% parties remain in full compliance. -% -% 5. You are not required to accept this License, since you have not -% signed it. However, nothing else grants you permission to modify or -% distribute the Program or its derivative works. These actions are -% prohibited by law if you do not accept this License. Therefore, by -% modifying or distributing the Program (or any work based on the -% Program), you indicate your acceptance of this License to do so, and -% all its terms and conditions for copying, distributing or modifying -% the Program or works based on it. -% -% 6. Each time you redistribute the Program (or any work based on the -% Program), the recipient automatically receives a license from the -% original licensor to copy, distribute or modify the Program subject to -% these terms and conditions. You may not impose any further -% restrictions on the recipients' exercise of the rights granted herein. -% You are not responsible for enforcing compliance by third parties to -% this License. -% -% 7. If, as a consequence of a court judgment or allegation of patent -% infringement or for any other reason (not limited to patent issues), -% conditions are imposed on you (whether by court order, agreement or -% otherwise) that contradict the conditions of this License, they do not -% excuse you from the conditions of this License. If you cannot -% distribute so as to satisfy simultaneously your obligations under this -% License and any other pertinent obligations, then as a consequence you -% may not distribute the Program at all. For example, if a patent -% license would not permit royalty-free redistribution of the Program by -% all those who receive copies directly or indirectly through you, then -% the only way you could satisfy both it and this License would be to -% refrain entirely from distribution of the Program. -% -% If any portion of this section is held invalid or unenforceable under -% any particular circumstance, the balance of the section is intended to -% apply and the section as a whole is intended to apply in other -% circumstances. -% -% It is not the purpose of this section to induce you to infringe any -% patents or other property right claims or to contest validity of any -% such claims; this section has the sole purpose of protecting the -% integrity of the free software distribution system, which is -% implemented by public license practices. Many people have made -% generous contributions to the wide range of software distributed -% through that system in reliance on consistent application of that -% system; it is up to the author/donor to decide if he or she is willing -% to distribute software through any other system and a licensee cannot -% impose that choice. -% -% This section is intended to make thoroughly clear what is believed to -% be a consequence of the rest of this License. -% -% 8. If the distribution and/or use of the Program is restricted in -% certain countries either by patents or by copyrighted interfaces, the -% original copyright holder who places the Program under this License -% may add an explicit geographical distribution limitation excluding -% those countries, so that distribution is permitted only in or among -% countries not thus excluded. In such case, this License incorporates -% the limitation as if written in the body of this License. -% -% 9. The Free Software Foundation may publish revised and/or new versions -% of the General Public License from time to time. Such new versions will -% be similar in spirit to the present version, but may differ in detail to -% address new problems or concerns. -% -% Each version is given a distinguishing version number. If the Program -% specifies a version number of this License which applies to it and "any -% later version", you have the option of following the terms and conditions -% either of that version or of any later version published by the Free -% Software Foundation. If the Program does not specify a version number of -% this License, you may choose any version ever published by the Free Software -% Foundation. -% -% 10. If you wish to incorporate parts of the Program into other free -% programs whose distribution conditions are different, write to the author -% to ask for permission. For software which is copyrighted by the Free -% Software Foundation, write to the Free Software Foundation; we sometimes -% make exceptions for this. Our decision will be guided by the two goals -% of preserving the free status of all derivatives of our free software and -% of promoting the sharing and reuse of software generally. -% -% NO WARRANTY: -% -% 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -% FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -% OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -% PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -% OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -% MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -% TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -% PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -% REPAIR OR CORRECTION. -% -% 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -% WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -% REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -% INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -% OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -% TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -% YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -% PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -% POSSIBILITY OF SUCH DAMAGES. -% -% END OF TERMS AND CONDITIONS -% -% -% How to Apply These Terms to Your New Programs -% ============================================= -% -% If you develop a new program, and you want it to be of the greatest -% possible use to the public, the best way to achieve this is to make it -% free software which everyone can redistribute and change under these terms. -% -% To do so, attach the following notices to the program. It is safest -% to attach them to the start of each source file to most effectively -% convey the exclusion of warranty; and each file should have at least -% the "copyright" line and a pointer to where the full notice is found. -% -% -% Copyright (C) -% -% 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 -% -% -% Also add information on how to contact you by electronic and paper mail. -% -% If the program is interactive, make it output a short notice like this -% when it starts in an interactive mode: -% -% Gnomovision version 69, Copyright (C) year name of author -% Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. -% This is free software, and you are welcome to redistribute it -% under certain conditions; type `show c' for details. -% -% The hypothetical commands `show w' and `show c' should show the appropriate -% parts of the General Public License. Of course, the commands you use may -% be called something other than `show w' and `show c'; they could even be -% mouse-clicks or menu items--whatever suits your program. -% -% You should also get your employer (if you work as a programmer) or your -% school, if any, to sign a "copyright disclaimer" for the program, if -% necessary. Here is a sample; alter the names: -% -% Yoyodyne, Inc., hereby disclaims all copyright interest in the program -% `Gnomovision' (which makes passes at compilers) written by James Hacker. -% -% , 1 April 1989 -% Ty Coon, President of Vice -% -% This General Public License does not permit incorporating your program into -% proprietary programs. If your program is a subroutine library, you may -% consider it more useful to permit linking proprietary applications with the -% library. If this is what you want to do, use the GNU Library General -% Public License instead of this License. -% -% ============================================================================== - -function [d,beta] = dprime(pHit,pFA) - -%-- Convert to Z scores, no error checking -zHit = norminv(pHit) ; -zFA = norminv(pFA) ; - -%-- Calculate d-prime -d = zHit - zFA ; - -%-- If requested, calculate BETA -if (nargout > 1) - yHit = normpdf(zHit) ; - yFA = normpdf(zFA) ; - beta = yHit ./ yFA ; -end - -%% Return DPRIME and possibly BETA -%%%%%% End of file DPRIME.M diff --git a/functions/miscfunc/eeg_ms2f.m b/functions/miscfunc/eeg_ms2f.m index ddfa38ca2..b22581939 100644 --- a/functions/miscfunc/eeg_ms2f.m +++ b/functions/miscfunc/eeg_ms2f.m @@ -1,4 +1,4 @@ -% eeg_ms2f() - convert epoch latency in ms to nearest epoch frame number +% EEG_MS2F - convert epoch latency in ms to nearest epoch frame number % % Usage: % >> outf = eeg_ms2f(EEG,ms); @@ -10,11 +10,38 @@ % % Author: Scott Makeig, SCCN/INC, 12/05 +% Copyright (C) Scott Makeig, SCCN/INC, 12/05 +% +% This file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. + function outf = eeg_ms2f(EEG,ms) - ms = ms/1000; - if ms < EEG.xmin | ms > EEG.xmax - error('time out of range'); - end - outf = 1+round((EEG.pnts-1)*(ms-EEG.xmin)/(EEG.xmax-EEG.xmin)); - % else - % [tmp outf] = min(abs(EEG.times-ms)); +ms = ms/1000; +if ms < EEG.xmin || ms > EEG.xmax + error('time out of range'); +end +outf = 1+round((EEG.pnts-1)*(ms-EEG.xmin)/(EEG.xmax-EEG.xmin)); +% else +% [tmp outf] = min(abs(EEG.times-ms)); diff --git a/functions/miscfunc/eeg_time2prev.m b/functions/miscfunc/eeg_time2prev.m index 65f831892..4c1f07d8b 100644 --- a/functions/miscfunc/eeg_time2prev.m +++ b/functions/miscfunc/eeg_time2prev.m @@ -1,9 +1,9 @@ -% eeg_time2prev() - returns a vector giving, for each event of specified ("target") type(s), +% EEG_TIME2PREV - returns a vector giving, for each event of specified ("target") type(s), % the delay (in ms) since the preceding event (if any) of specified % ("previous") type(s). Requires the EEG.urevent structure, plus -% EEG.event().urevent pointers to it. +% EEG.EVENT.urevent pointers to it. % -% NOW SUPERCEDED BY eeg_context() +% NOW SUPERSEDED BY EEG_CONTEXT % Usage: % >> [delays,targets,urtargs,urprevs] = eeg_time2prev(EEG,{target},{previous}); % Inputs: @@ -28,6 +28,33 @@ %% % Scott Makeig & Arnaud Delorme, SCCN/INC/UCSD, August 28, 2003 +% Copyright (C) Scott Makeig & Arnaud Delorme, SCCN/INC/UCSD, August 28, 2003 +% +% This file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. + function [delays,targets,urtargets,urprevs] = eeg_time2prev(EEG,target,previous); verbose = 1; % FLAG (1=on|0=off) @@ -72,9 +99,9 @@ %%%%%%%%%%%%%%%%%%%% Initialize output arrays %%%%%%%%%%%%%%%%%%%%%% % delays = zeros(1,nevents); % holds output times in ms -targets = zeros(1,nevents); % holds indxes of targets -urtargets = zeros(1,nevents); % holds indxes of targets -urprevs = zeros(1,nevents); % holds indxes of prevs +targets = zeros(1,nevents); % holds indexes of targets +urtargets = zeros(1,nevents); % holds indexes of targets +urprevs = zeros(1,nevents); % holds indexes of prevs targetcount = 0; % index of current target % Below: diff --git a/functions/miscfunc/eegdraw.m b/functions/miscfunc/eegdraw.m index 54535260d..0bd14947a 100644 --- a/functions/miscfunc/eegdraw.m +++ b/functions/miscfunc/eegdraw.m @@ -1,22 +1,33 @@ -% eegdraw() - subroutine used by eegplotold() to plot data. +% EEGDRAW - subroutine used by EEGPLOTOLD to plot data. % % Author: Colin Humphries, CNL, Salk Institute, La Jolla, 7/96 -% Copyright (C) Colin Humphries, CNL, Salk Institute 7/96 from eegplot() +% Copyright (C) Colin Humphries, CNL, Salk Institute 7/96 from EEGPLOT % -% 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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. % 11-07-97 fix incorrect start times -Scott Makeig % 01-25-02 reformated help & license -ad diff --git a/functions/miscfunc/eegdrawg.m b/functions/miscfunc/eegdrawg.m index 5c3289874..504bdf0b5 100644 --- a/functions/miscfunc/eegdrawg.m +++ b/functions/miscfunc/eegdrawg.m @@ -1,24 +1,35 @@ -% eegdrawg() - subroutine used by eegplotgold() to plot data. +% EEGDRAWG - subroutine used by EEGPLOTGOLD to plot data. % % Author: Colin Humphries, CNL, Salk Institute, La Jolla, 7/96 -% Copyright (C) Colin Humphries, CNL, Salk Institute 7/96 from eegplot() +% Copyright (C) Colin Humphries, CNL, Salk Institute 7/96 from EEGPLOT % -% 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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 - -% 4-4-97 shortened name to eegdrawq() -sm +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. + +% 4-4-97 shortened name to EEGDRAWQ -sm % 4-7-97 allowed data names other than 'data' -ch % 01-25-02 reformated help & license -ad diff --git a/functions/miscfunc/eegmovie.m b/functions/miscfunc/eegmovie.m index 4720fae9a..f19df81d9 100644 --- a/functions/miscfunc/eegmovie.m +++ b/functions/miscfunc/eegmovie.m @@ -1,6 +1,6 @@ -% eegmovie() - Compile and view a Matlab movie. -% Uses scripts eegplotold() and topoplot(). -% Use seemovie() to display the movie. +% EEGMOVIE - Compile and view a Matlab movie. +% Uses scripts EEGPLOTOLD and TOPOPLOT. +% Use SEEMOVIE to display the movie. % Usage: % >> [Movie,Colormap] = eegmovie(data,srate,elec_locs, 'key', val, ...); % @@ -44,23 +44,36 @@ % % Author: Arnaud Delorme, Colin Humphries & Scott Makeig, CNL, Salk Institute, La Jolla, 3/97 % -% See also: seemovie(), eegplotold(), topoplot() +% Example of usage for 3D movie: see https://github.com/amisepa/eegmovie_topo3d +% +% See also: SEEMOVIE, EEGPLOTOLD, TOPOPLOT % Copyright (C) 6/4/97 Colin Humphries & Scott Makeig, CNL / Salk Institute / La Jolla CA % -% 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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. % -% 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. +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. % -% 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 +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. % 6/6/97 added movieframes arg -sm % 6/12/97 removed old 'startframes' var., fixed vertical line frame selection -sm @@ -100,7 +113,7 @@ if nargin>=4, options = { options{:} 'title' varargin{1} }; end else options = varargin; -end; +end opt = finputcheck(options, { 'startsec' 'real' {} 0; 'minmax' 'real' {} 0; @@ -114,7 +127,7 @@ 'time' 'string' { 'on' 'off' } 'off'; 'topoplotopt' 'cell' {} {}; 'headplotopt' 'cell' {} {} }, 'eegmovie'); -if isstr(opt), error(opt); end; +if ischar(opt), error(opt); end if opt.minmax ==0, datamin = min(min(data)); datamax = max(max(data)); @@ -135,13 +148,13 @@ if srate ==0, srate = DEFAULT_SRATE; end -if strcmpi(opt.time, 'on'), opt.framenum = 'off'; end; +if strcmpi(opt.time, 'on'), opt.framenum = 'off'; end mframes = length(opt.movieframes); fprintf('Making a movie of %d frames\n',mframes) Movie = moviein(mframes,gcf); -%%%%%%%%%%%%%%%%%%%%% eegplot() of data %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%% EEGPLOT of data %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if strcmpi(opt.timecourse, 'on') axeegplot = axes('Units','Normalized','Position',[.75 .05 .2 .9]); @@ -152,12 +165,12 @@ adddots = '...'; for iChan = 1:length(eloc_locs) fprintf(fid, '0 0 0 %s\n', [ eloc_locs(iChan).labels adddots(length(eloc_locs(iChan).labels):end) ]); - end; + end fclose(fid); eegplotold('noui',-data,srate,0,'tmp_file.loc',opt.startsec,'r'); else eegplotold('noui',-data,srate,0,eloc_locs,opt.startsec,'r'); - end; + end % set(axeegplot,'XTick',[]) %%CJH % plot negative up @@ -170,8 +183,8 @@ frameind = (opt.vert(ind)-opt.startsec)*srate+1; line([frameind frameind],limits,'color','k'); % draw vertical line at map timepoint set(axeegplot,'Xtick',frameind,'XtickLabel',num2str(opt.vert(ind),'%4.3f')); - end; -end; + end +end %%%%%%%%%%%%%%%%%%%%% topoplot/headplot axis %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -190,7 +203,7 @@ if isequal(opt.camerapath, 0) opt.camerapath = [-127 0 30 0]; fprintf('Using default view [-127 0 30 0].'); - end; + end if size(opt.camerapath,2)~=4 error('Camerapath parameter must have exact 4 columns'); end @@ -206,7 +219,7 @@ elevation = opt.camerapath(1,3); el_step = opt.camerapath(1,4); -end; +end %%%%%%%%%%%%%%%%%%%%%%%%% "Roll'em!" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -219,7 +232,7 @@ x1 = opt.startsec+(indFrame-1)/srate; l1 = line([indFrame indFrame],limits,'color','b'); % draw vertical line at map timepoint set(axeegplot,'Xtick',indFrame,'XtickLabel',num2str(x1,'%4.3f')); - end; + end % plot headplot or topoplot axes(axtopoplot) @@ -260,7 +273,7 @@ 'PlotBoxAspectRatioMode','manual',... 'DataAspectRatioMode','manual'); % keep camera distance constant - end; + end % show frame number if strcmpi(opt.framenum, 'on') @@ -269,17 +282,17 @@ elseif strcmpi(opt.time, 'on') txt = sprintf('%3.3f s', opt.startsec+(indFrame-1)/srate); text(-0.5,-0.5,txt,'FontSize',14); - end; + end Movie(:,f) = getframe(gcf); drawnow if strcmpi(opt.timecourse, 'on') delete(l1) - end; + end % print advancement fprintf('.',f); - if rem(indFrame,10) == 0, fprintf('%d',f); end; + if rem(indFrame,10) == 0, fprintf('%d',f); end if rem(indFrame,50) == 0, fprintf('\n'); end end fprintf('\nDone\n'); diff --git a/functions/miscfunc/eegplotgold.m b/functions/miscfunc/eegplotgold.m index dbcb7fed1..eede3fdf9 100644 --- a/functions/miscfunc/eegplotgold.m +++ b/functions/miscfunc/eegplotgold.m @@ -1,4 +1,4 @@ -% eegplotgold() - display EEG data in a clinical format +% EEGPLOTGOLD - display EEG data in a clinical format % % Usage: % >> eegplotgold('dataname', samplerate, 'chanfile', 'title', yscaling, range) @@ -6,13 +6,13 @@ % Inputs: % 'dataname' - quoted name of a desktop global variable (see Ex. below) % samplerate - EEG sampling rate in Hz (0 -> default 256 Hz) -% 'chanfile' - file of channel info in topoplot() style +% 'chanfile' - file of channel info in TOPOPLOT style % (0 -> channel numbers) -% 'title' - plot title string (0 -> 'eegplotgold()') +% 'title' - plot title string (0 -> 'EEGPLOTGOLD') % yscaling - initial y scaling factor (0 - default is 300) % range - how many seconds to display in window (0 -> 10) % -% Note: this version of eegplotgold() reguires that your data matrix +% Note: this version of EEGPLOTGOLD requires that your data matrix % be defined as a global variable before running this routine. % % Example: >> global dataname @@ -20,25 +20,36 @@ % % Author: Colin Humphries, CNL, Salk Institute, La Jolla, 3/97 % -% See also: eegplot(), eegplotold(), eegplotsold() +% See also: EEGPLOT, EEGPLOTOLD, EEGPLOTSOLD -% Copyright (C) Colin Humphries, CNL, Salk Institute 3/97 from eegplotold() +% Copyright (C) Colin Humphries, CNL, Salk Institute 3/97 from EEGPLOTOLD % -% 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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 - -% 4-4-97 shortened name to eegplotgold() -sm +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. + +% 4-4-97 shortened name to EEGPLOTGOLD -sm % 5-20-97 added read of icadefs.m for MAXEEGPLOTCHANS -sm % 8-10-97 Clarified chanfile type -sm % 01-25-02 reformated help & license, added links -ad @@ -100,7 +111,7 @@ end if samplerate == 0, samplerate = DEFAULT_SAMPLERATE; -end; +end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Define internal variables @@ -124,7 +135,7 @@ channamefile = 0; else fprintf('Chan info file %s opened\n',channamefile); - end; + end icadefs; % read MAXEEGPLOTCHANS from icadefs.m if errorcode==0, @@ -135,18 +146,18 @@ for j=1:c if channames(i,j)=='.', channames(i,j)=' '; - end; - end; - end; + end + end + end % fprintf('%d channel names read from file.\n',r); if (r>chans) fprintf('Using first %d names.\n',chans); channames = channames(1:chans,:); - end; + end if (r > eegplotold(data,srate,spacing,eloc_file,windowlength,title) @@ -17,23 +17,34 @@ % % Author: Colin Humphries, CNL, Salk Institute, La Jolla, 5/98 % -% See also: eegplot(), eegplotgold(), eegplotsold() +% See also: EEGPLOT, EEGPLOTGOLD, EEGPLOTSOLD -% Copyright (C) Colin Humphries, CNL, Salk Institute 3/97 from eegplotold() +% Copyright (C) Colin Humphries, CNL, Salk Institute 3/97 from EEGPLOTOLD % -% 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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. % Runs under Matlab 5.0+ (not supported for Matlab 4) % @@ -82,7 +93,7 @@ % Setup inputs % %%%%%%%%%%%%%%%%%%%%%%%% -if ~isstr(data) % If NOT a 'noui' call or a callback from uicontrols +if ~ischar(data) % If NOT a 'noui' call or a callback from uicontrols if nargin == 7 % undocumented feature - allows position to be specd. posn = p6; @@ -151,7 +162,7 @@ YLabels = flipud(str2mat(YLabels,' ')); elseif length(eloc_file) == chans YLabels = num2str(eloc_file'); - elseif length(eloc_file) == 1 & eloc_file(1) == 0 + elseif length(eloc_file) == 1 && eloc_file(1) == 0 YLabels = num2str((1:chans)'); % Use numbers else YLabels = []; % no labels used @@ -203,7 +214,7 @@ 'XColor',DEFAULT_AXIS_COLOR,... 'YColor',DEFAULT_AXIS_COLOR); - if isstr(titleval) % plot title + if ischar(titleval) % plot title title(titleval) elseif titleval == 2 title(inputname(1)) @@ -532,7 +543,7 @@ spacing = str2num(get(ESpacing,'string')); % current spacing winlength = get(figh,'UserData'); - if isempty(spacing) | isempty(time) + if isempty(spacing) || isempty(time) return % return if valid numbers are not in the edit boxes end @@ -758,7 +769,7 @@ timestring = ['OBJ2 = findobj(''tag'',''electedit'');',... '[LAB1,LAB2] = uigetfile(''*'',''Electrode File'');',... - 'if (isstr(LAB1) & isstr(LAB2));',... + 'if (ischar(LAB1) & ischar(LAB2));',... 'set(OBJ2,''string'',[LAB2,LAB1]);',... 'end;',... 'clear OBJ2 LAB1 LAB2;']; @@ -956,7 +967,7 @@ end if spacing == 0 spacing = 1; - end; + end if Fs == 0 Fs = DEFAULT_SAMPLE_RATE; end diff --git a/functions/miscfunc/eegplotsold.m b/functions/miscfunc/eegplotsold.m index 9c0044ced..457370472 100644 --- a/functions/miscfunc/eegplotsold.m +++ b/functions/miscfunc/eegplotsold.m @@ -1,4 +1,4 @@ -% eegplotsold() - display data in a clinical format without scrolling +% EEGPLOTSOLD - display data in a clinical format without scrolling % % Usage: % >> eegplotsold(data, srate, 'chanfile', 'title', ... @@ -7,8 +7,8 @@ % Inputs: % data - data matrix (chans,frames) % srate - EEG sampling rate in Hz (0 -> 256 Hz) -% 'chanfile' - file of channel info, topoplot() style, (0 -> chan nos) -% 'title' - plot title string {0 -> 'eegplotsold()'} +% 'chanfile' - file of channel info, TOPOPLOT style, (0 -> chan nos) +% 'title' - plot title string {0 -> 'EEGPLOTSOLD'} % yscaling - initial y scaling factor (0 -> 300) % epoch - how many seconds to display in window (0 -> 10 sec) % linecolor - color of eeg (0 -> 'y') @@ -17,30 +17,41 @@ % % Author: Colin Humphries, CNL, Salk Institute, La Jolla, 3/97 % -% See also: eegplot(), eegplotold(), eegplotgold() +% See also: EEGPLOT, EEGPLOTOLD, EEGPLOTGOLD -% Copyright (C) Colin Humphries, CNL, Salk Institute 3/97 from eegplotold() +% Copyright (C) Colin Humphries, CNL, Salk Institute 3/97 from EEGPLOTOLD % -% 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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. % 05-01-97 added xstart argument -sm % 05-20-97 added read of icadefs.m % 06-12-97 EPOCH -> epoch line 71 below -sm % 8-10-97 Clarified chanfile type -sm -% 12-08-97 Added isstr(titleval) test -sm -% 02-09-98 legnth(data)->size(data,2) -sm +% 12-08-97 Added ischar(titleval) test -sm +% 02-09-98 length(data)->size(data,2) -sm % 01-25-02 reformated help & license, added links -ad %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -105,7 +116,7 @@ if nargin < 4 titleval = DEFAULT_TITLE; end -if ~isstr(titleval) +if ~ischar(titleval) if titleval == 0 titleval = DEFAULT_TITLE; else @@ -121,7 +132,7 @@ end if srate == 0, srate = DEFAULT_SRATE; -end; +end if PLOT_TIME == 0 PLOT_TIME = ceil(frames/srate); if PLOT_TIME > DEFAULT_EPOCH @@ -147,7 +158,7 @@ channamefile = 0; else % fprintf('Chan info file %s opened\n',channamefile); - end; + end if errorcode==0, channames = fscanf(chid,'%d %f %f %s',[7 MAXEEGPLOTCHANS]); channames = channames'; @@ -157,18 +168,18 @@ for j=1:c if channames(i,j)=='.', channames(i,j)=' '; % convert dots to spaces - end; - end; - end; + end + end + end % fprintf('%d channel names read from file.\n',r); if (r>chans) fprintf('Using first %d names.\n',chans); channames = channames(1:chans,:); - end; + end if (r 0 +if xstart<0 && xstart+PLOT_TIME > 0 linetime = round(-xstart/srate); line ([linetime linetime],[1e10,-1e10]); end diff --git a/functions/miscfunc/envproj.m b/functions/miscfunc/envproj.m index 8c920794f..05054244e 100644 --- a/functions/miscfunc/envproj.m +++ b/functions/miscfunc/envproj.m @@ -1,12 +1,12 @@ -% envproj() - plot envelopes of projections of selected ICA component +% ENVPROJ - plot envelopes of projections of selected ICA component % projections against envelope of the original data % % Usage: >> [envdata] = envproj(data,weights,compnums); % >> [envdata] = envproj(data,weights,compnums, ... % title,limits,chanlist,compnames,colors); % Inputs: -% data = runica() input data (chans,frames) <- best one epoch only! -% weights = unmixing weight matrix (runica() weights*sphere) +% data = RUNICA input data (chans,frames) <- best one epoch only! +% weights = unmixing weight matrix (RUNICA weights*sphere) % compnums = list of component numbers to project and plot % % Optional inputs: @@ -24,27 +24,38 @@ % % Author: Scott Makeig, SCCN/INC/UCSD, La Jolla, 1/1997 % -% See also: envtopo() +% See also: ENVTOPO % Copyright (C) 01-23-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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. -% 03-19-97 use datamean instead of frames/baseframes, diag(cov()) for var() -sm -% 04-03-97 changed name to envproj() -sm -% 05-20-97 used sum-of-squares for var instead of diag() to allow long data +% 03-19-97 use datamean instead of frames/baseframes, diag(COV) for VAR -sm +% 04-03-97 changed name to ENVPROJ -sm +% 05-20-97 used sum-of-squares for var instead of DIAG to allow long data % read MAXPLOTDATACHANS from icadefs.m -sm % 06-07-97 changed order of args to conform to runica -sm % 06-18-97 read MAXENVPLOTCHANS instead of MAXPLOTDATACHANS -sm @@ -66,7 +77,7 @@ % 06-05-98 made NEG_UP optional -sm % 02-22-99 added FILL mode default when numcomps==1 -sm % 03-14-99 made envelope finding code more efficient -sm -% 12-19-00 updated icaproj() args -sm +% 12-19-00 updated ICAPROJ args -sm % 01-25-02 reformated help & license, added links -ad function [envdata] = envproj(data,weights,compnums,titl,limits,chanlist,compnames,colors) @@ -119,20 +130,20 @@ % if chanlist == 0, chanlist = [1:chans]; -end; +end if compnums == 0, compnums = [1:wr]; -end; +end if size(compnums,1)>1, % handle column of compnums ! compnums = compnums'; -end; +end numcomps = length(compnums); if numcomps > MAXENVPLOTCHANS, fprintf(... 'envproj(): cannot plot more than %d channels of data at once.\n',... MAXENVPLOTCHANS); return -end; +end if max(compnums)>wr fprintf('\nenvproj(): Component index %d out of bounds (1:%d).\n',... @@ -146,7 +157,7 @@ return end -if FILL>0 & numcomps == 1 +if FILL>0 && numcomps == 1 FILL = 1; else FILL = 0; @@ -163,33 +174,33 @@ fprintf( ... 'envproj(): limits should be 0 or an array [xmin xmax ymin ymax].\n'); return - end; - if limits(1,1) == 0 & limits(1,2) ==0, + end + if limits(1,1) == 0 && limits(1,2) ==0, xmin=0; xmax=0; else xmin = limits(1,1); xmax = limits(1,2); - end; - if limits(1,3) == 0 & limits(1,4) ==0, + end + if limits(1,3) == 0 && limits(1,4) ==0, ymin=0; ymax=0; else ymin = limits(1,3); ymax = limits(1,4); - end; - end; + end + end - if xmax == 0 & xmin == 0, + if xmax == 0 && xmin == 0, x = (0:1:frames-1); xmin = 0; xmax = frames-1; else dx = (xmax-xmin)/(frames-1); x=xmin*ones(1,frames)+dx*(0:frames-1); % construct x-values - end; + end - if ymax == 0 & ymin == 0, + if ymax == 0 && ymin == 0, ymax=max(max(data(chanlist,:))); ymin=min(min(data(chanlist,:))); end @@ -197,7 +208,7 @@ % %%%%%%%%%%%%%%%%%%%% Read the color names %%%%%%%%%%%%%%%%%%%%%%%%%%%% % - if ~isstr(colors) + if ~ischar(colors) fprintf('envproj(): color file name must be a string.\n'); return end @@ -213,10 +224,10 @@ for j=1:c if colors(i,j)=='.', colors(i,j)=' '; - end; - end; - end; - end; + end + end + end + end [rr cc] = size(colors); % @@ -241,12 +252,12 @@ % append envelope of projected data sets onto envdata % Note: size(envdata) = [length(chanlist) frames*(numcomps+1)] n = n+1; -end; +end fprintf('\n'); % %%%%%%%%%%%%%%%%%%%%%%%% Make the plot %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -if ~isstr(titl) +if ~ischar(titl) if titl==0, titl = ' '; else @@ -310,7 +321,7 @@ l=ylabel('Potential (uV)'); % yaxis label set(l,'FontSize',14); -if xmax > 0 & xmin < 0 +if xmax > 0 && xmin < 0 plot([0 0],[ymin ymax],'k','linewidth',1.5); % plot vertical line at time 0 end diff --git a/functions/miscfunc/erpregout.m b/functions/miscfunc/erpregout.m index 4a64b7c24..3dc4d3370 100755 --- a/functions/miscfunc/erpregout.m +++ b/functions/miscfunc/erpregout.m @@ -1,87 +1,98 @@ -% erpregout() - regress out the ERP from the data -% -% Usage: -% newdata = erpregout(data); -% [newdata erp factors] = erpregout(data, tlim, reglim); -% -% Inputs: -% data - [float] 2-D data (times x trials) or 3-D data -% (channels x times x trials). -% -% Optional inputs: -% tlim - [min max] time limits in ms. -% reglim - [min max] regression time window in ms (by default -% the whole time period is used -% Outputs: -% newdata - data with ERP regressed out -% erp - data ERP -% factors - factors used for regressing out the ERP (size is the same -% as the number of trials or (channels x trials) -% -% Note: it is better to regress out the ERP about 4 times (launch the -% function 4 times in a row) to really be able to regress out the -% ERP and have a residual ERP close to 0. -% -% Author: Arnaud Delorme, Salk, SCCN, UCSD, CA, April 29, 2004 - -%123456789012345678901234567890123456789012345678901234567890123456789012 - -% Copyright (C) 2004 Arnaud Delorme -% -% 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 - -function [data, erp, factors] = erpregout(data, tlim, reglim); - - if nargin < 1 - help erpregout; - return; - end; - if nargin < 2 - tlim = [0 1]; - end; - if nargin < 3 - reglim = tlim; - end; - if ndims(data) == 2 - data = reshape(data, 1, size(data,1), size(data,2)); - redim = 1; - else - redim = 0; - end; - - % find closest points - % ------------------- - timevect = linspace(tlim(1), tlim(2), size(data,2)); - [tmp begpoint] = min( abs(timevect-reglim(1)) ); - [tmp endpoint] = min( abs(timevect-reglim(2)) ); - erp = mean(data, 3); - - % regressing out erp in channels and trials - % ----------------------------------------- - for chan = 1:size(data,1) - fprintf('Channel %d (trials out of %d):', chan, size(data,3)); - for trial = 1:size(data,3) - if ~mod(trial, 10) , fprintf('%d ', trial); end; - if ~mod(trial, 200), fprintf('\n', trial); end; - [factors(chan, trial) tmpf exitflag] = fminbnd('erpregoutfunc', 0, 10, [], ... - data(chan, begpoint:endpoint, trial), erp(chan, begpoint:endpoint)); - data(chan,:,trial) = data(chan,:,trial) - factors(chan, trial)*erp(chan, :); - end; - fprintf('\n'); - end; - - if redim - data = squeeze(data); - end; \ No newline at end of file +% ERPREGOUT - regress out the ERP from the data +% +% Usage: +% newdata = erpregout(data); +% [newdata erp factors] = erpregout(data, tlim, reglim); +% +% Inputs: +% data - [float] 2-D data (times x trials) or 3-D data +% (channels x times x trials). +% +% Optional inputs: +% tlim - [min max] time limits in ms. +% reglim - [min max] regression time window in ms (by default +% the whole time period is used +% Outputs: +% newdata - data with ERP regressed out +% erp - data ERP +% factors - factors used for regressing out the ERP (size is the same +% as the number of trials or (channels x trials) +% +% Note: it is better to regress out the ERP about 4 times (launch the +% function 4 times in a row) to really be able to regress out the +% ERP and have a residual ERP close to 0. +% +% Author: Arnaud Delorme, Salk, SCCN, UCSD, CA, April 29, 2004 + +%123456789012345678901234567890123456789012345678901234567890123456789012 + +% Copyright (C) 2004 Arnaud Delorme +% +% This file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. + +function [data, erp, factors] = erpregout(data, tlim, reglim); + + if nargin < 1 + help erpregout; + return; + end + if nargin < 2 + tlim = [0 1]; + end + if nargin < 3 + reglim = tlim; + end + if ndims(data) == 2 + data = reshape(data, 1, size(data,1), size(data,2)); + redim = 1; + else + redim = 0; + end + + % find closest points + % ------------------- + timevect = linspace(tlim(1), tlim(2), size(data,2)); + [tmp begpoint] = min( abs(timevect-reglim(1)) ); + [tmp endpoint] = min( abs(timevect-reglim(2)) ); + erp = mean(data, 3); + + % regressing out erp in channels and trials + % ----------------------------------------- + for chan = 1:size(data,1) + fprintf('Channel %d (trials out of %d):', chan, size(data,3)); + for trial = 1:size(data,3) + if ~mod(trial, 10) , fprintf('%d ', trial); end + if ~mod(trial, 200), fprintf('\n', trial); end + [factors(chan, trial) tmpf exitflag] = fminbnd('erpregoutfunc', 0, 10, [], ... + data(chan, begpoint:endpoint, trial), erp(chan, begpoint:endpoint)); + data(chan,:,trial) = data(chan,:,trial) - factors(chan, trial)*erp(chan, :); + end + fprintf('\n'); + end + + if redim + data = squeeze(data); + end diff --git a/functions/miscfunc/erpregoutfunc.m b/functions/miscfunc/erpregoutfunc.m index b9e7b5003..243b86a9d 100755 --- a/functions/miscfunc/erpregoutfunc.m +++ b/functions/miscfunc/erpregoutfunc.m @@ -1,38 +1,49 @@ -% erpregoutfunc() - sub function of erpregout() used to regress -% out the ERP from the data -% -% Usage: -% totdiff = erpregout(fact, data, erp); -% -% Inputs: -% fact - factor -% data - [float] 1-D data (time points). -% erp - [float] 1-D data (time points). -% -% Outputs: -% totdif - residual difference -% -% Author: Arnaud Delorme, Salk, SCCN, UCSD, CA, April 29, 2004 - -%123456789012345678901234567890123456789012345678901234567890123456789012 - -% Copyright (C) 2004 Arnaud Delorme -% -% 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 - -function totdiff = erpregoutfunc(fact, data, erp); - - totdiff = mean(abs(data - fact*erp)); - \ No newline at end of file +% ERPREGOUTFUNC - sub function of ERPREGOUT used to regress +% out the ERP from the data +% +% Usage: +% totdiff = erpregout(fact, data, erp); +% +% Inputs: +% fact - factor +% data - [float] 1-D data (time points). +% erp - [float] 1-D data (time points). +% +% Outputs: +% totdif - residual difference +% +% Author: Arnaud Delorme, Salk, SCCN, UCSD, CA, April 29, 2004 + +%123456789012345678901234567890123456789012345678901234567890123456789012 + +% Copyright (C) 2004 Arnaud Delorme +% +% This file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. + +function totdiff = erpregoutfunc(fact, data, erp); + + totdiff = mean(abs(data - fact*erp)); + diff --git a/functions/miscfunc/eucl.m b/functions/miscfunc/eucl.m index 748a8d40b..ca011d46f 100644 --- a/functions/miscfunc/eucl.m +++ b/functions/miscfunc/eucl.m @@ -1,3 +1,4 @@ +function dists = eucl(crds1,crds2) % EUCL: Calculates the euclidean distances among a set of points, or between a % reference point and a set of points, or among all possible pairs of two % sets of points, in P dimensions. Returns a single distance for two points. @@ -31,15 +32,14 @@ % 6/12/98 - allow for P=1. % 11/11/03 - initialize dists to NaN for error return. -function dists = eucl(crds1,crds2) - if nargin == 0, help eucl; return; end; + if nargin == 0, help eucl; return; end dists = NaN; if (nargin < 2) % If only crds1 provided, [N,P] = size(crds1); if (N<2) error(' EUCL: need at least two points'); - end; + end crds1 = crds1'; % Transpose crds dists = zeros(N,N); % Calculate pairwise distances @@ -50,13 +50,13 @@ d = sqrt(sum((c1-crds1(:,(i+1:N))).^2)); else d = abs(c1-crds1(:,(i+1:N))); - end; + end dists(i,(i+1:N)) = d; dists((i+1:N),i) = d'; - end; + end if (N==2) % Single distance for two points dists = dists(1,2); - end; + end else % If crds1 & crds2 provided, [N1,P1] = size(crds1); @@ -65,12 +65,12 @@ error(' EUCL: sets of coordinates must be of same dimension'); else P = P1; - end; + end crds1 = crds1'; % Transpose crds crds2 = crds2'; - if (N1>1 & N2>1) % If two matrices provided, + if (N1>1 && N2>1) % If two matrices provided, dists = zeros(N1,N2); % Calc all pairwise distances between them for i = 1:N1 c1 = crds1(:,i) * ones(1,N2); @@ -78,33 +78,33 @@ d = sqrt(sum((c1-crds2).^2)); else d = abs(c1-crds2); - end; + end dists(i,:) = d; - end; - end; + end + end - if (N1==1 & N2==1) % If two vectors provided, + if (N1==1 && N2==1) % If two vectors provided, dists = sqrt(sum((crds1-crds2).^2)); % Calc scalar - end; + end - if (N1>1 & N2==1) % If matrix & reference point provided, + if (N1>1 && N2==1) % If matrix && reference point provided, crds1 = crds1 - (ones(N1,1)*crds2')'; % Center points on reference point if (P>1) % Calc euclidean distances in P-space dists = sqrt(sum(crds1.^2))'; else dists = abs(crds1)'; - end; + end end; % Return column vector - if (N1==1 & N2>1) % If reference point & matrix provided, + if (N1==1 && N2>1) % If reference point && matrix provided, crds2 = crds2 - (ones(N2,1)*crds1')'; % Center points on reference point if (P>1) % Calc euclidean distances in P-space dists = sqrt(sum(crds2.^2)); else dists = abs(crds2); - end; + end end; % Return row vector - end; + end return; diff --git a/functions/miscfunc/fastregress.m b/functions/miscfunc/fastregress.m index 71090e113..290daf313 100644 --- a/functions/miscfunc/fastregress.m +++ b/functions/miscfunc/fastregress.m @@ -1,26 +1,62 @@ % fastregress - perform fast regression and return p-value % % Usage: -% [ypred, alpha, rsq, B] = myregress(x, y, plotflag); +% [ypred, alpha, rsq, slope, intercept] = fastregress(x, y); +% [ypred, alpha, rsq, slope, intercept] = fastregress(x, y, plotflag, plotleg); % % Inputs % y - y values % x - x values -% plotflag - [0|1] plot regression +% plotflag - [0|1] plot regression and legend. Default 0. +% plotleg - [0|1] plot legend. Default same as plotflag. % % Outputs % ypred - y prediction % alpha - significance level % R^2 - r square % slope - slope of the fit +% intercept - intercept of the fit % % Arnaud Delorme, 25 Feb 2003 -function [ypred, alpha, rsq, B] = fastregress(x, y, ploting); +% Copyright (C) Arnaud Delorme, 25 Feb 2003 +% +% This file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. + +function [ypred, alpha, rsq, B, intercept, h] = fastregress(x, y, plotflag, plotleg) if nargin < 1 help fastregress; return; - end; + end + if nargin < 3 + plotflag = false; + end + if nargin < 4 + plotleg = plotflag; + end % this part is useless but still works %B=polyfit(x, y, 1); % B is the slope @@ -41,12 +77,15 @@ ypred = x*B(2) + B(1); % B(1) contain the offset, B(2) the slope + intercept = B(1); B = B(2); - if nargin > 2 + if plotflag hold on; - [ynew tmp] = sort(ypred); - xnew = x(tmp); - plot(xnew, ynew, 'r'); + [ynew, tmp] = sort(ypred); + xnew = x(tmp); + h = plot(xnew, ynew, 'r'); + end + if plotleg legend(sprintf('R^2=%f', rsq), sprintf('p =%f', alpha)); - end; \ No newline at end of file + end diff --git a/functions/miscfunc/fieldtrip2eeglab.m b/functions/miscfunc/fieldtrip2eeglab.m index 77c1acb99..270cd25bf 100644 --- a/functions/miscfunc/fieldtrip2eeglab.m +++ b/functions/miscfunc/fieldtrip2eeglab.m @@ -1,52 +1,140 @@ -% load data file ('dataf') preprocessed with fieldtrip -% and show in eeglab viewer -% -% This function is provided as is. It only works for some specific type of -% data. This is a simple function to help the developer and by no mean -% an all purpose function. - -function [EEG] = fieldtrip2eeglab(dataf) - -[ALLEEG EEG CURRENTSET ALLCOM] = eeglab; - -if exist(dataf,'file') - load(dataf) -end - -% load chanlocs.mat -% EEG.chanlocs = chanlocs; -EEG.chanlocs = []; - -for i=1:size(data.trial,2) - EEG.data(:,:,i) = single(data.trial{i}); -end - -EEG.setname = dataf; %data.cfg.dataset; -EEG.filename = ''; -EEG.filepath = ''; -EEG.subject = ''; -EEG.group = ''; -EEG.condition = ''; -EEG.session = []; -EEG.comments = 'preprocessed with fieldtrip'; -EEG.nbchan = size(data.trial{1},1); -EEG.trials = size(data.trial,2); -EEG.pnts = size(data.trial{1},2); -EEG.srate = data.fsample; -EEG.xmin = data.time{1}(1); -EEG.xmax = data.time{1}(end); -EEG.times = data.time{1}; -EEG.ref = []; %'common'; -EEG.event = []; -EEG.epoch = []; -EEG.icawinv = []; -EEG.icasphere = []; -EEG.icaweights = []; -EEG.icaact = []; -EEG.saved = 'no'; - -[ALLEEG EEG CURRENTSET] = eeg_store(ALLEEG, EEG); -eeglab redraw -pop_eegplot( EEG, 1, 1, 1); - - \ No newline at end of file +% fieldtrip2eeglab - convert Fieldtrip structures to EEGLAB dataset +% +% EEG = fieldtrip2eeglab(header, rawdata, evt); +% EEG = fieldtrip2eeglab(data); +% +% Inputs: +% header - Fieldtrip data header +% rawdata - Fieldtrip raw data +% evt - Fieldtrip event structure (optional) +% data - Fieldtrip data out of ft_preprocessing. Note that this uses +% a legacy conversion method. It is better to use +% fieldtrip2eeglab(data.hdr, data.trial) to use the default +% FileIO API. +% +% Output: +% EEG - EEGLAB structure +% +% Author: Arnaud Delorme, UCSD + +% Copyright (C) Arnaud Delorme, UCSD 2018 +% +% This file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. + +function EEG = fieldtrip2eeglab(header,data,evt) + +if nargin < 3 + evt = []; +end + +if nargin >= 2 + EEG = pop_fileio(header, data, evt); +else + fprintf(2, 'fieldtrip2eeglab: Use 2-input argument, header and data to use the fileio API to convert Fieldtrip data\n') + + if isfield(header, 'hdr') + % use the hdr field in the data + hdr = header.hdr; + if isfield(header, 'label') + hdr.label = header.label; + end + else + % create a minimal header + hdr.nChans = numel(header.label); + hdr.nSamplesPre = 0; % FIXME perhaps better to make it nan?; And what about nSamplesPst? + if iscell(header.trial) + hdr.nTrials = numel(header.trial); + hdr.nSamples = numel(header.time{1}); % variable length trials will be caught below + if isfield(header, 'fsample') + hdr.Fs = header.fsample; + else + hdr.Fs = 1./mean(diff(header.time{1})); + end + else + hdr.nTrials = size(header.trial,1); + hdr.nSamples = numel(header.time); + if isfield(header, 'fsample') + hdr.Fs = header.fsample; + else + hdr.Fs = 1./mean(diff(header.time)); + end + end + + end + + EEG = pop_fileio(hdr, header); + if iscell(EEG.data) && length(EEG.data) == 1 + EEG.data = EEG.data{1}; + EEG.times = header.time{1}; + elseif iscell(EEG.data) + len = cellfun(@(x)size(x,2), EEG.data); + unLen = unique(len); + if length(unLen) > 1 + if length(unLen) > 2 || diff(unLen) > 1 + error('Epochs of different length, conversion is not possible'); + else + fprintf(2, 'Epochs of different length, but small difference in sample\n'); + fprintf(2, 'Assuming outlier due to fractional sample limits and selecting the most common epoch length\n'); + e1 = sum(len == unLen(1)); + e2 = sum(len == unLen(2)); + if min(e1, e2) > 5 + error('Too many epochs to remove, check data'); + end + if e1 > e2 + fprintf(2, 'Truncating %d epochs\n', e2); + epochsToTruncate = find(len == unLen(2)); + truncateLen = unLen(1); + else + fprintf(2, 'Truncating %d epochs\n', e1); + epochsToTruncate = find(length == unLen(1)); + truncateLen = unLen(2); + end + for iEpoch = 1:length(epochsToTruncate) + EEG.data{epochsToTruncate(iEpoch)} = EEG.data{epochsToTruncate(iEpoch)}(:,1:end-1); + end + end + end + % EEG.data = [ EEG.data{:} ]; + EEG.data = cat(3, EEG.data{:}); + EEG.pnts = len(1); + else + % error('Unknown fieldtrip data format'); + % the trial field was a 3D matrix + EEG.data = permute(EEG.data, [2 3 1]); + + % overrule the previously created metadata + [EEG.nbchan, EEG.pnts, EEG.trials] = size(EEG.data); + end + if iscell(header.time) % assuming uniformity of trials + EEG.xmin = header.time{1}(1); + EEG.xmax = header.time{1}(end); + else + EEG.xmin = header.time(1); + EEG.xmax = header.time(end); + end + EEG.trials = size(EEG.data,3); + EEG = eeg_checkset(EEG); +end diff --git a/functions/miscfunc/fillcurves.m b/functions/miscfunc/fillcurves.m index c7fa2d07b..8a82a5ca9 100644 --- a/functions/miscfunc/fillcurves.m +++ b/functions/miscfunc/fillcurves.m @@ -1,4 +1,4 @@ -% fillcurves() - fill the space between 2 curves +% FILLCURVES - fill the space between 2 curves % % Usage: % h=fillcurves( Y1, Y2); @@ -13,40 +13,51 @@ % Copyright (C) Arnaud Delorme, arno@salk.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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. function h = fillcurves(X, Y1, Y2, color, transparent, legends) if nargin < 2 help fillcurves; return; - end; + end if nargin < 3 Y2 = Y1; Y1 = X; X = [1:length(Y1)]; - end; + end if nargin < 4 || isempty(color) color = { 'r' 'b' 'g' 'c' }; elseif ~iscell(color) color = { color }; - end; + end if nargin < 5 transparent = 0.5; - end; + end X1 = X(:)'; X2 = X(:)'; @@ -62,7 +73,7 @@ tmp2 = find(~Y2); Y1(tmp1) = []; X1(tmp1) = []; Y2(tmp2) = []; X2(tmp2) = []; - end; + end % multiple curve plot % ------------------- @@ -70,11 +81,11 @@ for index = 1:size(Y1,2) fillcurves(X, Y1(:,index)', Y2(:,index)', color{index}, transparent); hold on; - end; - yl = ylim; - xl = xlim; - line([xl(1) xl(1)]+(xl(2)-xl(1))/2000, yl, 'color', 'k'); - line(xl, [yl(1) yl(1)]+(yl(2)-yl(1))/2000, 'color', 'k'); + end +% yl = ylim; +% xl = xlim; +% line([xl(1) xl(1)]+(xl(2)-xl(1))/2000, yl, 'color', 'k'); +% line(xl, [yl(1) yl(1)]+(yl(2)-yl(1))/2000, 'color', 'k'); % write legend and add transparency to it % --------------------------------------- @@ -86,11 +97,11 @@ if isfield(fields, 'FaceAlpha'); numfaces = size(get(hh(index), 'Vertices'),1); set(hh(index), 'FaceVertexCData', repmat([1 1 1], [numfaces 1]), 'Cdatamapping', 'direct', 'facealpha', transparent, 'edgecolor', 'none'); - end; - end; - end; + end + end + end return; - end; + end % plot % ---- @@ -102,14 +113,14 @@ if transparent numfaces = size(get(h, 'Vertices'),1); set(h, 'FaceVertexCData', repmat([1 1 1], [numfaces 1]), 'Cdatamapping', 'direct', 'facealpha', transparent, 'edgecolor', 'none'); - end; + end % replot lines at boundaries % -------------------------- - parent = dbstack; - if length(parent) == 1 || ~strcmpi(parent(2).name, 'fillcurves') - yl = ylim; - xl = xlim; - line([xl(1) xl(1)]+(xl(2)-xl(1))/2000, yl, 'color', 'k'); - line(xl, [yl(1) yl(1)]+(yl(2)-yl(1))/2000, 'color', 'k'); - end; +% parent = dbstack; +% if length(parent) == 1 || ~strcmpi(parent(2).name, 'fillcurves') +% yl = ylim; +% xl = xlim; +% line([xl(1) xl(1)]+(xl(2)-xl(1))/2000, yl, 'color', 'k'); +% line(xl, [yl(1) yl(1)]+(yl(2)-yl(1))/2000, 'color', 'k'); +% end diff --git a/functions/miscfunc/findduplicatefunctions.m b/functions/miscfunc/findduplicatefunctions.m index 840fb65d2..f3de52e9b 100644 --- a/functions/miscfunc/findduplicatefunctions.m +++ b/functions/miscfunc/findduplicatefunctions.m @@ -1,8 +1,35 @@ -% find potential conflict between Matlab functions +% script to find potential conflict between Matlab functions in the current +% path % % A. Delorme, May 25th, 2012 -matlabRoot = fileparts(fileparts(fileparts(fileparts(which('ispc'))))); +% Copyright (C) A. Delorme, May 25th, 2012 +% +% This file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. + folders = path; delim = find(folders == ':'); delim = [ 0 delim length(folders)+1 ]; @@ -12,7 +39,7 @@ folderContent = dir(currentFolder); - if isempty(findstr(matlabRoot, currentFolder)) + if ~contains( currentFolder, matlabroot) rmpath(currentFolder); folderContent = { folderContent.name }; @@ -23,15 +50,23 @@ if length(currentFile) > 2 && strcmpi(currentFile(end-1:end), '.m') if ~strcmpi(currentFile, 'Contents.m') - if ~isempty(which(currentFile)) + tmp = which(currentFile); + + if ~isempty(tmp) fullFileName1 = fullfile(currentFolder, currentFile); fullFileName2 = which(currentFile); + % cond1 = contains(fullFileName1, 'toolbox/matlab') || contains(fullFileName1, 'toolbox\matlab'); + cond1 = contains(fullFileName1, matlabroot); + if cond1 + sadffdas + end + % if ~cond1 fprintf('Potential conflict between %s and %s\n', fullFileName1, fullFileName2); - end; - end; - end; - end; + end + end + end + end addpath(currentFolder); - end; -end; \ No newline at end of file + end +end diff --git a/functions/miscfunc/formatsvnrevision.m b/functions/miscfunc/formatsvnrevision.m deleted file mode 100644 index 613e5c6d5..000000000 --- a/functions/miscfunc/formatsvnrevision.m +++ /dev/null @@ -1,44 +0,0 @@ -function formatsvnrevision(v1, v2) - -disp('Getting revision information...'); -system(sprintf('svn log --verbose -r%d:%d > tmprev.txt', v1, v2)); - -oldpwd = pwd; -newpwd = fileparts(which('eeglab.m')); -cd(newpwd); - -fid = fopen('tmprev.txt', 'r'); - -state = 1; -while ~feof(fid) - txt = fgetl(fid); - if length(txt) > 4 && strcmpi(txt(1:4), '----') - state = 1; - if feof(fid), return; end; - end; - if state == 1, - % get rev number - txt = fgetl(fid); - rev = strtok(txt); - revnum = rev(2:end); - - % get function name - txt = fgetl(fid); - txt = fgetl(fid); - [tmp file] = strtok(txt); - file = deblank(file); - [tmp file ext] = fileparts(file); - file = [ file ext ]; - state = 2; - end; - if isempty(txt) - state = 3; - end; - if state == 3 - revinfo = fgetl(fid); - revinfo = revinfo(1:end); - state = 1; - fprintf('** %s, %s (SVN %s - Arno)\n', file, revinfo, revnum); - end; -end; -cd(oldpwd); diff --git a/functions/miscfunc/gabor2d.m b/functions/miscfunc/gabor2d.m index 3436ea6f5..87027aad7 100644 --- a/functions/miscfunc/gabor2d.m +++ b/functions/miscfunc/gabor2d.m @@ -1,4 +1,4 @@ -% gabor2d() - generate a two-dimensional gabor matrice. +% GABOR2D - generate a two-dimensional gabor matrice. % % Usage: % >> [ matrix ] = gabor2d(rows, columns); @@ -22,26 +22,37 @@ % 0 and 90 being the phase offset of the real and imaginary parts % cut - percentage (0->1) of maximum value below which to remove values % from the matrix {default: 0} -% Ouput: +% Output: % matrix - output gabor matrix % % Author: Arnaud Delorme, CNL / Salk Institute, 2001 % Copyright (C) 2001 Arnaud Delorme, Salk Institute, arno@salk.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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. function mat = gabor2d( sizeX, sizeY, freq, angle, sigmaX, sigmaY, meanX, ... meanY, dephase, cut); @@ -49,31 +60,31 @@ if nargin < 2 help gabor2d return; -end; +end if nargin < 3 freq = 360/sizeX; -end; +end if nargin < 4 angle = 0; -end; +end if nargin < 5 sigmaX = sizeX/5; -end; +end if nargin < 6 sigmaY = sizeY/5; -end; +end if nargin < 7 meanX = (sizeX+1)/2; -end; +end if nargin < 8 meanY = (sizeY+1)/2; -end; +end if nargin < 9 dephase = 0; -end; +end if nargin < 10 cut = 0; -end; +end freq = freq/180*pi; X = linspace(1, sizeX, sizeX)'* ones(1,sizeY); @@ -87,10 +98,10 @@ /((sigmaX*sigmaY)^(0.5)*pi); if cut > 0 - maximun = max(max(mat))*cut; - I = find(mat < maximun); + maximum = max(max(mat))*cut; + I = find(mat < maximum); mat(I) = 0; -end; +end return; @@ -103,7 +114,7 @@ .*exp(-0.5*( ((X-meanX)/sigmaX).*((X-meanX)/sigmaX)... +((Y-meanY)/sigmaY).*((Y-meanY)/sigmaY)))... /((sigmaX*sigmaY)^(0.5)*pi); - end; -end; + end +end return; diff --git a/functions/miscfunc/gauss.m b/functions/miscfunc/gauss.m index 00d1e2637..cf826979f 100644 --- a/functions/miscfunc/gauss.m +++ b/functions/miscfunc/gauss.m @@ -1,4 +1,5 @@ -% gauss() - return a smooth Gaussian window +function outvec = gauss(frames,sds) +% GAUSS - return a smooth Gaussian window % % Usage: % >> outvector = gauss(frames,sds); @@ -8,14 +9,12 @@ % sds = number of +/-std. deviations = steepness % (~0+ -> flat; >>10 -> spike) -function outvec = gauss(frames,sds) - outvec = []; if nargin < 2 help gauss return end -if sds <=0 | frames < 1 +if sds <=0 || frames < 1 help gauss return end diff --git a/functions/miscfunc/gauss2d.m b/functions/miscfunc/gauss2d.m index 7ddcca1ae..c7677d3e0 100644 --- a/functions/miscfunc/gauss2d.m +++ b/functions/miscfunc/gauss2d.m @@ -1,4 +1,4 @@ -% gauss2d() - generate a 2-dimensional gaussian matrix +% GAUSS2D - generate a 2-dimensional gaussian matrix % % Usage: % >> [ gaussmatrix ] = gauss2d( rows, columns, ... @@ -16,48 +16,59 @@ % peakC - location of the peak in each column (default: columns/2) % mask - (0->1) portion of the matrix to mask with zeros (default: 0) % -% Ouput: +% Output: % gaussmatrix - 2-D gaussian matrix % % Author: Arnaud Delorme, CNL/Salk Institute, 2001 % Copyright (C) 2001 Arnaud Delorme, Salk Institute, arno@salk.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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. function mat = gauss2d( sizeX, sizeY, sigmaX, sigmaY, meanX, meanY, cut); if nargin < 2 help gauss2d return; -end; +end if nargin < 3 sigmaX = sizeX/5; -end; +end if nargin < 4 sigmaY = sizeY/5; -end; +end if nargin < 5 meanX = (sizeX+1)/2; -end; +end if nargin < 6 meanY = (sizeY+1)/2; -end; +end if nargin < 7 cut = 0; -end; +end X = linspace(1, sizeX, sizeX)'* ones(1,sizeY); Y = ones(1,sizeX)' * linspace(1, sizeY, sizeY); @@ -69,10 +80,10 @@ /((sigmaX*sigmaY)^(0.5)*pi); if cut > 0 - maximun = max(max(mat))*cut; - I = find(mat < maximun); + maximum = max(max(mat))*cut; + I = find(mat < maximum); mat(I) = 0; -end; +end return; diff --git a/functions/miscfunc/gauss3d.m b/functions/miscfunc/gauss3d.m index c29744985..b1866dfbc 100644 --- a/functions/miscfunc/gauss3d.m +++ b/functions/miscfunc/gauss3d.m @@ -1,4 +1,4 @@ -% gauss3d() - generate a 3-dimensional gaussian matrix +% GAUSS3D - generate a 3-dimensional gaussian matrix % % Usage: % >> [ gaussmatrix ] = gauss2d( nX, nY, nZ); @@ -22,54 +22,65 @@ % mask - (0->1) percentage of low values in the matrix to mask % with zeros (default: 0 or none) % -% Ouput: +% Output: % gaussmatrix - 3-D gaussian matrix % % Author: Arnaud Delorme, 2009 % Copyright (C) 2009 Arnaud Delorme, Salk Institute, arno@salk.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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. function mat = gauss3d( sizeX, sizeY, sizeZ, sigmaX, sigmaY, sigmaZ, meanX, meanY, meanZ, cut); if nargin < 2 help gauss2d return; -end; +end if nargin < 4 sigmaX = sizeX/5; -end; +end if nargin < 5 sigmaY = sizeY/5; -end; +end if nargin < 6 sigmaZ = sizeZ/5; -end; +end if nargin < 7 meanX = (sizeX+1)/2; -end; +end if nargin < 8 meanY = (sizeY+1)/2; -end; +end if nargin < 9 meanZ = (sizeZ+1)/2; -end; +end if nargin < 10 cut = 0; -end; +end [X,Y,Z] = ndgrid(1:sizeX,1:sizeY,1:sizeZ); @@ -79,10 +90,10 @@ /((sigmaX*sigmaY*sigmaZ)^(0.5)*pi); if cut > 0 - maximun = max(mat(:))*cut; - I = find(mat < maximun); + maximum = max(mat(:))*cut; + I = find(mat < maximum); mat(I) = 0; -end; +end return; diff --git a/functions/miscfunc/getallmenus.m b/functions/miscfunc/getallmenus.m index d5f2331f0..bb8345feb 100644 --- a/functions/miscfunc/getallmenus.m +++ b/functions/miscfunc/getallmenus.m @@ -1,4 +1,4 @@ -% getallmenus() - get all submenus of a window or a menu and return +% GETALLMENUS - get all submenus of a window or a menu and return % a tree. % % Usage: @@ -15,19 +15,30 @@ % Copyright (C) 2001 Arnaud Delorme, Salk Institute, arno@salk.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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. function [txt, nb, labels] = getallmenus( handler, level ) @@ -36,10 +47,10 @@ if nargin < 1 help getallmenus; return; - end; + end if nargin < 2 level = 0; - end; + end txt = ''; nb = 0; @@ -53,12 +64,12 @@ txt = [ txtmp txt ]; labels = { tmplab labels{:} }; nb = nb+nbtmp; - end; - end; + end + end try txt = [ get(handler, 'Label') 10 txt ]; nb = nb+1; - catch, end; + catch, end if isempty(labels) labels = { nb }; end; @@ -72,9 +83,9 @@ lines = find( txt == 10 ); for index = 1:length(lines)-1 tmptext = txt(lines(index)+1:lines(index+1)-1); - if maxlength < length( tmptext ), maxlength = length( tmptext ); end; + if maxlength < length( tmptext ), maxlength = length( tmptext ); end newtext(index, 1:length(tmptext)) = tmptext; - end; + end txt = char( newtext(1:index+1, 1:maxlength) ); end; return; diff --git a/functions/miscfunc/getallmenuseeglab.m b/functions/miscfunc/getallmenuseeglab.m index 2c82587e6..7ae099643 100644 --- a/functions/miscfunc/getallmenuseeglab.m +++ b/functions/miscfunc/getallmenuseeglab.m @@ -1,4 +1,4 @@ -% getallmenuseeglab() - get all submenus of a window or a menu and return +% GETALLMENUSEEGLAB - get all submenus of a window or a menu and return % a tree. The function will also look for callback. % % Usage: @@ -15,19 +15,30 @@ % Copyright (C) 2001 Arnaud Delorme, Salk Institute, arno@salk.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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. function [txt, nb, labels] = getallmenuseeglab( handler, level ) @@ -36,10 +47,10 @@ if nargin < 1 help getallmenuseeglab; return; - end; + end if nargin < 2 level = 0; - end; + end txt = ''; nb = 0; @@ -53,8 +64,8 @@ txt = [ txtmp txt ]; labels = { tmplab labels{:} }; nb = nb+nbtmp; - end; - end; + end + end try lab = get(handler, 'Label'); cb = get(handler, 'Callback'); @@ -62,11 +73,11 @@ if ~isempty(cb) newtxt = [ lab ' - ' cb '']; else newtxt = [ lab ]; - end; + end txt = [ newtxt 10 txt ]; %txt = [ get(handler, 'Label') 10 txt ]; nb = nb+1; - catch, end; + catch, end if isempty(labels) labels = { nb }; end; @@ -76,7 +87,7 @@ fclose(fid); disp(' '); disp('Results saved in tmpfile.m'); - end; + end % transform into array of text % ---------------------------- @@ -87,9 +98,9 @@ lines = find( txt == 10 ); for index = 1:length(lines)-1 tmptext = txt(lines(index)+1:lines(index+1)-1); - if maxlength < length( tmptext ), maxlength = length( tmptext ); end; + if maxlength < length( tmptext ), maxlength = length( tmptext ); end newtext(index, 1:length(tmptext)) = tmptext; - end; + end txt = char( newtext(1:index+1, 1:maxlength) ); end; @@ -103,19 +114,19 @@ if ~isempty(indList), if strcmpi(cbin(indList(1):indList(1)+length('pop_stdwarn')-1), 'pop_stdwarn') indList = findstr(funcList{iList}, cbin(indList(1)+1:end))+indList(1); - end; + end break; - end; -end; + end +end if ~isempty(indList) indEndList = find( cbin(indList(1):end) == '(' ); if isempty(indEndList) || indEndList(1) > 25 indEndList = find( cbin(indList(1):end) == ';' ); if cbin(indList(1)+indEndList(1)-2) == ')' indEndList = indEndList-2; - end; - end; + end + end cbout = cbin(indList(1):indList(1)+indEndList(1)-2); else cbout = ''; -end; +end diff --git a/functions/miscfunc/getipsph.m b/functions/miscfunc/getipsph.m index 2a6b0812c..70d54d9d1 100644 --- a/functions/miscfunc/getipsph.m +++ b/functions/miscfunc/getipsph.m @@ -1,4 +1,4 @@ -% getipsph() - Compute "in place" (m by n) sphering or quasi-sphering matrix for an (n by t) +% GETIPSPH - Compute "in place" (m by n) sphering or quasi-sphering matrix for an (n by t) % input data matrix. Quasi-sphering reduces dimensionality of the data, while % maintaining approximately the "original" positions of the axes. That is, % quasi-sphering "rotates back" as much as possible into the original channel @@ -31,19 +31,30 @@ % Copyright (C) Jason Palmer, SCCN / INC / UCSD , La Jolla 2008 % -% 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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. function S = getipsph(x,m) diff --git a/functions/miscfunc/getmfilelist.m b/functions/miscfunc/getmfilelist.m new file mode 100644 index 000000000..588e8e2b1 --- /dev/null +++ b/functions/miscfunc/getmfilelist.m @@ -0,0 +1,56 @@ +% recursively get the list of Matlab file in +% a given directory +% +% A. Delorme, 2017 + +% Copyright (C) A. Delorme, 2017 +% +% This file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. + +function fileList = getmfilelist(folder) + +fileList = {}; +if nargin < 1 + folder = pwd; +end + +allFiles = dir(folder); + +for iFile = 1:length(allFiles) + + if ~isequal(allFiles(iFile).name, '..') && ~isequal(allFiles(iFile).name, '.') + + if exist(fullfile(folder, allFiles(iFile).name), 'dir') + fileList2 = getmfilelist(fullfile(folder, allFiles(iFile).name)); + fileList = [ fileList fileList2 ]; + elseif isequal(allFiles(iFile).name(end-1:end), '.m') + fileList{end+1} = fullfile(folder, allFiles(iFile).name); + end + + end +end + + diff --git a/functions/miscfunc/gradmap.m b/functions/miscfunc/gradmap.m index a291ee970..5bb1e25f7 100644 --- a/functions/miscfunc/gradmap.m +++ b/functions/miscfunc/gradmap.m @@ -1,4 +1,4 @@ -% gradmap() - compute the gradient of an EEG spatial distribution. +% GRADMAP - compute the gradient of an EEG spatial distribution. % % Usage: % >> [gradX, gradY ] = gradmap( map, filename, draw ) @@ -22,26 +22,37 @@ % Copyright (C) 2001 Arnaud Delorme, Salk Institute, arno@salk.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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. function [gradx, grady] = gradmap( map, filename, draw ) if nargin < 2 help gradmap; return; -end; +end MAXCHANS = size(map,1); GRID_SCALE = 2*MAXCHANS+5; @@ -68,7 +79,7 @@ for i=1:MAXCHANS [useless_var horizidx(i)] = min(abs(y(i) - xi)); % find pointers to electrode [useless_var vertidx(i)] = min(abs(x(i) - yi)); % positions in Zi -end; +end draw = 1; @@ -91,8 +102,8 @@ quiver(imresize(FX, 0.5), imresize(FY, 0.5)); hold off else disp('Warning: cannot plot because imresize function is missing (image processing toolbox)'); - end; - end; + end + end end; return; diff --git a/functions/miscfunc/gradplot.m b/functions/miscfunc/gradplot.m index 70a7b17fa..bf77e9d22 100644 --- a/functions/miscfunc/gradplot.m +++ b/functions/miscfunc/gradplot.m @@ -1,4 +1,4 @@ -% gradplot() - Compute the gradient of EEG scalp map(s) on a square grid +% GRADPLOT - Compute the gradient of EEG scalp map(s) on a square grid % % Usage: % >> [gradX, gradY] = gradplot(maps,eloc_file,draw) @@ -12,27 +12,38 @@ % gradX - Gradients in X direction % gradY - Gradients in Y directions % -% Note: Use cart2pol() to convert to polar (amp, direction) coordinates). +% Note: Use CART2POL to convert to polar (amp, direction) coordinates). % % Authors: Marissa Westerfield & Arnaud Delorme, CNL/Salk Institute, La Jolla 3/10/01 % -% See also: topoplot(), lapplot() +% See also: TOPOPLOT, LAPPLOT % Copyright (C) 3/10/01 Marissa Westerfield & Arnaud Delorme, CNL/Salk Institute, La Jolla % -% 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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. % 01-25-02 reformated help & license, added links -ad @@ -41,7 +52,7 @@ if nargin < 2 help gradplot; return; -end; +end NCHANS = size(map,1); GRID_SCALE = 2*NCHANS+5; @@ -50,7 +61,7 @@ % -------------------------------- % Read the electrode location file % -------------------------------- -if isstr(locs_file) % a locs file +if ischar(locs_file) % a locs file [tmpeloc labels Th Rd ind] = readlocs(locs_file,'filetype', ... 'loc'); [x,y] = pol2cart(Th/180*pi,Rd); % See Bug 149 @@ -86,7 +97,7 @@ for c=1:NCHANS [useless_var horizidx(c)] = min(abs(y(c) - xi)); % find pointers to electrode [useless_var vertidx(c)] = min(abs(x(c) - yi)); % positions in Zi -end; +end % ------------------- % Compute gradient(s) @@ -160,7 +171,7 @@ axis off - end; -end; + end +end return; diff --git a/functions/miscfunc/headmovie.m b/functions/miscfunc/headmovie.m index 85d1e9e19..d57a36473 100644 --- a/functions/miscfunc/headmovie.m +++ b/functions/miscfunc/headmovie.m @@ -1,7 +1,7 @@ % ########## This function is deprecated. Use eegmovie instead. ########## % -% headmovie() - Record a Matlab movie of scalp data. -% Use seemovie() to display the movie. +% HEADMOVIE - Record a Matlab movie of scalp data. +% Use SEEMOVIE to display the movie. % % Usage: >> [Movie,Colormap] = headmovie(data,elec_loc,spline_file); % >> [Movie,Colormap,minc,maxc] = headmovie(data,elec_loc,spline_file,... @@ -9,7 +9,7 @@ % Inputs: % data = (chans,frames) EEG data set to plot % elec_loc = electrode locations file for eegplot {default 'chan.loc'} -% spline_file = headplot() produced spline 'filename' {default 'chan.spline'} +% spline_file = HEADPLOT produced spline 'filename' {default 'chan.spline'} % srate = sampling rate in Hz {default|0 -> 256 Hz} % title = 'plot title' {default|0 -> none} % camerapath = [az_start az_step el_start el_step] {default [-127 0 30 0]} @@ -22,27 +22,38 @@ % {default|0 -> +/-abs max of data} % startsec = starting time in seconds {default|0 -> 0.0} % -% Note: BUG IN MATLAB 5.0-5.1 -- CANT SHOW MOVIES IN CORRECT COLORS +% Note: BUG IN MATLAB 5.0-5.1 -- CAN'T SHOW MOVIES IN CORRECT COLORS % % Authors: Scott Makeig & Colin Humphries, SCCN/INC/UCSD, La Jolla, 2/1998 % -% See also: seemovie(), eegmovie(), headplot() +% See also: SEEMOVIE, EEGMOVIE, HEADPLOT % Copyright (C) 2.6.98 Scott Makeig & Colin Humphries, 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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. % 01-25-02 reformated help & license, added links -ad @@ -64,7 +75,7 @@ if nargin<8 minmax = 0; end -if size(minmax)==[1 1] & minmax ~= 0 +if size(minmax)==[1 1] && minmax ~= 0 minmax = [-minmax minmax]; end if minmax ==0, @@ -102,7 +113,7 @@ eloc_file = 0; end -if movieframes(1) < 1 | movieframes(length(movieframes))>frames +if movieframes(1) < 1 || movieframes(length(movieframes))>frames fprintf('headmovie(): specified movieframes not in data!\n'); return end @@ -130,7 +141,7 @@ help headmovie return end -if size(camerapath,1) > 1 & size(camerapath,2)~=4 +if size(camerapath,1) > 1 && size(camerapath,2)~=4 help headmovie return end @@ -150,7 +161,7 @@ figure(gcf); % bring figure to front clf % clear figure -%%%%%%%%%%%%%%%%%%%%% eegplot() of data %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%% EEGPLOT of data %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% axeegplot = axes('Units','Normalized','Position',[.75 .05 .2 .9]); if isstruct(eloc_file) diff --git a/functions/miscfunc/help2html2.m b/functions/miscfunc/help2html2.m index a7e469e8c..bffe3370c 100644 --- a/functions/miscfunc/help2html2.m +++ b/functions/miscfunc/help2html2.m @@ -1,4 +1,4 @@ -% help2html() - Convert a Matlab m-file help-message header into an .html help file +% HELP2HTML - Convert a Matlab m-file help-message header into an .html help file % % Usage: % >> linktext = help2html( filein, fileout, 'key1', val1, 'key2', val2 ...); @@ -34,7 +34,7 @@ % to allow .html help file generation. Characters '-' and ':' are used % explicitly by the function for parsing. % -%% function_name() - description line 1 +%% FUNCTION_NAME - description line 1 %% description line 2 %% etc. %% @@ -50,7 +50,7 @@ %% text line 2 %% %% See also: -%% function1(), function2() +%% FUNCTION1, FUNCTION2 % % Author: Arnaud Delorme, Salk Institute 2001 % @@ -61,7 +61,7 @@ % each descriptor (i.e., single_word followed by '-' or '=' % or multiple quoted words followed by a '-' or '=') % are concatenated. -% 2) The pattern 'function()' is detected and is printed in bold +% 2) The pattern 'FUNCTION' is detected and is printed in bold % if it is the first function descriptor. Otherwise, % it is used as a web link to the .html function file % 'function.html' if this exists. @@ -75,33 +75,44 @@ % Copyright (C) 2001 Arnaud Delorme, Salk Institute, arno@salk.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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. function [linktext,allvars,alltext] = help2html( filename, htmlfile, varargin) if nargin < 1 help help2html; return; -end; +end if nargin <3 g = []; else g = struct( varargin{:});; end; -try, g.font; catch, g.font = 'Helvetica'; end; +try, g.font; catch, g.font = 'Helvetica'; end g.functionname = [ '%s' ]; g.description = [ '%s' ]; @@ -116,8 +127,8 @@ g.doublecol = ' '; g.seefile = [ 'See the matlab file %s (may require other functions)
' ]; -try, g.outputonly; catch, g.outputonly = 'off'; end; -try, g.background; catch, g.background = ''; end; +try, g.outputonly; catch, g.outputonly = 'off'; end +try, g.background; catch, g.background = ''; end try, g.header; catch, g.header = ''; end; try, g.footer; catch, g.footer = ''; end; try, g.refcall; catch, g.refcall = '%s.html'; end; @@ -132,29 +143,29 @@ % output file % ----------- -if nargin < 2 | isempty(htmlfile); +if nargin < 2 || isempty(htmlfile); indexdot = findstr( filename, '.'); - if isempty(indexdot), indexdot = length(filename)+1; end; + if isempty(indexdot), indexdot = length(filename)+1; end htmlfile = [ filename(1:indexdot(end)-1) '.html' ]; else indexdot = findstr( filename, '.'); -end; +end % open files % ---------- fid = fopen( filename, 'r'); if fid == -1 error('Input file not found'); -end; +end if ~strcmp(g.outputonly, 'on') fo = fopen(htmlfile, 'w'); if fo == -1 error('Cannot open output file'); - end; + end % write header % ------------ fprintf(fo, '%s\n%s\n
' g.seefile '%s'], lower(filename), filename, g.footer); fclose( fid ); fclose( fo ); @@ -366,52 +377,52 @@ strout = [strout ' ' tokout ]; end; [tok1 strrm] = strtok( strrm ); - end; + end return; -% final formating +% final formatting function str = finalformat(str); % bold text in bracket if just in the beginning tmploc = sort(union(find(str == '['), find(str == ']'))); - if ~isempty(tmploc) & str(1) == '[' - if mod(length(tmploc),2) ~= 0, str, error('Opening but no closing bracket'); end; + if ~isempty(tmploc) && str(1) == '[' + if mod(length(tmploc),2) ~= 0, str, error('Opening but no closing bracket'); end tmploc = tmploc(1:2); str = [ str(1:tmploc(1)) '' str(tmploc(1)+1:tmploc(2)-1) '' str(tmploc(2):end) ]; - end; + end %tmploc = find(str == '"'); %if ~isempty(tmploc) - % if mod(length(tmploc),2) ~= 0, str, error('Opening but no closing parenthesis'); end; + % if mod(length(tmploc),2) ~= 0, str, error('Opening but no closing parenthesis'); end % for index = length(tmploc):-2:1 % str = [ str(1:tmploc(index-1)-1) '' str(tmploc(index-1)+1:tmploc(index)-1) '' str(tmploc(index)+1:end) ]; - % end; - %end; + % end + %end function tokout = functionformat( tokin, refcall ); tokout = tokin; % default [test, realtokin, tail, beg] = testfunc1( tokin ); - if ~test, [test, realtokin, tail] = testfunc2( tokin ); end; + if ~test, [test, realtokin, tail] = testfunc2( tokin ); end if test i1 = findstr( refcall, '%s'); i2 = findstr( refcall(i1(1):end), ''''); - if isempty(i2) i2 = length( refcall(i1(1):end) )+1; end; + if isempty(i2) i2 = length( refcall(i1(1):end) )+1; end filename = [ realtokin refcall(i1+2:i1+i2-2)]; % concatenate filename and extension %disp(filename) if exist( filename ) % do not make link if the file does not exist tokout = sprintf( [ beg '%s' tail ' ' ], realtokin, realtokin ); - end; + end end; return; function [test, realtokin, tail, beg] = testfunc1( tokin ) % test if is string is 'function()[,]' test = 0; realtokin = ''; tail = ''; beg = ''; if ~isempty( findstr( tokin, '()' ) ) - if length(tokin)<3, return; end; + if length(tokin)<3, return; end realtokin = tokin( 1:findstr( tokin, '()' )-1); - if length(realtokin) < (length(tokin)-2) tail = tokin(end); else tail = []; end; + if length(realtokin) < (length(tokin)-2) tail = tokin(end); else tail = []; end test = 1; - if realtokin(1) == '(', realtokin = realtokin(2:end); beg = '('; end; - if realtokin(1) == ',', realtokin = realtokin(2:end); beg = ','; end; - end; + if realtokin(1) == '(', realtokin = realtokin(2:end); beg = '('; end + if realtokin(1) == ',', realtokin = realtokin(2:end); beg = ','; end + end return; function [test, realtokin, tail] = testfunc2( tokin ) % test if is string is 'FUNCTION[,]' @@ -422,15 +433,15 @@ tail = ','; else realtokin = tokin; - end; + end testokin = realtokin; testokin(findstr(testokin, '_')) = 'A'; testokin(findstr(testokin, '2')) = 'A'; - if all(double(testokin) > 64) & all(double(testokin) < 91) + if all(double(testokin) > 64) && all(double(testokin) < 91) test = 1; end; realtokin = lower(realtokin); - end; + end return; function [tok, str] = mystrtok(str) @@ -439,8 +450,8 @@ if tok(1) == '"' while tok(end) ~= '"' [tok2 str] = strtok(str); - if isempty(tok2), tok, error('can not find closing quote ''"'' in previous text'); end; + if isempty(tok2), tok, error('can not find closing quote ''"'' in previous text'); end tok = [tok ' ' tok2]; - end; - end; + end + end diff --git a/functions/miscfunc/helpforexe.m b/functions/miscfunc/helpforexe.m index 06df583ad..097d82526 100644 --- a/functions/miscfunc/helpforexe.m +++ b/functions/miscfunc/helpforexe.m @@ -1,4 +1,4 @@ -% helpforexe() - Write help files for exe version +% HELPFOREXE - Write help files for exe version % % Usage: % histtoexe( mfile, folder) @@ -12,30 +12,41 @@ % % Author: Arnaud Delorme, 2006 % -% See also: eeglab() +% See also: EEGLAB % Copyright (C) 2006 Arnaud Delorme % -% 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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. function helpforexe( funct, fold ); if nargin <1 help histforexe; return; -end; +end nonmatlab = 0; % write all files @@ -47,11 +58,11 @@ for ind2 = 1:length(doc1) if isempty(doc1{ind2}) fprintf(fid, [ 'disp('' '');\n' ]); else fprintf(fid, [ 'disp(' vararg2str({ doc1{ind2} }) ');\n' ]); - end; - end; + end + end fclose(fid); %fprintf(fid, 'for tmpind = 1:length(tmptxt), if isempty(tmptxt{tmpind}), disp('' ''); else disp(tmptxt{tmpind}); end; end; clear tmpind tmptxt;\n' ); -end; +end % try all functions % ----------------- @@ -59,7 +70,7 @@ cd(fold); for index = 1:length(funct) evalc([ 'help_' funct{index}(1:end-2) ]); -end; +end cd(tmppath); return; @@ -74,17 +85,17 @@ fid = fopen( funct, 'r'); else fid = fopen( [funct '.m'], 'r'); - end; -end; + end +end if fid == -1 error('File not found'); -end; +end sub = 1; try, - if ~isunix, sub = 0; end; -catch, end; + if ~isunix, sub = 0; end +catch, end if nonmatlab str = fgets( fid ); @@ -92,13 +103,13 @@ str = deblank(str(1:end-sub)); doc = { doc{:} str(1:end) }; str = fgets( fid ); - end; + end else str = fgets( fid ); while (str(1) == '%') str = deblank(str(1:end-sub)); doc = { doc{:} str(2:end) }; str = fgets( fid ); - end; -end; + end +end fclose(fid); diff --git a/functions/miscfunc/hist2.m b/functions/miscfunc/hist2.m index 7d97c7320..da6d61140 100644 --- a/functions/miscfunc/hist2.m +++ b/functions/miscfunc/hist2.m @@ -1,4 +1,4 @@ -% hist2() - draw superimposed histograms +% HIST2 - draw superimposed histograms % % Usage: % >> hist2(data1, data2, bins); @@ -14,19 +14,30 @@ % Copyright (C) 2003 Arnaud Delorme, Salk Institute, arno@salk.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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. % draw superimposed histograms @@ -36,12 +47,12 @@ if nargin < 1 help hist2; return; -end; +end if nargin < 3 bins = linspace(min(min(data1), min(data2)), max(max(data1), max(data2)), 100); elseif length(bins) == 1 bins = linspace(min(min(data1), min(data2)), max(max(data1), max(data2)), bins); -end; +end hist(data1, bins); hold on; hist(data2, bins); diff --git a/functions/miscfunc/hungarian.m b/functions/miscfunc/hungarian.m index 5713ff467..a35ab1131 100644 --- a/functions/miscfunc/hungarian.m +++ b/functions/miscfunc/hungarian.m @@ -1,4 +1,5 @@ -% hungarian() - Solve the assignment problem using the Hungarian method. +function [C,T]=hungarian(A) +% HUNGARIAN - Solve the assignment problem using the Hungarian method. % % Usage: >> [C,T]=hungarian(A) % @@ -14,15 +15,13 @@ % Mathematical Software, 6(1):104-111, 1980. % % v1.0 96-06-14. Niclas Borlin, niclas@cs.umu.se. -% Department of Computing Science, Umeå University, +% Department of Computing Science, Ume University, % Sweden. % % NOTE: A substantial effort was put into this code. If you use it for a % publication or otherwise, please include an acknowledgement and notify % me by email. /Niclas -function [C,T]=hungarian(A) - [m,n]=size(A); if (m~=n) @@ -65,7 +64,7 @@ % If there are more free zeros in row r and row r in not % yet marked as unexplored.. - if (A(r,l)~=0 & RH(r)==0) + if (A(r,l)~=0 && RH(r)==0) % Insert row r first in unexplored list. RH(r)=RH(n+1); RH(n+1)=r; @@ -200,7 +199,7 @@ [n,np1]=size(A); -% Initalize return vectors. +% Initialize return vectors. C=zeros(1,n); U=zeros(1,n+1); diff --git a/functions/miscfunc/icademo.m b/functions/miscfunc/icademo.m index ed102ebab..47ff7cd72 100644 --- a/functions/miscfunc/icademo.m +++ b/functions/miscfunc/icademo.m @@ -1,4 +1,4 @@ -% icademo() - a sample ICA analysis script using the ICA/ERP package +% ICADEMO - a sample ICA analysis script using the ICA/ERP package % of Matlab functions distributed via % http://www.sccn.ucsd.edu/eeglab % @@ -8,37 +8,48 @@ % % Author: Scott Makeig, SCCN/INC/UCSD, La Jolla, 5-18-97 % -% See also: runica(), icavar(), icaproj(), icaact() +% See also: RUNICA, ICAVAR, ICAPROJ, ICAACT % 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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. % This version tested on package version -% Added envproj(), used maxmap in compplot() 6-18-97 -sm +% 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 +% 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 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-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) @@ -72,7 +83,7 @@ p = which('eeglab'); p = p(1:findstr(p,'eeglab.m')-1); addpath([ p 'sample_data' ] ); -end; +end % name of channel locations file chan_locs = 'pnas_chan14.locs'; @@ -99,7 +110,7 @@ if ~exist('icademoauto') fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%% -end; +end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Load an ascii ERP data matrix @@ -129,7 +140,7 @@ if ~exist('icademoauto') fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%% -end; +end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % @@ -147,7 +158,7 @@ if ~exist('icademoauto') fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%% -end; +end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % @@ -163,7 +174,7 @@ if ~exist('icademoauto') fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%% -end; +end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % @@ -178,7 +189,7 @@ if ~exist('icademoauto') fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%% -end; +end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % @@ -197,7 +208,7 @@ if ~exist('icademoauto') fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%% -end; +end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % @@ -219,7 +230,7 @@ if ~exist('icademoauto') fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%% -end; +end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % @@ -235,7 +246,7 @@ if ~exist('icademoauto') fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%% -end; +end [weights,sphere,activations,bias,signs,lrates] = runica(data); @@ -243,7 +254,7 @@ if ~exist('icademoauto') fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%% -end; +end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % @@ -274,11 +285,11 @@ if ~exist('icademoauto') fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%% -end; +end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Plot the activation waveforms of all the components -% as reordered by compsort() +% as reordered by COMPSORT % Identify the components using the original component numbers. % fprintf('Plotting the component activation waveforms using plotdata()') @@ -291,7 +302,7 @@ if ~exist('icademoauto') fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%% -end; +end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Plot the contributions to the first epoch of data by the first reordered @@ -308,7 +319,7 @@ if ~exist('icademoauto') fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%% -end; +end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Plot the contributions to the first epoch of data by the 5 largest @@ -326,7 +337,7 @@ if ~exist('icademoauto') fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%% -end; +end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Plot the envelopes of the data epoch 1 and the first 10 components @@ -343,7 +354,7 @@ if ~exist('icademoauto') fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%% -end; +end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % fprintf('Now plotting envelopes PLUS scalp maps using envtopo().\n'); @@ -357,7 +368,7 @@ if ~exist('icademoauto') fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%% -end; +end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Plot a close-up of the decomposition of epoch 2, channel 2. @@ -378,7 +389,7 @@ if ~exist('icademoauto') fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%% -end; +end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Plot the scalp maps of the first four reordered components @@ -393,7 +404,7 @@ if ~exist('icademoauto') fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%% -end; +end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Display the projected epoch-1 data for reordered ICA component windex(7) @@ -412,7 +423,7 @@ if ~exist('icademoauto') fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%% -end; +end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Make and display a brief movie of a small segment of the first data epoch @@ -431,11 +442,11 @@ seemovie(Movie,-5,Colormap); catch, disp('Problem generating movie'); -end; +end if ~exist('icademoauto') fprintf('\n****> Hit any key to continue: '); pause; fprintf('\n\n'); %%% -end; +end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Run testica script using optimum parameters @@ -454,7 +465,7 @@ testica(chans,epochs*frames,14,-0.05,1.4); else [testresult] = testica(chans,epochs*frames,14,-0.05,1.4); -end; +end % model 14 sources with a wide range of sizes & positive kurtosis diff --git a/functions/miscfunc/imagescloglog.m b/functions/miscfunc/imagescloglog.m index 5d09fa8e3..f10255f49 100644 --- a/functions/miscfunc/imagescloglog.m +++ b/functions/miscfunc/imagescloglog.m @@ -1,4 +1,4 @@ -% imagescloglog() - make an imagesc(0) plot with log y-axis and +% IMAGESCLOGLOG - make an imagesc(0) plot with log y-axis and % x-axis values % % Usage: >> imagescloglog(times,freqs,data); @@ -19,19 +19,30 @@ % Copyright (C) 4/2003 Arnaud Delorme, 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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. function imagescloglog(times,freqs,data,clim, xticks, yticks, varargin) @@ -77,16 +88,16 @@ function imagescloglog(times,freqs,data,clim, xticks, yticks, varargin) border = mean(newfreqs(2:end)-newfreqs(1:end-1))/2; % automatically added to the borders in imagesc newfreqs = linspace(realborders(1)+border, realborders(2)-border, length(freqs)); - if nargin == 4 & ~isempty(clim) + if nargin == 4 && ~isempty(clim) imagesc(newtimes,newfreqs,data,clim); else imagesc(newtimes,newfreqs,data); - end; + end set(gca, 'yscale', 'log', 'xscale', 'log'); - try colormap(DEFAULT_COLORMAP); catch, end; + try colormap(DEFAULT_COLORMAP); catch, end - % puting ticks + % putting ticks % ------------ if nargin >= 5 divs = xticks; @@ -94,7 +105,7 @@ function imagescloglog(times,freqs,data,clim, xticks, yticks, varargin) divs = linspace(log(times(1)), log(times(end)), 10); divs = ceil(exp(divs)); divs = unique_bc(divs); % ceil is critical here, round might misalign % out-of border label with within border ticks - end; + end set(gca, 'xtickmode', 'manual'); set(gca, 'xtick', divs); if nargin >= 6 @@ -103,7 +114,7 @@ function imagescloglog(times,freqs,data,clim, xticks, yticks, varargin) divs = linspace(log(freqs(1)), log(freqs(end)), 10); divs = ceil(exp(divs)); divs = unique_bc(divs); % ceil is critical here, round might misalign % out-of border label with within border ticks - end; + end set(gca, 'ytickmode', 'manual'); set(gca, 'ytick', divs); @@ -112,5 +123,5 @@ function imagescloglog(times,freqs,data,clim, xticks, yticks, varargin) set(gca, 'yminortick', 'off', 'xaxislocation', 'bottom', 'box', 'off', 'ticklength', [0.03 0], 'tickdir','out', 'color', 'none'); if ~isempty(varargin) set(gca, varargin{:}); - end; + end diff --git a/functions/miscfunc/imagesclogy.m b/functions/miscfunc/imagesclogy.m index 8ce9015b3..742db311a 100644 --- a/functions/miscfunc/imagesclogy.m +++ b/functions/miscfunc/imagesclogy.m @@ -1,4 +1,4 @@ -% imagesclogy() - make an imagesc(0) plot with log y-axis values (ala semilogy()) +% IMAGESCLOGY - make an imagesc(0) plot with log y-axis values (ala SEMILOGY) % % Usage: >> imagesclogy(times,freqs,data); % Usage: >> imagesclogy(times,freqs,data,clim,xticks,yticks,'key','val',...); @@ -18,19 +18,30 @@ % Copyright (C) 4/2003 Arnaud Delorme, 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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. function imagesclogy(times,freqs,data,clim, xticks, yticks, varargin) @@ -63,23 +74,23 @@ function imagesclogy(times,freqs,data,clim, xticks, yticks, varargin) border = mean(newfreqs(2:end)-newfreqs(1:end-1))/2; % automatically added to the borders in imagesc newfreqs = linspace(realborders(1)+border, realborders(2)-border, length(freqs)); - if nargin == 4 & ~isempty(clim) + if nargin == 4 && ~isempty(clim) imagesc(times,newfreqs,data,clim); else imagesc(times,newfreqs,data); - end; + end set(gca, 'yscale', 'log'); - % puting ticks + % putting ticks % ------------ - if nargin >= 5, set(gca, 'xtick', xticks); end; + if nargin >= 5, set(gca, 'xtick', xticks); end if nargin >= 6 divs = yticks; else divs = linspace(log(freqs(1)), log(freqs(end)), 10); divs = ceil(exp(divs)); divs = unique_bc(divs); % ceil is critical here, round might misalign % out-of border label with within border ticks - end; + end set(gca, 'ytickmode', 'manual'); set(gca, 'ytick', divs); @@ -88,5 +99,5 @@ function imagesclogy(times,freqs,data,clim, xticks, yticks, varargin) set(gca, 'yminortick', 'off', 'xaxislocation', 'bottom', 'box', 'off', 'ticklength', [0.03 0], 'tickdir','out', 'color', 'none'); if ~isempty(varargin) set(gca, varargin{:}); - end; + end diff --git a/functions/miscfunc/iscellnumeric.m b/functions/miscfunc/iscellnumeric.m deleted file mode 100644 index 724cb7959..000000000 --- a/functions/miscfunc/iscellnumeric.m +++ /dev/null @@ -1,6 +0,0 @@ -function b = iscellnumeric(C) -% Return 1 if all elements of cell array are numeric -% -% Tim Mullen, 2011, SCCN/INC, UCSD - -b = all(cellfun(@(x) isnumeric(x),C)); diff --git a/functions/miscfunc/kmeans_st.m b/functions/miscfunc/kmeans_st.m index bc51ef4dc..71190c77f 100644 --- a/functions/miscfunc/kmeans_st.m +++ b/functions/miscfunc/kmeans_st.m @@ -1,3 +1,4 @@ +function [centr,clst,sse] = kmeans_st(X,k,restarts) % KMEANS: K-means clustering of n points into k clusters so that the % within-cluster sum of squares is minimized. Based on Algorithm % AS136, which seeks a local optimum such that no movement of a @@ -26,20 +27,19 @@ % RE Strauss, 8/26/98 % 8/21/99 - changed misc statements for Matlab v5. -% 10/14/00 - use means() rather than mean() to update cluster centers; +% 10/14/00 - use MEANS rather than MEAN to update cluster centers; % remove references to TRUE and FALSE. -function [centr,clst,sse] = kmeans_st(X,k,restarts) - if (nargin<3) restarts = []; end; + if (nargin<3) restarts = []; end if (isempty(restarts)) restarts = 0; - end; + end [n,p] = size(X); - if (k<1 | k>n) + if (k<1 || k>n) error('KMEANS: k out of range 1-N'); - end; + end max_iter = 50; highval = 10e8; @@ -74,7 +74,7 @@ grp(indx) = t3 * ones(length(indx),1); indx = find(grp==t2); grp(indx) = t3 * ones(length(indx),1); - end; + end grpid = uniquef(grp); % Unique group identifiers centr = zeros(k,p); @@ -86,13 +86,13 @@ centr(kk,:) = mean(Xk); else centr(kk,:) = Xk; - end; - end; + end + end else % Else if randomized, rndprm = randperm(n); % Pull out random set of points centr = X(rndprm(1:k),:); - end; + end % For each point i, find its two closest centers, c1(i) and c2(i), and % assign it to c1(i) @@ -100,7 +100,7 @@ dist = zeros(n,k); for kk = 1:k % Dists to centers of all clusters dist(:,kk) = eucl(X,centr(kk,:)); - end; + end [d,indx] = sort(dist'); % Sort points separately c1 = indx(1,:)'; @@ -115,10 +115,10 @@ % centr(kk,:) = mean(X(indx,:)); % else % centr(kk,:) = X(indx,:); -% end; +% end centr(kk,:) = means(X(indx,:)); nclst(kk) = len_indx; - end; + end % Initialize working matrices @@ -131,7 +131,7 @@ for i = 1:n % Adjusted dist from each pt to own cluster center R1(i) = adj2(c1(i)) * eucl(X(i,:),centr(c1(i),:))^2; - end; + end % Iterate @@ -157,7 +157,7 @@ indx = find(~live); % find min R2 over live clusters only R2([L1;indx]) = highval * ones(length(indx)+1,1); [r2min,L2] = min(R2); - end; + end if (r2min >= R1(i)) % No reallocation necessary c2(i) = L2; @@ -172,9 +172,9 @@ centr(kk,:) = mean(X(indx,:)); else centr(kk,:) = X(indx,:); - end; + end nclst(kk) = len_indx; - end; + end adj1([L1,L2]) = nclst([L1,L2]) ./ (nclst([L1,L2])+1); adj2([L1,L2]) = nclst([L1,L2]) ./ (nclst([L1,L2])-1+eps); @@ -182,13 +182,13 @@ live([L1,L2]) = [1,1]; % Put into live set update([L1,L2]) = [n,n]; % Reinitialize update counters - end; + end end; % if nclst(L1)>1 indx = find(update<1); % Remove clusters from live set if (~isempty(indx)) % that haven't been recently updated live(indx) = zeros(length(indx),1); - end; + end end; % while (i0) clst = best_c1; diff --git a/functions/miscfunc/laplac2d.m b/functions/miscfunc/laplac2d.m index 43417bde1..a1749e3a6 100644 --- a/functions/miscfunc/laplac2d.m +++ b/functions/miscfunc/laplac2d.m @@ -1,4 +1,4 @@ -% laplac2d() - generate a 2 dimensional gaussian matrice +% LAPLAC2D - generate a 2 dimensional laplacian matrice % % Usage : % >> [ gaussmatrix ] = laplac2d( rows, columns, sigma, ... @@ -10,7 +10,7 @@ % Inputs: % rows - number of rows % columns - number of columns -% sigma - standart deviation (default: rows/5) +% sigma - standard deviation (default: rows/5) % meanR - mean for rows (default: center of the row) % meanC - mean for columns (default: center of the column) % cut - percentage (0->1) of the maximum value for removing @@ -20,44 +20,55 @@ % research. For a more rigorous validated approach use the freely % available Current Source Density Matlab toolbox. % -% See also: eeg_laplac() +% See also: EEG_LAPLAC % % Author: Arnaud Delorme, CNL, Salk Institute, 2001 % Copyright (C) 2001 Arnaud Delorme, Salk Institute, arno@salk.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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. function mat = laplac2d( sizeX, sizeY, sigma, meanX, meanY, cut); if nargin < 2 help laplac2d return; -end; +end if nargin < 3 sigma = sizeX/5; -end; +end if nargin < 4 meanX = (sizeX+1)/2; -end; +end if nargin < 5 meanY = (sizeY+1)/2; -end; +end if nargin < 6 cut = 0; -end; +end X = linspace(1, sizeX, sizeX)'* ones(1,sizeY); Y = ones(1,sizeX)' * linspace(1, sizeY, sizeY); @@ -71,9 +82,9 @@ % zeros crossing at r = -/+ sigma; % mat = r2; if cut > 0 - maximun = max(max(mat))*cut; - I = find(mat < maximun); + maximum = max(max(mat))*cut; + I = find(mat < maximum); mat(I) = 0; -end; +end return; diff --git a/functions/miscfunc/lapplot.m b/functions/miscfunc/lapplot.m index fb98d27d4..42056eb68 100644 --- a/functions/miscfunc/lapplot.m +++ b/functions/miscfunc/lapplot.m @@ -1,4 +1,4 @@ -% lapplot() - Compute the discrete laplacian of EEG scalp distribution(s) +% LAPPLOT - Compute the discrete laplacian of EEG scalp distribution(s) % % Usage: % >> laplace = lapplot(map,eloc_file,draw) @@ -12,27 +12,38 @@ % Output: % laplace - Laplacian map, size (nelectrodes,nmaps) % -% Note: uses del2() +% Note: uses DEL2 % % Author: Scott Makeig, SCCN/INC/UCSD, La Jolla, 1998 % -% See also: topoplot(), gradplot() +% See also: TOPOPLOT, GRADPLOT % Copyright (C) Scott Makeig, SCCN/INC/UCSD, La Jolla, 1998 % -% 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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. % 01-25-02 reformated help & license, added links -ad @@ -41,7 +52,7 @@ if nargin < 2 help lapplot; return; -end; +end MAXCHANS = size(map,1); GRID_SCALE = 2*MAXCHANS+5; @@ -50,7 +61,7 @@ % --------------------- % Read the channel file % --------------------- -if isstr( filename ) +if ischar( filename ) fid = fopen(filename); locations = fscanf(fid,'%d %f %f %s',[7 MAXCHANS]); fclose(fid); @@ -74,7 +85,7 @@ for i=1:MAXCHANS [useless_var horizidx(i)] = min(abs(y(i) - xi)); % find pointers to electrode [useless_var vertidx(i)] = min(abs(x(i) - yi)); % positions in Zi -end; +end % ----------------- % Compute laplacian @@ -131,7 +142,7 @@ hold off axis off - end; + end end; return; diff --git a/functions/miscfunc/loadelec.m b/functions/miscfunc/loadelec.m index eb802287d..59143cd9d 100644 --- a/functions/miscfunc/loadelec.m +++ b/functions/miscfunc/loadelec.m @@ -1,26 +1,37 @@ -% loadelec() - Load electrode names file for eegplot() +% LOADELEC - Load electrode names file for EEGPLOT % % Usage: >> labelmatrix = loadelec('elec_file'); % % Author: Colin Humprhies, CNL / Salk Institute, 1996 % -% See also: eegplot() +% See also: EEGPLOT % Copyright (C) Colin Humphries, CNL / Salk Institute, Aug, 1996 % -% 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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. % 01-25-02 reformated help & license, added links -ad @@ -34,7 +45,7 @@ % Read the channel names %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -if channamefile ~= 0 & channamefile ~= '0' % read file of channel names +if channamefile ~= 0 && channamefile ~= '0' % read file of channel names chid = fopen(channamefile,'r'); if chid <3, fprintf('cannot open file %s.\n',channamefile); @@ -42,7 +53,7 @@ channamefile = 0; else fprintf('Channamefile %s opened\n',channamefile); - end; + end if errorcode==0, channames = fscanf(chid,'%s',[6 MAXCHANS]); channames = channames'; @@ -51,20 +62,20 @@ for j=1:c if channames(i,j)=='.', channames(i,j)=' '; - end; - end; - end; + end + end + end % fprintf('%d channel names read from file.\n',r); if (r>chans) fprintf('Using first %d names.\n',chans); channames = channames(1:chans,:); - end; + end if (r length(chanlocs) error('Total channels in requested subsets larger than number of EEG channels.'); -end; +end if min(numberOfChannelsInSubset) < 2 error('Number of channels in the requested subsets must be >= 2.'); -end; +end rand('state',0); if nargin < 5 mandatoryChannelsForSet = {}; -end; +end if nargin < 4 plotSubsets = false; -end; +end if nargin < 3 plotOptimization = false; -end; +end pos=[cell2mat({chanlocs.X}); cell2mat({chanlocs.Y}); cell2mat({chanlocs.Z});]; dist = squareform(pdist(pos')); @@ -95,7 +106,7 @@ idx = ones(nChans,1); setId = cell(1, length(numberOfChannelsInSubset)); % cell array containing channels in each set -remainingChannels = 1:nChans; % channles that are to be assigned to subsets +remainingChannels = 1:nChans; % channels that are to be assigned to subsets % channels that have to stay in their original subset (as in % mandatoryChannelsForSet) and should not be re-assigned @@ -105,7 +116,7 @@ for i=1:length(mandatoryChannelsForSet) setId{i} = mandatoryChannelsForSet{i}; remainingChannels(mandatoryChannelsForSet{i}) = NaN; % flag with Nan so they can be deleted later, this is to keep indexing simple -end; +end remainingChannels(isnan(remainingChannels)) = []; r = remainingChannels(randperm(length(remainingChannels))); @@ -115,11 +126,11 @@ numberOfChannelsTobeAddedToSubset = numberOfChannelsInSubset(i) - length(setId{i}) setId{i} = [setId{i} r(1:numberOfChannelsTobeAddedToSubset)]; r(1:numberOfChannelsTobeAddedToSubset) = []; -end; +end if length(r) > 0 setId{length(numberOfChannelsInSubset) + 1} = r; % last set gets remaining channels -end; +end if plotOptimization|plotSubsets fprintf(['Creating total of ' num2str(length(setId)) ' channel subsets:\n']); @@ -129,7 +140,7 @@ figure; xp = floor(sqrt(length(setId))); yp = ceil(length(setId)/xp); -end; +end counter = 1; exchangeHappened = true; @@ -142,14 +153,14 @@ for j = 1:length(setId{set2}) chan(1) = setId{set1}(i); chan(2) = setId{set2}(j); - if cost_of_exchanging_channels(chan,[set1 set2], setId, dist) < 0 & ~ismember(chan, allMandatoryChannels) + if cost_of_exchanging_channels(chan,[set1 set2], setId, dist) < 0 && ~any(ismember(chan, allMandatoryChannels)) setId{set1}(find(setId{set1} == chan(1))) = chan(2); setId{set2}(find(setId{set2} == chan(2))) = chan(1); sumDistances(counter) = 0; for s = 1:length(setId) sumDistances(counter) = sumDistances(counter) ... + (sum(sum(dist(setId{s},setId{s}))) / length(setId{s})); - end; + end if plotOptimization plot(1:counter,sumDistances,'-b'); xlabel('number of exchanges'); @@ -159,21 +170,21 @@ if mod(counter, 20) ==0 fprintf('number of exchanges = %d\nsum of mean distances = %g\n',... counter, sumDistances(counter)); - end; + end end counter = counter + 1; exchangeHappened = true; - end; - end; - end; - end; - end; -end; + end + end + end + end + end +end for set = 1:length(setId) idx(setId{set}) = set; % legendTitle{set} = ['subset ' num2str(set)]; -end; +end subset = setId; @@ -186,9 +197,9 @@ %legend(legendTitle); it does not work propr th=title('Channel Subsets'); %set(th,'fontsize',14) -end; +end -if length(r)>0 & (plotOptimization|plotSubsets) +if length(r)>0 && (plotOptimization|plotSubsets) fprintf('The last subset returned contains the %d unused channels.\n',... length(r)); end @@ -201,14 +212,14 @@ for i=1:2 newSetId{betweenSets(i)} = setId{betweenSets(i)}; newSetId{betweenSets(i)}(find(newSetId{betweenSets(i)} == chan(i))) = chan(mirrorChan(i)); -end; +end cost = 0; for i=betweenSets distSumBefore{i} = sum(sum(dist(setId{i},setId{i}))); distSumAfter{i} = sum(sum(dist(newSetId{i},newSetId{i}))); cost = cost + (distSumBefore{i} - distSumAfter{i}) / length(setId{i}); -end; +end %cost = (distSumAfter{1} > distSumBefore{1}) && (distSumAfter{2} > distSumBefore{2}); diff --git a/functions/miscfunc/logimagesc.m b/functions/miscfunc/logimagesc.m index 0f5f37053..00aca02a1 100644 --- a/functions/miscfunc/logimagesc.m +++ b/functions/miscfunc/logimagesc.m @@ -1,4 +1,4 @@ -% logimagesc() - make an imagesc(0) plot with log y-axis values (ala semilogy()) +% LOGIMAGESC - make an imagesc(0) plot with log y-axis values (ala SEMILOGY) % % Usage: >> [logfreqs,dataout] = logimagesc(times,freqs,data); % @@ -10,25 +10,36 @@ % Optional Input: % plot = ['on'|'off'] plot image or return output (default 'on'). % -% Note: Entering text() onto the image requires specifying (x,log(y)). +% Note: Entering text onto the image requires specifying (x,log(y)). % Author: Scott Makeig, SCCN/INC/UCSD, La Jolla, 4/2000 % Copyright (C) 4/2000 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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. % 08-07-00 made ydir normal -sm % 01-25-02 reformated help & license -ad @@ -38,7 +49,7 @@ if nargin < 1 help logimagesc; return - end; + end if size(data,1) ~= length(freqs) fprintf('logfreq(): data matrix must have %d rows!\n',length(freqs)); datout = data; @@ -78,7 +89,7 @@ if strcmp(plot, 'on') imagesc(times,freqs,data); - try colormap(DEFAULT_COLORMAP); catch, end; + try colormap(DEFAULT_COLORMAP); catch, end nt = ceil(min(freqs)); % new tick - round up min y to int ht = floor(max(freqs)); % high freq - round down diff --git a/functions/miscfunc/loglike.m b/functions/miscfunc/loglike.m index db4d0af94..3e606065f 100644 --- a/functions/miscfunc/loglike.m +++ b/functions/miscfunc/loglike.m @@ -1,4 +1,5 @@ -% loglike() - log likehood function to estimate dependence between components +function f=loglike(W, S) +% LOGLIKE - log likehood function to estimate dependence between components % % Usage: f = loglike(W, S); % @@ -18,8 +19,6 @@ % % Author: Arnaud Delorme and Jorn Anemuller -function f=loglike(W, S); - W = double(W); S = double(S); % normalize activities @@ -30,7 +29,7 @@ M = size(W,1); if ndims(S) == 3 S = reshape(S, size(S,1), size(S,3)*size(S,2)); - end; + end N = size(S,2); % detect infinite and remove them diff --git a/functions/miscfunc/logspec.m b/functions/miscfunc/logspec.m index 2d98c8b40..091a1dc40 100644 --- a/functions/miscfunc/logspec.m +++ b/functions/miscfunc/logspec.m @@ -1,5 +1,5 @@ -% logspec() - plot mean log power spectra of submitted data on loglog scale -% using plotdata() or plottopo() formats +% LOGSPEC - plot mean log power spectra of submitted data on loglog scale +% using PLOTDATA or PLOTTOPO formats % % Usage: % >> [spectra,freqs] = logspec(data,frames,srate); @@ -12,31 +12,42 @@ % 'title' = plot title {default: none} % [loHz-hiHz] = [loHz hiHz] plotting limits % {default: [srate/fftlength srate/2]} -% 'chan_locs' = channel location file (ala topoplot()) +% 'chan_locs' = channel location file (ala TOPOPLOT) % Else [rows cols] to plot data in a grid array % rm_mean = [0/1] 1 -> remove log mean spectrum from all % % Author: Scott Makeig, SCCN/INC/UCSD, La Jolla, 11-07-97 % -% See also: plotdata(), plottopo() +% See also: PLOTDATA, PLOTTOPO % Copyright (C) 11-07-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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 - -% Changed plotdata() below to plottopo() 11/12/99 -sm +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. + +% Changed PLOTDATA below to PLOTTOPO 11/12/99 -sm % Mentioned new grid array option 12/22/99 -sm % 01-25-02 reformated help & license, added links -ad @@ -99,9 +110,9 @@ end for e=1:epochs - for r=1:rows, - [Pxx,freqs] = psd(data(r,(e-1)*frames+1:e*frames),fftlength,srate,... - fftlength,fftlength/4); + for r=1:rows + [Pxx,freqs] = pwelch(data(r,(e-1)*frames+1:e*frames),fftlength,... + fftlength/4,fftlength,srate); spectra(r,(e-1)*f2+1:e*f2) = Pxx(2:f2+1)'; % omit DC bin end end diff --git a/functions/miscfunc/make_timewarp.m b/functions/miscfunc/make_timewarp.m index ac2b9516b..b8b6df409 100644 --- a/functions/miscfunc/make_timewarp.m +++ b/functions/miscfunc/make_timewarp.m @@ -1,6 +1,6 @@ -% make_timewarp() - Select a subset of epochs containing a given event sequence, and return +% MAKE_TIMEWARP - Select a subset of epochs containing a given event sequence, and return % a matrix of latencies for time warping the selected epochs to a common -% timebase in newtimef(). Events in the given sequence may be further +% timebase in NEWTIMEF. Events in the given sequence may be further % restricted to those with specified event field values. % Usage: % >> timeWarp = make_timewarp(EEG, eventSequence, 'key1',value1, @@ -32,11 +32,11 @@ % from the mean in the selected epochs. {default: Inf -> no removal} % Outputs: % timeWarp - a structure with latencies (time-warp matrix with fields -% timeWarp.latencies - an (N, M) timewarp matrix for use in newtimef() +% timeWarp.latencies - an (N, M) timewarp matrix for use in NEWTIMEF % where N = number of selected epochs containing the specified sequence, % M = number of events in specified event sequence. % timeWarp.epochs - a (1, M) vector giving the index of epochs with the -% specified sequence. Only these epochs should be passed to newtimef(). +% specified sequence. Only these epochs should be passed to NEWTIMEF. % timeWarp.eventSequence - same as the 'eventSequence' input variable. % Example: % % Create a timewarp matrix for a sequence of events, first an event of type 'movement Onset' followed by @@ -52,7 +52,34 @@ % 'eventConditions', {'vx>0' 'vx>0 && vy<1'},'maxSTDForAbsolute', 3,'maxSTDForRelative', 2); % % Author: Nima Bigdely Shamlo, SCCN/INC/UCSD, 2008 -% See also: show_events(), newtimef() +% See also: SHOW_EVENTS, NEWTIMEF + +% Copyright (C) Nima Bigdely Shamlo, SCCN/INC/UCSD, 2008 +% +% This file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. function timeWarpStructure = make_timewarp(EEG, eventSequence, varargin) @@ -72,14 +99,14 @@ inputKeyValuesFields = fieldnames(inputKeyValues); for i=1:length(inputKeyValuesFields) eval([inputKeyValuesFields{i} '= inputKeyValues.' inputKeyValuesFields{i} ';']); -end; +end if length(eventConditions) < length(eventSequence) for i = (length(eventConditions)+1):length(eventSequence) eventConditions{i} = ''; - end; -end; + end +end epochsIsAcceptable = ones(1, length(EEG.epoch)); for epochNumber = 1:length(EEG.epoch) @@ -95,13 +122,13 @@ timeWarp{epochNumber} = [timeWarp{epochNumber}; firstLatency]; minimumLatency = firstLatency; eventNameID = eventNameID + 1; - end; - end; + end + end if length(timeWarp{epochNumber}) < length(eventSequence) epochsIsAcceptable(epochNumber) = false; - end; -end; + end +end acceptableEpochs = find(epochsIsAcceptable); @@ -115,14 +142,14 @@ timeWarp(:,rejectedEpochesBasedOnLateny) = []; acceptableEpochs(rejectedEpochesBasedOnLateny) = []; -end; +end % since latencies and accepted epochs always have to be together, we put them in one structure timeWarpStructure.latencies = timeWarp'; % make it suitable for newtimef() if isempty(timeWarpStructure.latencies) % when empty, it becomes a {} instead of [], so we change it to [] timeWarpStructure.latencies = []; -end; +end timeWarpStructure.epochs = acceptableEpochs; timeWarpStructure.eventSequence = eventSequence; @@ -134,7 +161,7 @@ rejectedBasedOnLateny = []; for eventNumber = 1:size(timeWarpDiff, 1) rejectedBasedOnLateny = [rejectedBasedOnLateny find(abs(timeWarpDiff(eventNumber, :)- mean(timeWarpDiff(eventNumber, :))) > maxSTDForRelative * std(timeWarpDiff(eventNumber, :)))]; - end; + end rejectedEpochesBasedOnLateny = unique_bc(rejectedBasedOnLateny); end @@ -144,7 +171,7 @@ rejectedBasedOnLateny = []; for eventNumber = 1:size(timeWarp, 1) rejectedBasedOnLateny = [rejectedBasedOnLateny find(abs(timeWarp(eventNumber, :)- mean(timeWarp(eventNumber, :))) > maxSTDForAbsolute* std(timeWarp(eventNumber, :)))]; - end; + end rejectedEpochesBasedOnLateny = unique_bc(rejectedBasedOnLateny); end @@ -158,9 +185,9 @@ if isempty(firstLatency) firstLatency = epoch.eventlatency{eventNumber}; - end; - end; - end; + end + end + end end function result = eventMeetsCondition(epoch, eventNumber, condition) @@ -173,10 +200,10 @@ for i=1:length(epochField) epochField{i} = strrep(epochField{i},'event',''); % remove event from the beginning of field names condition = strrep(condition, epochField{i}, ['cell2mat(epoch.event' epochField{i} '(' num2str(eventNumber) '))' ]); - end; + end result = eval(condition); - end; + end end @@ -185,15 +212,15 @@ if ischar(types) if iscell(eventStr) && isnumeric(cell2mat(eventStr)) eventStr = num2str(cell2mat(eventStr)); - end; + end result = strcmp(eventStr, types); else % it must be a cell of strs result = false; for i=1:length(types) result = result || strcmp(eventStr, types{i}); - end; - end; + end + end end end diff --git a/functions/miscfunc/makeelec.m b/functions/miscfunc/makeelec.m index 255dce810..5e05c2cc5 100644 --- a/functions/miscfunc/makeelec.m +++ b/functions/miscfunc/makeelec.m @@ -1,4 +1,4 @@ -% makeelec() - subroutine to make electrode file in eegplot() +% MAKEELEC - subroutine to make electrode file in EEGPLOT % % Usage: >> makeelec(chans) % >> [channames] = makeelec(chans) @@ -8,23 +8,34 @@ % % Author: Colin Humprhies, CNL / Salk Institute, 1996 % -% See also: eegplot() +% See also: EEGPLOT % Copyright (C) Colin Humphries, CNL / Salk Institute, Aug, 1996 % -% 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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. % 01-25-02 reformated help & license, added links -ad diff --git a/functions/miscfunc/makehelpfiles.m b/functions/miscfunc/makehelpfiles.m index 3c8d70e1f..545075f82 100644 --- a/functions/miscfunc/makehelpfiles.m +++ b/functions/miscfunc/makehelpfiles.m @@ -1,4 +1,4 @@ -% makehelpfiles() - generate function help pages +% MAKEHELPFILES - generate function help pages % % Usage: % >> makehelpfiles(list); @@ -22,39 +22,50 @@ % Copyright (C) Arnaud Delorme, CNL / Salk Institute, 2002 % -% 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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. function makehelpfiles( varargin ); if nargin < 1 help makehelpfiles; return; -end; +end opt = finputcheck( varargin, { 'folder' 'string' { } ''; 'outputfile' 'string' { } ''; 'title' 'string' { } '' }, 'makehelpfiles'); -if isstr(opt), error(opt); end; -if isempty(opt.folder), error('You need to specify a folder'); end; -if isempty(opt.outputfile), error('You need to specify an output file'); end; +if ischar(opt), error(opt); end +if isempty(opt.folder), error('You need to specify a folder'); end +if isempty(opt.outputfile), error('You need to specify an output file'); end fo = fopen( opt.outputfile, 'w'); if ~isempty(opt.title) fprintf(fo, '%%%s (%s folder):\n', opt.title, opt.folder); else fprintf(fo, '%% *Content of %s folder:*\n', opt.folder); -end; +end dirContent = dir(fullfile(opt.folder, '*.m')); dirContent = { dirContent.name }; for iFile = 1:length(dirContent) @@ -65,7 +76,7 @@ % get help from the first line if isempty(firstLine) || firstLine(1) ~= '%' firstLine = fgetl(fidTmp); - end; + end fclose(fidTmp); if isempty(firstLine) || firstLine(1) ~= '%' @@ -75,16 +86,16 @@ if ~isempty(indexMinus) firstLineText = deblank(firstLine(indexMinus(1)+1:end)); else firstLineText = deblank(firstLine(2:end)); - end; - if isempty(firstLineText), firstLineText = 'No help information'; end; - if firstLineText(1) == ' ', firstLineText(1) = []; end; - if firstLineText(1) == ' ', firstLineText(1) = []; end; - if firstLineText(1) == ' ', firstLineText(1) = []; end; + end + if isempty(firstLineText), firstLineText = 'No help information'; end + if firstLineText(1) == ' ', firstLineText(1) = []; end + if firstLineText(1) == ' ', firstLineText(1) = []; end + if firstLineText(1) == ' ', firstLineText(1) = []; end firstLineText(1) = upper(firstLineText(1)); - if firstLineText(end) ~= '.', firstLineText = [ firstLineText '...' ]; end; - end; + if firstLineText(end) ~= '.', firstLineText = [ firstLineText '...' ]; end + end refFunction = sprintf('%s', fileName(1:end-2), fileName(1:end-2)); fprintf(fo, '%% %-*s - %s\n', 50+length(fileName(1:end-2)), refFunction, firstLineText); -end; +end fclose( fo ); diff --git a/functions/miscfunc/makehtml.m b/functions/miscfunc/makehtml.m index 9fb08c5f0..3a5e6a067 100644 --- a/functions/miscfunc/makehtml.m +++ b/functions/miscfunc/makehtml.m @@ -1,4 +1,4 @@ -% makehtml() - generate .html function-index page and function help pages +% MAKEHTML - generate .html function-index page and function help pages % composed automatically from formatted Matlab function help messages % % Usage: @@ -28,8 +28,8 @@ % Optional inputs: % 'outputfile' - Output file name. {default: 'index.html'} % 'header' - Command to insert in the header of all .html files (e.g., javascript -% declaration or meta-tag). {default: javascript 'openhelp()' -% function. See help2htm() code for details.} +% declaration or meta-tag). {default: javascript 'OPENHELP' +% function. See HELP2HTM code for details.} % 'footer' - Command to insert at the end of all .html files (e.g., back % button. {default: reference back to the function-index file} % 'refcall' - Syntax format to call references. {default is @@ -41,7 +41,7 @@ % standard .html page link instead.} % 'fontindex' - Font for the .html index file (default: 'Helvetica') % 'backindex' - Background tag for the index file (c.f. 'background') -% 'mainheader' - Text file to insert at the beggining of the index page. Default is +% 'mainheader' - Text file to insert at the beginning of the index page. Default is % none. % 'mainonly' - ['on'|'off'] 'on' -> Generate the index page only. % {default: 'off' -> generate both the index and help pages} @@ -54,30 +54,41 @@ % { { 'toolbox', 'toolbox2' } 'Signal processing functions' 'adminfunc/eeg_helpsigproc.m' }}, ... % '/home/www/eeglab/allfunctions', 'mainheader', '/data/common/matlab/indexfunchdr.txt'); % -% See also: help2html2() +% See also: HELP2HTML2 % Copyright (C) Arnaud Delorme, CNL / Salk Institute, 2002 % -% 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 file is part of EEGLAB, see http://www.eeglab.org +% for the documentation and details. % -% 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. +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: % -% 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 +% 1. Redistributions of source code must retain the above copyright notice, +% this list of conditions and the following disclaimer. +% +% 2. Redistributions in binary form must reproduce the above copyright notice, +% this list of conditions and the following disclaimer in the documentation +% and/or other materials provided with the distribution. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +% THE POSSIBILITY OF SUCH DAMAGE. function makehtml( directorylist, outputdir, varargin ); if nargin < 2 help makehtml; return; -end; +end if outputdir(end) ~= '/', outputdir(end+1) = '/'; end; @@ -85,44 +96,44 @@ g = struct( varargin{:} ); else g = []; -end; +end -try, g.mainonly; catch, g.mainonly = 'off'; end; -try, g.mainheader; catch, g.mainheader = ''; end; -try, g.outputfile; catch, g.outputfile = 'index.html'; end; -try, g.fontindex; catch, g.fontindex = 'Helvetica'; end; -try, g.backindex; catch, g.backindex = ''; end; -try, g.header; catch, g.header = [ '' ]; end; -try, g.background; catch, g.background = ''; end; -%try, g.background; catch, g.background = ''; end; -try, g.refcall; catch, g.refcall = 'javascript:openhelp(''%s.html'')'; end; -try, g.font; catch, g.font = 'Helvetica'; end; -try, g.footer; catch, g.footer = 'Back to functions'; end; -try, g.outputlink; catch, g.outputlink = [ ' ' ]; end; +try, g.mainonly; catch, g.mainonly = 'off'; end +try, g.mainheader; catch, g.mainheader = ''; end +try, g.outputfile; catch, g.outputfile = 'index.html'; end +try, g.fontindex; catch, g.fontindex = 'Helvetica'; end +try, g.backindex; catch, g.backindex = ''; end +try, g.header; catch, g.header = [ '' ]; end +try, g.background; catch, g.background = ''; end +%try, g.background; catch, g.background = ''; end +try, g.refcall; catch, g.refcall = 'javascript:openhelp(''%s.html'')'; end +try, g.font; catch, g.font = 'Helvetica'; end +try, g.footer; catch, g.footer = 'Back to functions'; end +try, g.outputlink; catch, g.outputlink = [ ' %s %s ' ]; end % read header text file % --------------------- if ~isempty(g.mainheader) doc = []; fid = fopen(g.mainheader , 'r'); - if (fid == -1), error(['Can not open file ''' g.mainheader '''' ]); end; + if (fid == -1), error(['Can not open file ''' g.mainheader '''' ]); end str = fgets( fid ); while ~feof(fid) str = deblank(str(1:end-1)); doc = [ doc str(1:end) ]; str = fgets( fid ); - end; + end g.backindex = [ g.backindex doc ]; -end; +end options = { 'footer', g.footer, 'background', g.background, ... 'refcall', g.refcall, 'font', g.font, 'header', g.header, 'outputlink', g.outputlink}; if strcmpi( g.mainonly, 'on') options = { options{:}, 'outputonly', g.mainonly }; -end; +end % ------------------------------------------- -% scrips which generate a web page for eeglab +% scripts which generate a web page for eeglab % ------------------------------------------- STYLEHEADER = ' %s %s %s
\n'; OPENWIN = [ '