# Closed-Loop Current Stimulation Feedback Control of a Neural Mass Model Using Reservoir Computing
## 1 Introduction  
The human brain coordinates the activity of billions of neurons to give rise to cognition and perception. Traditional attempts to understand neural mechanisms rely on observing indirect measures of neural activity when a subject performs a carefully designed, controlled cognitive task. Electroencephalography (EEG), which measures voltages on the scalp that reflect the summation of activity of tens of thousands pyramidal cells (PCs) in the cortex [1], provides one common tool for such observations. Many cognitive tasks elicit rich oscillatory EEG dynamics; however, correlative observational studies cannot address whether such patterns in local field potentials (and subsequently EEG) serve a mechanistic purpose or are simply an epiphenomenon not directly related to cognition [2]. To address this issue, experimenters have used neuromodulation to demonstrate a causal role of oscillatory patterns by perturbing neural activity and observing impacts on cognitive behavior [3]. For instance, transcranial electrical stimulation (tES) studies, in which an electric field is injected into the scalp to alter the local field potential, have been shown to affect neural oscillations important in attention [4, 5, 6] and working memory [7, 8]. While tES has contributed to our understanding of neural mechanisms that underlie cognitive processes, both the technology itself and the experimental designs that use tES suffer from important limitations. First and most critically, the way in which tES modulates neural activity and behavior is not clear. Some argue that low intensity, random noise stimulation can bias a neuron to respond when its activity is close to its firing threshold throughstochastic resonance [9]. On the other hand, a higher intensity sinusoidal current may cause network entrainment in which external and internal oscillations synchronize [10]. Models of coupled oscillators suggest that the frequency of the externally applied current should match the natural resonance of the internal model to best facilitate entrainment [11; 12; 13]. However, practical considerations lead many experimenters to opt instead for a simpler, less tailored scheme in which all subjects receive the same fixed-frequency stimulation [14]. This failure to individualize stimulation may lead to inconsistent effects in tES experiments, since resonant frequencies of neural oscillators can vary across subjects for the same cognitive task [15; 16]. To further complicate issues, keeping tES electrode placement fixed while ignoring individual anatomical differences can impact the effective strength of the imposed electric field at a targeted brain region [17]. These shortcomings of tES experimental designs can be ameliorated using a closed-loop design, where current stimulation hyperparameters (e.g., stimulation waveform and location) are updated in response to ongoing brain activity [18]. The ideal tES closed-loop setting would utilize rhythmic resonance, which is similar to stochastic resonance; however, in rhythmic resonance excitation is precisely timed to real-time membrane potential recordings to bias a single neuron near the threshold [13]. Non-invasive tES using existing technologies, such as with state-of-the-art targeting algorithms combined with high-definition stimulation electrodes, cannot achieve this. Stimulation spreads widely, across entire gyri, rather than being localized to small subsets of neurons [19; 20]. Additionally, though artifact removal algorithms have shown some success in recovering the underlying EEG signal, real-time neural recordings with simultaneous tES still are contaminated by electrical artifacts [21; 22]. One closed-loop study attempted to deliver transcranial alternating current stimulation (tACS) in-phase with ongoing alpha oscillations recorded via EEG, but found that alpha amplitude modulation was independent of the endogenous alpha phase, inconsistent with predictions from rhythmic resonance [23].