Slow waves (SWs) are EEG or local field potential (LFP) events that are present preferentially during slow-wave sleep and reflect periods of synchronized hyperpolarization followed by depolarization of many cortical neurons. We developed a new algorithm of supervised semi-automatic SW detection based on pattern recognition of the original signal with artificial neural network. The method enabled fast analysis of long-lasting recordings in non-anaesthetized freely behaving mice. It allowed finding tens of thousands of SW in 24-hour period of recording with their density in the order of 1.3 SW per second during slow-wave sleep and 0.03 SW per second during waking state. Occasional SWs were also found in REM sleep. The proposed algorithm can be used for off-line and on-line detection of SW.
slow waves, supervised semi-automatic detection, artificial neural network, EEG, mice, states of vigilance.
EEG: electroencephalography; LFP: local field potentials; REM: rapid eye movement; SW: slow wave;
SWS: slow-wave sleep
Slow waves (SW) are recurrent fluctuations of EEG or local field potentials (LFP) that dominate during slow-wave sleep . Simultaneous recordings of cortical intracellular activity and LFP showed that the SWs reflect synchronized activity of large groups of cortical neurons that nearly simultaneously alternate between depolarized and hyperpolarized states [2-7].
Typically, the quality of sleep is estimated from the calculation of delta power, the power of EEG/LFP events in a frequency <4 Hz [8,9]. Although SWs are the main elements that contribute to the EEG delta power (0.2-4 Hz), they are not synonymous  and the number and other characteristics of the SWs such as amplitude and duration cannot be directly estimated with simple filtering. Multiple studies point to the importance of SWs as critical elements mediating sleep-dependent plasticity, epileptogenesis and memory consolidation [11-14].
Trained observers can relatively easily distinguish the SWs in short segments of LFP recordings. The specific shape of an SW can be described as a sharp deflection of depth-positive or surface-negative wave with reduction in fast-frequency components [4,15]. During sleep, their amplitude and duration vary a little and depend on cortical area, being shorter and of lower amplitude in motor and somatosensory areas, and longer and ampler in associative and visual cortical areas, but the duration of intracellular silent states always exceeded 100 ms .
However, the visual examination is time consuming. In addition, the increasing rate of human errors with the fatigue of the examiner makes it impossible to visually analyze long-term recordings.
The existing methods of automatic SW detection are based on their particular features such as amplitude and duration thresholds [17,18], and spectral characteristics of the signal . The amplitude and polarity of SWs are depth-dependent, and the local neuronal synchrony also affects the amplitude of SWs. Therefore, these methods are not sufficiently robust for their effective automatic recognition in non-anaesthetized freely behaving mice.
We developed a new method for SW detection that is based on the recognition of their original shape with the use of artificial neural network. With a different level of accuracy, the machine-learning approach was previously used for automatic detection of various EEG events [19-22]. Unlike other methods, our approach did not require preliminary formal extraction of a pre-set number of SW features (such as slope, amplitude etc.). By contrast, we let the artificial neural network to find the characteristics of the shape of the original signal segment that would allow its identification as an SW.
Materials and methods
All experiments were performed under sterile conditions and in accordance with the guideline of the Canadian Council on Animal Care and approved by the Université Laval Committee on Ethics and Animal Research. Experiments were performed on young (2-3 months) male C57Bl/6 mice (n=5).
Surgery and electrode implantation
Mice were first anaesthetized with 1-2% isoflurane and the head was shaved. The mouse was then fixed in the stereotaxic frame. All incision sites and pressure points were injected with a mixture of Bupivacaine (0.25%)/Lidocaine (0.5%). The head was cleaned with three passages of chlorhexidine/alcohol (0.5%). Buprenorphine (0.1 mg/kg) and saline (0.9% NaCl) (s.c.) were injected. Alternating passages (n=3) of bleach (0.03% sodium hypochlorite) and hydrogen peroxide (3%) were used to clean the skull. The skull was drilled and LFP electrodes (custom-made electrodes, stainless steel wires, 125 μm diameter, PFA-insulated) were implanted in diverse cortical regions to a depth of 0.6 mm from the cortical surface: frontal cortex (AP: +2.5 mm; ML: 1.5 mm; DV: -600 µm); somatosensory cortex (AP: -1.46 mm; ML: 2 mm, DV: -600 µm and AP: -0.94 mm, ML: 3 mm, DV: -600 µm). We used one screw (stainless steel) over the cerebellum as a reference and 4 anchoring screws (2 screws on each side of the skull). Two electromyogram (EMG) electrodes (single-stranded stainless steel wire (PFA-insulated), 75 μm) were inserted into the neck muscle to record EMG activity. All the LFP, EMG electrodes and the reference electrode were connected to a Nano-Miniature omnetic connector and were covered and fixed with dental acrylic (mixture of Dentsply Repair Material Powder and Dentsply Repair Material Pourable Denture Base Liquid, Dentsply-Sundries, DA, USA).
The recordings were done within standard animal facility settings. The standard mice cages were modified enabling the passage of a cable connecting the animal to the recording system. Miniature custom-made buffer pre-amplifier (voltage amplification coefficient 1, but it amplifies current) was attached directly to the head and it was used to reduce movement artefacts in cables. These pre-amplifiers were connected to the commercially available AM amplifiers (Model 3000, A-M system, Sequim, WA, USA). The signals were band-pass filtered between 1 and 100 Hz and the notch filter was used at 60 Hz. The light cycle was 12h/12h with the lights off at 7 pm. LFPs and EMG were continuously recorded (sampling rate 1 kHz) with LabChart (AD instruments, Colorado Springs, CO, USA) 24 hours per day at least for 3 weeks.
All recordings were analysed off-line using custom-written routines in IgorPro (Lake Oswego, Oregon, USA) and Matlab 2011a (MathWorks, Massachusetts, USA).
Determination of states of vigilance
The states of vigilance were determined based on visual examination of 3 LFP channels and EMG. Presence of SWs in all 3 channels with low EMG activity was considered as SWS, high EMG activity was considered as wake and the presence of LFP theta-rhythm with very low EMG values was considered as REM. The dynamic thresholds for EMG activity were set for every 4-hour segment of recordings.
Supervised semi-automatic SW detection with the neural network approach. The algorithm for SW detection consisted of the following steps:
1. Segmentation of the original signal
a. The original signal was filtered in the range of 0.2-4 Hz (Figure 1A).
Figure 1. Artificial neural network approach used to analyze local field potential recordings. A. Fragment of frontal LFP (black – original trace, grey – 0.2-4 Hz filtered trace). Numbers indicate locations of LFP segments shown as templates in B and C. B. Examples of slow wave templates manually selected for neural network training (red trace). C. Examples of noise templates manually chosen for neural network training (blue trace). D. Architecture of the 2 layer feed-forward neural network that was used to classify analyzed segments of the original signal as SW or Noise; w – weights, b – bias. Hidden layer neurons use tan-sigmoid transfer function. Output layer neurons use softmax transfer function.
b. The filtered trace was used only as reference to find the time points for splitting the original signal into smaller segments. For the beginning of each segment we chose a time point corresponding to 150 ms prior to the median between all local negative and positive peaks of the filtered signal (ascending trace). A time point of 150 ms after the median between local positive and negative peaks (descending trace) was defined as the end of the segment.
2. Preparing input data for neural network training.
Original LFPs with overlaying filter trace of 2-3 minutes of SWS with regular SW activity were plotted (Figure 1A). SWs were user defined based on their amplitude, duration, slope, curve characteristics, reduction in fast-frequency components during depth-positive waves and their presence before and after the slow wave. Everything else was considered as Noise. Each analyzed fragment contained 1 “SW” (red) or “Noise” (blue) element marked with a color trace and 5 seconds of background LFP activity. The marked elements were visually inspected and the plots were manually sorted into separate folders for “SW” (Figure 1B) and “Noise” (Figure 1C). The title of each contained a number that corresponded to the starting time point of the inspected segment. These numbers were extracted from the folders and then used as reference for starting and ending time points of original signal segments that served as user-defined “SW” and “Noise” templates. Only definite SW and noise segments were used as input for artificial neural network training. Each group of templates was defined separately for recordings from each electrode and contained at least 100 segments of each class.
3. Training of the neural network to classify the chosen templates into 2 groups.
We used Neural Network Pattern Recognition Tool from Matlab to process data. The structure of the artificial neural network that was created with a built-in function patternnet is shown in Figure 1D. It consisted of input (segments of original signal that were predefined as templates for “SW” and “Noise”, the size of input depended on the maximal duration of the preselected elements and was in the range of 650 msec), a hidden layer and an output layer with 20 nodes (the interconnected computing elements that could extract logical rules of relationship between inputs and associated classes), and outputs (binary values corresponding to the 2 classes of elements) [23,24]. The number of weights and bias (‘w’ and ‘b’ in Figure 1D) slightly differed between channels and in average equaled to 10852 ± 425 elements. The preselected templates were randomly divided into 3 groups: for training (60%), validation (20%) and test (20%). The network was trained with the use of the function trainscg. Being trained on a small number of examples (Figures 1B and 1C), when the relationship with their pattern and associated class was found, the rules could be generalized onto large amount of data.
4. Application of the neural network.
The SW and the background ‘noise’ patterns depend on different factors including location of the electrode. Therefore, the training sets were created separately for each animal and for each channel of the recording. Due to random process of initializing the weights, each training of the neural network gave slightly different results. After 3-5 rounds of neural network training, we chose the neural networks that showed the highest overall rates of correct classification of SW and Noise elements that were in the range of 96.1 ± 1.6%. Then the trained neural network was used to identify SW in long-lasting recordings.
5. Post-processing of the results.
The developed algorithm allowed identification and storage of each single detected SW. To improve the quality of SW detection during movements, we semi-automatically removed artefacts that were co-incident with high muscle activity with the use of dynamic EMG thresholds defined for every 4 hours of recordings on the basis of distribution of absolute EMG potential values.
The results of SW detection with neural network on a short segment are shown in Figure 2. The original trace (Figure 2A) was filtered to create the reference time points of all events for their further classification (Figure 2B). The detected SWs are shown in red and detected segments of noise are shown in blue (Figures 2B-2D). It is evident that the applied algorithm yields an excellent quality of detection, however some aspects need to be discussed. Neural network detected as noise (blue) an event that by brief visual inspection could be defined as an SW (Figure 2C, red offset trace). This event was characterized by ample depth-positive smooth half-wave followed by a sharp, depth-negative half-wave accompanied with high frequency activities. Such events are normally considered to be real SW because a ‘smooth’ depth-positive LFP wave is typically associated with hyperpolarization and silence of cortical neurons and depth-negative LFP waves are associated with neuronal depolarization, high-frequency neuronal activities and firing [4,15]. Closer examination however, revealed that the duration of silent phase of the oscillation was well below 100 ms, therefore, the network correctly did not detect this event as an SW if we assume that the typical duration of intracellular silent states during slow-wave activity is longer than 100 ms (see introduction). On the other hand the network detected an event as an SW that might not be one (Figure 2D, blue offset trace). The duration of this event is roughly 200 ms, but it contains high frequency components that are usually not found during ‘true’ silent states. This might be considered as a false positive detection. However, the proposed method enabled 91 ± 5.3% correct classifications for SW (as we mentioned above it was 96.6 ± 1.3 for Noise). Therefore, we conclude that the neural network method can be used to detect semi-automatically SWs if a few percent errors are acceptable.
Figure 2. Results of the neural network segment detection. A. Fragment of the original signal (frontal channel) to which the trained neural network was applied. B. Results of pattern recognition and classification performed by neural network: detected SWs are marked with red; absence of SWs is marked with blue. C and D. Lower traces indicate the examples of ambiguous results of neural network SW (C) and noise (D) recognition (see text for details).
Next, we used the neural network algorithm to detect SWs from long segments of recordings. The neural network processed signals very fast. Using a MacBookPro computer (OS 8.3, Processor Intel Core i7, 2.3 GHz, memory 8 GB), 4 hours of LFP recordings from one channel were analyzed within 0.59 sec (excluding time for filtering and segmentation of the signal). Overall we found tens of thousands of SWs in 24-hour period of recording, with a density in the order of 1.3 SWs per second during slow-wave sleep and 0.03 SWs per second during waking state. An example of about 12 min of recording with detected SWs is shown in Figure 3A. The initial 3 min of recording were identified as waking state because there were relatively low amplitude LFP activities in all recorded channels and variable muscle tone. After that, the mice entered in a 6 min long SWS state characterized by increased LFP amplitude, low and relatively stable muscle tone except some twitches. The last part of this recoding segment shows REM sleep characterized by low LFP amplitude and an absence of neck muscle tone. As expected, neural network detected multiple SWs during SWS episode (Figures 3A and 3D). However, it also detected a relatively large number of SWs during waking state (Figure 3A) and visual inspection confirms that many of the detected events have features of real SWs (Figure 3B). Slow waves were practically absent during REM sleep.
Figure 3. Supervised semi-automatic detection of slow waves during the three states of vigilance. A. Fragment of multisite channel LFP and EMG that includes wake, slow-wave sleep (SWS) and rapid eye movement sleep (REM). Neural network detected SWs are marked with red. B-D. Expanded fragments of wake, SWS and REM LFP with SWs marked with red (mPFC – medial prefrontal cortex, SSant – anterior somatosensory cortex, SSpost – posterior somatosensory cortex).
We proposed a new method of SW detection with the use of artificial neural network that uses the same characteristics for SW recognition as the classical visual approach. The main advantage of this method is the very high speed of detection of defined events; therefore, it can be effectively used to analyze long-lasting recordings and for on-line SW detection. The main limiting factor is that it requires an observer experienced enough to visually distinguish between SWs and Noise to preselect corresponding templates for each recording electrode and it takes some time to train the artificial neural network to detect SWs.
The time spent for the neural network training was paid off by fast execution of the algorithm of the neural network application. We used splitting of the original signal into short segments referenced to particular points of the delta-filter trace that allowed not only to create a database of the templates but also to reduce the number of computations and thus to increase the speed of analysis without losing the data. Even though the rate of correct semi-automatic event detection was high, the proposed method was not ideal if high precision detection was required. The variability of SW shapes, presence of relatively high amplitude activity in higher frequency bands and offsets in the recorded signal due to animal movement artefacts are among the factors that contribute to the false-negative and false-positive results. The detection rate can be improved by careful reselection of templates for neural network training or by post-processing artefact removal procedure.
The obtained information about each SW can be used to extract various features of the detected elements such as their number, amplitude, duration, shape peculiarities, co-incidence, density in relation to time of the day and the background LFP that can enable comparison of SWs between species and enrich translational studies of the normal SWS and pathological SW activity.
The presence of SWs during wake and REM may be a specific feature of activated states appearance in mice and reflect instability of their states of vigilance. Previous work on sleep-deprived rats demonstrated the presence of isolated SWs during wake . Large amplitude membrane potential fluctuations and corresponding EEG waves could be recorded during quiet, but not active wakefulness in mice [26-28]. The proposed method of SW detection using artificial neural network can provide an unbiased characterization of SW activity in different states of vigilance.
Thus, the proposed algorithm of SW detection with the neural network pattern recognition can be recommended for use in analysis of long-lasting LFP recordings.
We are thankful to Sergiu Ftomov for technical assistance and Josée Seigneur for management assistance.
This study was supported by the National Sciences and Engineering Research Council of Canada (grant 298475) and the Canadian Institutes of Health Research (MOP-136969, MOP-136967).
There are no potential conflicts of interest.
- Blake H, Gerard RW (1937) Brain potentials during sleep. Am J Physiol 119: 692-703.
- Chauvette S, Volgushev M, Timofeev I (2010) Origin of active states in local neocortical networks during slow sleep oscillation. Cereb Cortex 20: 2660-2674. [Crossref]
- Chen JY, Chauvette S, Skorheim S, Timofeev I, Bazhenov M (2012) Interneuron-mediated inhibition synchronizes neuronal activity during slow oscillation. J Physiol 590: 3987-4010. [Crossref]
- Contreras D, Steriade M (1995) Cellular basis of EEG slow rhythms: a study of dynamic corticothalamic relationships. J Neurosci 15: 604-622. [Crossref]
- Steriade M, Timofeev I, Grenier F (2001) Natural waking and sleep states: a view from inside neocortical neurons. J Neurophysiol 85: 1969-1985. [Crossref]
- Volgushev M, Chauvette S, Mukovski M, Timofeev I (2006) Precise long-range synchronization of activity and silence in neocortical neurons during slow-wave oscillations [corrected]. J Neurosci 26: 5665-5672. [Crossref]
- Sheroziya M, Timofeev I (2014) Global intracellular slow-wave dynamics of the thalamocortical system. J Neurosci 34: 8875-8893. [Crossref]
- Borbély AA, Baumann F, Brandeis D, Strauch I, Lehmann D (1981) Sleep deprivation: effect on sleep stages and EEG power density in man. Electroencephalogr Clin Neurophysiol 51: 483-495. [Crossref]
- Borbély AA, Tobler I, Loepfe M, Kupfer DJ, Ulrich RF, et al. (1984) All-night spectral analysis of the sleep EEG in untreated depressives and normal controls. Psychiatry Res 12: 27-33. [Crossref]
- Dang-Vu TT, Schabus M, Desseilles M, Albouy G, Boly M, et al. (2008) Spontaneous neural activity during human slow wave sleep. Proc Natl Acad Sci U S A 105: 15160-15165. [Crossref]
- Marshall L, Helgadóttir H, Mölle M, Born J (2006) Boosting slow oscillations during sleep potentiates memory. Nature 444: 610-613. [Crossref]
- Rasch B, Born J (2013) About sleep's role in memory. Physiol Rev 93: 681-766. [Crossref]
- Chauvette S, Seigneur J, Timofeev I (2012) Sleep oscillations in the thalamocortical system induce long-term neuronal plasticity. Neuron 75: 1105-1113. [Crossref]
- Timofeev, I., Injury induced epileptogenesis: contribution of active inhibition, disfacilitation and deafferentation to seizure induction in thalamocortical system, in Inhibitory Synaptic Plasticity, M.A. Woodin and A. Maffei, Editors. 2011, Springer New York. p. 107-122.
- Mukovski M, Chauvette S, Timofeev I, Volgushev M (2007) Detection of active and silent states in neocortical neurons from the field potential signal during slow-wave sleep. Cereb Cortex 17: 400-414. [Crossref]
- Chauvette S, Crochet S, Volgushev M, Timofeev I (2011) Properties of slow oscillation during slow-wave sleep and anesthesia in cats. J Neurosci 31: 14998-15008. [Crossref]
- Mölle M, Marshall L, Gais S, Born J (2002) Grouping of spindle activity during slow oscillations in human non-rapid eye movement sleep. J Neurosci 22: 10941-10947. [Crossref]
- Vyazovskiy VV, Olcese U, Lazimy YM, Faraguna U, Esser SK, et al. (2009) Cortical firing and sleep homeostasis. Neuron 63: 865-878. [Crossref]
- Jandó G, Siegel RM, Horváth Z, Buzsáki G (1993) Pattern recognition of the electroencephalogram by artificial neural networks. Electroencephalogr Clin Neurophysiol 86: 100-109. [Crossref]
- Liu HS, Zhang T, Yang FS (2002) A multistage, multimethod approach for automatic detection and classification of epileptiform EEG. IEEE Trans Biomed Eng 49: 1557-1566. [Crossref]
- Harner R (2009) Automatic EEG spike detection. Clin EEG Neurosci 40: 262-270. [Crossref]
- Strungaru C, Popescu MS (1998) Neural network for sleep EEG K-complex detection. Biomed Tech (Berl) 43 Suppl 3: 113-116. [Crossref]
- Fiesler E (1994) Neural network classification and formalization. Computer Standards & Interfaces 16: 231-239.
- Duch W, Adamczak R, Grabczewski K (1998) Extraction of Logical Rules from Neural Networks. Neural Processing Letters 7: 211-219.
- Vyazovskiy VV, Olcese U, Hanlon EC, Nir Y, Cirelli C, et al. (2011) Local sleep in awake rats. Nature 472: 443-447. [Crossref]
- Crochet S, Petersen CC (2006) Correlating whisker behavior with membrane potential in barrel cortex of awake mice. Nat Neurosci 9: 608-610.
- Poulet JFA, Petersen CCH (2008) Internal brain state regulates membrane potential synchrony in barrel cortex of behaving mice. Nature 454: 881-885. [Crossref]
- Gentet LJ, Avermann M, Matyas F, Staiger JF, Petersen CC (2010) Membrane potential dynamics of GABAergic neurons in the barrel cortex of behaving mice. Neuron 65: 422-435. [Crossref]