Giter Club home page Giter Club logo

bbci_public's Introduction

BBCI Toolbox

The BBCI Toolbox is a Brain-Computer Interface (BCI) toolbox, suitable for online experiments and offline analysis.

Documentation

The documentation is available here

Citing Us

The authors would be grateful if published reports of research using this code (or a modified version, maintaining a significant portion of the original code) would cite an article dedicated on this toolbox (to be published soon) or the following article:

Blankertz B, Acqualagna L, Dähne S, Haufe S, Schultze-Kraft M, Sturm I, Ušćumlic M, Wenzel MA, Curio G, Müller KR. The Berlin Brain-Computer Interface: Progress Beyond Communication and Control. Frontiers in Neuroscience. 2016;10. http://journal.frontiersin.org/article/10.3389/fnins.2016.00530

License

The toolbox is licensed under the terms of the MIT license.

bbci_public's People

Contributors

benjaminblankertz avatar danielmiklody avatar dnck avatar hanjeong avatar hekolk avatar i-sturm avatar irinanicolae avatar janfb avatar johanneshoehne avatar mihailbogojeski avatar mtangermann avatar svendaehne avatar venthur avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bbci_public's Issues

util_printFigure: printing to PDF

Currently util_printFigure uses a hack to produce PDFs: print to EPS first and then call a console scirpt to convert EPS to PDF (works under Linux only). But there seems to be the possibility to print directly to PDF with option -dpdf in Matlab's print function. Probably, this feature was introduced at some new Matlab version: Change util_printFigure to check the Matlab version and use the -dpdf option if available.

acq_checkTriggers multiple errors

[Line 17] inp= 2^[0:7];
causes Matlab error:
Error using ^
Inputs must be a scalar and a square matrix.
To compute elementwise POWER, use POWER (.^) instead.
Solution: change to
inp= 2.^(0:7);

[Line 47] bbci_apply_acquireData(data.source, bbci.source, data.marker);
causes Matlab error:
Undefined variable "data" or class "data.source".
Problem: "data" is a return value of "bbci_apply_initData(bbci)". However, the buggy line is inside an auxiliary function "acq_checkTrigger(bbci, inp, timeout)".
Solution: change the following lines:
[Line 21] outp{k}= acq_checkTrigger(bbci, inp(k), 500);
[Line 40] function outp= acq_checkTrigger(bbci, inp, timeout)
to:
outp{k}= acq_checkTrigger(bbci, data, inp(k), 500);
function outp= acq_checkTrigger(bbci, data, inp, timeout)

[Line 53] bbci_apply_close(bbci);
causes Matlab error:
Error using bbci_acquire_bv
bbci_acquire_bv: open a connection first!
Error in bbci_apply_acquireData (line 35)
[new_data, mrkTime, mrkDesc, source.state] = ...
Error in acq_checkTriggers>acq_checkTrigger (line 47)
[source, marker]= ...
Error in acq_checkTriggers (line 22)
outp{k}= acq_checkTrigger(bbci, data, 500);
Problem: bbci_apply_close should not be called in the auxiliary function "acq_checkTrigger", as this will close the connection before the next iteration can begin, see [Line 21].
Solution: Move the mentioned line to the bottom of acq_checkTriggers. This will close the connection after the whole function is finished.

[Line 21] outp{k}= acq_checkTrigger(bbci, inp(k), 500);
causes Matlab warning (not error):
The variable 'outp' appears to change size on every loop operation. [...]
Solution: insert the following line [before line 19]:
outp=cell(1:8);

[Line 40] function outp= acq_checkTrigger(bbci, inp, timeout)
receives a variable "inp", which is one of the values [1 2 4 8 16 32 64 128]. However, this value is unused.
[Lines 27-29] if ~isequal(inp(k), outp{k}), trigger_ok= 0; end [Lines end]
compares the value of inp(k) with the return value of acq_checkTrigger. If they are unequal a single time, trigger_ok is set to 0.
[Lines 32-36]
if trigger_ok, fprintf('Trigger test successful.\n');
else error('!!! Trigger test unsuccessful !!!\n'); end [Lines end]
will therefore always trigger an error.
I have no solution, since I do not understand what "triggers are operational" (documentation) means and how this can be determined by the code of acq_checkTriggers.

Determine range in plot_scalpEvolutionPlusChannel beforehand

In the typical use case the scalps plotted in plot_scalpEvolutionPlusChannel have a common range (option UnifyCLim set to 'global', I think). Currently, it is implemented such that each scalp is plotted individually with its own range and in the end all CLims are unified. That work well EXCEPT that the contour lines might have different spacings in each map, because that is not modified when CLim is changed. Therefore the function must be implemented such that the range of all maps is determined beforehand, and the individual maps are plotted directly with that global range.

Variance channel rejection docu/implementation differences

Hi,
in https://github.com/bbci/bbci_public/blob/45cd9349dc60cb317e260b10d46de20bf9075afa/processing/utils/reject_varEventsAndChannels.m
the documentation doesn't seem to completely match what is happening I think(?)

