Abstract
Targeted interrogation of brain networks through invasive brain stimulation has become an increasingly important research tool as well as therapeutic modality. The majority of work with this emerging capability hasbeen focused on open-loop approaches. Closed-loop techniques, however, could improve neuromodulatory therapies and research investigations by optimizing stimulation approaches using neurally informed, personalized targets. Implementing closed-loop systems is challenging particularly with regard to applying consistent strategies considering inter-individual variability. In particular, during intracranial epilepsy monitoring, where much of this research is currently progressing, electrodes are implanted exclusively for clinical reasons. Thus, detection and stimulation sites must be participant- and task-specific. The system must run in parallel with clinical systems,inte-grate seamlessly with existing setups, and ensure safety features are in place. In other words, a robust, yetflexible platform is required to perform different tests with a single participant and to comply with clinical requirements.
In order to investigate closed-loop stimulation for research and therapeutic use, we developed a Closed-Loop System for Electrical Stimulation (CLoSES) that computes neural features which are then used in a decision algorithm to trigger stimulation in near real-time. To summarize CLoSES, intracranial electroencephalography (iEEG) signals are acquired, band-pass filtered, and local and network features are continuously computed.If target features are detected (e.g. above a preset threshold for a certain duration), stimulation is triggered. Not only could the system trigger stimulation while detecting real-time neural features, but we incorporated a pipeline wherein we used an encoder/decoder model to estimate a hidden cognitive state from the neural features.
CLoSES provides a flexible platform to implement a variety of closed-loop experimental paradigms in humans. CLoSES has been successfully used with twelve patients implanted with depth electrodes in the epilepsy monitoring unit. During cognitive tasks (N = 5), stimulation in closed loop modified a cognitive hidden state on a trial by trial basis. Sleep spindle oscillations (N = 6) and sharp transient epileptic activity (N = 9) were detected in near real-time, and stimulation was applied during the event or at specified delays (N = 3). In addition, we measured the capabilities of the CLoSES system. Total latency was related to the characteristics of the event being detected, with tens of milliseconds for epileptic activity and hundreds of milliseconds for spindle detection. Stepwise latency, the actual duration of each continuous step, was within the specified fixed-step duration and increased linearly with the number of channels and features.
We anticipate that probing neural dynamics and interaction between brain states and stimulation responses with CLoSES will lead to novel insights into the mechanism of normal and pathological brain activity, the discovery and evaluation of potential electrographic biomarkers of neurological and psychiatric disorders, and the development and testing of patient-specific stimulation targets and control signals before implanting a therapeutic device.
Keywords: Closed-loop, Direct electrical stimulation, Neuromodulation, intracranial EEG
1. Introduction
Neuromodulation with the use of direct electrical stimulation is a successful therapeutic approach for movement disorders (Lozano et al., 2019),pain (Levy et al., 2010), epilepsy (Morrell, 2006) and possibly for psychiatric disorders (Widge et al., 2018b). Currently most clinical approaches to parameter adjustment are based on either a trial-and-error parameter optimization protocol or a protocol based on clinician experience. There are some systematic investigations of parameters, primarily in relation to DBS for movement disorders, but these remain relatively sparse at this point. Success is often measured on subjective appreciation of symptoms instead of a direct biomarker measuring the effect of stimulation in the brain. A wider variety of diseases could benefit from neuromodulatory approaches, but the effect of stimulation on human electrophysiology and the modulatory effect of stimulation on brain activity needs to be thoroughly investigated to inform the field on how to proceed (Lozano et al., 2019; Widge et al., 2017).
Most therapeutic stimulation devices provide continuous open-loop stimulation. Open-loop paradigms consist of trains of direct electrical stimulation pulses that are delivered with an intermittent schedule. An exception is the RNS system (NeuroPace Inc, Mountain View, CA), that stimulates when a seizure is detected. It is the only closed-loop, or responsive, stimulator device approved by the FDA. Even in this case, it is not clear whether the effect is related to the closed-loop approach or simply to a long-term neuromodulatory effect of stimulation (Kokkinos et al., 2019). While the technology built into the RNS is in-deed impressive it ultimately is designed for a low channel count system and a fixed and relatively simple set of feature analysis.
Closed-loop brain stimulation paradigms allow optimizing stimulation approaches using targeted, informed, and personalized therapeutic strategies that could achieve better therapeutic results than open-loop stimulation as well as help understand underlying mechanisms. As stimulation can have very different effects with different brain states, brain regions, and pathological events, real time detection of these neural sig-natures during different brain states combined with stimulation can allow us to understand the ongoing networks. Detecting these brain states and applying the appropriate stimulation at the right time in the appropriate target could result in important therapeutic benefits including achieving better results, with fewer side effects, and longer battery life (Sun and Morrell, 2014; Tinkhauser et al., 2017). A flexible platform is needed to systematically perform diverse closed-loop tests in a clinical setting.
Most clinical research investigations in humans with semi-chronic implanted electrodes to localize the region responsible for seizure generation use open-loop direct electrical stimulation. For instance, during the intracranial pre-surgical workup of patients, electrical stimulation is helpful for functional mapping and to delineate the epileptic focus (Trébuchon and Chauvel, 2016). With open-loop stimulation, clinicians try to elicit the patient’s typical aura or seizure or look for regions with low thresholds to produce epileptiform after-discharges. As a research probe, single-pulse electrical stimulation (SPES; Valentín et al., 2002) or stimulation trains aim to understand neural mechanisms and test network connectivity (Matsumoto et al., 2006; Trebaul et al., 2018) by quantifying the brain’s evoked response to stimulation, referred to as cortico-cortical evoked potentials (CCEPs; Matsumoto et al., 2004). Re-sponse to SPES varies depending on stimulation site and applied charge (Trebaul et al., 2018). Furthermore, modifying train stimulation parameters showed a nonlinear relation between stimulation response and frequency and a linear relation with current (Basuetal.,2019).These studies suggest intriguing characteristics of the brain’s response to stimulation and a possible effect of underlying rhythms. However, because stimulation occurs at random times, there is intrinsic low specificity when trying to study particular rhythms or cognitive states which results in imperfect, noisy measures and requires a large number of stimulations. Instead, we are proposing a closed-loop system which could have higher sensitivity and specificity to electrographic biomarkers.
Technological advances have fostered an increase in closed-loop neuroscience tests. Open source software such as Open Ephys (Siegle et al., 2017)and BCI2000(Schalk et al., 2004) and hardware development of wireless implantable devices (Zhou et al., 2018) are greatly advanc-ing the field. Substantial work in brain computer interfaces (BCI) in animals (reviewed in Fetz, 2015) and patients with implanted Utah electrodes in motor regions have achieved volitional motor control (Ajiboye et al.,2017; Bouton et al., 2016; Hochberg et al., 2006) and improved task performance (Katnani et al., 2016) through closed-loop strategies. Different feedback mechanisms have been used to close-the-loop (Wright et al., 2016). Feedback could be obtained from visual observation of movement (Hochberg et al., 2012), motion sensors (Espay et al.,2010), electromyography (EMG) activity (Kuiken et al., 2009; Nishimura et al., 2013), and, of particular interest to our work, neural activity (Ajiboye et al., 2017; Nishimura et al., 2013). Closing the loop to neural signals, by stimulating the brain following neuronal changes, creates a fully integrated feedback system but it is also very challenging (Krook-Magnuson et al., 2015). Most of the work in this realm focused on detecting single or multi-unit activity from neuronal ensembles (Collinger et al., 2013). However, intracranial local field potentials (LFP) measured with clinical macro-electrodes provide stable recordings for longer periods than single/multi-unit recordings (Flint et al., 2012). Therapeutically, LFP event detection reduces seizure occurrence (Morrell, 2006) and LFPs have been considered as control signals for closed-loop control in movement disorders (Tan et al., 2019; Tinkhauser et al., 2017) and pain (Shirvalkar et al., 2018).
Closed-loop tests in humans could answer basic research questions and improve neuromodulatory therapies, but their implementation adds another layer of challenges (Caldwell et al.,2019). Developing systems that detect neural features and stimulate in real-time, deployed in the epilepsy monitoring unit (EMU) has technical, experimental, and design challenges. The technical challenges include: 1) the need to use continuous intracranial EEG (iEEG) activity which is recorded in a relatively noisy environment; 2) filtering at a variety of frequency bands; 3) implementing different control algorithms, such as power, coherence or cross-frequency coupling within the same framework; 4) ensuring low latency to detect and stimulate within the same physiological or pathological event; 5) guaranteeing precise processing times for seamless closed-loop operations; 6) implementing safety safeguards; and 7) ensuring reproducible tests. Experimental challenges during intracranial epilepsy monitoring, are due to variability in electrode locations implanted exclusively for clinical reasons and patients having different etiologies. There is little experimental control of specific channel locations, which vary across patients. Thus, detection and stimulation sites must be participant-and task-specific. Furthermore, the experimental paradigm involves hundreds of potential detection channels. This is challenging but could also be an advantage. With a flexible closed-loop system platform, different experiments could be performed with a single participant. In addition, the system would optimally run in parallel to clinical systems in different hospital rooms (e.g. epilepsy monitoring unit, intensive care unit, operating room) and integrate seamlessly with existing setups. From a design perspective, for the system to be useful for investigators and clinicians with different levels of technological ex-pertise, it is important to: 1) have an easy to use intuitive interface; 2) easily switch across experimental paradigms, each with task and participant specific channels, features, or state models; 3) have real-time visualization of ongoing iEEG activity, features, thresholds, detections and stimulation to allow confirmation of accurate experimental setup and manual parameter adjustment in real-time; 4) allow investigators to visualize stimulation-locked average iEEG activity to ensure that responses to stimulation can be obtained; and 5) allow for offline replay of the data to customize parameters and train algorithms.
To overcome these challenges, we introduce a Closed-Loop System for direct Electrical intracranial Stimulation (CLoSES), a general-purpose platform based on real-time decoding of intracranial brain signals. CLoSES fills a critical niche between animal investigations where highly flexible equipment can be used without regulatory constraints and implantable therapeutic devices in humans where the degrees of freedom are very limited. CLoSES provides a new tool to precisely probe the human brain, solving the need of a general framework tailored for the unique space of iEEG recordings in humans.
In the methods section, we describe CLoSES’ software and hardware design, together with a pipeline for closed-loop tests in humans. In the results section, we present four applications where we implemented and utilized the system in humans in the EMU and discuss performance ca-pability. Finally, in the discussion, we summarize the system’s configuration, strengths, and weaknesses and discuss its place in burgeoning avenues of basic and clinical neuroscience research.
2. Materials and methods
We developed a Closed-Loop System for Electrical Stimulation (CLoSES) that computes neural features which are, in turn, used in a decision algorithm to trigger stimulation in near real-time. To ensure fixed processing times, CLoSES runs on a dedicated Simulink Real-Time (MathWorks, Natick, MA) computer. This allows iEEG acquisition and processing (filter, compute features, detect) every millisecond. A separate computer runs the graphical user interface (GUI) for configuration and real-time visualization. CLoSES seamlessly runs in parallel with 24/7 clinical and research acquisition systems, avoiding interference with clinical equipment in the EMU. CLoSES accepts ancillary inputs that can be used to trigger threhold updates, feature calculation, and stimulation time. Offline replay of previously acquired datasets allows parameter optimization and feature analysis. This is useful to obtain patient- and task-specific features, parameters, and models. Implemented safety features are of importance to ensure controlled stimulation delivery as CLoSES is utilized in the hospital setting.
Fig. 1 shows the general hardware diagram of the complete rack-mounted system. It consists of the iEEG acquisition hardware; a presentation computer to run cognitive tasks; a stimulation system that sends a stimulation pulse or train upon receiving a stimulation trigger; and the closed-loop system, CLoSES, which is described in detail in this manuscript. CLoSES is composed of a Windows host computer and a dedicated target computer with Simulink Real-Time kernel. The host computer allows GUI visualization, data saving and configuration, while the target computer ensures fixed time processing for real-time computation.
Fig. 1. A) Schematic of closed-loop experiments. B) Example of CLoSES in the EMU.
The closed-loop system consists of intracranial EEG acquisition, a stimulation system, a computer to present cognitive tasks, and CLoSES. CLoSES is composed of a GUI for visualization, data saving, and configuration (host, that runs under Windows) and a dedicated target computer with Simulink Real-Time kernel to ensure fixed time processing for real-time computation. The iEEG data are acquired in parallel by the clinical system, the 24/7 research acquisition equipment, and CLoSES. Green arrows indicate iEEG data, blue arrows are related to task, orange arrows are related to stimulation. Dotted arrows indicate ancillary inputs (AINPs).
Two modes of operation were implemented: Real-Time CLoSES (CLoSES-RT), to stimulate in real-time following continuous neural feature detection and CLoSES with Neural State Estimate Encoder/Decoder Model (CLoSES-SEM), to stimulate triggered by decoded hidden states during trialed cognitive tasks.
The complete source code for these CLoSES variants are available on GitHub (https://github.com/Center-For-Neurotechnology, CLoSES-SEM and CLoSES-RT repositories), along with instructions for compilation and deployment. CLoSES is licensed under the BSD 3-Clause Clear License. Depending on the specific hardware involved, specific manufacturer software development kits (SDKs) may also be needed. For instance, the examples here used datagram decryption and stimulator control libraries from Blackrock Microsystems (Salt Lake City, UT).
2.1. CLoSES-RT: stimulate in near real-time following neural feature detection
In CLoSES-RT, iEEG brain signals are acquired, re-referenced as needed, band pass filtered, and neural features continuously computed. Implemented features include coherence across channels and multiband power per channel. These features are computed at each time step as an average over a time interval. As in a particular previous application (Sarma et al., 2016), we implement a dual-threshold control algo-rithm: if features are above (below) the upper (lower) threshold for a certain duration, stimulation is triggered. Thresholds can be manually adjusted or dynamically updated. Stimulation can occur following detection, after a fixed delay, or at the time of an external input. To study the effect of stimulation at the time of a spontaneous event, it is possible to compare detected and stimulated events to interleaved random stimulation and to detected events that were not stimulated. The rate of random stimulation and the percentage of detections that produce stimulation can be specified. The fixed step size can also be modified (default is 1 ms). Safety refractory periods prevent semi-continuous stimulation and an initial block-out period ensures stimulation occurs only under stable software and hardware conditions. Offline replay of data allows parameter optimization and channel selection. Fig. 2.A shows the block diagram of CLoSES-RT and Fig. 2.B an example of GUI visualization while CLoSES-RT is running in the EMU.
Fig. 2. Diagram and GUI of CLoSES-RT and CLoSES-SEM.
A) Diagram of CLoSES-RT. Neuronal iEEG signals are acquired, re-reference, band-pass filtered, and features computed in real-time. In the example, when power in detection channel is above threshold for certain time (20 ms), a stimulation pulse is sent. The detection process is repeated every millisecond. B) CLoSES-RT GUI showing ongoing neural activity during an experiment in the EMU. Intracranial EEG activity, features, threshold, detections, and stimulation of selected channels are updated every 100 ms. When stimulation occurs, the averaged iEEG plot is also updated. Most common configuration parameters can be selected in the right panel. C) Diagram of CLoSES-SEM with neural decoder model. Intracranial EEG signals are continuously acquired and band-pass filtered. Following image onset trigger, features are continuously computed. After a specified interval (default: 2 s), features are averaged in epochs and provided as input to the neural decoder model to estimate cognitive state. In the example, when mean state estimate is above threshold a stimulation train is sent at the time of the following image onset. D) CLoSES-SEM GUI showing ongoing visualization. iEEG, detection, and stimulation data are updated every 100 ms. Aver- aged features, state and threshold are updated every trial. Most common configuration parameters can be selected in the right panel. Blue boxes indicate continuous steps, green boxes indicate once per trial steps, boxes with arrows indicate external events.
2.2. CLoSES-SEM: stimulate following decoded cognitive state
In the case of CLoSES-SEM, a state-space model (Yousefi et al., 2019a) estimates the brain’s “state” from online recorded iEEG during the performance of cognitive tasks. That is, at each trial, features (power, log power or coherence) are continuously computed as in CLoSES-RT, but are then averaged for specific task related epochs, and are passed to a model to compute a cognitive hidden state. If decoded state exceeds (is below) threshold, stimulation is triggered. The model could range from a simple weighted combination of averaged features toan encoder/decoder model based on the assumption that it is possible to decode the latent-variable, or unobserved cognitive state of the brain, from neuronal activity (Yousefi et al., 2019a). The model (or any other model) can be optimized offline on non-stimulation and/or open-loop stimulation task data. Fig. 2.C shows the block diagram of CLoSES-SEM and GUI visualization. Table 1 summarizes the common steps and differ-ences between CLoSES-RT and CLoSES-SEM default mode of operation.
Table 1.
Comparison of operation for CLoSES-RT and CLoSES-SEM approaches.
| Common Steps | ||
| Acquisition | Continuously acquire intracranial electrical brain signals from NSPs or Acquisition boards. | |
| Montage | Create Bipolar or Referential Montage. | |
| Filters | Band-Pass Filters. | |
| Features | Compute Features (power, coherence). | |
| CLoSES-RT | CLoSES-SEM | |
| Control Signal | Compute Features continuously. | Compute Features per trial, averaged over time epochs, and a neural encoder/decoder model estimates a hidden state. |
| Detection | If features > threshold for certain duration. | If decoded state > threshold. |
| When to send stimulation | Trigger stimulation in real-time. | Stimulation occurs on the following trial. |
| Comparison | Interleaved Random stimulation. | Stimulation not linked to state variable. |
| Processing | Fixed steps = 1 ms. | Fixed steps = 10 ms. |
| Safety | 2 sec refractory period. | Stimulate only N out of every M trials. |
2.3. Graphical user interface
We developed a GUI for parameter configuration and near real-time visualization. For CLoSES-RT, iEEG, features, thresholds, detection, and stimulation signals are updated continuously (default every 100 ms; Fig. 2.B). For CLoSES-SEM, iEEG, detection, and stimulation data are updated continuously. Features, thresholds, and state estimate (mean and boundaries) are updated every trial (Fig. 2.D). In addition, real-time update of stimulation averaged iEEG under different conditions (e.g. random or detected events) helps visualize the response to stimulation. In this way, the effect of stimulation on the brain can be visualized as the test progresses. An advantage of using a MATLAB environment is that all figure functionalities are available.
The right panel allows parameter configuration of the most common parameters (Fig. 2.B & 2.D). In addition, all parameters can be specified through patient and task specific configuration files that load as initial values in the GUI. For a complete list of parameters see supplementary online material and online manual on GitHub release. Supplementary videos V1 and V2 show examples of GUI operation during offline replay data.
2.4. Intracranial EEG data acquisition
CLoSES can flexibly acquire data from multiple common human electrophysiology systems. Two acquisition inputs have been developed: Ethernet Network acquisition from BlackRock neural signal processors (NSPs) and National Instruments analog input card (NI, Austin, TX). The modular approach allows other input blocks to be added with minimal changes to the original design.
Ancillary analog inputs (AINPs), that are acquired together with the iEEG data, can be used as event markers or triggers. These inputs can indicate when to start computing features, when to update thresholds and when to stimulate. For instance, during cognitive tasks, features can be computed for each trial from the beginning of a trial (the input is referred to as image onset, when image appears) and stimulation could occur at the time of the following trial (following image onset).
Outputs from CLoSES, indicating stimulation and detections, can also be connected to AINPs. This is useful to avoid detections immediately following stimulation, to implement safety constrains, and to compute stimulation-locked averages. If another computer is calculating an important feature, e.g. a task performance variable estimated directly from behavior (Paulk et al., 2020) can be connected to another AINP for si-multaneous real-time visualization of neuronal and behavioral state es-timates.
2.5. Channel selection and montage generation
iEEG is acquired referenced to one of the leads. The acquired iEEG signal could be used in referential montage or re-referenced to bipolar montage. A bipolar montage is useful to cancel noise and focus on local characteristics recorded by iEEG. A referential montage is particularly useful when stimulating and recording from a small region. As an example, during closed-loop detection in the hippocampus, where only three contacts of the shaft are within the region of interest, we can use one contact for detection and the consecutive two contacts for bipolar stimulation. Bipolar montages are usually created from consecutive contacts within an electrode shaft, but different contact combinations could be specified in the configuration file or selected on the GUI. This can be useful to detect around stimulation contacts or if a contact is bro-ken. Similarly, the AINPs channels where stimulation return, behavioral data, or image onset trigger are connected could be specified. Triggers are detected as rising edges.
2.6. Filters
The following EEG traditional frequency bands have been implemented: Theta (3–9 Hz), Alpha (8–15 Hz), Spindles (11–15 Hz), Beta (15–30 Hz), LowGamma (30–55 Hz), HighGamma (65–110 Hz), and Ripple (80–200 Hz). Causal Infinite Impulse Response (IIR) Butterworth filters and Finite Impulse Response (FIR) filters were implemented.In the examples IIR were selected to reduce processing time (with low filter order: 2–32). A refractory period following stimulation reduces the contribution of stimulation artifacts. Multi-band filter banks are easily implemented as a parallel combination of filters. For instance, during the multi-source interference task (MSIT), we combined Theta, Alpha and HighGamma filters. See supplementary materials section “Filters Characteristics” for detailed filter characteristics. These filters are provided as reference but will likely be modified for specific applications. For instance, for sleep spindle detection we modified the alpha filter to create a “spindle ” filter.
2.7. Features
Currently the following features are implemented: smooth power, log power, and coherence. Given the modularity of the system, new features can be easily added or combined. Features are computed continuously at every step, following time domain band-pass filtering of the iEEG. The smooth power feature is obtained as the running average of the root mean square of the band-pass filtered signal, over a specified time interval. This averaging interval means that at each time point the smooth power value is the average power of the previous samples. In Log power, logarithm is applied to obtain a normally distributed signal. Coherence is also computed continuously. At each time point the coherence value is computed buffering previous samples. Depending on the feature, the calculation is bounded (e.g. 0–1 for coherence) or not. In CLoSES-SEM, features are then averaged per specified epoch within the window of analysis (e.g. there could be four 500 ms epochs in the two seconds following image onset) and used as input to the decoder model. Like most other aspects of CLoSES, additional features can be easily incorporated.
2.8. Decoder model
Decoder model complexity ranges from a simple weighted combination of features to a neural encoder-decoder model created with COMPASS software package (Yousefi et al., 2019a, 2019b) To select optimal features and train the model, features of a large number of channels are computed with the offline CLoSES-SEM Simulink software, using replay of datasets acquired during prior test runs with the participant. During the closed-loop online tests, one-step decoding is based on averaged real-time calculated features, with the model parameters and channels selected from this offline training. Given CLoSES modularity, new models could be easily incorporated.
2.9. Detectors
In CLoSES-RT, detection occurs if a threshold is crossed in the selected direction/s for a specified number of samples. Thresholds can be updated in a variety of ways (Table 2).
Table 2.
Threshold update implementation options.
| Threshold Updates |
|---|
| Fixed – Can be modified in Real-Time |
| Based on EEG triggers - e.g. before each trial |
| Periodically – e.g. Every minute |
| After N stimulations |
| After N stimulations or after X sec without stimulation |
In CLoSES-SEM, detection occurs based on the mean, upper and/or lower confidence bounds of the estimated state. To achieve bidirectional control, different pairs of stimulation channels can be configured in the GUI. For instance, if upper state bound is above the upper threshold, stimulation is delivered on bipolar pair one, if lower state estimate bound is below the lower threshold, stimulation is delivered on bipolar pair two.
2.10. Stimulation and safety
A stimulation pulse trigger is sent from the parallel port when detection occurs, after a fixed delay, or upon receiving a trigger from an ancillary external input following detection (Table 3). For instance, during cognitive tasks stimulation can be sent at the beginning of the following trial to test the hypothesis that future behavior could be modified with stimulation triggered by the present state.
Table 3.
Stimulation and safety options.
| Stimulation can be sent: |
| In real time |
| At a triggered future time (e.g. next trial) |
| With fix delay after detection |
| With fix delay after trigger |
| Multi-Site detection: |
| Stim on channel A if State > upper threshold |
| Stim on channel B if State < lower threshold |
| Safety: |
| Refractory period (e.g. 2 s between stimulation) |
| N out of M trials (e.g. 5 out of 10 trials) |
| Stimulation is blocked at start of tests (e.g. for 3 sec) |
For safety reasons, a ‘block out’ period at the beginning of the test and a refractory period (default two seconds) in which stimulation cannot occur can be configured. In addition, only N out of M trials can be stimulated. (Table 3).
2.11. Replay simulations vs. real-time data acquisition
All processing and control algorithms are the same for offline replay and real-time operation. Replaying of previously acquired datasets is useful to select features, for model training, to analyze parameters, and for visualization. In addition, it allows for comparisons of algorithms and detection strategies. For replay to be useful, it must produce the same features and make the same decisions regarding when to stimulate as in the real-time system in the EMU. Thanks to the modular system design, we can ensure that the exact same algorithms are applied in the offline and online situations. By design, only the input block is different when doing real-time acquisition and processing or replaying previously acquired data. Depending on the acquisition system, acquisition delay must be considered when comparing offline replayed and acquired data (for our setup see Performance section). Importantly, replay simulations can be run on any Windows computer (Simulink Real-time requiresa dedicated computer or Windows operating system). As this is a replay, there is no limitation on processing time per step. It is possible torun any number of channels and features, which is particularly important to train the encoder model with features generated exactly in the same way as will be obtained during the closed-loop tests. Participant and task specific configuration files are usually created after analyzing replay of data acquired during non-stimulation (training) days.
2.12. Fixed-step time implementation and latency analysis
In CLoSES-RT, near real-time processing is needed as detection is based on spontaneous neural features. To ensure repeatable results, fixed processing times are required. We therefore configured CLoSES-RT to have a default 1 ms fixed-step time. Thus, iEEG acquisition, channel selection, montage, band-pass filtering, feature calculation, and detection should occur every millisecond. This is an important characteristic for a closed-loop system that operates in near real-time.
In CLoSES-SEM, during cognitive tests organized in trials, it is possible to either stimulate in real-time following detection or when an ancillary input indicates a new trial. In the latter condition, which is the most common implementation, the real-time constraint can be relaxed for steps that only occur once per trial.
We therefore configured CLoSES-SEM to have a default 10 ms fixedstep, removed the fixed-step constraint in the decoder model block,and added rate transitions and buffers to ensure a robust implementation. This processing speed is below most BCI implementations (Wilson et al., 2010). Executing a step of the decoder model could take longer, since this step is computed only once per trial, at the end of the continuous feature calculation. Thus, the system has time to recover until the following cognitive task trial.
Performance information, recording the actual duration of each step, was saved in the host computer together with the iEEG data. This was useful for latency analysis and to find areas of improvement for each application.
2.12.1. Stepwise latency
To ensure repeatability the system must perform within the specific fixed-step duration. Using performance data, we analyzed the actual latency of each type of step. We evaluated whether per-step latency increased linearly with the number of channels and features. We computed histograms of actual latency for each step to assess whether they were within the specified fix-step duration (1 ms or 10 ms). We tested CLoSES-RT for 3, 5, 6, and 10 channels. We tested CLoSES-SEM for 10, 20 and 50 channels for power calculation (30, 60, and 150 features) and for 5, 10 and 20 channels for coherence (10, 45, and 190 pairs). This is more channels and features than would be used in practice in an implantable system, as usually 5–10 channels are selected and only a subset of features is used in the models (Widge et al., 2017, Basu et al., 2020).
2.12.2. Total latency
Total calculated latency of continuous steps (CalcLatency) is the com-posite of acquisition latency (LAcq) plus filter group delay (LFilter), feature calculation lag (LFeatCalc), and detection interval (LDetect), times the fixed-step duration (FixStep).
This is the maximum calculated latency and would correspond to the first sample used in the detection. Depending on threshold value, detection could start before LFeatCalc lag, reducing the actual latency. Hardware stimulator delay was 2 μs (Blackrock, personal communica-tion) and is ignored in subsequent analyses. When using Blackrock acquisition through Ethernet, LAcq was 6–7 ms. Importantly, the stepwise latency analyzed in the previous section must be below the fixed interval for all the continuous steps for this calculation to be meaningful.
We compared total calculated latency and actual latency (i.e. from start of an event to detection), for synthetic data and spindles detected in the EMU. For the synthetic data test, 20 sinewave bursts plus back-ground noise signal (12 Hz frequency, 3 mV peak to peak amplitude, 1 s duration bursts, ~2 s inter burst interval) were used as input. To perform these experiments in the same setup as the EMU experiments, we used the rack system and input the sinewave bursts through BlackRock’s amplifiers. Sinewave burst start time was estimated by first finding the first peak of each burst, and then finding the last negative value of the signal derivative before that peak. In other words, by finding the point just before sustained increase leading to the first peak of the sinewave burst. For the comparison for EMU spindle detection, an expert EEG reader (SSC) blinded to the calculated latencies retrospectively marked the start of 40 spindles acquired with CLoSES during EMU closed-loop to spindle experiments in two participants. The actual latency (ActualLatency) is the time of detection minus this estimated starting point. The difference between CalcLatency and ActualLatency was computed. Median and range are reported.
2.13. Pipeline for closes tests in humans
As important as developing a platform for closed-loop stimulation was to implement a pipeline for closed-loop tests with human participants in the EMU. In these cases, patients typically stayed for 7–15 days to record enough seizures via intracranial leads. For our work, research stimulation tests were performed only after the clinical team obtained all the relevant clinical information and following restoration of antiepileptic medication (usually the day before electrode explanta-tion). Safety testing of possible stimulation channels, consisting of the same stimulation parameters (SPES or trains) at intensities up to 7 mA, was performed before CLoSES tests. An experienced epileptologist re-viewed the iEEG online to ensure that no after-discharges were elicited. After each stimulation block, the participant was asked if s/he felt any-thing. Only if the iEEG did not indicate aberrant neural activity and the participant did not experience any subtle sensation, was the site eligible for CLoSES-driven stimulation. For all subsequent testing a trained electroencephalographer and clinician was present and able to immediately stop the experiment if there were any symptoms or concerning changes to the EEG.
2.14. Participants
Closed-loop tests were performed in twelve patients with semi-chronic electrodes implanted exclusively for clinical reasons at the Massachusetts General Hospital (MGH) or Brigham and Women’s Hospital (BWH). Depth electrodes (Ad-tech Medical, Racine WI, USA, or PMT, Chanhassen, MN, USA) with diameters of 0.8–1.0 mm and consisting of 8–16 platinum/iridium-contacts 1–2.4 mm long were stereotactically placed for seizure localization. iEEG was acquired with a Blackrock system at 2 kHz sampling rate (Blackrock Microsystems, Salt Lake City,UT, USA) referenced to a scalp contact.
A Cerestim stimulator (Blackrock Microsystems) was used. Individual biphasic pulses were 90 μs long each with 53 μs inter-stimulus interval. Interictal discharges (IID) and spindle tests used SPES. Cognitive tests used 130 Hz or 160 Hz trains. Current intensity was 2–7 mA, de-cided during open-loop safety testing.
2.14.1. Ethics statement
All patients voluntarily participated after fully informed consent ac-cording to NIH and Army Human Research Protection Office (HRPO) guidelines as monitored by Partners Institutional Review Board (IRB). Participants were informed that participation in the tests would not al-ter their clinical treatment in any way, and that they could withdraw at any time without jeopardizing their clinical care.
3. Results: examples of application
In this section we illustrate the use of CLoSES by providing example of applications of CLoSES-RT and CLoSES-SEM. CLoSES has been tested in twelve participants with implanted depth electrodes in the EMU during pathological IIDs (N=9), physiological sleep spindles (N=6), cognitive flexibility (N=3), and emotion conflict resolution (N=3) trial-based tasks. We first provide examples of CLoSES-RT during IIDs detection and sleep spindle detection. In these examples, processing time step wasset to 1 ms, and stimulation was sent in real-time. We address the performance through a series of analyses including the limitations and extent of the latencies from the time of acquisition to calculated features and stimulation in the CLoSES-RT system. Subsequently, we present examples of CLoSES-SEM during the multi-source interference task (MSIT) and emotion conflict resolution (ECR) task. In the these examples, processing time step was set to 10 ms and stimulation was sent on the following trial. Latencies from acquisition to stimulation were also measured in the CLoSES-SEM set up. These examples illustrate the flexibility of CLoSES in various experimental paradigms.
3.1. Application #1: CLoSES- RT detecting interictal discharges in epileptic tissue
The goal was to examine the association between IID events and brain excitability by delivering stimulation during detected IIDs (Sarma et al, 2016). We assessed the effects of SPES stimulation on IIDs and the effect of IIDs on CCEPs following SPES, across different brain ar-eas. These large amplitude short-duration events were detected with the following parameters in CLoSES-RT: unfiltered iEEG, smooth power (5–10 ms window average), detection occurred if power was above threshold for a duration of 10–25 ms. When an IID was detected, SPES was delivered to an adjacent bipolar channel pair in real-time to stimulate during the large epileptic spike or with a fixed delay to stimulate during the slow wave. The delay was estimated for each patient using offline replay of previously acquired data. When detecting IIDs, only one or a few channels are of interest. Fig. 3 shows examples of detected and stimulated IIDs, random stimulation, and detected but not stimulated IIDs. In the first example, IIDs were detected in referential montage in the deepest contact of the right posterior hippocampus and stimulation was delivered to the nearest bipolar channel. This ensured that detection and stimulation occurred within the same anatomical structure. In-creased amplitude can be observed just before detection during detected and stimulated IIDs compared to random stimulation. After stimulation, iEEG for the detected IIDs is a combination of the IID and the CCEP. A second example (Fig. 3.E–G) shows IIDs detected with a bipolar montage in the amygdala. In this case a bipolar montage between LAT1 and LAT4 was used to reduce line noise contamination. Stimulation pulses were delivered to LAT2-LAT3. SPESs were sent with zero delay (Fig. 3.E), 100 ms delay (Fig. 3.F), or 200 ms delay (Fig. 3.G). In the first case stimulation occurred during the IID spike, in the latter during the slow wave.
Fig. 3. Examples of CLoSES-RT during closed-loop to IIDs experiments.
A) IIDs were detected in the right hippocampus (red dot, RPH1), in the seizure onset zone. When an IID was detected, single pulse stimulation was delivered to adjacent channels (magenta dots, RPH2–3). B) CLoSES-RT GUI during offline replay of IIDs detection in RPH1 using same data and configuration as in real-time experiment. First row: stimulation pulses (red) and detected events (blue). Second row: visualization of features, in this case power, and thresholds (magenta). Third row: raw iEEG. Last row: averaged iEEG locked to stimulation. Right panel allows configuration of parameters including real-time adjustments. The GUI and algorithms were the same for replay or real-time experiments. C) Averaged iEEG for random stimulation (cyan), detected stimulation (red), and events detected without stimulation. Before stimulation, there was a large amplitude decrease only when IIDs were detected regardless of stimulation. Following stimulation, detected and stimulated events were a combination of the response to stimulation and the IID. D) Example of iEEG recordings in two channels surrounding stimulation site in the same test as in A-C. E-G) Examples of different delays following stimulation in a different participant. E) zero delay – stimulation occurred when an IID is detected. F) 100 ms delay- stimulation pulse was sent 100 ms after an IID is detected. G) 200 ms delay – stimulation pulse was sent 200 ms after an IID is detected. In this case stimulation occurred during the slow wave. LAT: Left amygdala; RPH: Right posterior hippocampus channels; SPES single pulse electrical stimulation.
3.2. Application #2: CLoSES- RT detecting sleep spindles
We were interested in detecting sleep spindles and stimulating during the ongoing oscillation. Understanding the effect of SPES on these spontaneous events could have implications for sleep maintenance and memory consolidation. To this end, we selected neocortical channels with clear spindles on previous nights’ recordings. We configured CloSES-RT in the following way: band-pass filter between 11 and 15 Hz (Butterworth order 2, details in supplementary online material, Fig. S3), smooth power (50 ms window average), sleep spindle detection occurs if smooth power exceeded a threshold for 200–500ms. When a spindle was detected SPES stimulation was delivered in real-time. Referential or bipolar montages were selected for detection based on electrode lo-cation and 60 Hz noise level. One to four channels were considered for detection. Fig. 4 shows an example of detected and stimulated spindles, interleaved random stimulation, and detected but not stimulated spindles in the prefrontal cortex. Clear spindle activity can be observed in detected events regardless of stimulation along with large CCEPs after detected or random stimulation.
Fig. 4. Example of CLoSES-RT during sleep spindle experiment.
A) Spindles were detected in the neocortex (red dots, RVF13 and RVF14) if power in any of these channels was above threshold for at least 250 ms. When a spindle was detected, single pulse stimulation was delivered to adjacent channels (magenta dots,RVF).B) CLoSES GUI during offline replay of spindle detection in RVF13 using same configuration as in real-time experiment. First row: detected and stimulated pulse(red) and random event (cyan). Because the random pulse was within the refractory period, it did not elicit stimulation. Second row: visualization of features, in this case power, and thresholds (magenta). Third row: raw iEEG. Last row: averaged iEEG locked to stimulation. Right panel allows configuration of parameters including real-time adjustments. The GUI and algorithms were the same for replay or real-time experiments. C) Example of iEEG recordings in two channels surrounding stimulation site. D) Per event stack plots of filtered iEEG. Top: Detected spindles followed by stimulation. Before stimulation, a spindle could be observed in the filtered EEG for each detection. Bottom: Random stimulation. Time zero (red line) indicates time of stimulation. E) Averaged features for random stimulation (cyan), detected stimulation (red) and events detected without stimulation (green). Time zero (orange line) indicates time of stimulation, at −500 ms, detection begins (green line). Following stimulation, power of detected and stimulated events were a combination of the response to stimulation and the spindle. RVF: Right ventro-frontal.
3.3. CLoSES-RT performance and latency analysis
3.3.1. Stepwise latency
In CLoSES-RT, we specified a 1 ms fixed step duration. At each step iEEG was acquired, channels selected, re-referenced, filtered, and power computed. Importantly, the tests required a low number of channels to detect events of interest at each fixed step.
In the examples of IID detection (Section 3.1), IIDs were acquired insix channels and detected in one channel. In this case, acquisition, feature calculation, and detection took 0.13+/−0.001 ms (see grey box area of data within one detection in Fig. 5.A, illustrating 10 s or 10,000 steps and histogram of actual latency distribution in Fig. 5.B). Every 100 steps data were sent to the GUI in the host computer as UDP packets for visualization and to be saved locally. In the steps when this happened, it took 0.14+/−0.01 ms (Fig. 5.A–B, green box). When detection occurred and SPES was sent, the step took 0.24+/−0.002 ms (Fig. 5.A–B, pink box). For 3–10 channels during IID detection the increase was linear with the number of channels. Even with 10 channels each step took less than 0.4ms (Fig. 5.C).
Fig. 5. Stepwise latencies during closed-loop to IID and spindles experiments.
Each step consists of iEEG acquisition at 2 kHz, buffering, power computation, detection and sending of stimulation pulse. Fix step was set to 1 ms (magenta lines) but it takes less than 0.25 ms to perform these steps. A) Example IID detections. B) Histograms. For IIDs filtering and power calculation takes 0.126 ms, when sending data back to GUI via UDP packets (every 100 ms) it takes 0.14 ms, when stimulation occurs it takes 0.24 ms. C) The actual latency of a step linearly increases with number of channels. D) Example spindle detections. E) Histograms. For spindles only filtering takes 0.11 ms, when sending data back to GUI it takes 0.14 ms, when stimulation occurs it takes 0.19 ms. F) The actual latency of a step linearly increases with number of channels. Min and median duration correspond to filtering and feature calculation steps. Max corresponds to steps when an IID was detected and stimulation pulse sent. In all situation the latency was well below 1 ms.
As an example of spindle detection (Section 3.2), iEEG was acquired in three channels and spindles detected in one channel. In this example, acquisition, filtering, and feature calculation took 0.11+/−0.001 ms (Fig. 5.D–E, grey boxes). When these data were sent to the GUI for visualization (every 100 steps),it took 0.14+/−0.001 ms (Fig. 5.D–E, green boxes). When spindles were detected and SPES was delivered, the step took 0.19+ /−0.002 ms(Fig. 5.D–E, pink boxes). For 3–10 channels, each step took less than 0.4 ms and the increase was linear with number of channels (Fig. 5.F). Thus, as each step’s actual duration was smaller than 1 ms, we could calculate total latency as the sum of steps.
3.3.2. Total latency
The total latency was related to the characteristics of the event being detected, with low frequency oscillations having long latencies and short transient events having the shortest possible latency.
When comparing the calculated latency to the actual latency using synthetic sinewave bursts as input (Fig. 6.A), actual total latency (me-dian [range]) was 557 [535 to 564] ms from the start of the sinewave bursts (with 500 ms detection interval). Total calculated latency was 681 ms = Filter group delay (81 ms) + smoothing window (100ms) + detection interval (500 ms). Thus, calculated total latency was 124 [117 to 146] ms longer than the actual latency.
Fig. 6. Detection of sinewaves, spindles and IIDs with calculated and actual latency.
A) Synthetic sinewave bursts used as inputs to the acquisition system through the clinical amplifiers to compare actual (blue) and total calculated latency (orange). The actual latency was 122 ms shorter than the calculated latency. Note that latency is related to required number of oscillations for detection and threshold amplitude. B) Sleep spindles during CLoSES-RT experiment in the EMU. Total calculated latency was 388 ms, actual latency was 294.5 ms (spindle start point visually marked). C) IIDs during CLoSES-RT experiment in the EMU (same participant as in Fig. 4.E). Total calculated latency was 27 ms. Note short feature lag as evident by difference in iEEG and feature signals. Note also 7 ms acquisition lag (mustard) evident as delayed iEEG stimulation artifact (blue trace) compared to stimulation pulse (vertical red line). Bottom part of each plot shows per-step latency for these events. It was always smaller than the fixed 1 ms step and therefore each step took 1 ms. See Fig. 5 for detailed per-step latency analysis. Lines indicate: actual start of event (blue vertical) and corresponding actual latency (blue horizontal); total calculated latency (orange horizontal), which corresponds to the earliest iEEG sample used to detect this event (orange vertical), filtering group delay (teal), feature calculation lag (smoothing window, purple), detection interval (burgundy), and acquisition lag (mustard). The 7 ms acquisition lag is evident as the difference between the time of detection, which is the same as the output stimulation pulse (red vertical) and the pulse from the stimulator as recorded by iEEG (black vertical).
For spindle detection during tests performed in the EMU, median [range] actual latency was 332.25 [83–614.5] ms (2 participants, 40 spindles, start marked by an expert). Total calculated latency with the configuration of the example was 388 ms = acquisition lag (7 ms)+ fil-ter’s group delay (81 ms) + smoothing window (50 ms) + detection interval (250 ms). Thus, calculated total latency was 55.75 [-226.5 to 305] ms longer than the actual latency.
For IIDs, with the configuration of example in Fig. 3.A–D, total calculated latency from start of IID to detection and stimulation was 37 ms (i.e. 37 steps). This latency is the summation of acquisition lag (7 ms), 10 ms lag added by smoothing (i.e. power at each step is the average of the 20 preceding samples) and the selected detection interval (20 ms). For the configuration of examples in Fig. 3.E–G, total calculated latency was 27 ms = acquisition delay (7 ms) + smoothing (10 ms) + detection interval (10 ms) (Fig. 6.C). This corresponds to the first point of the iEEG used for detection, presumably the start of the IID.
3.4. Application #3: CLoSES-SEM during cognitive flexibility task
CLoSES-SEM was used during a Multi-Source Interference Task (MSIT)to study the effect of stimulation on cognitive flexibility. An encoder/decoder model based on multiband log power input features was used to estimate hidden cognitive state(Yousefi et al., 2019a). Details on MSIT and corresponding model can be found else where (Basu et al., 2020). During MSIT CLoSES-SEM was configured in the following way: Theta, Alpha, and High Gamma multiband filter of pre-determined bipolar channels were implemented; aggregate logarithmic spectral power in the three frequency bands were calculated over a time window of 2 s following image onset; a neural decoder model was used to estimate a hidden flexibility state using the calculated log power; if estimated mean state value exceeded a pre-determined threshold a short train of 130 Hz stimulation was triggered on the following trial (following image onset). As a safety measure, only 5 out of 10 trials could receive stimulation within a sliding moving window including 10 trials.
To obtain a participant specific encoder/decoder model, each participant performed at least 128 trials of MSIT without stimulation and open-loop stimulation while their behavior and iEEG were simultaneously recorded. Simulation datasets with all channels were created from these trials and ran offline on replay with CLoSES GUI. This allowed de-termination of a reduced set of spectral features and a decoder model tailored for each participant (Yousefi et al., 2019a). This dataset was also used to estimate an initial threshold for stimulation. During the closed-loop tests, CLoSES-SEM was loaded with the optimized participant specific model and configuration file. There was ablock (664–96 trials) without stimulation, followed by 1–2 blocks (64–128 trials) with CLoSES-SEM, followed by one more block without stimulation. Fig. 7 shows an example of CLoSES-SEM during MSIT.
Fig. 7. Example of CLoSES-SEM during closed-loop MSIT experiment.
A) In this participant, power in Theta, Alpha and High-Gamma bands in several regions were used as input to the state estimate model. Stimulation was in dACC if mean state estimate was above the higher threshold. B) Illustration of MSIT task. C) CLoSES-SEM during replay of this participant’s data. D) State estimate based on multiband power. Up to trial 96-no stimulation, Trials 97–161 closed-loop experiments with stimulation on following trial, next trials: no stimulation. Threshold is shown in magenta. dACC: dorsal anterior cingulate cortex.
3.5. Application #4: CLoSES- SEM during emotion conflict resolution task
CLoSES-SEM was used during an Emotion Conflict Resolution (ECR) task to study the effect of stimulation responses to conflicting emotional cues. An encoder/decoder model based on theta band coherence input features across regions was used to estimate hidden state. Details on the implementation of ECR can be found else where (Paulk et al., 2020). During ECR CLoSES-SEM was configured on the following way: Theta band filter, coherence, detection if boundary of state estimates were above/below respective thresholds, and stimulation on the following trial (following image onset). As a safety measure, only 5 out of 10 trials could receive stimulation.
Similar to MSIT, to obtain a participant specific encoder/decoder model, each participant performed at least 128 trials of ECR without stimulation while their behavior and iEEG were simultaneously recorded. Simulation datasets with all channels were created from these trials and offline ran on replay with CLoSES GUI to create participant specific models. Given the large number of possible coherence pairs, replaying these datasets was an important step to reduce feature dimensionality. During the closed-loop tests, CLoSES-SEM was loaded with the optimized participant specific model and configuration file. There was a block (64 trials) without stimulation, followed by 1–3 blocks with CLoSES-SEM, followed by one more block without stimulation. Fig. 8 shows an example of CLoSES-SEM during ECR test in which bidirectional control was achieved (i.e. when state estimate decoded from neural features was above threshold stimulate on one site, when it was below another threshold stimulate in a different location).
Fig. 8. Example of CLoSES-SEM during closed-loop ECR experiment.
Bi-directional control was achieved A) Illustration of ECR task. B) In this participant, coherence in Theta band between several regions (in green) were used as input to the state estimate model. Stimulation was in dmPFC if lower bound of state estimate was below the lower threshold and in dACC if upper bound of state estimate was above the higher threshold. C) Five blocks of ECR, 1-no stimulation, 2–4 closed-loop experiments with stimulation on following trial, 5-no stimulation. Note in block 3 how the mean state gets lower with subsequent stimulations. dmPFC: dorso-medial prefrontal cortex; dACC: dorsal anterior cingulate cortex.
3.6. CLoSES-SEM performance and stepwise latency analysis
3.6.1. Stepwise latency
In the CLoSES-SEM examples, features were continuously computed from image onset up to one or two seconds. At this time point, features were averaged across the 1–2 s time window and used as input to the decoder model, which only occurred once per trial. Then, there was about one second until the stimulation pulse was sent at the following image onset. Thus, we verified that the stepwise latency of the continuous steps (acquisition, filtering and feature calculation) was within the fixed step. On the contrary, we could exceed the fix-step duration for the decoder model step, since it was executed only once per trial.
As cognitive tasks usually require large number of channels and fea tures and initial tests showed that computing coherence for more than 5 channels / 10 pairs took longer than 1 ms, the fix-step duration was se to 10 ms. In this case, acquisition rate was 2000 Hz, with iEEG data pro-cessed every 10 ms. For logPower up to 50 channels and coherence up to 20 channels the actual latency of the step was below the fixed 10 ms step. The actual latency of a step increased linearly with the number of channels for filtering, and feature (power and coherence) calculation (Fig. 9.A and 9.D). For the one time per trial when decoder mode ran, duration was linear with number of features (Fig. 9.A and 9.D). As an example for MSIT, 50 channels, each filtered in three frequency bands, and power calculated on 150 filtered signals, then averaged during one epoch, resulted in 150 input features to the decoder model. The actual duration for each step was (mean+/− std): when only filtering: 0.53+/−0.005 ms; when computing logpower: 0.68+/−0.005 ms; the one step per trial when decoder model ran: 54+/−0.1 ms; in the following step rate transitions were adjusted: 0.71+/−0.02; then detection occurs: 1.21+/−0.009 ms; and trial by trial information was saved: 0.54+/−0.01 ms (Fig.9.B&C). As an example for ECR, 20 channels filtered in the theta band, followed by coherence on all 190 pairs during 2 epochs, resulted in 374 input features (six features were not used as inputs in this example). Actual duration for each step was (mean+/− std): when only filtering: 0.25+/−0.002 ms; when coherence was computed: 4.92+/−0.004 ms; the step when decoder model ran: 105.8+/−0.03 ms; in the following step rate transitions were adjusted: 0.315+/−0.004; then detection occurred: 0.91+/−0.004 ms; and trial bytrial information was saved: 0.59+/−0.008 ms (Fig. 9.D,E & F). Thus, all continuous computations were with in the 10 ms fixed step. It is unlikely that more than 200 pairs of coherence would be required, but if more channels were of interest the fixed step could be adjusted. As shown in the examples, the decoder model step was dependent on number of features (54 ms or 6 steps for 150 features, 105 ms or 11steps for 374 features).
Fig. 9. Stepwise latencies during closed-loop MSIT and ECR experiments on the EMU compatible rig.
A) During MSIT tests (log power calculation, stim at following trial) the duration of each step increased linearly with the number of channels for filtering (circles) and power calculation (squares). The duration increased linearly with number of features for decoder model estimation (diamonds). B) Example of the time that took processing each step during MSIT for 50 channels, 96 features (marked with a yellow dot in A). Top part shows example of five consecutive trials, middle part a zoom for 0.5–1.5 ms. Black arrow indicates time of image onset (beginning of trial). Green arrow indicates time when continuous power was averaged, and decoder model ran. Magenta line indicates step fix duration (10 ms). C) Histograms of time that each step took organized by type of processing step for the same example of B. Histograms are ordered by when the type of steps was performed per trial. 1- Filtering is performed at every step (“continuously”) and took 0.53 +/−0.005 ms per step. 2-LogPower was computed from image onset to decoder time and took 0.68+/−0.005 ms. 3- Estimating the state with the decoder model took 54+/−0.1 ms, which is longer than the 10 ms fix step. Importantly, the decoder step is non-critical as it was run only once per trial (during one step) and the system had ~1 s to recover before the following trial. 4- A rate transition must run after the decoder step finished, to compensate for the extra allotted time (0.71+/−0.017 ms). 5- Detection based on the state estimated value took 1.21+/−0.01 ms. 6- Saving trial information took 0.55+/−0.01 ms. Y axis indicates percentage of steps for each duration. Gray, orange and pink boxes in B and C relate the histograms to the continuous plots. Step was set to 10 ms, meaning that the next processing step starts every 10 ms. D) During ECR tests (Coherence calculation, stim at following trial) the duration of each step increased linearly with the number of channels for filtering (circles) and power calculation (squares). The duration increased linearly with number of features for decoder model estimation (diamonds). E) Example of the time that took processing each step during ECR for 20 channels, 190 coherence pairs, averaged over 2 epochs, 374 decoder input features (marked with a yellow dot in D). Top part shows example of seven consecutive trials, middle part a zoom for 0–6 ms. Black arrow indicates time of image onset (beginning of trial). Green arrow indicates time when continuous power was averaged, and decoder model ran. Magenta line indicates step fix duration (10 ms) F) Histograms of time that each step took dividing by type of processing step for the same example of E. Histograms are ordered by when the type of steps was performed per trial. 1- Filtering is performed at every step (“continuously”) and took 0.25+/−0.002 ms per step. 2- Coherence was computed on 190 pairs from image onset to decoder time (4.92+/−0.004 ms per step). 3- Estimating the state with the decoder model took longer than the fix step, 105.8+/−0.03 ms. Importantly, the decoder step is non-critical as it was run only once per trial (during one step) and the system had ~1 s to recover before the following trial. 4- A rate transition must run after the decoder step finished, to compensate for the extra allotted time (0.315+/−0.004 ms). 5- Detection based on the state estimated value took 0.91+/−0.004 ms. 6- Saving trial information took 0.59+/−0.008 ms. Y axis indicates percentage of steps for each duration. Gray, orange and pink boxes in B and C relate the histograms to the continuous plots. Step was set to 10 ms, meaning that the next processing step starts every 10 ms.
To push the system outside normal operation limits, we tested ECR with 325 coherence pairs (all combinations from 26 channels) and found that coherence tooks lightly longer than 10 ms. Even though execution took sometimes longer than the fixed step, because the rate transitions and because coherence was only computed during certain epochs of a trial, CLoSES could still execute successfully. Indeed, CLoSES-SEM continued running successfully for 4 h (876 trials). As a comparison, during closed-loop cognitive tests in the EMU we ran 192 trials. Importantly, if larger number of features are required, the step size of 10 ms could be increased, effectively allowing for any number of channels and features.
3.6.2. Repeatability and reproducibility
CLoSES was successfully used in two hospitals settings (MGH and BWH) and deployed in three different EMU rigs. To test-retest repete-ability and reproducibility of the software and algorithms, we created datasets from 6 participants running MSIT or ECR. Experiments without stimulation, open-loop and closed-loop stimulation were included. We ran in replay mode these datasets twice in three Windows computers. The exact same features were obtained. Importantly, features generated during replay were identical to those obtained during closed-loop experiments in the EMU rigs with the same parameters.
4. Discussion
In this paper, we have presented CLoSES: a research tool that flexibly solves several challenges in closed-loop stimulation with iEEG in humans. We demonstrated the use of our closed-loop stimulation system in participants with implanted electrodes in the EMU in a variety of paradigms: 1) in real-time detection of spontaneous events or trialby trial during cognitive tasks; 2) with very low latency to stimulate during fast events like IIDs or with longer detection duration for slow neural rythms; 3) triggering stimulation with uni or bidirectional control at specific times; 4) during different brain states, such as sleep, awakeand rest, and during the performance of cognitive tasks. We reported latency for different situations and tested the limits of the system both for replay and real-time operation. CLoSES latency is lower than most BCI application (Wilson et al., 2010).
Brain oscillations at particular frequency bands are related to pathology (e.g. high-frequency oscillations in epilepsy, Beta oscillations in Parkinson) and physiology (e.g. Mu rhythm in movement, Gamma in attention, Ripples in memory, spindles during sleep). Duration, amplitude, location, interaction, and underlying mechanisms are different for different neuronal events. Our flexible closed-loop framework can detect these different oscillations and allows probing rhythms and cross-frequency interactions. CLoSES successfully produced responsive stimulation during short latency transient pathological IIDs, sleep spindles, theta band, or high gamma activity. By detecting transient or oscillations based on its particular characteristics, incorporating problem-specific control algorithms, and stimulating at precise times our system could help answer a variety of pressing neuroscience questions (Lozano et al., 2019; Widge and Miller, 2019).
4.1. Comparison to existing systems
In recent years, tremendous advances in software and hardware for closed-loop tests have been made. Development of flexible tools, freely available to the community, is important for neuroscience and clinical research, allowing the field to grow. Perhaps a paradigmatic example, Open Ephys is comprised of low cost acquisition equipment and a GUI (Siegle et al., 2017) that is open-source, and allows researchers to add their own modules. The Open Ephys GUI is written in C ++ and connects to the acquisition board through USB or custom modules (e.g. Neuropix-els module). It is mainly targeted to neuroscience basic research inani-mals but has also been used to record scalp EEG and EMG activity with inexpensive hardware (Black et al., 2017). BCI2000 (Schalk et al., 2004) has been widelly used by the BCI community. It is also written in C++ and its newest implementation allows web based control (Milsap et al., 2019). Real-Time eXperiment Interface (RTXI), provides a modified real-time Linux OS and was written in C ++ (Patel et al., 2017). RTXI is also aimed at basic science research. Similarly, Falcon was also written in C ++ and provides sub millisecond latencies, making it ideal for closed-loop tests recording from population bursts of neuronal spiking activity (Ciliberti and Kloosterman, 2017). Instead, we focused on LFP acquisition, computing local and network features. Using UDP or direct boards for acquisition and fixed steps provided by Simulink Real-Time resulted in short controlled latencies. Moreover, as CLoSES was developed with Simulink and MATLAB, it is easy to add new functionalities and visualization capabilities. In this way, we expect to reach a large number of clinical and translational researchers even if they have limited programming skills.
CLoSES is unique as it is targeted to be used in the hospital room with existing, robust multichannel acquisition systems and is flexiblein how it can be utilized from the features chosen for detection through to the outputs that can be delivered to control stimulation or other ac-tuators. Thus, we believe that CLoSES bridges a challenging gap, effectively complementing existing systems, but extending the strength of the closed loop approach in a hospital setting.
4.2. Safety considerations
CLoSES runs in parallel to clinical and other research acquisition systems (equipment only allowed for research purposes as it is notFDA approved). Adding an additional system, could affect the quality ofthe recordings or increase the susceptibility to interference. It is therefore important, as with any electrophysiological application, to carefully ver-ify connections, grounding and references, etc.
CLoSES was designed with safety as a priority. It has built-in lockout parameters to limit stimulation charge (N out of M trials, refractory intervals) and it is possible to stop the tests through software (and the hardware we have used). Easily implemented pipelines of testing prevented any significant consequences of the stimulation. Further more, a trained electroencephalographer and clinician was present to evaluate any symptoms or concerning changes to the EEG.
4.3. Performance and latency
The total latency for a particular application will be related to the characteristics of the event being detected, with low frequency oscillations having long latencies and short, transient events having the shortest possible latency. For instance, in the examples presented here, calculated latency was 27–37 ms for IID detection total while for spindle detection it was 388 ms. CLoSES flexibility allows configuration to match each of these needs. CLoSES software was highly repeatable and reproducible, which are fundamental to a reliable system.
Estimating the actual start point of these spontaneous events is challenging and could be the subject of a new study. In the sinewave bursts case the actual latency was smaller than calculated. Because signal to noise ratio was large, threshold could be set at 20% of the event power. Thus, detection could start during the feature buildup, reducing actual latency. This might be the case also for IIDs, although it is difficult to determine an ‘absolute’ start point. The case of spindle detection was even more challenging. The threshold had to be close to steady power value resulting in an actual latency of 332.25 [83 614.5] ms. Importantly, there was a wide range of latencies either due to fluctuations in the signal resulting in longer detection time (consecutive power above threshold was required) or due to difficulties in visually assessing the actual start of a spindle. Further studies could help understand this as it pertains to the definition of a spindle or the mechanistic understanding of what a spindleis. Total latency could also be shortened by specifying a smaller number of oscillations to consider as a detection. However, this would come with a higher probability of false detection.
In the case of CLoSES-SEM, ensuring low latency and compliance of the fixed-step duration was critical for the continuous steps: acquisition, filtering, and feature calculation. On the contrary, the decoder model was only utilized once per trial and stimulation occurred after about one second (in which nothing was required from the system). Thus, as the lag of this step was smaller than 200 ms and with the implemented rate transition blocks, the system had time to recover. We therefore implemented the decoder model as close as the offline one as possible without improving the performance. However, if shorter latencies were needed, model performance could be improved by removing loops and optimizing matrix algebra.
4.4. Limitations
It could be argued that a limitation of our system is that MATLAB and Simulink are paid software. However, we believe that the benefit of using a modular intuitive programing platform such as Simulink and the extensive visualization possibilities provided by MATLAB outweighs the cost.Importantly, the cost of the hardware equipment (e.g. NSP acquisition, amplifiers, stimulator) is significantly higher than the costof the software. Moreover, the wide spread use of MATLAB in the scien-tific community makes it easy for other groups to develop their own paradigms based on the CLoSES platform.
We foresee several technical additions in the near future. Stimulation artifact could obscure recordings. Initially, we implemented notch filters, but they were too slow for most applications. In practice, we avoid stimulation artifact effects on detection, by setting a refractory period following stimulation. Incorporating new artifact-removal tech-niques (Zhou et al., 2018) could allow detections closer to stimulation and newer amplifier systems are increasingly designed to decrease the stimulation artifact in general.
Only a few of the most common features were implemented. Given the modular approach of our platform, new features could be easily added. For example, in the case of neural oscillations, stimulating at a particular phase could have different effects (Widge et al., 2018a). Therefore, it would be interesting to incorporate phase-locked stimulation following detection of oscillations.
Finally, another path for development is the integration of the current system with field programmable gate arrays (FPGAs). FPGAs have been applied to large throughput systems (e.g. 10,000 input channels and deep learning recurrent networks) for real-time neural decoding (Heelan et al., 2018).
4.5. Future application
Precision medicine and adaptive DBS.
Therapeutically, CLoSES could be used as prototyping platform in the EMU before implanting a closed-loop DBS (Widge et al., 2017). The pipeline could be the following: 1) Tentative detection and control targets are obtained from neuro-psychological testing, questionnaires, and imaging; 2) Electrodes are implanted in these putative target areas; 3) Runtasks while stimulating with CLoSES to precisely identifying effective regions and better understand the effect of stimulation in each patient; 4) Implant chronic DBS system in the effective regions.
Study of human physiological and pathological neural mechanisms.
As a research tool, CLoSES streamlines the testing of a wide variety of questions in humans. CLoSES-RT has been used to investigate some mechanisms and roles of sleep spindles (Krempp et al., 2020) and epileptic IIDs. CLoSES-SEM has been used to investigate the effect of stimulation during cognitive flexibility and emotion conflict resolution tasks. Many other rhythms and cognitive questions can be effectively probed using the closed-loop approach made more turn-key through CLoSES. For instance, CLoSES could help better define the onset and duration of intracranial events, studying underlying excitatory or inhibitory mechanisms, and investigating network interactions.
CLoSES in other clinical environments.
CLoSES was developed and tested for use in the EMU, but could be utilized in other environments where we record electrophysiological signals and perform stimulation. In particular, in the operating room (OR), we could perform acute closed-loop tests with novel electrodes to study the response at different scales and study the response of the brain during diverse brain states, such as wake and general anesthesia. CLoSES is currently ready to be utilized in the OR. In outpatient clinics, we could easily adapt the input (ac-quisition) and output modules to adapt CLoSES to closed-loop tests using TMS-EEG or TMS-MEG. Combining results of closed-loop paradigms for non-invasive and direct stimulation, related to physiological and pathological activity, at different scales, and during different brain states, a more complete understanding of brain mechanisms and the effect of stimulation could be achieved.
With the release of the CLoSES platform as open-source software simultaneously with this paper publication, we hope that a wider number of research questions could be answered, and a large number of therapeutic clinical biomarkers could be evaluated.
5. Conclusions
CLoSES successfully triggers stimulation based on real-time detection and decoding of brain signals, during cognitive tasks, awake rest, and sleep. CLoSES provides a flexible platform to implement a variety of closed-loop experimental paradigms in humans including: 1) probe oscillations and understand their mechanisms, role in information transfer, and state maintenance; 2) study possible modulatory effect of physiological and pathological electrophysiological signals on the brain’s response to stimulation; 3) identify and evaluate potential electrographic biomarkers of neurological and psychiatric disorders; 4) and test patient specific stimulation targets and control signals before implanting a therapeutic device. We expect that this platform will facilitate studies of the effect of stimulation on brain dynamics and lead to important insights into the mechanisms of normal and pathological brain activity as well as more effective neuromodulatory therapies.
Supplementary Material
Acknowledgments
This work was supported in part by the Tiny Blue Dot foundation, NIH grant K24-NS088568, NIH grant R01-NS062092, NIH grant R01-NS079533 (WT), and the Defense Advanced Research Projects Agency (DARPA) under Cooperative Agreement Number W911NF-14-2-0045, issued by the Army Research Office contracting office in support of DARPA’S SUBNETS program. RZ was supported in part by the MGH ECOR Fund for Medical Discovery Postdoctoral Fellowship Award. The views, opinions, and/or findings expressed are those of the authors and should not be interpreted as representing the official views or policies of the Department of Defense or the U.S. Government.
Footnotes
Supplementary materials
Supplementary material associated with this article can be found, in the online version, at doi:10.1016/j.neuroimage.2020.117314.
References
- Ajiboye AB, Willett FR, Young DR, Memberg WD, Murphy BA, Miller JP, Walter BL, Sweet JA, Hoyen HA, Keith MW, Peckham PH, Simeral JD, Donoghue JP, Hochberg LR, Kirsch RF, 2017. Restoration of reaching and grasping movements through brain-controlled muscle stimulation in a person with tetraplegia: a proof-of-concept demonstration. Lancet 389, 1821–1830. doi: 10.1016/S0140-6736(17)30601-3. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Basu I, Yousefi A, Crocker B, Zelmann R, Paulk AC, Peled N, Ellard KK, Weisholtz DS, Cosgrove GR, Deckersbach T, Eden UT, Eskandar EN, Dougherty DD, Cash SS, Widge AS., 2020. Closed loop enhancement and neural decoding of human cognitive control. bioRxiv 2020.04.24.059964; doi: 10.1101/2020.04.24.059964 [DOI] [PMC free article] [PubMed] [Google Scholar]
- Basu I,Robertson MM, Crocker B, Peled N, Farnes K, Vallejo-Lopez DI, Deng H, Thombs M,Martinez-Rubio C, Cheng JJ, McDonald E, Dougherty DD, Eskandar EN, Widge AS, Paulk AC,Cash SS, 2019. Consistent linear and nonlinear responses to invasive electrical brain stimulation across individ-uals and primate species with implanted electrodes. Brain Stimul. 12, 877–892. doi: 10.1016/j.brs.2019.03.007. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Black C, Voigts J, Agrawal U, Ladow M, Santoyo J, Moore C, Jones S, 2017Open Ephys electroen cephalography (Open Ephys+EEG): a modular, low-cost, open-source solution to human neural recording. J. Neural Eng. 14, 035002. doi: 10.1088/1741-2552/aa651f. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Bouton CE, Shaikhouni A, Annetta NV, Bockbrader MA, Friedenberg DA, Niel-son DM, Sharma G, Sederberg PB, Glenn BC, Mysiw WJ, Morgan AG, De-ogaonkar M, Rezai AR, 2016. Restoring cortical control of functional movement in a human with quadriplegia. Nature 533, 247–250. doi: 10.1038/nature17435. [DOI] [PubMed] [Google Scholar]
- Caldwell DJ, Ojemann JG, Rao RPN, 2019. Direct electrical stimulation in electro-corticographic brain–computer interfaces: enabling technologies for input to cortex. Front. Neurosci. 13, 804. doi: 10.3389/fnins.2019.00804. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Ciliberti D, Kloosterman F, 2017. Falcon: a highly flexible open-source software for closed-loop neuroscience. J. Neural Eng. 14, 045004. doi: 10.1088/1741-2552/aa7526. [DOI] [PubMed] [Google Scholar]
- Collinger JL, Wodlinger B, Downey JE, Wang W, Tyler-Kabara EC, Weber DJ, McMorland AJC, Velliste M, Boninger ML, Schwartz AB, 2013. Highperformance neuroprosthetic control by an individual with tetraplegia. Lancet 381, 557–564.doi: 10.1016/S0140-6736(12)61816-9. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Espay AJ, Baram Y, Dwivedi AK, Shukla R, Gartner M, Gaines L, Duker AP, Revilla FJ, 2010. At-home training with closed-loop augmented-reality cueing device for improving gait in patients with Parkinson disease. J. Rehabil. Res. Dev. 47, 573–582. doi: 10.1682/JRRD.2009.10.0165. [DOI] [PubMed] [Google Scholar]
- Fetz EE, 2015. Restoring motor function with bidirectional neural interfaces. Prog. Brain Res. 241–252.doi: 10.1016/bs.pbr.2015.01.001. [DOI] [PubMed] [Google Scholar]
- Flint RD, Ethier C, Oby ER, Miller LE, Slutzky MW, 2012. Local field potentials allow accurate decoding of muscle activity. J. Neurophysiol. 108, 18–24. doi: 10.1152/jn.00832.2011. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Heelan C, Nurmikko AV, Truccolo W, 2018. FPGA implementation of deep-learning recurrent neural networks with sub-millisecond real-time latency for BCI-decoding of large-scale neural sensors(104 nodes). In: Proceedings of the Annual International Conference of the IEEE Engineering in Medicine and Biology Society. EMBS. Institute of Electrical and Electronics Engineers Inc., pp. 1070–1073. doi: 10.1109/EMBC.2018.8512415. [DOI] [PubMed] [Google Scholar]
- Hochberg LR, Bacher D, Jarosiewicz B, Masse NY, Simeral JD, Vogel J, Had-dadin S, Liu J, Cash SS, Van DerSmagt P, Donoghue JP, 2012. Reach and grasp by people with tetraplegia using a neurally controlled robotic arm. Nature 485, 372–375.doi: 10.1038/nature11076. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Hochberg LR, Serruya MD, Friehs GM, Mukand JA, Saleh M, Caplan AH, Branner A, Chen D, Penn RD, Donoghue JP, 2006. Neuronal ensemble control of prosthetic devices by a human with tetraplegia. Nature 442, 164–171. doi: 10.1038/nature04970. [DOI] [PubMed] [Google Scholar]
- Katnani HA, Patel SR, Kwon CS, Abdel-Aziz S, Gale JT, Eskandar EN, 2016. Temporally coordinated deep brain stimulation in the dorsal and ventral striatum synergistically enhances associative learning. Sci. Rep. 6. doi: 10.1038/srep18806. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Kokkinos V, Sisterson ND, Wozny TA, Richardson RM, 2019. Association of closed-loop brain stimulation neurophysiological features with seizure control among patients with focal epilepsy. JAMA Neurol. doi: 10.1001/jamaneurol.2019.0658. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Krempp C, Paulk AC, Truccolo W, Cash SS, Zelmann R, 2020. Effect of closed-loop direct electrical stimulation during sleep spindles in humans. In: Conference Proceedings of the IEEE Engineering in Medicine and Biology Society. Institute of Electrical and Electronics Engineers Inc. doi: 10.1109/EMBC44109.2020.9175404. [DOI] [PubMed] [Google Scholar]
- Krook-Magnuson E, Gelinas JN, Soltesz I, Buzsáki G, 2015. Neuroelectronics and biooptics: closed-loop technologies in neurological disorders. JAMA Neurol. doi: 10.1001/jamaneurol.2015.0608. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Kuiken TA, Li G, Lock BA, Lipschutz RD, Miller LA, Stubblefield KA, En-glehart KB, 2009. Targeted muscle reinnervation for real-time myoelectric control of multifunction artificial arms. JAMA - J. Am. Med. Assoc. 301, 619–628. doi: 10.1001/jama.2009.116. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Levy R, Deer TR, Henderson J, 2010. Intracranial neurostimulation for pain control: a review. Pain Phys. 13, 157–165. [PubMed] [Google Scholar]
- Lozano AM, Lipsman N, Bergman H, Brown P, Chabardes S, Chang JW, Matthews K, McIntyre CC, Schlaepfer TE, Schulder M, Temel Y, Volkmann J, Krauss JK, 2019. Deep brain stimulation: current challenges and future directions. Nat. Rev. Neurol. 15, 148–160. doi: 10.1038/s41582-018-0128-2. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Matsumoto R, Nair DR, LaPresto E, Bingaman W, Shibasaki H, Luders HO, 2006. Functional connectivity in human cortical motor system: a cortico-cortical evoked potential study. Brain 130, 181–197. doi: 10.1093/brain/awl257. [DOI] [PubMed] [Google Scholar]
- Matsumoto R, Nair DR, LaPresto E, Najm I, Bingaman W, Shibasaki H, Lüders HO, 2004. Functional connectivity in the human language system: a cortico-cortical evoked potential study. Brain 127, 2316–2330. doi: 10.1093/brain/awh246. [DOI] [PubMed] [Google Scholar]
- Milsap G, Collard M, Coogan C, Crone NE, 2019. BCI2000Web and WebFM: browserbased tools for brain computer interfaces and functional brain mapping. Front. Neurosci. 13. doi: 10.3389/fnins.2018.01030. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Morrell M, 2006. Brain stimulation for epilepsy: can scheduled or responsive neurostimulation stop seizures? Curr. Opin. Neurol. 19, 164–168. doi: 10.1097/01.wco.0000218233.60217.84. [DOI] [PubMed] [Google Scholar]
- Nishimura Y, Perlmutter SI, Fetz EE, 2013. Restoration of upper limb movementvia artificial corticospinal and musculospinal connections in a monkey with spinal cord injury. Front. Neural Circuits 7. doi: 10.3389/fncir.2013.00057. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Patel YA, George A, Dorval AD, White JA, Christini DJ, Butera RJ, 2017. Hard real-time closed-loop electrophysiology with the Real-Time eXperiment Interface (RTXI). PLOS Comput. Biol. 13, e1005430. doi: 10.1371/journal.pcbi.1005430. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Paulk AC, Yousefi A, Ellard KK, Farnes K, Peled N, Crocker B, Zelmann R, Vallejo-Lopez D, Belok G, Zorowitz S, Basu I, Afzal A, Gilmour A, Weisholtz DS, Cosgrove GR, Chang BS, Arle JE, Williams ZM, Eden UT, Deckersbach T, Dougherty DD, Eskandar EN, Widge AS, Cash SS, 2020. Bidirectional modulation of human emotional conflict resolution using intracranial stimulation. bioRxiv, 825893 doi: 10.1101/825893, Submitted for publication. [DOI] [Google Scholar]
- Sarma AA, Crocker B, Cash SS, Truccolo W, 2016. A modular, closed-loop platform for intracranial stimulation in people with neurological disorders. In: 2016 38th Annual International Conference of the IEEE Engineering in Medicine and Biology Society (EMBC). IEEE, pp. 3139–3142. doi: 10.1109/EMBC.2016.7591394. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Schalk G, McFarland DJ, Hinterberger T, Birbaumer N, Wolpaw JR, 2004. BCI2000: a general-purpose brain-computer interface (BCI) system. IEEE Trans. Biomed. Eng. 51, 1034–1043. doi: 10.1109/TBME.2004.827072. [DOI] [PubMed] [Google Scholar]
- Shirvalkar P, Veuthey TL, Dawes HE, Chang EF, 2018. Closed-loop deep brain stimulation for refractory chronic pain. Front. Comput. Neurosci. 12. doi: 10.3389/fn-com.2018.00018. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Siegle JH, López AC, Patel YA, Abramov K, Ohayon S, Voigts J, 2017. Open Ephys: an open-source, plugin-based platform for multichannel electrophysiology.J. Neural Eng. 14, 045003. doi: 10.1088/1741-2552/aa5eea. [DOI] [PubMed] [Google Scholar]
- Sun FT, Morrell MJ, 2014. The RNS system: responsive cortical stimulation for the treatment of refractory partial epilepsy. Expert Rev. Med. Devices 11, 563–572. doi: 10.1586/17434440.2014.947274. [DOI] [PubMed] [Google Scholar]
- Tan H, Debarros J, He S, Pogosyan A, Aziz TZ, Huang Y, Wang S, Timmer-mann L, Visser-Vandewalle V, Pedrosa DJ, Green AL, Brown P, 2019. Decoding voluntary movements and postural tremor based on thalamic LFPs as a basis for closed-loop stimulation for essential tremor. Brain Stimul. 12, 858–867. doi: 10.1016/j.brs.2019.02.011. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Tinkhauser G, Pogosyan A, Little S, Beudel M, Herz DM, Tan H, Brown P, 2017. The modulatory effect of adaptive deep brain stimulation on beta bursts in Parkinson’s disease. Brain 140, 1053–1067. doi: 10.1093/brain/awx010. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Trebaul L, Deman P, Tuyisenge V, Jedynak M, Hugues E, Rudrauf D, Bhattachar-jee M, Tadel F, Chanteloup-Foret B, Saubat C, Reyes Mejia GC, Adam C, Nica A, Pail M, Dubeau F, Rheims S, Trébuchon A, Wang H, Liu S, Blauw-blomme T, Garcés M, De Palma L, Valentin A, Metsähonkala EL, Petrescu AM, Landré E, Szurhaj W, Hirsch E, Valton L, Rocamora R, Schulze-Bonhage A, Mindruta I, Francione S, Maillard L, Taussig D, Kahane P, David O, 2018. Probabilistic functional tractography of the human cortex revisited. Neuroimage doi: 10.1016/j.neuroimage.2018.07.039. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Trébuchon A, Chauvel P, 2016. Electrical stimulation for seizure induction and functional mapping in stereoelectroencephalography. J. Clin. Neurophysiol. doi: 10.1097/WNP.0000000000000313. [DOI] [PubMed] [Google Scholar]
- Valentín A, Anderson M, Alarcón G, Seoane JJG, Selway R, Binnie CD, Polkey CE, 2002. Responses to single pulse electrical stimulation identify epilep-togenesis in the human brain in vivo. Brain 125, 1709–1718. [DOI] [PubMed] [Google Scholar]
- Widge AS, Boggess M, Rockhill AP, Mullen A, Sheopory S, Loonis R, Freeman DK, Miller EK, 2018a. Altering alpha-frequency brain oscillations with rapid analog feedback-driven neurostimulation. PLoS One 13. doi: 10.1371/jour-nal.pone.0207781. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Widge AS, Ellard KK, Paulk AC, Basu I, Yousefi A, Zorowitz S, Gilmour A, Afzal A, Deckersbach T, Cash SS, Kramer MA, Eden UT, Dougherty DD, Eskandar EN, 2017. Treating refractory mental illness with closed-loop brain stimulation: progress towards a patient-specific transdiagnostic approach. Exp. Neurol. 287, 461–472. doi: 10.1016/j.expneurol.2016.07.021. [DOI] [PubMed] [Google Scholar]
- Widge AS, Malone DA, Dougherty DD, 2018b. Closing the loop on deep brain stimulation for treatment-resistant depression. Front. Neurosci. 12, 175. doi: 10.3389/fnins.2018.00175. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Widge AS, Miller EK, 2019. Targeting cognition and networks through neural oscillations: next-generation clinical brain stimulation. JAMA Psychiatry doi: 10.1001/jamapsychiatry.2019.0740. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Wilson JA, Mellinger J, Schalk G, Williams J, 2010. A procedure for measuring latencies in brain computer interfaces. IEEE Trans. Biomed. Eng. 57, 1785–1797. doi: 10.1109/TBME.2010.2047259. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Wright J, Macefield VG, van Schaik A, Tapson JC, 2016. A review of control strategies in closed-loop neuroprosthetic systems. Front. Neurosci. 10, 312. doi: 10.3389/fnins.2016.00312. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Yousefi A, Basu I, Paulk AC, Peled N, Eskandar EN, Dougherty DD, Cash SS, Widge AS, Eden UT, 2019a. Decoding hidden cognitive states from behavior and physiology using a Bayesian approach. Neural Comput. doi: 10.1162/neco_a_01196. [DOI] [PubMed] [Google Scholar]
- Yousefi A, Paulk AC, Basu I, Mirsky JL, Dougherty DD, Eskandar EN, Eden UT, Widge AS, 2019b. ComPasS: an open-source, general-purpose software toolkit for computational psychiatry. Front. Neurosci. 13, 957. doi: 10.3389/fnins.2018.00957. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Zhou A, Johnson BC, Muller R, 2018. Toward true closed-loop neuromodulation: artifact-free recording during stimulation. Curr. Opin. Neurobiol. 50, 119–127. doi: 10.1016/j.conb.2018.01.012. [DOI] [PubMed] [Google Scholar]
Associated Data
This section collects any data citations, data availability statements, or supplementary materials included in this article.









