## 1 Introduction  
Rapidly changing neural oscillations are fundamental features of a working central nervous system. These oscillations can be seen as rhythmic changes either in cellular spiking behavior or subthreshold membrane potential in a single neuron. Large ensembles of these neurons can generate synchronous activity that results in rhythmic oscillations in the local field potential (LFP). These oscillations reflect the excitability of neurons. Their key role is to assist brain communication across a huge network of neurons via synchronous excitation [1]. At certain frequencies, oscillations are initiated by specific tasks, the outcome of which determines their amplitude or power [2]. Alpha oscillations have generally been considered a ubiquitous characteristic of neural activity; however, recent observations have demonstrated their roles in active inhibition [3, 4] and attention [5]. Although alpha frequencies are slower and tend to distribute frontally in older subjects [6], the largest alpha amplitude is observedat the scalp over the occipital and parietal areas of the brain [7]. Additionally, alpha oscillations are also evident in the form of mu oscillations over motor cortices [8]. These studies suggest that alpha oscillations play a specific role in brain information processing associated with specific functions in motor, perceptual, and cognitive processes. However, the role of oscillations is yet to be revealed. To understand the role of these oscillations in motor, perceptual, and cognitive processes, accurate estimations of instantaneous phase and amplitude are required. In most studies, instantaneous phase relationships are categorized post-hoc due to the requirement for analysis in the time-frequency domain. The focus on oscillatory phase does not imply that the amplitude of ongoing oscillations has no impact. In fact, the phase of an oscillatory signal can only be reliably computed when this signal has a significant amplitude, both in the mathematical and biophysical sense. Oscillatory amplitude in various frequency bands bears significant relations to sensory perception and attention [5; 7; 9; 10]. The instantaneous frequency of electroencephalography (EEG) oscillations has also been investigated [11; 12; 13; 14]. However, the ongoing oscillatory phase has been largely overlooked, at least up until recent studies, which showed the effects of the instantaneous phase on perceptual performance [15; 16; 17]. To reveal the functional role of the phase of neural oscillations, real-time prediction of the instantaneous phase is important. [PERSON] in 1988 [18] and [PERSON] in 1997 [19] built analog circuits that triggered stimulation at the peak, trough, and zero crossing of the hippocampal LFP based on the assumption of a sufficiently narrow bandwidth. [PERSON] [20] employed a dual-window discrimination method for peak detection in theta oscillations. The aforementioned approach required manual calibration in a specific setting; thus, real-time operation would not be possible. More recently, [PERSON] [21] used autoregressive (AR) modelling to accurately estimate the instantaneous phase and frequency of an intracranial EEG theta oscillation and phase-locked stimulation in real time. This study used a genetic algorithm to optimize several parameters before deploying the algorithm. Although the optimization procedure was a major limitation, this system provided a benchmark for comparing oscillations in other frequency bands. Alternatively, wavelet ridge extraction can be utilized to estimate the instantaneous phase [22]. This method is robust when presented with simultaneous multiple oscillatory schemes. However, the implementation of such a system in real time might be computationally expensive. Therefore, an adaptive method is needed. Closed-loop neuroscience has gained significant attention over the past few years with the latest technological advances.