Skip to content

Commit 10241b1

Browse files
committed
Major update
new features: - env_startup: now accepts name of a script that shall be run ("workflow" argument) - flt_beamforming: Beamformer integrated into source localization pipeline (old flt_beamformer used other head model structure, etc.) - ParadigmCFS: Common Feature Subspace method, which is a multi-task/subject version of ParadigmDALOSC/DALERP - a compatible copy of the SIFT toolbox is now included in the dependencies - added jsonlab dependency improvements: - set_targetmarkers: now assigns a per-event "targnum" variable that identifies each target marker, e.g., for debugging - env_acquire_cluster: - now accepts override parameters to customize how the cluster shall be acquired - returns whether the cluster needs to be shut down after use - doesn't launch the cluster when it's already running - env_startup: now allows overriding the temp file format (default: .sto) - flt_loreta: now supports epoch-wise estimation and separate pre/post standardization - flt_siftpipeline: now returns time-series fields for each conn method - flt_sourceLocalize: now supports per-subject and per-group head models, better handling of verbosity level, added support for 'beamforming' mode, uses a more generic default head model - flt_beamformer: now supports shirnkage and robust covariance estimation, changed default reference to common_average - flt_project: can now accept a function handle to compute a spatial filter - gui_showmenu: now closes all menus left over from previous bcilab runs - hlp_colsrc: now supports epoched signals - hlp_trycompile: warns if a directory clashes with name of some build products - ml_traindal: - can now perform nested cross-validation on a cluster (ParallelEngine argument) - can now spawn/release cluster by itself (ParallelScope argument) - ml_trainproximal: - now faster due to less tight tolerance parameters (RelativeTolerance, Epsilon) - now supports p-holdout, interval holdout, and k-fold where k is determined from #trials - can now perform nested cross-validation on a cluster (ParallelEngine argument - can now spawn/release cluster by itself (ParallelScope argument) - bci_train/bci_batchtrain: can now spawn/release cluster by itself (ParallelScope argument) - bci_train: code documentation improvements - ParadigmMSERP: can now group tasks in multi-task learning formulation by subject and other dataset properties - ParadigmSIFT: can now use an alternative (fast) classifier to guide pipeline parameter search (e.g., src localization or conn estimation reg. parameters), and use a better (slow) classifier to compute the final model; now also clears ADMM state between folds (slightly more rigorous) - parallel subsystem: - now using Java byte arrays instead of base64-encoded strings for data transfer (significantly faster) - Reference scheduler now also returns the unserialized data for serialization debugging - par_getworkers_ssh: - now accepts and optional list of hosts to avoid (AvoidHosts) - harvest timeout reduced to 300s - shutdown timeout now automatically increased if lower than harvest timeout - better diagnostic messages when a host doesn't have enough free mem to launch an instance, and when workers were launched whose process id could not be retrieved for clean shutdown - par_reschedule_policy: can now be disabled in the function - par_schedule: spawn/release cluster by itself ('scope' argument) - par_testworker: updated to support newer handshake protocol - par_worker: can now transfer data in chunks if data does not fit in Java memory; also now supports timing/data rate diagnostics - utl_collection_partition: now supports the NoCrossvalidation argument to bypass cross-validation (e.g., to perform just a parameter search and then use those parameters on other subjects) - glm-ie_v1.5/dli.m: now outputting additional return values for better inspection ability updates: - env_compile_bcilab: - updated documentation to reflect changed dependencies - added new dependencies related to SIFT toolbox - expose_handles: changed to work with new MATLAB restrictions on anonymous functions - ml_trainlogreg/predictlogreg: updated to support LIBLINEAR 2.01 for l2-regularized logistic regression; can now handle lambda search more efficiently - added liblinear-2.01 dependency - automatically excluding cummax mex binary on newer MATLABs that have it - tcp_io_udp toolbox updated to include the PTBMods by Mario Kleiner changes: - flt_interpchs: changed to match changes in head model structure - flt_sourceLocalize: changed to match changes in head model structure - dipfit2.3: renamed rotate to rotate_new due to name clash during MATLAB compile fixes: - flt_interpchs: hmObj parameter no longer type-checked - flt_loreta: now compensates for depth bias - flt_loreta: added traditional variant with GCV-based estimation of reg parameter - flt_interpchs, flt_loreta, flt_vblorta, flt_srcproj, flt_rej_impedance, set_insert_markers, set_partition: now properly call exp_endfun on all return paths - ridgeSVD: now correctly determines GCV optimum - flt_sourceLocalize: now also works when .srcweights not present - hlp_deserialize: adds support for previously missing 'function_handle' type - ml_trainproximal: termweight search now works correctly when model caching is enabled in development / unfinished: - dynamicLoreta: completely rewritten - evidence_approx_tikhonov_reg_svd: new algorithm for bayesian src localization - flt_spec_feature: new function to extract some traditional spectral features - ParadigmRWSRCSP: new method (Riemannian Weighted Subjects Regularized CSP) after 2015 Lotte paper known issues: - ml_trainglm: the optional bayesian evidence maximization does not work very well and will usually select the loosest prior value because of problematic numerics
1 parent 56f94e6 commit 10241b1

