bbci / bbci_public Goto Github PK
View Code? Open in Web Editor NEWMATLAB toolbox for Brain-Computer Interfacing (BCI)
License: MIT License
MATLAB toolbox for Brain-Computer Interfacing (BCI)
License: MIT License
from three functions in visualization
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!!!
So far can only indicate them as dotted lines (I think).
The function should check whether bbci.source.acquire_fcn is equal to @bbci_acquire_bv and if so do the recording via bv_startrecording, bv_stoprecording (unless bbci.source.record_param includes {'internal', 1}).
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).
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)
like this one:
from the functions:
stat_percentiles.m
stat_normal_cdf
nansum.m
nanstd.m
[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.
In demo_analysis_Spectra.m
H= grid_plot(spec, mnt, opt_grid_spec,'XUnit', spec.xUnit, 'YUnit', spec.yUnit);
the spcification of units should be obsolete (default of grid_plot)? Please check and remove if that's true.
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.
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
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'
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
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:
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? :)
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');
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);
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.
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.
Foo bar
def foo():
print "bar"
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
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.
Check for example the last plot that is generated in demo_analysis_ERPs. At least on my screen, the scalp maps overlay the channel labels. This may depend on the screen resolution.
The method foo
as a problem.
#!/usr/bin/env python
def foo():
print "bar"
if __name__ == '__main__':
foo()
Change: "bbci-tooblox" google group.
To: "bbci-toolbox" google group.
On the website: bbci.de/toolbox
Currently, you have to look into the help of plotutil_channel1D resp 2D. But help should be available in plot_channel.
If available, github uses the README.md
from the root of the project and shows it nicely rendered at the project page of the repository. See https://github.com/bbci/wyrm for a nice example and compare it with the puny https://github.com/bbci/bbci_public
The format of the file is markdown, and it should contain the various pointers an interested user might need to get up to speed.
I would prefer to be asked, whether I want those externals to be downloaded, i.e., make it optional based on user input.
returns the standard error .se in the wrong dimensions
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.
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
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).
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.
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.
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.
We should update the bbci.de webpage. When you google "BBCI toolbox", the you land on
http://bbci.de/toolbox/ which does not reference to github!
is my plan for the hackathon…
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.
In the newest versions of Matlab, handles to graphic objects are new, specific types of variables, while before they have just been number. This makes problems in a number of ways (don't know exactly, because I have an old version of Matlab).
util_timeind
proc_grandAverage
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 .
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.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.