Supervised semi-automatic detection of slow waves in non-anaesthetized mice with the use of neural network approach

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


Introduction
Slow waves (SW) are recurrent fluctuations of EEG or local field potentials (LFP) that dominate during slow-wave sleep [1]. 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][3][4][5][6][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 [10] 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][12][13][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 [16].
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 [15]. 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][20][21][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.

Animals
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 (custommade 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).

Recordings
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 custommade 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.

Analysis
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:

Segmentation of the original signal
a. The original signal was filtered in the range of 0.2-4 Hz ( Figure 1A). 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.

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.

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.

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.

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 coincident 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.

Results
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.
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.

Discussion
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 [25]. Large amplitude membrane potential fluctuations and corresponding EEG waves could be recorded during quiet, but not active wakefulness in mice [26][27][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.