Package: mindaffectBCI2
This repository contains the python SDK code for the Brain Computer Interface (BCI) developed by the companyMindaffect.Online Documentation and TutorialsAvailable at:https://mindaffect-bci.readthedocs.io/InstallationTo install fromsource(currently the recommended method):Clone or download this repository:git clone https://github.com/mindaffect/pymindaffectBCIInstall the necessary bits to your local python path:change to the directory where you cloned the repository.Add this module to the python path, and install dependencies:pip install -e .To install as a python library:pip install --upgrade mindaffectBCIInstallation TestYou can run a quick test if the installation without any additional hardware by running:python3 -m mindaffectBCI.online_bci --acquisition fakedataEssentially, this run the SDK test code which simulates afakeEEG source and then runs the full BCI sequence, with decoder discovery, calibration and prediction.If all is successfully installed then you should see a window like this open up.<img src=’docs/images/mainmenu.png’ width=300>If you now press 2 you should see a flickering grid of “buttons” like below.  You should see a random one briefly flash green (it’s the target) then rapidly flicker and eventually turn blue (to indicate it’s selected.)<img src=’docs/images/selectionMatrix.png’ width=300>If all this works then you have successfully installed the mindaffectBCI python software. You should now ensure your hardware (display, amplifier) is correctly configured before jumping into BCI control.Important: FrameRate CheckFor rapid visual stimulation BCI (like the noisetagging BCI), it isveryimportant that the visual flicker be displayedaccurately.  However, as the graphics performance of computers varies widely it is hard to know in advance if a particular configuration is accurate enough.  To help with this we also provide a graphics performance checker, which will validate that your graphics system is correctly configured.  You can run this with:python3 -m mindaffectBCI.examples.presentation.framerate_checkAs this runs it will show in a window your current graphics frame-rate and, more importantly, the variability in the frame times.  For good BCI performance this jitter should be <1ms.  If you see jitter greater than this you should probably adjust your graphics card settings.  The most important setting to consider is to be sure that you  have_vsync_ <https://en.wikipedia.org/wiki/Screen_tearing#Vertical_synchronization>turned-on.  Many graphics cards turn this off by default, as it (in theory) gives higher frame rates for gaming.  However, for our system, frame-rate is less important thanexacttiming, hence always turn vsync on for visual Brain-Compuber-Interfaces!Brain Computer Interface TestIf you have:installedpyglet, e.g. usingpip3 install pygletinstalledbrainflow, e.g. usingpip3 install brainflowhave connected anopenBCI ganglion,have followedMindAffect headset layout.pdfto attach the electrodes to the back of your head.Then you can jump directly to trying a fully functional simple letter matrix BCI using:python3 -m mindaffectBCI.online_bciNote: For more information on how to run an on-line BCI,including using other supported amplifiers, see our completeon-line documentationand in particular ourtutorials section.Getting SupportIf you run into and issue you can either directly raise an issue on the projectsgithub pageFile StructureThis repository is organized roughly as follows:mindaffectBCI- contains the python package containing the mindaffectBCI SDK.  Important modules within this package are:
-noisetag.py- This module contains the main API for developing User Interfaces with BCI control
-utopiaController.py- This module contains the application level APIs for interacting with the MindAffect Decoder.
-utopiaclient.py- This module contains the low-level networking functions for communicating with the MindAffect Decoder - which is normally a separate computer running the eeg analysis software.
- stimseq.py – This module contains the low-level functions for loading and codebooks - which define how the presented stimuli will look.decoder- contains our open source python based Brain Computer Interface decoder, for both on-line and off-line analysis of neuro-imaging data. Important modules within this package are:
-decoder.py- This module contains the code for the on-line decoder.
-offline_analysis.ipynb- Thisjuypternotebook contains to run an off-line analysis of previously saved data from the mindaffectBCI or other publically available BCI datasets.examples- contains python based examples for Presentation and Output parts of the BCI. Important sub-directoriesoutput- Example output modules.  An output module translates BCI based selections into actions.presentation- Example presentation modules.  A presentation module, presents the BCI stimulus to the user, and is normally the main UI.  In particular here we have:
-framerate_check.py- Which you can run to test if your display settings (particularly vsync) are correct for accurate flicker presentation.
-selectionMatrix.py- Which you can run as a simple example of using the mindaffectBCI to select letters from an on-screen grid.utilities- Useful utilities, such as a simplerawsignal vieweracquisition- Example data acquisition modules.  An acquisition module interfaces with the EEG measurment hardware and streams time-stamped data to the hub.docs– contains the documentation.source– contains the source for the documentation, in particular this directory contains the juypter notebooks for tutorials on how to use the mindaffectBCI.online_bci.ipynb- Thisjuypternotebook contains the code to run a complete on-line noise-tagging BCI