D’Andola et al. Journal of NeuroEngineering and Rehabilitation (2019) 16:7 https://doi.org/10.1186/s12984-018-0470-z RESEARCH Open Access Control of cortical oscillatory frequency by a closed-loop system Mattia D’Andola1†, Massimiliano Giulioni2†, Vittorio Dante2, Paolo Del Giudice2 and Maria V. Sanchez-Vives1,3* Abstract Background: We present a closed-loop system able to control the frequency of slow oscillations (SO) spontaneously generated by the cortical network in vitro. The frequency of SO can be controlled by direct current (DC) electric fields within a certain range. Here we set out to design a system that would be able to autonomously bring the emergent oscillatory activity to a target frequency determined by the experimenter. Methods: The cortical activity was recorded through an electrode and was analyzed online. Once a target frequency was set, the frequency of the slow oscillation was steered through the injection of DC of variable intensity that generated electric fields of proportional amplitudes in the brain slice. To achieve such closed-loop control, we designed a custom programmable stimulator ensuring low noise and accurate tuning over low current levels. For data recording and analysis, we relied on commercial acquisition and software tools. Results: The result is a flexible and reliable system that ensures control over SO frequency in vitro. The system guarantees artifact removal, minimal gaps in data acquisition and robustness in spite of slice heterogeneity. Conclusions: Our tool opens new possibilities for the investigation of dynamics of cortical slow oscillations—an activity pattern that is associated with cognitive processes such as memory consolidation, and that is altered in several neurological conditions—and also for potential applications of this technology. Keywords: Stimulation, Cortex, In vitro, Real-time, Slow oscillations, Emergent properties, Direct current stimulation, Brain stimulation Background conductances to the biological ones [2]. More recently, The control of brain activity to restore function ideally at the network level, different groups have demonstrated requires the recording, or reading, of such activity, its their ability to control the bursting frequency in in-vitro online analysis and the correct stimulation/inhibition to preparations [3, 4], and Jackson and colleagues were able achieve a target, which is a desired activity pattern. If to induce plasticity in the motor cortex during an this is done with periodicity, the system is defined as a in-vivo experiment thanks to an implantable closed-loop closed loop. In order to gain control over the modulated device [5]. Furthermore, a closed-loop system using al- parameters in electrophysiology, neuroscientists have ternating current (AC) stimulation of the human tem- employed closed-loop systems at different levels ranging poral cortex has been recently found to be useful for from single-cell to network levels. At the single-cell improving episodic memory [6] (for a review see [7]). level, notable examples are the voltage-clamp technique In the realm of clinical applications, even though some used in 1952 by Hodgkin and Huxley to design their brain stimulation procedures, such as deep brain stimu- model [1], or the dynamical-clamp technique introduced lation in Parkinson’s disease [8], have been well estab- in 1993 by Sharp and colleagues to add in-silico lished for over two decades, the use of closed-loop systems associated with deep brain stimulation is recent and still experimental [9] despite their advantages [10]. * Correspondence: msanche3@clinic.ub.es In order to advance the design and use of closed-loop † Mattia D’Andola and Massimiliano Giulioni contributed equally to this work. systems for the control of brain activity, in the current 1 Systems Neuroscience, IDIBAPS, Rosselló 149-153, Barcelona 08036, Spain 3 ICREA, Passeig de Lluís Companys, 23, Barcelona 08010, Spain study we designed and tested a closed-loop system that Full list of author information is available at the end of the article © The Author(s). 2019 Open Access This article is distributed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits unrestricted use, distribution, and reproduction in any medium, provided you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made. The Creative Commons Public Domain Dedication waiver (http://creativecommons.org/publicdomain/zero/1.0/) applies to the data made available in this article, unless otherwise stated. D’Andola et al. Journal of NeuroEngineering and Rehabilitation (2019) 16:7 Page 2 of 14 controls the frequency of cortical slow oscillations (SO) closed-loop system as a proof of concept: it allows us to by means of direct current (DC) stimulation of the cor- follow and to control the time evolution of the biological tical network, and we demonstrate that it is a flexible activity by controlling the injected current. Our and reliable system. closed-loop system is based on a commercial low-noise SO are the dominant activity pattern of the cerebral acquisition tool, a standard non-real-time PC, and a cus- cortex spontaneously emerging in various states, includ- tom reprogrammable DC stimulator. An abstract of this ing slow-wave sleep, deep anesthesia, and in some brain article was previously published in a conference pro- areas after lesions (e.g., cortical islands). SO also emerge ceedings [29]. spontaneously in acute cortical slices in vitro in the ab- sence of any pharmacological or electrical stimulation Methods [11, 12]. The tendency for the cortical network to gener- The aim of this study was to design a flexible and reli- ate SO has prompted the suggestion that this activity is able compact closed-loop system able to control the fre- indeed the default activity pattern of the cortex [13] quency of SO spontaneously generated by the cortical (reviewed in [14]). Furthermore, it is well established network in vitro. For this, we designed an experimental that SO during slow-wave sleep are associated with con- protocol consisting of two main parts: an open-loop solidation of information, and with enhanced memory part, for response characterization of the cortical net- and cognitive performance [15, 16] (reviewed in [17]). work response; and a closed-loop part, where the bio- SO alternate at a frequency of ≤1 Hz between active and logical activity was steered towards the desired SO silent periods of neuronal activity [18], also referred to frequency (see Experimental protocol below). as Up and Down states, respectively. The neuronal firing of both excitatory and inhibitory neurons, which are linked by recurrent connections, results in reverberant Setup or persistent activity during Up states. During Up states Our setup was a loop composed of four main elements there is synchronization in beta (15–30 Hz) and gamma (Fig. 1): a cortical slice, a recording system, a PC for data (30–90 Hz) frequencies, similar to what can be observed analysis and a stimulator. Such a loop allowed us to con- during wakefulness [12, 19]. These frequency bands dur- tinuously monitor the slow cortical oscillations, to com- ing wakefulness have been associated with cognitive pro- pute their frequency (v) on-line and to adjust the cesses, short-term and working memory [20, 21], as well stimulation current (I) to increase or decrease v. as with attention and arousal levels [22–25]. A key feature of a closed-loop system is the ability to Interestingly, SO in in-vitro cortical slices [11, 12] can monitor, analyze and react in real-time to the biological be modulated by DC stimulation. This is particularly behavior, “real-time” meaning that the time latencies of relevant given that transcranial direct current stimula- the loop should be much shorter than the time scales of tion (tDCS) has acquired a lot of attention in the past the dynamics being studied [30–35]. In our case, laten- few years but, in spite of the extended use of tDCS, the cies were not a tight constraint: up to hundreds of milli- network and cellular mechanisms underlying cortical seconds were acceptable. We were interested in DC stimulation are only partially known [26–28]. Appli- controlling the frequencies of slow oscillatory regimes cation of DC electric fields parallel to the polarization and those frequencies rarely exceed 1 Hz. Hence we direction of pyramidal neurons (i.e., perpendicular to the chose to record the slice activity through a commercial cortex layers) to act on the cortical activity modulates system that streamed the data on a Windows PC via many network parameters characterizing SO, such as USB and to run, on the same machine, the software for the frequency: the logarithm of the SO frequency varies the continuous data analysis. The same software con- linearly with the intensity and the polarity of the stimu- trolled the stimulator too. For us, three critical con- lation [28]. This effect is due to an elongation or short- straints arose that we had to take into account from the ening of the Down state duration due to hyperpolarizing stimulation side, in which we used an adjustable DC or depolarizing fields, respectively, while Up state dur- stimulation current. Those constraints were: (1) the cor- ation stays constant across stimulation levels. tical network proved to react even to small (less than Here we envisioned a closed-loop system that controls 10 μA) changes in current amplitude; (2) the nature of SO frequency in the cerebral cortex network in vitro as the stepwise stimulation did not allow for the use of a proof of concept of the possibility to control this activ- standard techniques for artifact removal; and (3) we ity in vivo, eventually with therapeutic applications. This were interested in local field potential (LFP) signals (< system is autonomous, able to stabilize the SO fre- 20 μV), thus a critical aspect was represented by the quency, robust across time and flexible, as the intensity amount of noise introduced by the constantly active of the network response to the stimulation varies across stimulator. Hence, to have fine control over the current slices [28]. In the following sections we present our amplitude, to avoid data loss after every stimulation D’Andola et al. Journal of NeuroEngineering and Rehabilitation (2019) 16:7 Page 3 of 14 Fig. 1 Closed-loop system. At the bottom of the figure is a photograph of four cortical slices in the recording chamber. In a counterclockwise direction, the loop proceeds from recording to stimulation. To the right, a sample of the local field potential (LFP) signal recorded from layer 5 is amplified, digitalized and sent to the PC via USB. At the top, the PC performs the online analysis for Up-state recognition and slow oscillation (SO) computation. To the left, the custom-made stimulator is controlled by the PC via Bluetooth. The stimulator injects DC current (i) into the slices by creating an adequate potential difference (ΔV) between the stimulation electrodes update, and to maintain a low noise level, we designed a recording chamber (Fine Science, Foster City, CA) where custom stimulator. the slices were superfused for 1–2 h with a continuous so- In the following sections we provide a detailed descrip- lution flow (2–4 ml/min); the artificial cerebrospinal fluid tion of the various parts composing the setup. (ACSF) contained (in mM): NaCl, 126; KCl, 2.5; MgSO4, 2; Na2HPO4, 1; CaCl2, 2; NaHCO3, 26; dextrose, 10; and Slice preparation and experimental conditions was aerated with 95% O2, 5% CO2 to a final pH of 7.4. Ferrets were cared for and treated in accordance with Then, a modified ACSF simulating ionic values in vivo (as Spanish regulatory laws (BOE-A-2013-6271), which described in [11, 36]), was used throughout the rest of the comply with the European Union guidelines on protec- experiment, which had the same ionic composition except tion of vertebrates used for experimentation (Directive for different levels of the following (in mM): KCl, 4; 2010/63/EU of the European Parliament and of the MgSO4, 1; and CaCl2, 1. Bath temperature was maintained Council of 22 September 2010). All experiments were at 34–36 °C. Throughout the experiment the temperature approved by the Ethics Committee of the Hospital Clinic was maintained at 34–36 °C. (Barcelona, Spain). Slice preparation and solution composition are de- scribed in detail in Sanchez-Vives [36]. In brief: ferrets (4– Electrophysiological recordings 6 months old, either sex) were anesthetized with sodium The extracellular LFP was recorded from deep cortical pentobarbital (40 mg/kg) and decapitated. Then the entire layers with a 2–5 MΩ tungsten electrode (FHC, Bow- forebrain was rapidly removed and placed into oxygenated doinham, ME) and was amplified by 1000 by a Neurolog cold (4–10 °C) bathing medium and 400-μm-thick coronal System (Digitimer, Letchworth, UK). The reference elec- slices from visual cortex (areas 17, 18 and 19) were ob- trode, a Ag-AgCl wire, was placed in the bath. The amp- tained. Tissue viability was increased during preparation lified signal was digitized at 5 kHz by a CED instrument by modification of the sucrose-substitution technique (Power1401 ADC/DAC, Cambridge Electronic Design, [37]. The slices were then placed into an interface style Cambridge, UK) and streamed to the PC. D’Andola et al. Journal of NeuroEngineering and Rehabilitation (2019) 16:7 Page 4 of 14 Slow oscillation identification and analysis signal and applied another moving-average filter with a As mentioned in the introduction, SO are characterized longer time-window of 80 ms to obtain MUA traces, simi- by the alternation of active and silent periods, namely lar to the ones obtained offline in [28, 38] (Fig. 2a). Up- Up and Down states. During Up states, the increase in ward and downward transitions — that is, from a Down the spiking activity of single neurons increases multiunit state to an Up state, respectively, and vice versa — were activity (MUA) levels. A method to estimate MUA has detected by setting time and amplitude thresholds in the already been described [28, 38]: in brief, the power MUA traces. In order to obtain a better automatic recog- spectrum of the population firing rate has Fourier com- nition of the Up/Down cycles, the frequency cutoff of the ponents proportional to the firing rate itself [39]. Thus bandpass filter for the MUA estimation was adjusted to the components of the LFP between 0.2 kHz and 1.5 [0.1 1.7] kHz on an empirical basis, with respect to the kHz can be seen as a linear transform of spiking activity one reported in [40]. [40], so that power changes in the Fourier components The detection procedure just described was performed at those frequencies provide a reliable estimation of the by our Spike2 scripts which analyzed data online, de- population firing rate. tected the Up states and computed their onset frequency For an online estimation of MUA, we applied a (i.e., the SO frequency) over a window of variable dur- DC-removal filter with a rectangular window of 10 ms ation (see below). Up state onsets were identified as an (roughly corresponding to a high-pass filter with cut-off increase in the MUA crossing a given threshold and last- frequency at 100 Hz) and a second online moving-average ing more than 200 ms. The threshold could be automat- filter with a rectangular window of 0.6 ms (roughly corre- ically adjusted by the software at a specific percentage of sponding to a low pass filter with a cut-off frequency at the amplitude of the MUA during Up states with respect 1700 Hz) to traces from LFP waveforms recorded during to the baseline activity. At the same time it was also pos- closed-loop stimulation (Fig. 2a). We then rectified the sible to adjust it manually at any moment of the Fig. 2 Sample recording traces, stimulation configuration and SO frequency behavior across injected DC currents. a Sample recording (3 s). Bottom row, raw LFP trace; middle and top rows, the MUA and MUA waveforms, respectively, obtained with online filtering of the LFP. Up states (gray shade) were automatically recognized through the use of amplitude and time thresholds in the MUA traces. b Scheme of electrode stimulation setup. Electric fields were directed parallel to the polarization direction of pyramidal neurons. c Typical distribution of SO frequency across injected currents for one of the recorded slices (mean ± SD). For each stimulation current (x axis), all the measured values of the slow oscillation frequency obtained during the stimulation interval at that specific intensity were averaged (58 values). The logarithm of the SO frequency monotonically increases with the applied DC currents. The linear fit is superimposed [28] (p-value = 3.9182 × 10− 7). The variability of the response to the stimulation across the five tested slices is showed in the inset by superimposing the linear fits for each slice, after normalization to the control condition (spontaneous activity). LFP, local field potential; MUA, multiunit activity; SO, slow oscillations D’Andola et al. Journal of NeuroEngineering and Rehabilitation (2019) 16:7 Page 5 of 14 recording. In the set of recordings that we will show, the a Bluetooth communication module. Wireless commu- threshold was either automatically set or manually ad- nication and battery powering were chosen primarily to justed throughout the experimental trials. get rid of ground loops that can arise in closed-loop Every second the software compared the chosen target systems that include multiple devices. In this way, and frequency ðv ) with the measured one (v) and increased or with additional measures including suited ground con- decreased the stimulation level by a certain current step nections, we eliminated noise due to power lines, radio (Istep). The software acted as a proportional controller, such mobile signals and so on. that the farther the signal was from the target the larger the The microcontroller was in charge of managing wire- current step was. When jv−vj ≤ 10%of v, we considered the less communication, DACs employed to set stimulation target had been reached and we did not modify the stimula- currents, and triggers for artifact removal. tion current. To avoid permanent damages to the slice we The stimulator offers a command-line COM-based also enforced a maximum absolute value for the stimulation user interface for easy programming and provides four current of 650 μA. Current intensity ranges were chosen on stimulation channels, independently settable. In the the basis of previous observations [28] (see below). experiments reported in this work we used a single To reduce false positives, the software detected and re- channel. moved artifacts on the MUA channel before performing The current injector is basically a voltage-current con- the analysis of the Up state onsets. Artifacts in the re- verter and is illustrated in the diagram in Fig. 3. The in- cordings derived from a sudden change of the voltage strumental amplifier and op-amp implement a feedback potential in the recording site caused by stimulus up- circuit that keep the voltage across the resistor R332 at dates or by environmental interferences. Fast oscillations the V_Inj value, which in turn determines the current of the signal, creating a V-shaped peak of at least 30 μV I_Out to be injected. height, were recognized by the system as artifacts. Apart Lab tests on the current injector confirmed linearity of from the real-time analysis, the software also ensured the relationship between set and injected currents, up to the execution of an entire experimental protocol involv- clipping conditions that depend on the load impedance; ing different phases (see below). such tests allowed us to easily assess whether the stimu- lation current is reliable by checking that, for the set Stimulation current, the applied voltage is below the clipping value Stimulation was effected by a custom-made stimulator com- (about 8 V). All measurements were remarkably stable posed of an injection module, an Atmel microcontroller and over time. For our injector, output noise can be safely Fig. 3 Diagram of the stimulator. Input voltage is applied at Vinj, output current flows between IOut and Gnd. The leftmost resistor branch ensures the current zero-point. AD62 0 AD is an instrumental amplifier; AD79 5 AD is an operational amplifier with very high input impedance. The configuration of the two amplifiers implements a feedback circuit based on the voltage across the R332 resistor, which dictates the V/I conversion factor D’Andola et al. Journal of NeuroEngineering and Rehabilitation (2019) 16:7 Page 6 of 14 estimated to be very small (3.3 μV peak-to-peak), based channel. We connected this output to the CED instru- on the components data sheet and circuit schematics. ment to mark current updates. The circuit guarantees a linear relationship between the For the present work we used one single stimulation input voltage V_Inj and the injected current I_Out as long channel, we configured the stimulator to have reliable as the output voltage of the instrumental amplifier is currents in the range − 1 mA to 1 mA settable with 100 below the clipping values VDD or VEE. We remark that nA accuracy for output load resistances in the order of the maximum injected current will obviously depend on few kOhms. the load downstream I_Out. The injected current will be The intensity for the applied current was kept in the positive (negative) for positive (negative) V_Inj. The avail- range [0 ± 0.65] mA. According to what has been previ- ability of the test points TP102 and TP103 allowed us to ously observed [28, 41], in an interface chamber, where check the V_Inj - I_Out ratio in situations where load in- slices are bathed with the ACSF described before, elec- crease and clipping conditions could be expected. tric fields were generated in the range 1–6 V/m. Current Every second the software instructed the stimulator to intensity and electric field intensity are usually linearly inject current into the cortical slice [26, 28, 41] through correlated in this range. This measure is not appreciably two parallel customized silver-chloride wires (1 mm modified, neither by the presence of the slice nor by the diameter, 10 mm length) placed 5–8 mm apart (depend- recording electrodes [41]. As our custom stimulator in- ing on the slice size), such that the electric field was ori- jects current, we present here the effects on the cortical ented parallel to the apical-dendritic axis of cortical activity provoked by the stimulation by showing the pyramidal cells (Fig. 2b). Positive fields are fields that amount of applied current instead of the obtained elec- depolarize the pyramidal neurons, oriented from the tric field intensity. white matter to the cortical surface, while negative fields Some of the limitations of the present version of the are oriented in the opposite direction, inducing hyperpo- stimulator will be overcome in an improved version larization of pyramidal neurons. Homogeneity of the (already designed) providing more channels, wider volt- electric fields generated by the electrodes was tested in a age range, optically decoupled input and output triggers, separate study with a systematic voltage measure across and embedded monitoring of V/I ratio. the recording area. Upon the arrival of a new command, the outputs were Experimental protocol updated within a few microseconds and a digital trigger The experimental protocol consisted of two main parts was activated on an optically decoupled dedicated (Fig. 4): an open-loop part, for response characterization Fig. 4 Experimental protocol. Left, initial open-loop characterization part: top left, profile of the applied current. Stimulation phases last 60 s. Current levels span the [− 0.6 + 0.6] mA range with 0.1-mA steps. There were 20 s between successive stimulation phases. Right, closed-loop part: bottom right, profile of the desired target SO frequency. A stimulation pause of 40 s was enforced after every set of three targets (0.5, 0.1 and 0.8 Hz) D’Andola et al. Journal of NeuroEngineering and Rehabilitation (2019) 16:7 Page 7 of 14 of the cortical network response, and a closed-loop part, applied the final stimulation protocol on 5 slices. The re- where the biological activity was steered towards the de- sults presented in the following session refer to these 5 sired SO frequency. cases. During the open-loop characterization (Fig. 4, left) we stimulated the slice with a series of six different random- Results ized current levels in the range [0.1 0.65] mA, injecting Reaching the target frequencies for each level first positive current and then negative Cortical slices spontaneously engaged in the generation current, and measuring the corresponding obtained SO of the typical pattern of slow (< 1 Hz) oscillatory activity frequency. Each current level was maintained for 60 s that has been proposed to be the default emergent activ- and in between the stimulation periods we introduced ity of the cortical network [13, 14]. In a previous study pauses of 20 s. For the entire open-loop characterization, [28] we demonstrated that the frequency of SO could be we fixed the duration of the window for SO frequency modulated in vitro by means of DC electric fields. In evaluation at 20 s; hence, to measure the activity we particular, positive (depolarizing) fields increased the SO waited 40 s after the current update. Data obtained from frequency, while negative (hyperpolarizing) fields de- this phase were collected in a current-vs-frequency creased it. Such modulation was proportional to the in- graph (Fig. 2c), which characterized the slice being tensity of electric fields on a logarithmic scale. We tested. For each stimulation current, we averaged all the aimed then to construct a closed-loop system (Fig. 1) measured values of the slow oscillation frequency ob- able to steer the SO frequency toward specific targets, tained during the stimulation interval at that specific in- by stimulating the slices with DC current, as a proof of tensity (58 values). Every slice responded differently to concept that the frequency of cortical SO can be con- the stimulation (see inset in Fig. 2c), as previously dem- trolled online at will. onstrated [28]. Duration of Up and Down states in the Throughout the run, the closed-loop system tuned the spontaneous activity determined reactivity of the net- current amplitude to induce the desired slice activity. In work to the applied electric fields. Fig. 2a we report 3 s of recording obtained with a fixed In the second part of the protocol we activated the stimulation intensity of 0.3 mA. In this case the SO fre- closed-loop control: it autonomously adjusted the current quency of the slice being tested was about 1 Hz. Up to steer the slice activity towards the desired targets. We states lasted 0.22 s on average (range [0.19 0.28] s, vari- chose three target values: 0.5, 0.1 and 0.8 Hz. For each ance 0.0019 s), and their duration did not vary with the slice we repeated three times the sequence of the three stimulation amplitude [28]. On the contrary, the dur- targets (Fig. 4, right). The duration of the measuring win- ation of the Down states was finely modulated by the dow was adjusted according to the target values such that, electric fields, decreasing for positive fields and increas- on average, ten Up states would be included in every ing for negative fields. Therefore, in this example, the measure. We also imposed a maximum limit of 40 s for duration of Down states decreased by raising the stimu- the window duration. Thus, when the target was 0.8 Hz lation level. For this particular slice the mean SO fre- the measuring windows lasted 12.5 s, for 0.5 Hz we used a quency in the absence of stimulation was 0.44 Hz. 20 s window and for 0.1 Hz a 40 s one. The closed-loop To validate our closed-loop system we tested the final took advantage of the open-loop characterization made protocol (Fig. 4) in 5 cortical slices. Previous results [28] specifically for each slice by using, as a first guess for the demonstrated that the intensity of the cortical response current, a value obtained from the characterization data. to the DC stimulation varies across slices. Thus, for each As in the open-loop characterization, there was a “transi- slice, an open-loop characterization was performed tion” phase before the start of data acquisition soon after through the application of DC stimulation at random- the first estimated current was applied. After the transi- ized intensities for periods of 60 s. The recorded re- tion phase, a fine-tuning closed-loop phase took place. sponses were rapidly fitted (Fig. 2c) in order to be able The maximum duration of such a phase was set to 120 s. to make a proper guess on the stimulation intensity to In case the target was reached, the system tried to main- be applied for each of the 3 closed-loop targets that we tain it for the following 40 s before passing on to the next imposed (0.5 Hz, 0.1 Hz and 0.8 Hz). In all cases the target value. closed-loop DC stimulation succeeded to steer the SO During the initial experimental trials we tested 15 frequency to the desired target. slices using different versions of the protocol, observing Figure 5 reports data from one of the runs in the trends of the SO frequency modulation and optimizing closed-loop phase. The SO frequency was modulated to- the system and the experimental protocol. Although we wards three successive target frequencies (0.5 Hz, 0.1 Hz faced some experimental issues, those initial tests pro- and 0.8 Hz). For every target frequency, we started with vided valuable results that we discuss in the next section. an initial current-guess derived from the open-loop After the test and troubleshooting phase was over, we characterization phase. Then, after a transition-phase as D’Andola et al. Journal of NeuroEngineering and Rehabilitation (2019) 16:7 Page 8 of 14 Fig. 5 A closed-loop run. Recording (400 s) from the closed-loop part of the protocol. Top panel: black trace represents the applied current. Central panel: blue trace represents the online measure of the SO frequency. The line is dashed during the transition phase. The fine-tuning closed-loop phases start soon after the transition phase. Dashed black lines represent the desired target frequency levels (0.5, 0.1 and 0.8 Hz). Around the target frequency, the blue shade represents the tolerance range, that was set at 10% of the target frequency (0.01 Hz, 0.05 Hz and 0.08 Hz respectively). MUA traces are shown for the last 10 s of each target phase. Bottom panel: three sections of the recording illustrating the expanded areas indicated. Each section illustrates one of the reached oscillatory frequencies. SO, slow oscillations; RMS, voltage root mean square to identify occurrence of SO long as the measuring window set for that target (see when the target was 0.5 Hz, to 40 s for 0.1 Hz and 12.5 s Methods), a fine tuning was started to bring and keep for 0.8 Hz (see Methods for details). the SO frequency inside the tolerance range around the target. For the first target (0.5 Hz), the system made an estimation of the necessary current injection that was Flexibility of the system and consistency of the network right and a short-lasting fine-tuning phase was neces- response sary. For the second target (0.1 Hz), the initial guess for As mentioned before, different slices responded with dif- current injection was not enough to reach the target, ferent intensity to DC stimulation, in a manner strongly and the network went into a frequency of oscillation of dependent on the initial activity [28]. DC fields act on the ca. 0.38 Hz. Then, the closed-loop acted to progressively activity produced by the local network during the Down reduce the stimulation current, achieving a stable fre- state, increasing or decreasing the firing rate (with de- quency of oscillation around 0.1 Hz. For the third target polarizing or hyperpolarizing fields, respectively) and (0.8 Hz), the current kept increasing trying to compen- changing the probability of the production of the follow- sate for a too-low SO frequency. In this last case, even ing Up state [28]. Networks with high initial excitability though we did not reach a final stable equilibrium, we (higher SO frequency) have small room for modulation at kept the slice activity close to the desired target. The the intensities that we tested, thus hardly showing a strong closed-loop continuously measured the activity and response to the stimulation [28]. The closed-loop is an fine-tuned the stimulation, thus allowing both for the ideal setup to keep networks with such a heterogeneous correction of imprecise current guesses and for slice ac- behavior under control (Fig. 6a). In order to make the tivity stabilization over long time periods. We also report plots easier to read, the frequency patterns were smoothed the MUA traces during the last 10 s of every phase by a cubic spline (Matlab ‘csaps’ function) with a smooth- (Fig. 5, bottom). We remark here that the duration of ing parameter of 0.5, resampled at 100 Hz, and the window used to measure the SO frequency varied color-coded to illustrate the response of the different accordingly to the target frequency: it was set to 20 s slices. Only the fine-tuning phase is illustrated in Fig. 6. D’Andola et al. Journal of NeuroEngineering and Rehabilitation (2019) 16:7 Page 9 of 14 Fig. 6 System flexibility and stability. a Behavior of SO frequency for all the slices (n = 5, color-coded). At t = 0, the closed-loop fine-tuning phase starts. In some cases (particularly at target 0.1 Hz), the frequency did not reach the target in the maximum time imposed by our protocol (120 s). The slope of the patterns, particularly for target 0.5 Hz and 0.8 Hz, suggests that the frequency would have reached the target over time. The same cannot be said for what concerns the 0.1 Hz, where many times the reached frequency was strongly decreased to a value between 0 and 0.2 Hz. b Data acquired from repetitions of one slice (slice 1) during a single uninterrupted series of 3 closed-loop protocols complete runs. Differences between the repetitions of the same target-reaching phase exist: the closed loop compensates for such unpredictable variations. Shadow bars represent the tolerance range, set at 10% of the target frequency (0.01 Hz, 0.05 Hz and 0.08 Hz respectively) Independently from the departing frequency, the com- in the time-evolution of the oscillatory patterns. In the bination of current guessing and fine-tuning allowed the illustrative case in Fig. 6b, when the target was 0.1 Hz system to bring the oscillations close to the desired fre- (left column) the slices responded similarly to the first quency. For the target 0.1 Hz, across all slices the mean current guess twice (run 1 and run 2), while the follow- SO frequency in the last 10 s of each run was 0.19 ± 0.1 ing evolution of the SO pattern was different across the Hz (mean ± SD), thus with an average deviation from two cases (target reached only in the first runs). In the the target of 0.09 Hz. For the targets 0.5 Hz and 0.8 Hz, third run, in contrast, the slice response was completely the average SO frequency in the last 10 s was respect- different even at the first stimulation guess. For the 0.5 ively 0.43 ± 0.06 Hz (deviation from target 0.07 Hz) and Hz target, the response was short and very similar twice 0.75 ± 0.04 (deviation from target 0.05 Hz). In some (run 1 and run 2), while during the third run a longer cases, the frequency did not reach the target in the max- fine-tuning phase was needed to reach the target. Fi- imum time imposed by our protocol (120 s). The slope nally, three very similar responses were observed when of the patterns, particularly for the targets 0.5 Hz and the target was 0.8 Hz, as probably there was little room 0.8 Hz, suggests that the frequency would have reached for activity variations at such oscillation frequency, the target over time. The same cannot be said for the when the applied current was so high. These heteroge- 0.1 Hz target, where many times the reached frequency neities in the response could probably be related to was strongly decreased to a value between 0 and 0.2 Hz some fatigue effects, to the intrinsic variability of the but, within the time and current amplitude constrains slice activity, or to some other environmental effects that we imposed, it instead remained constant without such as electrode oxidation or some unavoidable slight reaching exactly 0.1 Hz. The 120 s limit derives from the changes in temperature or solution flow. Nevertheless, experimental need not to “stress” the slice for too long the closed-loop system was able to steer the activity to- to avoid deterioration of the network, and from the elec- wards the desired target. Among all the recordings, trochemical degradation of the stimulation electrodes when the target was set to 0.1 Hz, the activity often when high currents are applied for very long periods. stabilized at a lower level (Fig. 6): at such low frequen- When comparing the slice response among reiterations cies, a much longer time period would probably be of the protocol, we often observed differences among necessary to evaluate whether the observed behavior repetitions of the same target-reaching phase (Fig. 6b). was actually an incorrect stable equilibrium or a long- Differences are evident both in the departing points and lasting undershoot. D’Andola et al. Journal of NeuroEngineering and Rehabilitation (2019) 16:7 Page 10 of 14 System stability which the current was changed. This allowed us to re- To obtain the control level described above, the first move online the majority of the artifacts from the fil- issue we encountered in this system involved artifacts in tered MUA traces (Fig. 7a and b, top). We note here the recordings due to the current intensity update: every that the commonly used artifact removal techniques change in the current applied to the slices created an consisting in disconnecting the pre-amplifiers for a artifact in the recordings consisting of oscillations in the short time-period around the stimulation is not useful in LFP signal baseline that caused the saturation of the ac- our context where we never detach the stimulation but quisition system for several seconds. Our custom stimu- instead keep adjusting its level. lator was designed paying particular attention to avoid Interestingly, the short artifacts generated by the the generation of undesired artifacts whose amplitude current injection seemed to have no effect on the emer- was reduced with respect to those observed in the same ging activity of the network, either when they occurred setup and preparation with commercial stimulators. during Down states or during Up states. We did not ob- With the custom stimulator, this kind of artifact was re- serve any network responses to the artifacts, as they just duced so that the artifacts appeared as small spikes in appeared in the recording trace and were mainly due to the MUA traces (Fig. 7a and b, bottom), with the ampli- the non-infinite CMRR (common-mode-rejection-ratio) tude depending on the current step (Fig. 7b, bottom) of the differential pre-amplifier. We also noted that the while the duration was short enough to be able to be Up and Down states amplitude in the frequency range automatically distinguished from the Up states, which considered for the MUA traces remained unchanged lasted at least 100 ms (Fig. 7b, top inset). Furthermore, across different amplitudes of artifacts (Fig. 7b, top). thanks to the digital trigger sent back to the recording Since the artifact amplitudes were proportional to the system, we were able to know precisely the moment in stimulation change, when the current step was large Fig. 7 Artifact management and adaptive behavior to large current steps. a Top panel: firing rate (logMUA), first 7 s of recording after a large (~ 1 mA) step in the injected current (from ~ − 0.4 mA to ~ 0.6 mA). An adaptation phenomenon is visible. The red and green dashed circles highlight respectively the changes in the MUA baseline and in the amplitude of the Up states during and after the adaptation phase. Bottom panel: the corresponding MUA trace. The arrows mark three artifacts due to three small (< 50 μA) current updates. b Top panel: firing rate (logMUA) illustrating slow oscillations. Bottom panel: spikes in the MUA trace are artifacts due to current updates: the amplitude of the artifacts is proportional to the current jump. Artifacts are removed before computing the MUA trace (top panel) and do not affect the Up state detection. MUA, multiunit activity. Inset, one expanded Up state. Top, log MUA. Bottom, MUA D’Andola et al. Journal of NeuroEngineering and Rehabilitation (2019) 16:7 Page 11 of 14 enough there was still a short period in which the signal The increase of firing rate during the Down states en- went out of scale (see Fig. 7a for a representative case). hances the probability of triggering new Up states, thus Stimulation aligned at t = 0, and activity returned to a resulting in a higher SO frequency. But it also results in measurable range at around t = 1.5 s, much earlier than a more challenging separation between Up and Down with other commercial stimulators. Since the signal did states, since there is more activity now in the Down not go out of scale for long, we were able to observe that states, and therefore a more difficult online autonomous the network needed a few seconds of adaptation to identification of the Up states (see Methods section), in return to its normal oscillatory activity (Fig. 7a). The ex- particular when injected currents were close to the max- ample in Fig. 7a shows the first 7 s of a stimulation imum (around 0.6 mA). In most cases, the method for phase in which the current jump was about 0.1 mA automatically setting the identification thresholds in the (from ~ − 0.4 mA to ~ 0.6 mA). During this short period, MUA traces worked fine; in a few cases (usually when the baseline of the MUA traces was increased (as injecting 0.5–0.6 mA), however, user intervention to highlighted by the red dashed circles in Fig. 7a) while change the Up state-identification threshold on the fly the amplitude of the Up states remained almost unchanged was needed, which was done without any interruption in (as highlighted by the green dashed circles in Fig. 7a). the protocol. This effect was, to our knowledge, not an artifact in the recordings, but a response of the network activity to a Challenges derived from the continuous DC stimulation large variation in the DC field. and its updates Particularly challenging was the managing of the arti- Discussion facts introduced in the recordings by the jumps in the In this study we designed, tested and demonstrated a level of injected currents, which in the first versions of closed-loop system that can control the frequency of the system looked almost as large as Up states. By redu- SO generated by the cerebral cortex by means of DC cing the noise produced by the hardware during current current stimulation. It is a proof of concept that this updates and by adopting software solutions (see above), rhythmic activity that emerges from cortical networks we were able to reduce the appearance of such artifacts can be regulated within some limits, a principle that to short-lasting spikes with amplitudes proportional to has both research and medical applications. To suc- the current jump (Fig. 7b). We could then easily avoid ceed, we solved several challenges in different fields the artifacts in the identification of Up states by setting a ranging from artifact-related issues to real-time data threshold on their minimum duration. analysis, to problems purely related to experiment A significant reduction of the out-scaling of the re- execution. We discuss these interesting challenges in cording in response to large steps in the current level the following paragraphs. was also achieved (Fig. 7a). This illustrates that the sys- tem initially reaches a certain frequency and then slowly Challenges faced by a closed-loop system that are adapts a stationary state-frequency for a given electric derived from the physiology field intensity. Since the spontaneously emergent rhyth- Our designed system falls into the category of semi- mic patterns are the result of both synaptic (excitation, automatic systems, meaning that it can work alone but it inhibition) and intrinsic properties (ionic channels, also allows for user intervention online. This possibility membrane properties) of the network’s neurons, every to automatically and manually intervene provides the new level of network excitability needs a period to settle flexibility of our system, which also responds to the nat- into a new balance of the different mechanisms resulting ural variability of the network oscillatory activity. We in a stable oscillatory frequency. tested our system on the SO spontaneously generated Prolonged application of high DC currents, without al- by the cortical network [14], that consist of Up states ternation of polarization, induces certain degradation of (active periods of neuronal firing) and Down states the stimulation electrodes by electrochemical reaction of (relatively silent periods). Automatic identification of the AgCl with the ACSF bath, consequently affecting the Up states can be difficult due to many factors, ranging homogeneity of the applied fields [28]. Prolonged appli- from the mechanisms of the network response to the cation of high currents could eventually also damage the changes in SO frequency caused by an applied electric tissue. Unfortunately, both the amplitude and the dur- field through DC stimulation. Changes in the SO fre- ation of the applied currents were defined in real-time quency due to DC stimulation are related to an increase by the closed-loop and are not predictable a priori. We in the activity levels at high frequencies (200–1500 Hz), just imposed some hard limits and this, in some cases, which corresponds to neuronal spikes, in the Down prevented the frequency from reaching its target (Fig. 6) states [28]. Depolarizing fields induce an increase in ex- In any case, permitted current ranges were sufficiently citability, and thus in the firing rate during Down states. extended to allow for a proper modulation of the activity D’Andola et al. Journal of NeuroEngineering and Rehabilitation (2019) 16:7 Page 12 of 14 of most slices. Limits can be easily expanded to user Alzheimer’s disease [43, 44], implantation of closed-loop wishes, and degradation of the electrodes could be systems may aid these clinical populations too. In fact, solved by using a different material: gold or platinum are tDCS has been shown to have good potential for a wide good candidates. We used silver-silver chloride (Ag/ range of clinical applications [45–47] (for a recent re- AgCl) to be consistent with previous studies from our- view see [48]). selves and others. Regarding SO, it is now rather established that en- hancement of SO during slow wave (NREM) sleep can Improving the control be a useful approach to enhance cognition at all ages A set of possible tools ranging from dedicated hardware (for a recent review see [17]). In particular, SO during to real-time operating systems could be adopted to re- sleep enhanced through transcranial magnetic stimula- duce latencies in the loop and to access faster dynamics tion have been found to enhance memory [49]. There is (for a review see [7]). In our case, to gain further control also memory enhancement while activated during over the SO dynamics, apart from reducing latencies it wakefulness [50], although through the activation of would also be interesting to acquire data simultaneously higher frequencies. Furthermore, slow waves have been from many spatially distributed electrodes, to impose entrained through auditory close-loop stimulation, also different electric fields to different areas of the tissue enhancing memory [51]. and to explore more complex and dynamically adjustable Our system is a proof of concept of the possibility of stimulation patterns. This would allow us to control and regulating SO by means of direct current in a understand the mechanisms underlying the SO dynam- closed-loop way, a principle that here we demonstrate ics in a more detailed way. in an in-vitro section of the cerebral cortex, but it can be The intensity of the response of in-vitro networks to applied in vivo. The possibility of an autonomous system DC stimulation varies along with the initial spontaneous that controls and sets SO during patient sleep could be activity. In particular, the intensity correlates with Up an interesting application for future developments of our and Down state durations in control conditions [28]. In system. The closed-loop would ensure a controlled ap- some slices it is more difficult to achieve modulation of plication of low intensity currents in order to re-adjust the SO frequency, especially for “extreme” targets such SO parameters in case they get aberrant during the as 0.1 Hz or 0.8 Hz. In those cases, the distribution of NREM sleep phases of patients, leading to a more fo- the logarithm of the frequency across current intensities cused use of this treatment. In this perspective, future looks more like a sigmoid rather than a linear distribu- improvements of the system would involve the control tion, and this makes it almost impossible to reach of many parameters simultaneously, an objective that boundaries frequencies, at least with the limits that we will pose challenges on the reduction of timing and de- imposed on timing and current intensities. lays of the computation system. Potential applications Conclusions The modulation of SO frequency represents a starting We designed a closed-loop system that can control the point for a more complete closed-loop control of cor- frequency of cortical slow oscillations. The designed sys- tical activity. Once the identification of activity phases is tem was able to identify Up states in real-time, measure achieved (in this case Up and Down states), it becomes their frequency, and autonomously adjust the intensity easier to compute other activity parameters besides Up of the injected current such that a target frequency set state frequency. It will then be possible to switch the sys- by the user would be reached. To minimize the time re- tem to control any of these activity parameters, as long quired to hit the target frequency, an initial current as there is a specific model describing the system’s guess was obtained from an exponential model of the changes in relation to the DC stimulation, and as long network’s reaction to DC electric fields [28]. By finely as the timing of the changing parameters fits with the and continuously tuning the injected current to keep the computation latencies. frequency inside a tolerance range around the target fre- The interest in closed-loop systems is corroborated by quency, the system compensated for natural and unpre- recent tests of closed-loop systems in humans. An im- dictable fluctuations arising from the spontaneous plantable closed-loop system is thought to ameliorate activity of the network. Our system paves the way for fu- the conditions of patients affected by Parkinson’s disease ture studies on in-vitro and in-vivo oscillatory dynamics or suffering from epileptic crises (for a review see [42]). of the cerebral cortex. Because the imbalance between excitation and inhibition that leads to an alteration of the network activation pat- Abbreviations AC: Alternating current; ACSF: Artificial cerebrospinal fluid; DC: Direct current; terns could be the basis of neurological or neurodegen- LFP: Local field potential; MUA: Multiunit activity; SO: Slow oscillations; erative diseases, such as Parkinson’s disease [24] and tDCS: Transcranial direct current stimulation D’Andola et al. Journal of NeuroEngineering and Rehabilitation (2019) 16:7 Page 13 of 14 Acknowledgements 9. Little S, Pogosyan A, Neal S, Zavala B, Zrinzo L, Hariz M, et al. Adaptive deep We would like to thank Dr. Maurizio Mattia (ISS, Rome) for his suggestions brain stimulation in advanced Parkinson disease. Ann Neurol. 2013;74:449–57. Dr. Cristina Gonzalez-Liencres for her comments on the manuscript and Tony 10. Rosin B, Slovik M, Mitelman R, Rivlin-Etzion M, Haber SN, Israel Z, et al. Donegan for the language revision. Closed-loop deep brain stimulation is superior in ameliorating parkinsonism. Neuron. 2011;72:370–84. Funding 11. Sanchez-Vives MV, McCormick DA. Cellular and network mechanisms of This study was supported by the EU project CORTICONIC (Contract number rhythmic recurrent activity in neocortex. Nat Neurosci. 2000;3:1027–34. 600806) to PdG and MVSV and by Ministerio de Economía y Competitividad 12. Compte A, Reig R, Descalzo VF, Harvey MA, Puccini GD, Sanchez-Vives MV. (Spain) (BFU2017–85048-R) and FLAG-ERA (PCIN-2015-162-C02–01) to MVSV. Spontaneous high-frequency (10-80 Hz) oscillations during up states in the cerebral cortex in vitro. J Neurosci. 2008;28:13828–44. Availability of data and materials 13. Sanchez-Vives MV, Mattia M. Slow wave activity as the default mode of the The datasets used and/or analyzed during the current study are available cerebral cortex. Arch Ital Biol. 2014;152:147–55. from the corresponding author on reasonable request. 14. Sanchez-Vives M V., Massimini M, Mattia M. Shaping the Default Activity Pattern of the Cortical Network. Neuron. 2017;94:993–1001. Authors’ contributions 15. Marshall L, Molle M, Hallschmid M, Born J. Transcranial direct current MD contributed to the design of the study, contributed to the design of the stimulation during sleep improves declarative memory. J Neurosci. closed-loop software, performed the experiments, analyzed data and wrote 2004;24:9985–92. the paper. MG contributed to the design of the study, to the design of the 16. Diekelmann S, Born J. The memory function of sleep. Nat Rev Neurosci. closed-loop software, to the creation of the stimulator, analyzed data and 2010;11:114–26. wrote the paper. VD built the stimulator. PG designed and supervised the 17. Wilckens KA, Ferrarelli F, Walker MP, Buysse DJ. Slow-wave activity study, wrote the paper. MVSV designed and supervised the study, wrote the enhancement to improve cognition. Trends Neurosci. 2018;41:470–82. paper. All authors read and approved the final manuscript. 18. Steriade M, Contreras D, Curró Dossi R, Nuñez A. The slow (< 1 Hz) oscillation in reticular thalamic and thalamocortical neurons: scenario of Ethics approval and consent to participate sleep rhythm generation in interacting thalamic and neocortical networks. J Ferrets were cared for and treated in accordance with Spanish regulatory Neurosci. 1993;13:3284–99. laws (BOE-A-2013-6271), which comply with the European Union guidelines 19. Steriade M, Amzica F, Contreras D. Synchronization of fast (30–40 Hz) on protection of vertebrates used for experimentation (Directive 2010/63/EU spontaneous cortical rhythms during brain activation. J Neurosci. 1996;16: of the European Parliament and of the Council of 22 September 2010). All 392 LP–417. experiments were approved by the Ethics Committee of the Hospital Clinic 20. Buzsaki G, Silva FL. High frequency oscillations in the intact brain. Prog (Barcelona, Spain). Neurobiol. 2012;98:241–9. 21. Siegel M, Donner TH, Engel AK. Spectral fingerprints of large-scale neuronal Consent for publication interactions. Nat Rev Neurosci. 2012;13:121–34. Not applicable. 22. Lopes da Silva FH, van Rotterdam A, Storm van Leeuwen W, Tielen AM. Dynamic characteristics of visual evoked potentials in the dog. I. Cortical Competing interests and subcortical potentials evoked by sine wave modulated light. The authors declare that they have no competing interests. Electroencephalogr Clin Neurophysiol. 1970;29:246–59. 23. Lopes da Silva FH, van Rotterdam A, Storm van Leeuwen W, Tielen AM. Publisher’s Note Dynamic characteristics of visual evoked potentials in the dog. II. Beta Springer Nature remains neutral with regard to jurisdictional claims in frequency selectivity in evoked potentials and background activity. published maps and institutional affiliations. Electroencephalogr Clin Neurophysiol. 1970;29:260–8. 24. Bouyer JJ, Montaron MF, Rougeul A, Buser P. Parietal electrocortical rhythms Author details in the cat: their relation to a behavior of focused attention and possible 1 Systems Neuroscience, IDIBAPS, Rosselló 149-153, Barcelona 08036, Spain. mesencephalic control through a dopaminergic pathway. C R Seances Acad 2 Istituto Superiore di Sanità, Rome, Italy. 3ICREA, Passeig de Lluís Companys, Sci D. 1980;291:779–83. 23, Barcelona 08010, Spain. 25. Desmedt JE, Tomberg C. Transient phase-locking of 40 Hz electrical oscillations in prefrontal and parietal human cortex reflects the process of Received: 7 June 2018 Accepted: 5 December 2018 conscious somatic perception. Neurosci Lett. 1994;168:126–9. 26. Frohlich F, McCormick DA. Endogenous electric fields may guide neocortical network activity. Neuron. 2010;67:129–43. References 27. Reato D, Rahman A, Bikson M, Parra LC. Low-intensity electrical stimulation 1. Hodgkin AL, Huxley AF. A quantitative description of membrane current affects network dynamics by modulating population rate and spike timing. and its application to conduction and excitation in nerve. J Physiol. 1952; J Neurosci. 2010;30:15067–79. 117:500–44. 28. D’Andola M, Weinert JF, Mattia M, Sanchez-Vives M V. Modulation of slow 2. Sharp AA, O’Neil MB, Abbott LF, Marder E. The dynamic clamp: artificial and fast oscillations by direct current stimulation in the cerebral cortex conductances in biological neurons. Trends Neurosci. 1993;16:389–94. in vitro. bioRxiv. Cold Spring Harbor Laboratory; 2018;246819. 3. Wagenaar DA, Madhavan R, Pine J, Potter SM. Controlling bursting in 29. D’Andola M, Giulioni M, Dante V, Del Giudice P, Sanchez-Vives M V. A cortical cultures with closed-loop multi-electrode stimulation. J Neurosci. closed-loop stimulation system to modulate slow oscillations frequency of 2005;25:680–8. in vitro acute cortical slices. B-DEBATE A Dialogue with Cereb Cortex 4. Keren H, Marom S. Controlling neural network responsiveness: tradeoffs and Cortical Funct Interfacing. Frontiers in Systems Neuroscience; 2015. constraints. Front Neuroeng. 2014;7:11. 30. Sorensen M, DeWeerth S, Cymbalyuk G, Calabrese RL. Using a hybrid neural 5. Jackson A, Mavoori J, Fetz EE. Long-term motor cortex plasticity induced by system to reveal regulation of neuronal network activity by an intrinsic an electronic neural implant. Nature. 2006;444:56–60. current. J Neurosci. 2004;24:5427–38. 6. Ezzyat Y, Wanda PA, Levy DF, Kadel A, Aka A, Pedisich I, et al. Closed-loop 31. Mavoori J, Jackson A, Diorio C, Fetz E. An autonomous implantable stimulation of temporal cortex rescues functional networks and improves computer for neural recording and stimulation in unrestrained primates. J memory. Nat Commun. 2018;9:365. Neurosci Methods. 2005;148:71–7. 7. Arsiero M, Luscher HR, Giugliano M. Real-time closed-loop 32. Schiff SJ. Neural control engineering: the emerging intersection between electrophysiology: towards new frontiers in in vitro investigations in the control theory and neuroscience. Press MIT, editor. Comput. Neurosci. neurosciences. Arch Ital Biol. 2007;145:193–209. Cambridge, Massachusetts: 2012 Massachusetts Institute of Technology; 2012. 8. Limousin P, Pollak P, Benazzouz A, Hoffmann D, Le Bas JF, Perret JE, et al. 33. Dorval AD, Christini DJ, White JA. Real-time linux dynamic clamp: a fast and Effect on parkinsonian signs and symptoms of bilateral subthalamic nucleus flexible way to construct virtual ion channels in living cells. Ann Biomed stimulation. Lancet. 1995;345:91–5. Eng. 2001;29:897–907. D’Andola et al. Journal of NeuroEngineering and Rehabilitation (2019) 16:7 Page 14 of 14 34. Rolston JD, Gross RE, Potter SM. Closed-loop, open-source electrophysiology. Front Neurosci. 2010;4. 35. Zrenner C, Eytan D, Wallach A, Thier P, Marom S. A generic framework for real-time multi-channel neuronal signal analysis, telemetry control, and sub- millisecond latency feedback generation. Front Neurosci. 2010;4:173. 36. Sanchez-Vives MV. Spontaneous Rhythmic Activity in the Adult Cerebral Cortex In Vitro. In: Ballanyi K, editor. Isol Cent Nerv Syst Circuits. 2012. p. 263–84. 37. Aghajanian GK, Rasmussen K. Intracellular studies in the facial nucleus illustrating a simple new method for obtaining viable motoneurons in adult rat brain slices. Synapse. 1989;3:331–8. 38. Reig R, Mattia M, Compte A, Belmonte C, Sanchez-Vives MV. Temperature modulation of slow and fast cortical rhythms. J Neurophysiol. 2010;103: 1253–61. 39. Mattia M, Del Giudice P. Population dynamics of interacting spiking neurons. Phys Rev E Stat Nonlin Soft Matter Phys. United States. 2002;66: 51917. 40. Ruiz-Mejias M, Ciria-Suarez L, Mattia M, Sanchez-Vives MV. Slow and fast rhythms generated in the cerebral cortex of the anesthetized mouse. J Neurophysiol. 2011;106(6):2910–21. 41. Bikson M, Inoue M, Akiyama H, Deans JK, Fox JE, Miyakawa H, et al. Effects of uniform extracellular DC electric fields on excitability in rat hippocampal slices in vitro. J Physiol. 2004;557:175–90. 42. Sun FT, Morrell MJ. Closed-loop neurostimulation: the clinical experience. Neurotherapeutics. NeuroPace Inc., 445 N. Bernardo Avenue, Mountain View, CA, 94043, USA, fsun@neuropace.com; 2014;11:553–63. 43. Stam CJ, van der Made Y, Pijnenburg YA, Scheltens P. EEG synchronization in mild cognitive impairment and Alzheimer’s disease. Acta Neurol Scand. 2003;108:90–6. 44. Babiloni C, Ferri R, Moretti DV, Strambi A, Binetti G, Dal Forno G, et al. Abnormal fronto-parietal coupling of brain rhythms in mild Alzheimer’s disease: a multicentric EEG study. Eur J Neurosci. 2004;19:2583–90. 45. Priori A, Berardelli A, Rona S, Accornero N, Manfredi M. Polarization of the human motor cortex through the scalp. Neuroreport. 1998;9:2257–60. 46. Nitsche MA, Cohen LG, Wassermann EM, Priori A, Lang N, Antal A, et al. Transcranial direct current stimulation: state of the art 2008. Brain Stimul. 2008;1:206–23. 47. Nitsche MA, Paulus W. Noninvasive brain stimulation protocols in the treatment of epilepsy: current state and perspectives. Neurotherapeutics. 2009;6:244–50. 48. Lefaucheur J-P, Antal A, Ayache SS, Benninger DH, Brunelin J, Cogiamanian F, et al. Evidence-based guidelines on the therapeutic use of transcranial direct current stimulation (tDCS). Clin Neurophysiol. 2017;128:56–92. 49. Marshall L, Helgadóttir H, Mölle M, Born J. Boosting slow oscillations during sleep potentiates memory. Nature. 2006;444:610–3. 50. Kirov R, Weiss C, Siebner HR, Born J, Marshall L. Slow oscillation electrical brain stimulation during waking promotes EEG theta activity and memory encoding. Proc Natl Acad Sci. 2009;106:15460–5. 51. Ngo HVV, Martinetz T, Born J, Mölle M. Auditory closed-loop stimulation of the sleep slow oscillation enhances memory. Neuron. 2013;78:545–53.