Jump to content

Closed-Loop Stimulation

From BCI2000 Wiki

How do we do closed-loop stimulation in BCI2000? This page will provide a foundation to help you on your closed-loop journey. Since BCI2000 is designed to be closed-loop, implementing stimulation is relatively simple. There are only a few adjustments needed to change a closed-loop task, like the Mu Rhythm tutorial, to a closed-loop stimulation task.

Stimulator Types

There are two types of stimulators in BCI2000 which are treated distinctly for closed-loop stimulation. The main distinction is where they are in the BCI2000 pipeline.

  1. Stimulation devices: Located in the Application module, as extensions. E.g., g.tec gEstim PRO, Blackrock CereStim
  2. Amplifiers: A Signal Source module that acquires data and delivers stimulation. E.g., Cortec Brain Interchange, AlphaOmega neuromodulation system

Stimulators in the Application module can handle closed-loop stimulation seamlessly. After this is covered, we will document how we can approach the stimulators that are also amplifiers as a Signal Source module.

1) Stimulation devices

All the stimulators have a parameter that triggers the stimulation based on a BCI2000 Expression. This can use the incoming signal or state. Since the stimulator is in the Application module, which is after the Signal Processing, the incoming signal can be processed appropriately to trigger stimulation however you like.

For example, if you want to stimulate using the standard SpectralSignalProcessing, you can format the output to be a single channel corresponding to the average power of a frequency band. Therefore, this output signal, also called the control signal, can be used in a BCI2000 Expression to trigger stimulation with a simple threshold: Signal(1,1)>100.

Similarly, a BCI2000 State can be used in the Expression to trigger the stimulation.

2) Amplifiers with stimulation

Please read #1 first, as all the information is relevant. The only difference is that we can't directly use the control signal (the signal from the Signal Processing pipeline), as the stimulation is located as a SignalSource. See the sidebar image for reference.

The Source module accesses past States, not past Signals

Therefore, we need an adaptable way to transfer the Signal to States. This is done with the ControlStateFilter. The parameter ControlExpression replaces the Trigger Expression of the stimulator, where if the Expression is true, the new state ControlState is 1, and when it is false, the ControlState is 0. Then in your Trigger Expression of the stimulator, ControlState can simply be used.

To improve flexibility, the ControlStateFilter also has a RefractoryPeriod parameter, which defines the minimum time needed between true occurrences of the ControlState. With these two parameters, any SignalProcessing pipeline can be used before it, and the results can be passed to the stimulator in the Signal Source.

Tutorial Video (with Cortec BIC)

Since CortecADC is a source module, stimulation is conducted in the source module. This example uses an alternate method to the ControlStateFilter by harnessing the power of the EarlyOffsetExpression available in the StimulusPresentation Application module. This allows you to change stimuli once the processed signal meets a certain condition. You would set up the stimulation to be triggered once the new stimulus is reached, due to EarlyOffsetExpression becoming true.