Using an Adaptive Thresholding Algorithm to Detect CA1 Hippocampal Sharp Wave Ripples Jay Patel Michigan State University Department of Physics and Astronomy, University of California, Los Angeles 2013 Summer REU Program August 30, 2013 Abstract Sharp wave ripples (high frequency events which occur in the CA1 hippocampal region of the brain) are detected using algorithms which automatically threshold the data at certain voltage values. Typically, detection algorithms use the same threshold throughout the entire voltage trace. The problem with this method is that the amplitude distribution of the noise is not constant in time; algorithms that employ constant thresholds may pick up false positives and false negatives when detecting ripples. False positives act to skew the interpretation of what ripples are; false negatives act to reduce the amount of valuable information we have on ripples. Using an algorithm with an adaptive threshold (which is designed to follow the noise level over time) greatly reduces the amount of false positives and may decrease the amount of false negatives. The total ripple "charge" (integral of ripple voltage [z-score] over time in ripple) in an interval of time where very few actual ripples occur is reduced by a factor of approximately four as compared to the case where a constant threshold is used. The total ripple charge in a temporal region where ripples readily occur increases by roughly five percent as compared to the constant threshold case. Using an adaptive threshold to reduce the amount of false positives and false negatives results in more accurate data on ripples which can potentially give us a better idea of how these brain patterns might form. I. Introduction Sharp wave ripple complexes are oscillatory current patterns which occur in the CA1 region of the hippocampus. Widespread neuron depolarization in the CA3 region of the hippocampus is thought to produce sharp waves which travel to the CA1 region via the Schaffer collateral pathway. The sharp wave is believed to provide ideal conditions for high frequency inhibitory neuron activity in CA1 which gives rise to the so-called sharp wave ripples (Taxidis et al., 2012). Ripples are usually 50-150ms in duration, 140-220 Hz in frequency (Sullivan et al., 2011). Ripples are important mainly because of their affiliation with hippocampal place cells (neurons which spike in only certain spatial locations). In rats, place cells have been shown to fire in a certain temporal order during spatial navigation tasks. Prior to the task, however, all of the place cells will fire in the same order on a compressed timescale coincident with a ripple (Diba and Buzsaki, 2007). Neuroscientists hypothesize that this may be important for memory consolidation (Girardeau et al., 2009). This feature makes it important for us to obtain meaningful data on ripples. In order to obtain good data, it s very important that we know when to call a high frequency oscillation a ripple and when to ignore it. This is the problem of thresholding. Upper thresholds are implemented to determine 1
whether or not an oscillation is a ripple by looking at how high the peak value of the RMS of the oscillation is. Once the upper threshold picks out the ripples, a lower threshold is used to determine where the ripple begins and where it ends. Having too large of an upper threshold will cause the algorithm to miss ripples (many false negatives). A very small upper threshold will cause the algorithm to obtain too many false positives. A medium upper threshold is hard to determine. The median of the data is changing as a function of time, so a medium threshold at one point in time may not be "medium" at another point in time (figure 1). This paper will address this issue and provide a possible solution to the problem: an adaptive threshold. the purpose of an adaptive threshold is to follow how the data changes over time, and then compensate for that change in order to pick out ripples and determine where they start or end with a higher degree of precision. If an adaptive threshold is used, then the total ripple charge during periods of increased median should decrease. Decreasing the amount of supposed ripples during periods of time where ripples are obviously not happening will rid the ripple data of false positives, resulting in more accurate numerical data (magnitude, frequency, duration, etc.) on ripples. This, in turn, will allow us to make more accurate conclusions about ripples. II. Methods Rats were implanted in the CA1 region of the hippocampus with drives containing 22 13 micrometer thick independently adjustable nichrome tetrodes. Prior to immersion, the tetrodes were plated with a gold-carbon nanotube solution (3:1 gold:carbon ratio), such that the impedance for 1 khz signals was around 100-200 kohm. Voltage signals from tetrodes implanted in CA1 were recorded continuously using a Neuralynx data acquisition system. The sampling rate used was 40 khz and the signal was bandpassed between.1 Hz and 9 khz. The data was then downsampled to a sampling rate of 1.25 khz for analysis in Python 2.7. The signal was then bandpass filtered in the range of 80 Hz-250 Hz (n=11). The high frequency filtered signal was z-scored to put it units of standard deviations. Then, the signal was Hilbert transformed to obtain its envelope. Once the envelope was obtained, it was run through a smoothing function which convolves a signal with a Gaussian function with a window size of approximately 41ms. The smoothed signal was then run through a peak finding algorithm, which recorded information on where the peaks were in time. The data set containing the peak information was run through a sliding window histogram function which used a window size of 10s, a step (overlap) of 5s, and a voltage (measured in standard deviations) bin size of 200. The histograms of the peak amplitudes for each 5s period were then plotted side by side from the initial time to the final time (roughly 3742s total) of the voltage trace (figure 1). The sliding window mean was then calculated for the smoothed signal over all time using a window size of 10s and a step (overlap) of 5s. The mean as a function of time was then multiplied by constants 2.7 and 1.6 to obtain the upper and lower adaptive thresholds, respectively, which were then plotted against the sliding window histogram over time along with corresponding constant thresholds. The constant upper and lower thresholds used were 2.7 multiplied by the mean of the mean as a function of time and 1.6 multiplied by the mean of the mean as a function of time, respectively. A spectrogram of the raw voltage trace was taken (NFFT=65536, overlap=58982) (figure 4). 2
will not pick up those ripples (figure 1); as a result the number of ripples in interval 2 using an adaptive threshold is much lower (figure 3). The adaptive upper threshold results in a ripple charge decrease in interval 2 by a factor of nearly 4 (table 1). The adaptive threshold in interval 1 results in roughly 5 percent more ripple charge than in the constant threshold case (table 1). The constant threshold remains above the adaptive threshold from 6664s to 6983s (figure 1). Figure 1: Sliding window histogram. Horizontal axis depicts time. Vertical axis depicts amplitude in sigma. Color axis depicts log (base 10) of the number of peaks in a given bin. Interval 1 is from 6384s to 6589s. Interval 2 is from 6549s to 6664s. The top and bottom green lines represent the upper and lower constant thresholds, respectively. The top and bottom black lines represent the upper and lower adaptive thresholds, respectively. The upper and lower adaptive thresholds were designed to follow the edge of the blue and yellow regions of the distribution, respectively. III. Results Figure 2: Constant Thresholds: Histogram depicting the number of ripples in 5s wide time bins. Vertical axis is number of ripples, horizontal axis is time. Interval 1 and interval 2 (defined earlier) are shown adjacent to one another. Notice the large number of ripples in interval 2. Threshold Interval 1 Interval 2 Constant 42.967 10.147 Adaptive 45.263 2.577 Table 1: Interval Ripple Charge [sigma*s] for Thresholds. Interval 1 is in the time range 6384s- 6589s (figure 1). Interval 2 is in the time range 6549s-6664s (figure 1). The contour of the noise jumps significantly in amplitude in interval 2 (figure 1). The constant upper threshold cuts right through this, causing the algorithm to display a higher ripple count (figure 2). The adaptive upper threshold, however, increases as the contour of the noise increases, ensuring that the algorithm Figure 3: Adaptive Thresholds: histogram depicting the number of ripples in 5s wide time bins. Vertical axis is number of ripples, horizontal axis is time. Notice the vast decrease in ripple count during interval 1. This decrease is due to the adaptive nature of the upper threshold. 3
IV. Discussion The original problem was that the constant upper threshold in the ripple detection algorithm did not have a properly defined value at every point in time. At some times an upper threshold of 3 may not get any of the ripples in the data segment, whereas at other times an upper threshold of 3 may not only detect ripples, but may also mistake noise for ripples. The solution to the problem is to implement an adaptive upper threshold. An adaptive lower threshold is also needed, because ripples are defined to begin and end when the noise ends and begins, respectively. since the noise is shifting in amplitude over time (figure 1), so will the start and end points of the ripples. Naturally, the adaptive thresholds implemented in this project were designed to follow the contour of the noise such that during periods of high noise, the requirement for being a ripple was made higher. It is clear from interval 2 that keeping a constant threshold would allow more noise to be mistaken for ripples (figure 1). With an adaptive threshold, false positives (interval 2) are reduced by a significant amount (table 1). the adaptive lower threshold lies below the constant lower threshold for a significant fraction of the time. It is possible that the adaptive lower threshold is finding ripples where the constant lower threshold missed them. In interval 1, the ripple charge of potential false negatives that were recovered is roughly 5 percent of the total ripple charge in interval 1 during the constant threshold case. It is not entirely clear whether or not the adaptive threshold is picking up false negatives of the constant threshold case. It has been suggested that during REM sleep, ripple activity is less prominent than during slow Wave sleep. During REM sleep, theta wave activity is prominent (Diekelmann and Born, 2010). It is possible that interval 2 is actually the REM sleep state of the rat s sleep (figure 4). Notice how theta power is much higher during interval 2 than interval 1. Perhaps interval 1 is SWS, as this interval is characterized by high ripple activity (figure 1). If this is the case, then it makes sense that there would be little to no ripples during interval 2, as it would be the REM phase of sleep. Using a constant threshold, one would conclude that there are in fact many ripples during this phase (interval 2). This, however, would not be the case during REM sleep. Figure 4: spectrogram of the raw voltage trace over time. Vertical axis is frequency. Theta corresponds to 6-9Hz. Notice how the theta power is large during interval 2, and insignificant in interval 1. Periods of high theta power may be related to REM sleep. References [1] Diba K, Buzsaki G. (2007). Forward and reverse hippocampal place-cell sequences during ripples. Nature Neuroscience, 10(10):1241-1242. [2] Diekelmann S, Born J. (2010). The memory function of sleep. Nature Reviews Neuroscience, 11:114-126. [3] Girardeau G, Benchenane K, Wiener S I, Buzsaki G, Zugaro M B. (2009). Selective suppression of hippocampal ripples impairs spatial memory. Nature Neuroscience, 12:1222-1223. [4] Sullivan D, Csicsvari J, Mizuseki K, Montgomery S, Diba K, Buzsaki G. (2011). Relationships between hippocampal sharp waves, ripples and fast gamma oscillation: 4
influence of dentate and entorhinal cortical activity. J Neurosci., 31(23):8605-8616. [5] Taxidis J, Coombes S, Mason R, Owen Acknowledgements: MR. (2012). Modeling sharp wave-ripple complexes through a CA3-CA1 network model with chemical synapses. Hippocampus, 22(5):995-1017. This research was supported by the NSF. I would like to thank Mayank Mehta for encouraging me to think about problems, Jason Moore for educating me in various data analysis techniques, Zahra Aghajan for assisting me with the Neuralynx software files, and everyone else at the lab for answering my basic questions on neuroscience. 5