From reading the code I thought the cleaning process is:

  1. (Bandpass)
  2. Epoch markers
  3. Compute Variances
  4. (Remove channels with too small variance)
  5. Remove extreme outlier trials
  6. (Remove channels with too high variance)
  7. Main part, first always remove channels, then trials with too high variance (optionally multipass)
  8. (Remove trials by relative variance (variance - mean variance across channels))
  9. (Remove channels with highly varying (from trial to trial) variance)

In the documentation there is a point 6 before the main part which does not seem to exist?(https://bitbucket.org/robintibor/machine-learning-for-motor-imagery/src/d05718f585943691a8475bc315fe40cf85206d37/matlab/gold-standard/epo_reject_varEventsAndChannels.m?at=master#cl-37):

% (6) remove trails with a var > threshold, while (for opt.Whiskerperc = 10)
%       threshold = percentile(allVar, 90) + opt.Whiskerlength * diff(percentile(allVar, 10), percentile(allVar, 90))      
% (7) combined trials/channels rejection, optionally as multi-pass

Also, is it intended that there is an option RemoveChannelsFirst and in the main loop channels are also always cleaned first?

Also, in the checks

 if sum(isout(:))>0.05*nEvents,

nEvents is always the original number of trials, not the number of "still good" trials.. is this intended? :)

reordering in proc_selectChannels [Johannes]

proc_selectChannels returns an epo or cnt with an ordered list of channes. So if I ask for

cnt2 = proc_selectChannels(cnt1, {'Fz', 'Oz', 'Cz'});
then
cnt2.clab --> {'Fz', 'Cz', 'Oz'}

There should be a warning at least!!!

Part of fileutil_concatMatlab wrong. In which cases do we need that part?

Do we need the following part of fileutil_concatMatlab at all?
Anyway, it seems to me to be outdated (old svn toolbox based on samples not on time).

if ~isempty(iMrkBV),
if length(varargcat{iMrkBV})>1,
orig_fs= file_loadMatlab(file_list{ii-1}, 'vars','fs_orig');
TT(ii-1)= round(T(ii-1)/varargcat{iNfo}.fs*orig_fs);
shift= sum(TT(1:ii-1));
for ii= 1:length(varargcat{iMrkBV}),
varargcat{iMrkBV}(ii).pos= varargcat{iMrkBV}(ii).pos + shift;
end
varargout{iMrkBV}= cat(1, varargout{iMrkBV}, varargcat{iMrkBV});
else
varargcat{iMrkBV}.pos= varargcat{iMrkBV}.pos + sum(T(1:ii-1));
varargout{iMrkBV}= ...
mrk_mergeMarkers(varargout{iMrkBV}, varargcat{iMrkBV});
end
end

Add version numbers to the toolbox

Adding version numbers will make it a lot easier to refer to a certain state of the toolbox.

If we use versioning, we can use git tag, and github will automatically create downloadable zip files for each version.

I propose a versioning scheme that follows the widely accepted standard MAJOR.MINOR.PATCH. An Increase of MAJOR signifies a backwards incompatible changes, MINOR for backwards compatible changes, and PATCH for small bugfixes. See http://semver.org/ for more details.

Typo (change of function name in) acq_checkTriggers

Change misc_checkTypeifExists to misc_checkTypeIfExists in acq_checkTriggers
Matlab error message:
Cannot find an exact (case-sensitive) match for 'misc_checkTypeifExists'
The closest match is: misc_checkTypeIfExists in D:\git\bbci_public\misc\misc_checkTypeIfExists.m
Error in acq_checkTriggers (line 11)
misc_checkTypeifExists('bbci', 'STRUCT');

channel order destroyed in proc_grandAverage [Johannes]

The function proc_grandAverage puts the channels into a new (alphabetical) order. Since this is done consistently in the data (cnt.x) and cnt.clab, it is not a bug or strong problem. However, the original order should be kept as good as possible.
The problem occurs in line 116 (intersect function to get a common set of channels).

fileutil_concatMatlab three errors

A) '" opt.vars" should be "opt.Vars" like in the function "file_loadMatlab.m"

B) "opt.path" should be "opt.Path" like in the function "file_loadMatlab.m"

B) Markers are now in "time" not in "samples". Thus, "pos" should be replaced by "time", see error message below (possibly not directly, maybe further changes are required!):

Reference to non-existent field 'pos'.
Error in fileutil_concatMatlab (line 87)
varargcat{iMrk}.pos= varargcat{iMrk}.pos + sum(T(1:ii-1));
Error in file_loadMatlab (line 120)
[varargout{:}]= fileutil_concatMatlab(fullname, opt);

plot_channel should be able to indicate sem

Currently, plot_channel can only indicate standard deviation (assuming to be given as erp.std, if averaged data is provided). It should be possible to indicate alternatively standard error of the mean (SEM), which is provided as erp.se in proc_average.
This should be implemented in a general way. Similarly, it should be possible to indicate percentile levels, see issue #35 .

Please decide on a free software license

We should decide on a free software license and thereby clarify under which terms and conditions others are allowed to re-use and modify the MATLAB toolbox.

