A device and a signal processing method that can be used with a device to recognize and distinguish a physiological high-frequency oscillation (HFO) from a pathological high-frequency oscillation. The signal processing method detects a physiological HFO in the electrical brain signal one regimen of electrical or optogenetic brain stimulation can be triggered, alternatively if the method detects a pathological HFO associated with epilepsy a different regimen of electrical or optogenetic brain stimulation can be triggered. Thus, the signal processing method can be utilized in a closed loop brain stimulation device that serves the dual purpose of both enhancing memory encoding, consolidation, and recall, or improving cognition, and reducing the probability of a seizure in a patient with epilepsy.