Skip to main page content
U.S. flag

An official website of the United States government

Dot gov

The .gov means it’s official.
Federal government websites often end in .gov or .mil. Before sharing sensitive information, make sure you’re on a federal government site.

Https

The site is secure.
The https:// ensures that you are connecting to the official website and that any information you provide is encrypted and transmitted securely.

Access keys NCBI Homepage MyNCBI Homepage Main Content Main Navigation
. 2020 Apr 15;6(3):035023.
doi: 10.1088/2057-1976/ab6e20.

SimBSI: An open-source Simulink library for developing closed-loop brain signal interfaces in animals and humans

Affiliations

SimBSI: An open-source Simulink library for developing closed-loop brain signal interfaces in animals and humans

Alejandro Ojeda et al. Biomed Phys Eng Express. .

Abstract

Objective: A promising application of BCI technology is in the development of personalized therapies that can target neural circuits linked to mental or physical disabilities. Typical BCIs, however, offer limited value due to simplistic designs and poor understanding of the conditions being treated. Building BCIs on more solid grounds may require the characterization of the brain dynamics supporting cognition and behavior at multiple scales, from single-cell and local field potential (LFP) recordings in animals to non-invasive electroencephalography (EEG) in humans. Despite recent efforts, a unifying software framework to support closed-loop studies in both animals and humans is still lacking. The objective of this paper is to develop such a unifying neurotechnological software framework.

Approach: Here we develop the Simulink for Brain Signal Interfaces library (SimBSI). Simulink is a mature graphical programming environment within MATLAB that has gained traction for processing electrophysiological data. SimBSI adds to this ecosystem: 1) advanced human EEG source imaging, 2) cross-species multimodal data acquisition based on the Lab Streaming Layer library, and 3) a graphical experimental design platform.

Main results: We use several examples to demonstrate the capabilities of the library, ranging from simple signal processing, to online EEG source imaging, cognitive task design, and closed-loop neuromodulation. We further demonstrate the simplicity of developing a sophisticated experimental environment for rodents within this environment.

Significance: With the SimBSI library we hope to aid BCI practitioners of dissimilar backgrounds in the development of, much needed, single and cross-species closed-loop neuroscientific experiments. These experiments may provide the necessary mechanistic data for BCIs to become effective therapeutic tools.

PubMed Disclaimer

Figures

