Skip to content

Devel #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 193 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
193 commits
Select commit Hold shift + click to select a range
d085500
Update set_concat.m
chkothe Feb 27, 2014
fc619e5
Added support for private plugins in a separate directory tree.
chkothe Feb 28, 2014
8badb9e
Started to implement large-scale argument validation.
chkothe Feb 28, 2014
73a2293
Fix in gui_listapproaches (for case of approaches from workspace in c…
chkothe Mar 2, 2014
21922f3
Some more updates.
chkothe Mar 2, 2014
aa8aa0f
Further work on the input validation...
chkothe Mar 3, 2014
478156c
Next round of updates on input validation.
chkothe Mar 4, 2014
d69eb51
Next batch of updates...
chkothe Mar 4, 2014
dbfdf1a
Minor updates.
chkothe Mar 5, 2014
fdef75d
Fixed two things.
chkothe Mar 5, 2014
f25c468
Merge branch 'input_validation' of https://github.com/sccn/BCILAB int…
chkothe Mar 5, 2014
5e31f6a
More validation code. Also generalized hlp_handleerror to allow for p…
chkothe Mar 6, 2014
cf9b697
Next round of updates.
chkothe Mar 6, 2014
70f8b87
Minor refactoring of utl_memoize_* functions
chkothe Mar 7, 2014
906c236
More updates....
chkothe Mar 7, 2014
943f86c
More files updated...
chkothe Mar 8, 2014
d638e1b
Solid number of additional checks.
chkothe Mar 13, 2014
4708fc4
Few more.
chkothe Mar 13, 2014
1b123ab
Some more checks, now largely done (some future work could include ch…
chkothe Mar 13, 2014
d9d3e3f
Starting to test and fix validation code...
chkothe Mar 13, 2014
73670d7
Some first fixes to validation code...
chkothe Mar 14, 2014
7fbf1fe
More fixes.
chkothe Mar 14, 2014
2e38ef2
Carried over some more additions to helper functions.
chkothe Mar 20, 2014
3dd55df
Fixed a typo in env_startup that prevented private dependencies from …
chkothe Mar 20, 2014
f2a73ca
Added the ability to have configurable base paths refer to other base…
chkothe Mar 20, 2014
03bd618
Fixed the option_single issue ...
chkothe Mar 20, 2014
174b152
Updated the smal montreall headmodel (added meta-data).
chkothe Mar 20, 2014
c64bc55
Fixed an issue in arg_tovals.
chkothe Mar 29, 2014
c4e1bc1
Carried over some fixes from GTC stack.
trmullen Mar 24, 2014
7a3d14b
updated a mex file
chkothe Apr 5, 2014
76d5489
Updated mex files
chkothe Apr 5, 2014
506a4f1
Merge branch 'input_validation' of https://github.com/sccn/BCILAB int…
chkothe Apr 5, 2014
943ce25
Fixed regression in bci_batchtrain.
chkothe Jun 10, 2014
b65cfee
Merge remote-tracking branch 'origin/devel' into input_validation.
chkothe Jun 11, 2014
1809c78
Merge branch 'testing' into input_validation
chkothe Jun 11, 2014
766a1bf
Fixed MATLAB incompatibility issue.
chkothe Jun 11, 2014
61cd703
Fixed a number of unrelated issues during testing.
chkothe Jun 11, 2014
1c5f30f
Various fixes during testing:
chkothe Jun 13, 2014
b1a78cf
Started implementing complete GUI support for glm-ie.
chkothe Jun 13, 2014
9e65ca0
More progress on the generalized Bayesian GLM implementation.
chkothe Jun 14, 2014
41f082e
Finished glm-ie support (largely).
chkothe Jun 14, 2014
9ed5535
Breaking change:
chkothe Jun 19, 2014
ffd35f1
Removed stray check
chkothe Jun 19, 2014
fe77cc4
Implemented automatic montage selection based on channel-to-channel c…
chkothe Jun 19, 2014
6cbf959
Breaking change:
chkothe Jun 20, 2014
a976db5
Fixed arg_report to play better with expression-enabled functions; no…
chkothe Jun 20, 2014
1497f15
Speeded up set_infer_chanlocs for large data (a bit).
chkothe Jun 20, 2014
9a3005f
Substantial improvements:
chkothe Jun 25, 2014
0dc94ac
Slightly improved play_eegset_lsl.
chkothe Jun 26, 2014
2b8b001
- flt_resample now estimates the filter delay
chkothe Jun 26, 2014
661ff42
Montage information is now in a unified file format under resources/c…
chkothe Jun 26, 2014
3d6f9ef
Fixed issue in utl_resolve_streams.
chkothe Jun 26, 2014
0dcf030
- Fixed an oversight in utl_timeseries_fields
chkothe Jun 26, 2014
4e4c681
- update to latest EEGLAB version complete
chkothe Jun 26, 2014
60720d8
- fixed estimation of filter delay in flt_resample
chkothe Jun 26, 2014
00b1772
- added jitter correction to run_readlsl (can now handle time series …
chkothe Jun 27, 2014
4fb590c
Minor doc changes noticed during merge.
chkothe Jun 27, 2014
0d6b22b
Updated env_version.
chkothe Jun 27, 2014
84f45b3
Made the clock alignment estimation window configurable in run_readls…
chkothe Jun 27, 2014
452928d
Fixed mistake in par_beginschedule: would iterate over tasks in rever…
chkothe Jun 27, 2014
f2a36b0
- Breaking change: changed the initial output line of par_worker to: …
chkothe Jun 28, 2014
b3c1272
- finished harvesting of hostnames/IPs/ports in par_getworkers_qsub
chkothe Jul 1, 2014
14dc1de
* Added ADiGator auto-diff toolbox
chkothe Jul 29, 2014
9b75b9b
Merge branch 'devel' of https://github.com/sccn/BCILAB into devel
chkothe Jul 29, 2014
fc32426
Fixed bug where an arg_norep would remain unassigned if the default i…
chkothe Jul 29, 2014
c6de257
Corrected previous fix.
chkothe Jul 29, 2014
95f59b2
ParadigmSIFT now caches features on disk by default, instead of memory.
chkothe Aug 11, 2014
a35434c
Added the nth_element package to dependencies (for fast median comput…
chkothe Aug 11, 2014
e544764
FIR and IIR filters now store their kernels in signal.etc for future …
chkothe Aug 11, 2014
b43741e
flt_clean_settings now supports an early low-pass filtering stage to …
chkothe Aug 11, 2014
30fc6a7
flt_clean_channels has been improved:
chkothe Aug 11, 2014
28a0b21
gui_chooseapproach now supports approaches specified in cell-array sh…
chkothe Aug 11, 2014
958ea10
io_loadset: fixed handling of type-based channel selection (e.g., io_…
chkothe Aug 11, 2014
9b034e9
ml_trainproximal: fixed recently-introduced crash bug (joint_best_reg…
chkothe Aug 11, 2014
c42f434
ml_traindal: improved the "reasonable range" of the lambda argument t…
chkothe Aug 11, 2014
109ee13
ParadigmDALERP: extra error message.
chkothe Aug 11, 2014
a5421a2
utl_printapproach: now supports printing the entire approach spec, no…
chkothe Aug 11, 2014
3f853d2
par_worker: eliminate a circumstance under which the heartbeat signal…
chkothe Aug 11, 2014
3cdc960
par_getworkers_qsub now re-seeds the random number generator to ensur…
chkothe Aug 11, 2014
1882d25
Added readme to build folder; removed eegplugin_bcilab (toolbox has b…
chkothe Aug 11, 2014
ff5d506
vis_artifacts: now returns the correct figure handle, can be used to …
chkothe Aug 11, 2014
5f2ca81
Fixed scaling bug. Patch provided by Clemens Brunner & David Steyrl.
chkothe Aug 11, 2014
be497cf
Added online plugin for Neuroscan Scan software (patch provided by Da…
chkothe Aug 11, 2014
d659ff0
Changed 'timestamps_ptr' to 'tmax', as this stream field was renamed …
chkothe Aug 11, 2014
aa9ccd3
Updated pnet.c to version compatible with 64-bit systems, as modified…
chkothe Aug 11, 2014
989f602
Merge remote-tracking branch 'origin/devel' into devel
chkothe Aug 11, 2014
73f65d9
Upaded pnet.c to compiled with mex again (replaced C++ comments by C …
chkothe Aug 11, 2014
42842de
Updated env_compile for tcp_udp_ip toolbox to compile on Windows.
chkothe Aug 11, 2014
367780f
Breaking Changes:
chkothe Mar 23, 2015
15c36a0
Added simple support for an in-memory file system on the cluster (bar…
chkothe Mar 23, 2015
71dca3f
Merge remote-tracking branch 'origin/devel' into devel
chkothe Mar 23, 2015
34d9cef
* added 'std-nocenter' mode to rescaling modes (rarely used, included…
chkothe Mar 23, 2015
d42bfff
Fixed bug reported by Luca.
chkothe Mar 23, 2015
8b94c8a
Worked around utility function of same name in latest MATLAB (cummax).
chkothe Apr 14, 2015
67088c2
Updated EEGLAB to 13.4.4b (brings fixes for MATLAB figure type change…
chkothe Apr 14, 2015
c9826a2
Added EEGLAB import plugins to repo.
chkothe Apr 14, 2015
47aaa1c
* Improved behavior of io_loadset when 'channels' and 'type' argument…
chkothe Apr 14, 2015
7859da4
* set_insert_markers: fixed an regression caused during the latest pe…
chkothe Apr 15, 2015
d962d0a
* set_gettarget: changed it so that it is not an error if the dataset…
chkothe Apr 15, 2015
f82bc8d
* utl_collection_closest: fixed parameter help text
chkothe Apr 15, 2015
989fac9
* bci_train: added the option to disable local pre-checks of the data
chkothe Apr 15, 2015
bcedb31
* utl_collection_closest: merged in documentation improvements
chkothe Apr 15, 2015
d97a19b
* env_startup: by default suppressing the warning MATLAB:structOnObje…
chkothe Apr 16, 2015
1e8fdfc
BCILAB can now auto-kill its workers. Also fixed a bug in ParadigmMKL…
chkothe Apr 16, 2015
4555db9
Added ability to stream console output back from workers via logfiles…
chkothe Apr 17, 2015
079b819
Added ability to broadcast commands to all workers. Fixed minor snag …
chkothe Apr 17, 2015
46501a2
* Added a classifier based on the covariance toolbox by A. Barachant.…
chkothe Apr 22, 2015
519156f
* minor updates to MKL(FB)CSP and par_broadcast
chkothe Apr 24, 2015
bfe1b2d
* added ability for bci_train to checkpoint (disk-cache) results of p…
chkothe Apr 26, 2015
9d85ac2
bci_train can now cache per-fold results, and optionally return only …
chkothe May 2, 2015
05f3899
run_readlsl now allows ChannelOverride to be a struct array.
chkothe May 2, 2015
f74bb9d
Fixed regression last commit.
chkothe May 3, 2015
45a8eb1
* flt_repair_bursts has gained the ability to separate or keep artifacts
chkothe Jul 9, 2015
aca3a22
Fixed error message in onl_append.
chkothe Jul 12, 2015
b81f0e1
Fixed xmin/xmax in onl_peek output (if not passing timestamps to onl_…
chkothe Jul 12, 2015
b0300b4
asr_process now falling back to TotalMemory if FreeMemory fails on GPU.
chkothe Jul 12, 2015
9dbb752
Online plugins can now stop streaming, run_readdataset now uses this …
chkothe Jul 12, 2015
668213d
Added flt_sliding_window for sliding-window online processing without…
chkothe Jul 12, 2015
2a63f67
Rebuilt revised chopdeal on win64 (adds support for uint8).
chkothe Jul 12, 2015
56f94e6
Fixed recent regression in nested CV
chkothe Aug 7, 2015
10241b1
Major update
chkothe Sep 6, 2015
747f0c8
Added more features to play_eegset_lsl.
chkothe Oct 31, 2015
3ab30d7
Rebuilt some dependencies on Windows.
chkothe Oct 31, 2015
4894bf6
Improvements:
chkothe Nov 1, 2015
b34505e
Added optional wait prompt to play_eegset_lsl
chkothe Nov 2, 2015
0bebe3c
Merge branch 'devel' of https://github.com/sccn/BCILAB into devel
chkothe Nov 2, 2015
dbe5294
* Added experimental version of FBCSP that uses continuous-time FIR/IIR
chkothe Nov 5, 2015
5a3c02e
* added framework support for filters that process trials independently
chkothe Nov 5, 2015
c9af004
* flt_clean_settings: added ability to specify the type of IIR filter to
chkothe Nov 11, 2015
5a455ba
Made flt_repair_bursts offline processing no longer depend on free
chkothe Nov 11, 2015
cb7f1f2
Made flt_repair_channels deterministic during offline processing.
chkothe Nov 11, 2015
848f0bd
Made flt_standardize deterministic during offline processing.
chkothe Nov 11, 2015
edd54fb
Fixed a bug in the argument parsing of flt_window (didn't work properly
chkothe Nov 11, 2015
17bfaf6
ml_trainlda/ml_trainqda: added a "robust" option that uses geometric
chkothe Nov 11, 2015
d89d042
ml_trainsvmlight: added built-in parameter search, which makes it quite
chkothe Nov 11, 2015
ab5ef50
utl_calc_crossspec: added option to return the real-valued
chkothe Nov 11, 2015
d1dbddb
Changed default timeout in par_fileclient to 30m to work better under
chkothe Nov 11, 2015
b4f9c63
Added nTrials to the model (allowing for later checks of how many trials
chkothe Nov 11, 2015
3d01048
Added ParadigmSpecRCSP - combination of SpecCSP and RCSP, plus added
chkothe Nov 11, 2015
0dfd044
Made marker-channel processing optional in io_loadset.
chkothe Nov 14, 2015
41cb0ba
ml_trainlda: now stores the estimated shrinkage lambdas
chkothe Nov 14, 2015
5fd3246
ParadigmDALERP: now supports decimation; can be used instead of the r…
chkothe Nov 14, 2015
a9f72c6
play_eegset_lsl: now a bit faster at launch when playing large datasets.
chkothe Nov 14, 2015
832489c
Fixed regression with MATLAB 2015a or later when compiling binaries w…
chkothe Nov 17, 2015
5c0daa3
Fixed bug in llpredict.c dependency (caused compilation fail on 2015a…
chkothe Nov 17, 2015
83a30b4
Added some instructions on how to debug broken compiles with hlp_tryc…
chkothe Nov 17, 2015
d9b4944
Some more binaries recompiled.
chkothe Nov 17, 2015
113615f
Changes made to fix the compile issues on Maci64.
nedaeh Feb 5, 2016
153efce
including all mex files from compile on maci64.
nedaeh Feb 5, 2016
52e42d0
Merge pull request #9 from nedaeh/devel
chkothe Feb 5, 2016
76ebcc8
* fixes for MATLAB 2015b compatibility (change to how the stack entri…
nedaeh Feb 8, 2016
edac719
Merge pull request #10 from nedaeh/devel
chkothe Feb 8, 2016
3f4f4e0
renaming strjoin and strsplit.
nedaeh Mar 3, 2016
187819d
strjoin2 and strsplit2 renaming.
nedaeh Mar 3, 2016
980e6ac
added some debug printouts and some other misc additions...
chkothe May 2, 2016
f46a4ce
rolled back a change in set_insert_markers
chkothe May 2, 2016
81d4b45
Merge pull request #12 from nedaeh/devel
chkothe May 4, 2016
8e0b0bd
Removed some MATLAB autosave files.
chkothe May 12, 2016
b442f8d
Small fix to set_insert_markers (stray exp_endfun)
chkothe May 12, 2016
7568a4c
Small fix for load_xdf (where the time series is empty)
chkothe May 12, 2016
5b7db7f
Merge branch 'devel' of https://github.com/sccn/BCILAB into devel
chkothe May 12, 2016
5384222
Modified version of FBCSP using welch method, this replicates the cur…
nedaeh May 12, 2016
27cd14d
Included code review comments for FBCSP modified version.
nedaeh May 12, 2016
e287299
Merge pull request #16 from nedaeh/EmotionRecognition2
chkothe May 13, 2016
1e25894
Fixed issue in ParadigmSpecCSP that would cause a crash if the traini…
chkothe Aug 29, 2016
5c52362
Added ability to save in MATLAB legacy file format in io_save and io_…
chkothe Sep 8, 2016
cce2bb8
Suppressed some new warnings and fixed positioning of BCILAB window o…
chkothe Nov 17, 2016
f5181a7
Fixed positioning of BCILAB toolbar on some screen setups.
chkothe Dec 4, 2016
20a6cad
FIR filter now has a UseFFT option that makes using the FFT optional.
intheon-buildbot Apr 6, 2017
fddc9c2
Updated vis_artifacts so that it works with more recent MATLABs.
intheon-buildbot Apr 6, 2017
569bca0
Added option 'streamindex' to eeg_load_xdf to import a particular str…
intheon-buildbot Apr 6, 2017
18af157
Fixed an issue in load_xdf where there are no clock offset chunks in …
intheon-buildbot Apr 6, 2017
38403da
Updated formatting of extra arguments for pop_readbdf in io_loadset.
intheon-buildbot May 17, 2017
35abfd6
Patched behavior of bci_visualize to be closer to doing the right thi…
intheon-buildbot May 17, 2017
24c7886
Update gui_newapproach.m
chkothe Nov 3, 2018
75a22cc
set_infer_chanlocs now auto-assigning ch1..chN if names not given
intheon-buildbot Nov 8, 2018
c8c4e04
io_loadset: not resampling if desired rate matches data rate
intheon-buildbot Nov 8, 2018
8d41741
xdfimport fix for chopped-off clockoffset chunk (rare)
intheon-buildbot Nov 8, 2018
85572f4
xdfimport: added ability to sort events in ascending order, and optio…
intheon-buildbot Nov 8, 2018
c37c725
Merge branch 'devel' of https://github.com/sccn/BCILAB into devel
intheon-buildbot Nov 8, 2018
10ccbb1
Added CreateTable dependency
intheon-buildbot Nov 10, 2018
a666282
Fixes for broken comboboxes in propertygrid on MacOS for MATLAB >= 2015b
intheon-buildbot Nov 10, 2018
a0672a5
Added env_add file for createTable
intheon-buildbot Nov 10, 2018
ded5323
fixed an issue where there could be more than 2 BCILAB menus open.
intheon-buildbot Nov 10, 2018
6621e78
Fixed issue during online event-locked processing (a parameter wasn't…
intheon-buildbot Apr 8, 2019
fd20397
Suppressed a noisy warning during online processing
intheon-buildbot Apr 8, 2019
e6772d9
run_writelsl now prints what it sends in verbose mode
intheon-buildbot Apr 8, 2019
6fc7e38
Fixed an issue with freeing memory when reading string markers from L…
intheon-buildbot Apr 8, 2019
f1dd6ed
updating Mac DLL for LSL
arnodelorme May 21, 2020
4cdc2dc
adding old juggling compilation for Ubuntu - not sure it is absolutel…
arnodelorme May 27, 2020
1e3d041
Update README.md
arnodelorme Oct 6, 2020
8f50ca8
Update README.md
arnodelorme Oct 6, 2020
b2600e8
Update README.md
chkothe Oct 4, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
BCILAB
======

MATLAB Toolbox for Brain-Computer Interface Research

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).
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
======

MATLAB Toolbox for Brain-Computer Interface Research

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).
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.

This toolbox is no longer actively developed as of 2017. However, critical updates are still performed. If you are interested in further developping and maintaining BCILAB, feel free to contact us.

See documentation on the [Github repository wiki](https://github.com/sccn/BCILAB/wiki).
242 changes: 123 additions & 119 deletions bcilab.m
Original file line number Diff line number Diff line change
@@ -1,119 +1,123 @@
function bcilab(varargin)
% BCILAB startup function
%
% The startup function determines startup options according to a config file and then starts the
% BCILAB toolbox by calling env_startup() with the config options. If a file named bcilab_config.m
% exists in the user's home directory (under .bcilab) it will take precedence, otherwise the file
% of the same name in the bcilab folder will be used. The file name (or path) can also be specified
% directly as the first argument to this function.
%
% In addition, startup options can also be passed directly to this function, in the form of name-
% value pairs. These options override those that are specified in the config file.
%
% Generally, the way to load bcilab is to cd into the BCILAB path, and execute this function.
% The BCILAB path should not be added to the default MATLAB path, especially *never* recursively.
%
% In:
% ConfigScript : optional file name of a configuration script (assigning values to config
% variables, see bcilab_config.m for an example)
%
% Options... : optional name-value pairs to override options; for possible options,
% see env_startup
%
% Notes:
% The config file is a regular MATLAB script and may include conditional statements (depending on
% the platform used), etc. However, to allow modification of this file via the GUI, it is
% recommended to keep this file simple.
%
% Examples:
% % start the toolbox using default settings (found in bcilab_config.m)
% cd /my/path/to/bcilab-0.9-beta2b; bcilab
%
% % start the toolbox, passing a particular config script
% cd /my/path/to/bcilab-0.9-beta2b; bcilab('myconfig.m')
%
% % start the toolbox, passing a particular config script, and also override a few parameters directly
% cd /my/path/to/bcilab-0.9-beta2b; bcilab('myconfig.m','data','/data','worker',true)
%
% See also:
% env_startup
%
% Christian Kothe, Swartz Center for Computational Neuroscience, UCSD
% 2010-10-30

disp('starting BCILAB...');
if mod(nargin,2) == 0
% an even number of arguments (or none) was passed -- therefore, no config script was given,
% so assume the default one
configscript = 'bcilab_config';
else
% an odd number of arguments was passed
% --> the first argument is the name of the config script
configscript = varargin{1};
% ... and the rest are the options.
varargin = varargin(2:end);
end

% check if the user's home directory (.bcilab sub-directory) contains a bcilab_config.m, and prefer
% that if present
home = char(java.lang.System.getProperty('user.home'));
if exist([home filesep '.bcilab' filesep configscript '.m'],'file')
configscript = [home filesep '.bcilab' filesep configscript '.m']; end

if isdeployed && ~isempty(varargin)
try
varargin = cellfun(@eval,varargin,'UniformOutput',false);
catch
disp('When passing command-line arguments, make sure that strings are enclosed in '''' characters.');
disp('Otherwise, all of them will be assumed to be strings.');
end
end


% sanitize and run the config script
if ~any(configscript == filesep)
% relative path given
if isdeployed
if ~any(configscript == '.')
configscript = [configscript '.m']; end
% we assume that the configscript lies in a directory at or above the binary
tmpdir = [pwd filesep];
delims = strfind(tmpdir,filesep);
for k=length(delims):-1:1
scriptpath = [tmpdir(1:delims(k)) configscript];
if exist(scriptpath,'file')
configscript = scriptpath;
break;
end
end
if ~exist(scriptpath,'file')
error('Config script %s not found in any path relative to the binary.',configscript); end
else
configscript = which(configscript);
end
end
fprintf('running config script %s...\n',configscript);
addpath([fileparts(mfilename('fullpath')) filesep 'code' filesep 'misc']);
run_script(configscript);

% collect the variables as defined in the config script into a struct
infos = whos();
for n = {infos.name}
settings.(n{1}) = eval(n{1}); end

% load the toolbox (using code/environment/env_startup)
% (using the settings from the config script, possibly overridden by name-value pairs in varargin)
disp('running startup function...');
if ~isdeployed
cd([fileparts(mfilename('fullpath')) filesep 'code' filesep 'environment']); end

try
env_startup(settings,varargin{:},'configscript',configscript);
catch
% store a crash report for debugging in deployed cases
report.settings = settings;
report.varargin = varargin;
report.lasterror = lasterror; %#ok<*LERR>
save bcilab_crashreport report
rethrow(lasterror);
end
function bcilab(varargin)
% BCILAB startup function
%
% The startup function determines startup options according to a config file and then starts the
% BCILAB toolbox based on config options. If a file named bcilab_config.m exists in the user's home
% directory (under .bcilab) it will take precedence, otherwise the file of the same name in the
% bcilab folder will be used. The file name (or path) can also be specified directly as the first
% argument to this function.
%
% In addition, startup options can also be passed directly to this function, in the form of name-
% value pairs. These options selectively override those that are specified in the config file.
%
% Generally, the way to load bcilab is to cd into the BCILAB path, and execute this function.
% The BCILAB path should not be added to the default MATLAB path, especially *never* recursively.
%
% In:
% ConfigScript : optional file name of a configuration script (assigning values to config
% variables, see bcilab_config.m for an example)
%
% Options... : optional name-value pairs to override options; for possible options,
% see env_startup
%
% Notes:
% The config files are regular MATLAB script and may include conditional statements (depending on
% the platform used), etc. However, to allow modification of these files via the GUI, it is
% recommended to keep them simple.
%
% Examples:
% % start the toolbox using default settings (found in bcilab_config.m)
% cd /my/path/to/bcilab-0.9-beta2b; bcilab
%
% % start the toolbox, passing a particular config script
% cd /my/path/to/bcilab-0.9-beta2b; bcilab('myconfig.m')
%
% % start the toolbox, passing a particular config script, and also override a few parameters directly
% cd /my/path/to/bcilab-0.9-beta2b; bcilab('myconfig.m','data','/data','worker',true)
%
% See also:
% env_startup
%
% Christian Kothe, Swartz Center for Computational Neuroscience, UCSD
% 2010-10-30

disp('starting BCILAB...');
if mod(nargin,2) == 0
% an even number of arguments (or none) was passed -- therefore, no config script was given,
% so assume the default one
configscript = 'bcilab_config';
else
% an odd number of arguments was passed
% --> the first argument is the name of the config script
if ~ischar(varargin{1})
error('If an odd number of parameters is provided then the first parameter must be the name of a config script.'); end
configscript = varargin{1};
% ... and the rest are the options.
varargin = varargin(2:end);
end
if ~iscellstr(varargin(1:2:end))
error('The arguments to bcilab.m must be name-value pairs.'); end

% check if the user's home directory (.bcilab sub-directory) contains a bcilab_config.m, and prefer
% that if present
home = char(java.lang.System.getProperty('user.home'));
if exist([home filesep '.bcilab' filesep configscript '.m'],'file')
configscript = [home filesep '.bcilab' filesep configscript '.m']; end

if isdeployed && ~isempty(varargin)
try
varargin = cellfun(@eval,varargin,'UniformOutput',false);
catch
disp('When passing command-line arguments, make sure that strings are enclosed in '''' characters.');
disp('Otherwise, all of them will be assumed to be strings.');
end
end


% sanitize and run the config script
if ~any(configscript == filesep)
% relative path given
if isdeployed
if ~any(configscript == '.')
configscript = [configscript '.m']; end
% we assume that the configscript lies in a directory at or above the binary
tmpdir = [pwd filesep];
delims = strfind(tmpdir,filesep);
for k=length(delims):-1:1
scriptpath = [tmpdir(1:delims(k)) configscript];
if exist(scriptpath,'file')
configscript = scriptpath;
break;
end
end
if ~exist(scriptpath,'file')
error('Config script %s not found in any path relative to the binary.',configscript); end
else
configscript = which(configscript);
end
end
fprintf('running config script %s...\n',configscript);
addpath([fileparts(mfilename('fullpath')) filesep 'code' filesep 'misc']);
run_script(configscript);

% collect the variables as defined in the config script into a struct
infos = whos();
for n = {infos.name}
settings.(n{1}) = eval(n{1}); end

% load the toolbox (using code/environment/env_startup)
% (using the settings from the config script, possibly overridden by name-value pairs in varargin)
disp('running startup function...');
if ~isdeployed
cd([fileparts(mfilename('fullpath')) filesep 'code' filesep 'environment']); end

try
env_startup(settings,varargin{:},'configscript',configscript);
catch
% store a crash report for debugging in deployed cases
report.settings = settings;
report.varargin = varargin;
report.lasterror = lasterror; %#ok<*LERR>
save bcilab_crashreport report
rethrow(lasterror);
end
Loading