There are hundreds of licenses out there, but the choice is usually between a permissive- or a copyleft license, with the MIT- and GPL licenses being the most prominent ones (http://choosealicense.com/)

After the decision has been made we should put the full text of the license in a LICENSE file and place that file in the root directory of the project.

function to add percentiles

Similar to adding STD or SEM, there should be the possibility to add certain percentiles to EPO data. Instead of overloading the proc_average function with more functionality, I suggest to create a new function that adds(classwise!) percentiles to EPO data. The percentiles can be calculated with stat_percentiles.
Make sure, that plot_channel is able to use the percentile information (e.g. plotting tubes from 25-percentile to 75-percentile around the mean), see issue #31.

add help to plot_channel

Currently, you have to look into the help of plotutil_channel1D resp 2D. But help should be available in plot_channel.

provide a wrapper for removal of EOG activity with regression

I have some code that "cleans" continous data from EOG activity, given a clear estimate of the EOG activity from the respective EOG channels (EOGh, EOGv channels, or F10 minus F9 etc). In order to make this accessable a wrapper function needs to be written.

BUG: str_PatternMatch

proc_selectClasses > procutil_getClassIndices > str_PatternMatch:
doesn't work if the name of the class contains the characters '^' or '(' or ')', e.g. for signed r square classes

Make visutil_correctIvalsForDisplay obsolete

As far as I remember, this function was introduced due to the following dilemma: On one hand time intervals, as returned by procutil_selectTimeIntervals, are use for feature extraction (e.g., proc_jumpingMeans), for indicating time intervals as labels (in plot_scalpEvolution?), and for shading intervals grid_markInterval (private function). There were probably conflicting requirements, which which unelegantly solved by introducing the aforementioned function.

Outdated parameter in file_saveMatlab

The following warning appears when the function file_saveMatlab is used:

In file_saveMatlab at 225
Warning: Ignoring the version specified. The version flag is not required when using the '-append' flag.

Possibly, the default entry
'SaveParam' {'-v7'} 'CELL'
in the variable props can be replaced by
'SaveParam' {''} 'CELL'

Demo for validation of classification including feature selection

If the classification method includes feature selection, that has to be performed on the training set only. In the old svn toolbox, there is a demo that first shows the wrong validation (feature selection on the whole data set) which underestimates the generalization error. In a second part, the valid validation is demonstrated. That should be transferred to the new git toolbox. Please use some of the demo datasets (see other demos).

Fix layout in plot_scalpEvolution

This function should use the whole axis for the scalp maps. However, it seems to reserve space for plotting additionally a channel (as ERP), which is left blank.
Try this:

demo_analysis_ERPs
fig_set(1, 'Resize',[1 1/2]); clf
plot_scalpEvolution(epo_r, mnt, ival_scalps)

Typo on bbci.de/toolbox

Change: "bbci-tooblox" google group.
To: "bbci-toolbox" google group.
On the website: bbci.de/toolbox

Introduce 'markers' for longer blocks

For specifying longer intervals, e.g., blocks of conditions 'low workload', 'high workload'. These blocks may have different lengths. Then there should be functions like mrk_evenlyWithinBlocks that outputs a regular marker structure, with e.g., one marker every 1000ms within the given blocks with corresponding marker labels.
There were some functions (I think called blk_* in the old SVN toolbox). Not sure whether that was the best way to do it, but it is at least a reference.

Remove outdated identifier strings

like this one:
$Id: percentiles.m,v 1.4 2006/08/30 14:21:27 neuro_toolbox Exp $
from the functions:
stat_percentiles.m
stat_normal_cdf
nansum.m
nanstd.m

bug in plot_barwithAntenna

Error in line 98: "Attempted to access xdata(3,1); index out of bounds because size(xdata)=[0,0]."
compatibility problem with new matlab version

Please provide online documentation

Currently there is no online documentation available, maybe we could use the contents of the doc dir and generate the docs automatically. http://readthedocs.org looks promising and is often used for python projects. It supports markdown and the github webhooks, so we could have updated docs on every push.

Grids should be plotted over the shading of intervals

In plot_grid or plot_scalpEvolutionPlusChannel, the shading of the selected intervals (grid_markInterval) covers the grid (dotted lines). This problem should be resolved by the function plotutil_gridOverPatches.m, but in the new toolbox it does not work.

Add Matlab syntax highlighting to code examples in markdown files

Most markdown files in the doc directory come with code examples that use fenced code blocks:

```
some code
some more code
```

This signals markdown that there is code and it will format properly. But with a little more effort we can tell markdown the programming language as well and get proper syntax highlighting:

```Matlab
some code
some more code
```

I fixed one file:

https://github.com/bbci/bbci_public/blob/master/doc/ToolboxOnlineBbciApplyIntroduction.markdown

Note that the first example uses Pseudocode, and the rest is Matlab. The others should be fixed as well.

BUG: proc_appendEpochs

proc_appendEpochs > (proc_rValues) > proc_meanAcrossTime:
proc_appendEpochs (used e.g. by proc_rValues) concatenates the time vector in field .t along a third dimension for each appended epoch. is that necessary? the problem: proc_meanAcrossTime doesn't work on the resulting data structure because it assumes a 1 x nT dimensional .t

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.