Figure 1.
Figure 1.
SimBSI shown inside the Simulink library browser. The documentation, code, and examples can be found online at https://bitbucket.org/neatlabs/simbsi/wiki/Home.
Figure 2.
Figure 2.
LSL plugin for Open Ephys GUI. The configuration shows Open Ephys connected to the RHD2000 FPGA Rhythm board (Intan Thechnologies, Inc., USA) for 30 kHz data acquisition from implanted electrodes and visualization. Every small batch of data acquired from the board is forwarded to LSL for online analysis or storage to disk.
Figure 3.
Figure 3.
EEG data acquisition and visualization. A: Simulink pipeline that uses the LSLInlet block for reading data in from the network and the Multichannel Scope block for visualization. B: LSL configuration window. C: Stream selection tool that pops up if we click on Select stream. D: Interactive figure generated by the Multichannel Scope block showing the EEG data acquired by LSLInlet.
Figure 4.
Figure 4.
Bandbass filtering example in Simulink using blocks from SimBSI and DSP libraries. Left: Processing pipeline using prerecorded data. Right: Filter design window.
Figure 5.
Figure 5.
Filter visualization tool showing the frequency response of the FIR (left) and IIR (right) filters used in the example of figure 4. The blue and orange traces represent the magnitude and phase responses of each respective filter.
Figure 6.
Figure 6.
10 sec snapshot of the output of figure 4 pipeline. The top and bottom panels show the effect of FIR and IIR filters, respectively. The eye-blink event was used to illustrate the time delay introduced by each filter. In both panels, the blue trace represents the raw data lagged by the group delay of each filter. Note that the IIR-filtered signal (yellow trace bottom panel) is obtained with a delay of only 15 msec while the FIR-filtered one (yellow trace top panel) is obtained with a delay of approximately 3.6 section Minimizing the delays introduced by the signal processing stack is crucial in applications where we need to estimate brain states and give feedback on short timescales.
Figure 7.
Figure 7.
Pipeline for real-time EEG data cleaning, source separation, and imaging using the RSBL algorithm and OpenGL viewers.
Figure 8.
Figure 8.
Python-based OpenGL real-time scalp and source viewers. Left: Scalp viewer. Reproduced from [49]. Right: Cortex viewer. Reproduced from [50].
Figure 9.
Figure 9.
Stateflow experimental design. A: Parameters of the task (top) and subject’s behavior coming through LSL (bottom). B: Trial logic coded in Stateflow.C: Multimonitor setup, one for stimulus presentation facing the subject and the other one facing the experimenter in a control room.
Figure 10.
Figure 10.
Closed-loop BCI with TMSstimulation composed of four major modules: 1) Data acquisition, 2) Alpha phase estimation, 3) Control and stimulation, and 4) Visualization. The system is designed to acquire EEG data through LSL and trigger a TMSpulse if an alpha wave is detected at the Oz channel and it is stable for at least one second. The stimulation pulse is locked to the positive peak of the EEG signal, which at that point should consist of mostly alpha rhythm activity. Each submodule is explained in the panels below.
Figure 11.
Figure 11.
Data acquisition submodule: 1) The LSLInlet pulls EEG samples from LSL at the sampling rate of the EEG acquisition device. 2) The Selector block allows us to select the subset of channels we are going to work with, which in this case is Oz. 2) The Sample and Hold block enables EEG samples to pass through while theTMSpulse is not active, otherwise, it holds the last sample acquired before aTMSpulse and resumes sampling once theTMSartifacts are gone. 4) The Spectrum Estimator block computes the Welch (or filter bank) power spectral density estimates on 1 sec windows with a 50% overlap. 5) User-defined function that sums the power in δ, θ, α, β, γ bands and outputs 1 if the maximum power is in α, otherwise, the output is 0.
Figure 12.
Figure 12.
Submodule for triggering aTMSpulse time-locked to the positive phase of the α rhythm. The bottom branch produces a Kronecker delta at the positive peak of theOz signal, say y(tk), implementing the expression diff(−sign(y (tk) − y (tk−1))). Note that to time-lock to the trough of the α-wave we just flip the sign of the unitary gain above.
Figure 13.
Figure 13.
Control submodule. Once we have determined that a TMSpulse should be delivered, in parallel we send out the trigger by the serial port and use two Monostable blocks to 1) disable the data acquisition for the time span of the TMS artifact and 2) disable the stimulation based on α-waves for a prespecifed period. This can be reconfigured depending on the stimulation protocol, e.g., single pulse, burst, and so on.
Figure 14.
Figure 14.
Left: Visualization submodule. Right: Excerpt of 2 sec data flowing through the system.
Figure 15.
Figure 15.
Animal experimental environment.
Figure 16.
Figure 16.
The BrainER GUI allows us to manage the software that runs on Pis that control several behavioral boxes that we may have in the lab. Once the GUI is first launched, it searches the network for Pi devices connected between IP addresses 192.186.0.90–150.

Similar articles

Cited by

References

    1. Liang SF, Shaw FZ, Young CP, Chang DW and Liao YC 2010. A closed-loop brain computer interface for real-time seizure detection and control 2010 Annual International Conf. of the IEEE Engineering in Medicine and Biology Society, EMBC’10 (IEEE) (http://ieeexplore.ieee.org/document/5627243/) (10.1109/IEMBS.2010.5627243) - DOI - PubMed
    1. Hurtier J, Van Dokkum L, Dalhoumi S, Coffey A, Perrey S, Jourdan C, Dray G, Ward T, Froger J and Laffont I 2016. A closed-loop BCI system for rehabilitation of the hemiplegic upper-limb: A performance study of the systems ability to detect intention of movement Annals of Physical and Rehabilitation Medicine 59 88 (https://linkinghub.elsevier.com/retrieve/pii/S1877065716302810)
    1. Burke JF, Merkow MB, Jacobs J, Kahana MJ and Zaghloul KA 2015. Brain computer interface to enhance episodic memory in human participants Frontiers in Human Neuroscience 8 1055 (http://journal.frontiersin.org/article/10.3389/fnhum.2014.01055) - DOI - PMC - PubMed
    1. McFarland DJ, Daly J, Boulay C and Parvaz MA 2017. Therapeutic applications of BCI technologies Brain-Computer Interfaces 4 37–52 (https://tandfonline.com/doi/full/10.1080/2326263X.2017.1307625) - DOI - PMC - PubMed
    1. Carelli L et al. 2017. Brain-computer interface for clinical purposes: cognitive assessment and rehabilitation BioMed Research International 2017 1–11 (https://hindawi.com/journals/bmri/2017/1695290/) - PMC - PubMed

Publication types