File tree

7,263 files changed

+1157305
-933028
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

7,263 files changed

+1157305
-933028
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
BCILAB
2-
======
3-
4-
MATLAB Toolbox for Brain-Computer Interface Research
5-
6-
This software was written at the Swartz Center for Computational Neuroscience, UCSD. This work was funded by the Army Research Laboratory under Cooperative Agreement Number W911NF-10-2-0022 and a gift from The Swartz Foundation (Old Field, NY).
7-
The design of BCILAB was inspired by a preceding toolbox (the PhyPA toolbox) written in 2006-'09 by C. Kothe with contributions from T. Zander at the Department for Human-Machine Systems, Berlin Institute of Technology.
1+
BCILAB
2+
======
3+
4+
MATLAB Toolbox for Brain-Computer Interface Research
5+
6+
This software was written at the Swartz Center for Computational Neuroscience, UCSD. This work was funded by the Army Research Laboratory under Cooperative Agreement Number W911NF-10-2-0022 and a gift from The Swartz Foundation (Old Field, NY).
7+
The design of BCILAB was inspired by a preceding toolbox (the PhyPA toolbox) written in 2006-'09 by C. Kothe with contributions from T. Zander at the Department for Human-Machine Systems, Berlin Institute of Technology.

bcilab.m

Lines changed: 123 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,123 @@
1-
function bcilab(varargin)
2-
% BCILAB startup function
3-
%
4-
% The startup function determines startup options according to a config file and then starts the
5-
% BCILAB toolbox based on config options. If a file named bcilab_config.m exists in the user's home
6-
% directory (under .bcilab) it will take precedence, otherwise the file of the same name in the
7-
% bcilab folder will be used. The file name (or path) can also be specified directly as the first
8-
% argument to this function.
9-
%
10-
% In addition, startup options can also be passed directly to this function, in the form of name-
11-
% value pairs. These options selectively override those that are specified in the config file.
12-
%
13-
% Generally, the way to load bcilab is to cd into the BCILAB path, and execute this function.
14-
% The BCILAB path should not be added to the default MATLAB path, especially *never* recursively.
15-
%
16-
% In:
17-
% ConfigScript : optional file name of a configuration script (assigning values to config
18-
% variables, see bcilab_config.m for an example)
19-
%
20-
% Options... : optional name-value pairs to override options; for possible options,
21-
% see env_startup
22-
%
23-
% Notes:
24-
% The config files are regular MATLAB script and may include conditional statements (depending on
25-
% the platform used), etc. However, to allow modification of these files via the GUI, it is
26-
% recommended to keep them simple.
27-
%
28-
% Examples:
29-
% % start the toolbox using default settings (found in bcilab_config.m)
30-
% cd /my/path/to/bcilab-0.9-beta2b; bcilab
31-
%
32-
% % start the toolbox, passing a particular config script
33-
% cd /my/path/to/bcilab-0.9-beta2b; bcilab('myconfig.m')
34-
%
35-
% % start the toolbox, passing a particular config script, and also override a few parameters directly
36-
% cd /my/path/to/bcilab-0.9-beta2b; bcilab('myconfig.m','data','/data','worker',true)
37-
%
38-
% See also:
39-
% env_startup
40-
%
41-
% Christian Kothe, Swartz Center for Computational Neuroscience, UCSD
42-
% 2010-10-30
43-
44-
disp('starting BCILAB...');
45-
if mod(nargin,2) == 0
46-
% an even number of arguments (or none) was passed -- therefore, no config script was given,
47-
% so assume the default one
48-
configscript = 'bcilab_config';
49-
else
50-
% an odd number of arguments was passed
51-
% --> the first argument is the name of the config script
52-
if ~ischar(varargin{1})
53-
error('If an odd number of parameters is provided then the first parameter must be the name of a config script.'); end
54-
configscript = varargin{1};
55-
% ... and the rest are the options.
56-
varargin = varargin(2:end);
57-
end
58-
if ~iscellstr(varargin(1:2:end))
59-
error('The arguments to bcilab.m must be name-value pairs.'); end
60-
61-
% check if the user's home directory (.bcilab sub-directory) contains a bcilab_config.m, and prefer
62-
% that if present
63-
home = char(java.lang.System.getProperty('user.home'));
64-
if exist([home filesep '.bcilab' filesep configscript '.m'],'file')
65-
configscript = [home filesep '.bcilab' filesep configscript '.m']; end
66-
67-
if isdeployed && ~isempty(varargin)
68-
try
69-
varargin = cellfun(@eval,varargin,'UniformOutput',false);
70-
catch
71-
disp('When passing command-line arguments, make sure that strings are enclosed in '''' characters.');
72-
disp('Otherwise, all of them will be assumed to be strings.');
73-
end
74-
end
75-
76-
77-
% sanitize and run the config script
78-
if ~any(configscript == filesep)
79-
% relative path given
80-
if isdeployed
81-
if ~any(configscript == '.')
82-
configscript = [configscript '.m']; end
83-
% we assume that the configscript lies in a directory at or above the binary
84-
tmpdir = [pwd filesep];
85-
delims = strfind(tmpdir,filesep);
86-
for k=length(delims):-1:1
87-
scriptpath = [tmpdir(1:delims(k)) configscript];
88-
if exist(scriptpath,'file')
89-
configscript = scriptpath;
90-
break;
91-
end
92-
end
93-
if ~exist(scriptpath,'file')
94-
error('Config script %s not found in any path relative to the binary.',configscript); end
95-
else
96-
configscript = which(configscript);
97-
end
98-
end
99-
fprintf('running config script %s...\n',configscript);
100-
addpath([fileparts(mfilename('fullpath')) filesep 'code' filesep 'misc']);
101-
run_script(configscript);
102-
103-
% collect the variables as defined in the config script into a struct
104-
infos = whos();
105-
for n = {infos.name}
106-
settings.(n{1}) = eval(n{1}); end
107-
108-
% load the toolbox (using code/environment/env_startup)
109-
% (using the settings from the config script, possibly overridden by name-value pairs in varargin)
110-
disp('running startup function...');
111-
if ~isdeployed
112-
cd([fileparts(mfilename('fullpath')) filesep 'code' filesep 'environment']); end
113-
114-
try
115-
env_startup(settings,varargin{:},'configscript',configscript);
116-
catch
117-
% store a crash report for debugging in deployed cases
118-
report.settings = settings;
119-
report.varargin = varargin;
120-
report.lasterror = lasterror; %#ok<*LERR>
121-
save bcilab_crashreport report
122-
rethrow(lasterror);
123-
end
1+
function bcilab(varargin)
2+
% BCILAB startup function
3+
%
4+
% The startup function determines startup options according to a config file and then starts the
5+
% BCILAB toolbox based on config options. If a file named bcilab_config.m exists in the user's home
6+
% directory (under .bcilab) it will take precedence, otherwise the file of the same name in the
7+
% bcilab folder will be used. The file name (or path) can also be specified directly as the first
8+
% argument to this function.
9+
%
10+
% In addition, startup options can also be passed directly to this function, in the form of name-
11+
% value pairs. These options selectively override those that are specified in the config file.
12+
%
13+
% Generally, the way to load bcilab is to cd into the BCILAB path, and execute this function.
14+
% The BCILAB path should not be added to the default MATLAB path, especially *never* recursively.
15+
%
16+
% In:
17+
% ConfigScript : optional file name of a configuration script (assigning values to config
18+
% variables, see bcilab_config.m for an example)
19+
%
20+
% Options... : optional name-value pairs to override options; for possible options,
21+
% see env_startup
22+
%
23+
% Notes:
24+
% The config files are regular MATLAB script and may include conditional statements (depending on
25+
% the platform used), etc. However, to allow modification of these files via the GUI, it is
26+
% recommended to keep them simple.
27+
%
28+
% Examples:
29+
% % start the toolbox using default settings (found in bcilab_config.m)
30+
% cd /my/path/to/bcilab-0.9-beta2b; bcilab
31+
%
32+
% % start the toolbox, passing a particular config script
33+
% cd /my/path/to/bcilab-0.9-beta2b; bcilab('myconfig.m')
34+
%
35+
% % start the toolbox, passing a particular config script, and also override a few parameters directly
36+
% cd /my/path/to/bcilab-0.9-beta2b; bcilab('myconfig.m','data','/data','worker',true)
37+
%
38+
% See also:
39+
% env_startup
40+
%
41+
% Christian Kothe, Swartz Center for Computational Neuroscience, UCSD
42+
% 2010-10-30
43+
44+
disp('starting BCILAB...');
45+
if mod(nargin,2) == 0
46+
% an even number of arguments (or none) was passed -- therefore, no config script was given,
47+
% so assume the default one
48+
configscript = 'bcilab_config';
49+
else
50+
% an odd number of arguments was passed
51+
% --> the first argument is the name of the config script
52+
if ~ischar(varargin{1})
53+
error('If an odd number of parameters is provided then the first parameter must be the name of a config script.'); end
54+
configscript = varargin{1};
55+
% ... and the rest are the options.
56+
varargin = varargin(2:end);
57+
end
58+
if ~iscellstr(varargin(1:2:end))
59+
error('The arguments to bcilab.m must be name-value pairs.'); end
60+
61+
% check if the user's home directory (.bcilab sub-directory) contains a bcilab_config.m, and prefer
62+
% that if present
63+
home = char(java.lang.System.getProperty('user.home'));
64+
if exist([home filesep '.bcilab' filesep configscript '.m'],'file')
65+
configscript = [home filesep '.bcilab' filesep configscript '.m']; end
66+
67+
if isdeployed && ~isempty(varargin)
68+
try
69+
varargin = cellfun(@eval,varargin,'UniformOutput',false);
70+
catch
71+
disp('When passing command-line arguments, make sure that strings are enclosed in '''' characters.');
72+
disp('Otherwise, all of them will be assumed to be strings.');
73+
end
74+
end
75+
76+
77+
% sanitize and run the config script
78+
if ~any(configscript == filesep)
79+
% relative path given
80+
if isdeployed
81+
if ~any(configscript == '.')
82+
configscript = [configscript '.m']; end
83+
% we assume that the configscript lies in a directory at or above the binary
84+
tmpdir = [pwd filesep];
85+
delims = strfind(tmpdir,filesep);
86+
for k=length(delims):-1:1
87+
scriptpath = [tmpdir(1:delims(k)) configscript];
88+
if exist(scriptpath,'file')
89+
configscript = scriptpath;
90+
break;
91+
end
92+
end
93+
if ~exist(scriptpath,'file')
94+
error('Config script %s not found in any path relative to the binary.',configscript); end
95+
else
96+
configscript = which(configscript);
97+
end
98+
end
99+
fprintf('running config script %s...\n',configscript);
100+
addpath([fileparts(mfilename('fullpath')) filesep 'code' filesep 'misc']);
101+
run_script(configscript);
102+
103+
% collect the variables as defined in the config script into a struct
104+
infos = whos();
105+
for n = {infos.name}
106+
settings.(n{1}) = eval(n{1}); end
107+
108+
% load the toolbox (using code/environment/env_startup)
109+
% (using the settings from the config script, possibly overridden by name-value pairs in varargin)
110+
disp('running startup function...');
111+
if ~isdeployed
112+
cd([fileparts(mfilename('fullpath')) filesep 'code' filesep 'environment']); end
113+
114+
try
115+
env_startup(settings,varargin{:},'configscript',configscript);
116+
catch
117+
% store a crash report for debugging in deployed cases
118+
report.settings = settings;
119+
report.varargin = varargin;
120+
report.lasterror = lasterror; %#ok<*LERR>
121+
save bcilab_crashreport report
122+
rethrow(lasterror);
123+
end

0 commit comments

Comments
 (0)