Finds documents with both search terms in any word order, permitting "n" words as a maximum distance between them. Best choose between 15 and 30 (e.g. NEAR(recruit, professionals, 20)).
Finds documents with the search term in word versions or composites. The asterisk * marks whether you wish them BEFORE, BEHIND, or BEFORE and BEHIND the search term (e.g. lightweight*, *lightweight, *lightweight*).
This chapter delves into the complex world of neural signal recording and processing, focusing on the detection and analysis of action potentials and local field potentials. It begins with an overview of the brain's intricate neuronal networks and the importance of understanding neuronal activity. The chapter then explores methods for recording and processing neural electrical signals, including the detection and analysis of extracellularly recorded action potentials, power spectrum analysis, and current density analysis. It also covers techniques for removing stimulus artifacts to extract neural signals during electrical stimulations. The impact of frequency-band selection on spike recordings is thoroughly examined, highlighting the trade-offs between preserving spike waveforms and reducing noise. The chapter also discusses the effects of analog-to-digital conversion on spike waveforms, emphasizing the importance of sampling frequency and resolution. Additionally, it provides insights into spike detection and sorting methods, including threshold methods, window methods, and template matching methods. The chapter concludes with an analysis of neuronal responses to external stimuli, using techniques like peri-stimulus time histograms, joint peri-stimulus scatter diagrams, and joint peri-stimulus time histograms. Readers will gain a comprehensive understanding of the latest techniques and tools used in neural signal processing, making this chapter an essential resource for anyone involved in neuroscience research or clinical applications.
AI Generated
This summary of the content was generated with the help of AI.
Abstract
This chapter introduces methods for detecting and analyzing extracellularly recorded action potentials from individual neurons, also known as unit spikes. It describes the settings of appropriate recording frequency band, sampling rate and resolution for spike recordings. It introduces window-based detection and multiple-channel sorting algorithms for spikes, along with analysis methods for spike sequences (including inter-spike-interval histogram, autocorrelation histogram, cross-correlation histogram, and so on). The chapter also covers spectrum analysis methods for local field potentials and EEG signals. Finally, it presents the current source density analysis for tracking transmembrane current during neuronal activation and provides methods for removing stimulation artifacts from both sinusoidal and pulse electrical stimulations.
The brain is the most complex structure and functional organization among living organisms. The human brain contains a hundred-billion of neurons, each forming connections with other neurons through numerous synapses—up to thousands per neuron. These synapses create extremely complex neuronal networks that can rapidly transmit and process neural information. Any brain response to external events requires information processing across numerous neurons. To reveal these complex working mechanisms, we need to collect adequate data on neuronal activity in living brains. Action potentials of neuronal firing carry vital neural information. Detecting and analyzing action potential sequences from individual neurons and neuronal ensembles form the basis for deciphering how the brain works (Hochberg et al. 2006).
This chapter introduces methods for recording and processing neural electrical signals. It covers the detection and analysis of extracellularly recorded action potentials (unit spikes), as well as power spectrum analysis and current density analysis for local field potentials. It also describes methods for removing stimulus artifacts to extract neural signals during electrical stimulations. These methods are essential for studying neuromodulation.
Advertisement
4.1 Detecting and Analyzing Unit Spikes
When a neuron receives excitatory inputs or stimuli that depolarize its membrane to firing threshold, it can generate an action potential (AP). Figure 4.1A illustrates both intracellular and extracellular methods for measuring APs from individual neurons, which yield distinct potential waveforms. For distinction, we refer to the intracellular waveform as an AP and the extracellular waveform as a unit spike—or simply a spike.
Fig. 4.1
Intracellular and extracellular recordings of neuronal action potentials. A Schematic diagram illustrating the electrode positions for the two recording methods. B Intracellular AP waveform simulated using the HH model (see Sect. 1.3). C Typical spike waveforms recorded extracellularly from a pyramidal neuron and an interneuron in the rat hippocampal CA1 region
Intracellular recording measures the potential difference across the neuronal membrane. The AP, recorded by a glass pipette microelectrode positioned inside the membrane, is a sharp positive-going waveform with its rising phase primarily caused by Na+ influx (Fig. 4.1B). This Na+ influx simultaneously reduces the positive charges outside the membrane to create a current “sink” nearby. As a result, the corresponding spike recorded extracellularly exhibits a sharp negative-going waveform (Fig. 4.1C), opposite to the intracellular recording. In theory, using a point source model, the spike waveform can be inferred as the negative first-derivative of the AP waveform (Henze et al. 2000). However, real experimental measurements have shown that this relationship only holds during the initial period of AP rising phase when the Na+ influx stems from a small area near the soma, making the point source model fairly accurate. Quickly, the ionic currents generated from other parts of the neuron—such as dendrites—can distort this first-derivative approximation (Somogyvári et al. 2005).
The diverse morphological structures of neurons result in various spike waveforms (Henze et al. 2000; Barthó et al. 2004; Huberfeld et al. 2011; Csicsvari et al. 1998). The waveform differences enable the identification of neuronal types based on their spikes. In a wideband signal recording with a frequency range from several to thousands of hertz, the rising phase width of a pyramidal neuron spike (> 0.7 ms) is significantly wider than that of an interneuron (< 0.4 ms) (Fig. 4.1C). This width index has become one of the best indices for distinguishing between the two neuron types (Barthó et al. 2004). Obviously, the extracellular recording site can significantly affect both spike amplitude and waveshape. Spikes recorded near soma have a dominant negative peak due to Na+ influx during the initial action potential phase. In contrast, spikes recorded near dendrites exhibit a dominant positive peak due to the current outflux in its return loop (Pettersen et al. 2012; Obien et al. 2015). Furthermore, the larger soma membrane area can concentrate a greater Na+ flow, resulting in a larger spike, while the return current around dendrites is more dispersed, producing a smaller spike. Therefore, larger spikes typically have a negative peak, while spikes with a positive peak are usually smaller.
The amplitudes of intracellular and extracellular recordings are significantly different. Intracellular AP can exceed 100 mV in amplitude, while extracellular spikes are much smaller, mostly around 100 μV or below. (Note: unless specified, spike amplitude refers to the peak-to-peak amplitude in this book.) Spike amplitude decreases rapidly and exponentially as the distance between the recording site and the neuronal membrane increases. Neurons within a ~ 100 μm radius around a recording point typically produce spikes with amplitudes ranging from tens to hundreds of microvolts (Buzsáki 2004; Henze et al. 2000; Obien et al. 2015). While an expanded radius contains more neurons, the spikes from these additional neurons have diminished amplitudes. These tiny spikes are difficult to detect and simply contribute to background activity, often considered as “noise”. To record spikes with sufficiently large amplitudes, the electrode contact must be close to neuronal somata. In our experiments in the rat hippocampal region, we occasionally recorded spikes exceeding 1 mV in amplitude, primarily from pyramidal neurons. Besides distance and location, other factors can affect spike amplitude and waveform, including neuronal size and morphology, dendritic structures, ion channel distribution and density on membranes (Gold et al. 2006, 2007), as well as the size and features of electrode contacts.
Advertisement
Neurons generate action potentials with a well-known characteristic of “all-or-none”. This means that all action potentials from the same neuron have the same amplitude, regardless of their triggers. Furthermore, the action potentials can travel outward along axons without losing strength. Neurons can encode information by varying their firing rate (frequency)—the average number of action potentials per unit time, known as frequency encoding. Other encoding modes include time, phase, and spatial encoding. All the encoding modes rely on the action potential timing rather than its amplitude or waveform. With rapid advancements in recording techniques like array microelectrodes, ADC and computer data storage, the number of neurons that can be recorded simultaneously has grown exponentially. This growth has driven continuous development of new analysis and processing methods for spike signals (Stevenson and Kording 2011; Horváth et al. 2021; Yuan et al. 2021; Buzsáki 2004; Carlson and Carin 2019; Pachitariu et al. 2024).
Due to the “all-or-none” characteristic, the amplitudes of intracellular APs from the same neuron are identical. However, the amplitudes of extracellular spikes can vary due to the following factors. (1) An electrode contact can pick up signals from many surrounding neurons locating at different distances. Nearby neurons produce large spikes with their waveforms distorted by the background noise—the numerous indistinguishable small spikes formed by the firing of distant neurons. (2) Electronic thermal noise from recording electrodes, amplifiers, and signal acquisition devices can alter recorded spikes. (3) Spikes themselves may exhibit varying waveforms during brief periods of intense firing, such as bursts. (4) Low-frequency influences from local field potentials and other potential drifts may affect spike recordings. (5) Changes in the relative positions between the electrode and recorded neuron over time, especially during long-term recordings, can affect recorded spikes.
Among these factors, the first and second are belong to noise interferences. Spikes are small in amplitude and short in duration, typically lasting no more than 2–3 ms. Their waveforms contain high-frequency components, mainly in the range of 300–5000 Hz. As a result, spike recordings are susceptible to various high-frequency noises, like electronic thermal noises and background noises of indistinguishable spikes. The amplitude of such noises usually ranges in 5 to 20 μV (Maccione et al. 2009; Nelson et al. 2008; Bretschneider and de Weille 2006). Spike recording involves a trade-off. A wider frequency band is necessary to fully preserve the spike waveform. However, noise reduction requires narrowing the frequency band, particularly by eliminating high-frequency components. The third factor is the unique variation of burst spikes, which cannot be removed and must be correctly identified. The fourth factor—low-frequency interferences—can be filtered out. The final factor—changes in electrode position—needs to be tracked and determined.
Weak neural signals collected by microelectrodes must be amplified with a gain of hundreds to thousands. The amplified signals then undergo ADC and save as digital data for subsequent analysis and processing. In this process, it is crucial to correctly set the amplifier frequency range and gain, as well as the ADC sampling frequency and resolution. In the following sections, we will first examine the real spike waveforms without noise, then investigate how frequency range and ADC settings affect spike recordings, and finally study the methods for spike detecting and sorting.
4.1.1 Wideband Noise-Free Spike Waveforms from Signal Averaging
To obtain real spike waveforms, the signal amplification and acquisition system shown in Fig. 3.17 was set up as following. Set the model 3600 amplifier at a frequency range of 0.3 Hz–20 kHz, much larger than spike bandwidth. Set the PowerLab recorder at a sampling frequency of 100 kHz. For spike recordings, the low-frequency cutoff doesn't need to be as low as 0.3 Hz. However, during experiments, LFP signals often need to be recorded simultaneously, requiring the retention of low-frequency signals. Figure 4.2 displays a brief neural signal recorded in the rat hippocampal CA1 soma layer with the above settings. The first row shows the original signal, dominated by slow rhythms at about 0.7 Hz that overshadows small unit spikes. The second row reveals clear spikes after LFP removal by a 300–3000 Hz bandpass digital filter in the LabChart. The enlarged inset in the upper middle clearly shows high-frequency noises with a relatively large amplitude of about 50 μV under the frequency band up to 20 kHz. These noises are reduced significantly in the filtered signal shown below. The right insets are further enlarged in time scale, highlighting amplitude and waveform differences between the filtered and original spikes. Obviously, the filtering distorted spike waveforms simultaneously with noise removal. Next, we will obtain undistorted spikes using signal averaging.
Fig. 4.2
Wideband signals (upper) recorded from the soma layer in rat hippocampal CA1 region and their bandpass filtered signals (lower).
Signal averaging is widely used for denoising. When the noise is random and the wanted signal is consistent and repeatable, averaging can effectively eliminate the random noise while obtaining the deterministic signal with an improved signal-to-noise ratio (SNR). This process involves aligning repeated signals at a specific time point and then calculating their average. The increase in SNR is proportional to the square root of the number of averaged signals. For example, an auditory evoked potential (AEP) in a single trial of scalp EEG recording is typically undetectable, buried within other irrelevant EEG signals and noises. However, a clear AEP can emerge after averaging the EEG episodes from hundreds of repeated auditory stimulations (Enderle and Bronzino 2012).
Based on the “all-or-none” characteristic of action potentials, spikes from an identical neuron can be considered as repeated deterministic signals. Note that changes in burst spikes are excluded here. Figure 4.3A displays the spikes extracted from a wideband recording of 0.3 Hz to 20 kHz, sampled at 100 kHz as the recording shown on the upper row of Fig. 4.2, and detected by using a threshold on the 300–3000 Hz bandpass filtered signal. Each spike waveform included 200 sampling points, covering 1 ms before and after the negative peak respectively. Total 1500 spikes (green waves) were superimposed in Fig. 4.3A, aligned with their negative peaks. Due to the shift of low-frequency field potentials, each spike had a potential shift. Zero-mean spike waveforms were obtained by subtracting their mean from individual spikes (Fig. 4.3B). The high-frequency noise in each zero-mean spike became evident, which was removed by signal averaging (Fig. 4.3C–F). We quantified the denoising effect using the coefficient of variation (CV) among spike waveforms.
Fig. 4.3
Denoising spike waveforms through averaging. A–E Original wideband recordings of 1500 spikes (A); spikes after removing mean (B); and average waveforms for every 10 (C), 100 (D), and 500 (E) spikes. The black waveforms in (A–E) are the identical average spike calculated by averaging all 1500 zero-mean spikes. F Changes of the CV against the number of spikes for averaging
Let xij be the jth sampling point of the ith spike waveform, M be the number of spikes, and xj be the jth sampling point of the average waveform fromM spikes, then
Let APP represent the peak-to-peak amplitude of the average waveform (xj), and N be the length of spike waveform—the number of sampling points per spike, then
The CV is the percentage ratio of the mean spike standard deviation to the APP, representing the variability among spike waveforms. Note that the definitions of xij and xj may vary accordingly in different CV calculations.
Due to the shifts in low-frequency field potentials (Fig. 4.3A), the CV of the 1500 original spikes reached 278% (APP = 181 μV). After mean removal, the CV of zero-mean spikes dropped to 12% (Fig. 4.3B).
Using the CV index, we can examine how denoising efficiency changes with the number of averaged spikes. Averaging every 10 spikes from the total 1500 yielded 150 average spikes, reducing the CV to 3.6% (Fig. 4.3C). Additional noise reduction occurred when averaging every 100 and 500 spikes, respectively (Fig. 4.3D, E). The CV decreased rapidly as the number of averaged spikes increased (Fig. 4.3F). When more than 200 spikes were averaged, the CV fell below 1%, indicating that the obtained spikes can be treated as noise-free waveforms—real spikes. In the next section, we will use the wideband real spikes obtained through averaging to explore how frequency-band settings affect spike waveforms.
4.1.2 Effect of Frequency-Band Selection on Spike Recording
First, let's explore the selection of high-frequency cutoff (fH). We set the amplifier's fH respectively from high to low at 20, 10, 5, 3, and 1 kHz, while keeping the low-frequency cutoff (fL) at 0.3 Hz and the sampling frequency at 100 kHz. Recordings were taken from the rat hippocampal CA1 pyramidal layer for about 2 min at each fH setting. Figure 4.4A shows 10 ms recording samples and their corresponding spike SNR values under different fH settings. The SNR was calculated as the ratio of the spike peak-to-peak amplitude (APP) to five times the noise standard deviation (Feng et al. 2012; Joshua et al. 2007):
$${\text{SNR}} = A_{{{\text{PP}}}} /({5} \times {\text{noise standard deviation}})$$
(4.3)
Fig. 4.4
Effects of high-frequency cutoff (fH) on spike waveforms. A Representative signal episodes recorded at five different fH settings from a same rat experiment, with their SNR values listed alongside. B Noise-free spike waveforms of two distinct neurons at different fH settings. C–E Statistical data from eight rat experiments showing changes in the normalized APP—normalized by the APP at fH = 20 kHz (C), CV (D), and SNR (E) against fH.
The high-frequency noise decreased with fH decreasing, leading to an improved SNR. However, when fH decreased to 1 kHz, the SNR dropped again due to a substantial APP reduction.
The noise-free spike waveforms under different fH settings were calculated from 1300 to 1800 averaged spikes. Figure 4.4B shows the noise-free spike waveforms from an interneuron (left) and a pyramidal neuron (right) recorded at five different fH values. No significant waveform loss occurred with an fH above 5 kHz. As fH decreased, the waveform loss increased, especially at the negative peak of spikes. However, even when fH dropped to 1 kHz, the repolarization phase after the “inflection point” in the pyramidal neuron's spike waveforms (Gold et al. 2007)—denoted by a black arrow in the figure—retained mostly due to its relatively low frequency components.
The statistical results from eight rat experiments showed that the normalized spike amplitudes (APP) at different fH were above 94% for fH ≥ 5 kHz (Fig. 4.4C). However, at fH = 1 kHz, the normalized APP dropped to ~ 52%, representing approximately half loss. Using the CV index to evaluate the waveform changes at different fH settings with the 20 kHz waveform (the real spike) as a reference (Eq. (4.2)), for fH ≥ 5 kHz, the CV remained below 2.5%, but increased to ~ 15% at fH = 1 kHz (Fig. 4.4D). Notably, the spike SNR exhibited a non-monotonic change against fH, peaking between 3 and 5 kHz (Fig. 4.4E). Note that the large standard deviations in SNRs (the error bars) resulted from substantial variations in spike APP values, which ranged from 90 to 205 μV across these rat experiments.
These results suggest that setting fH at 5 kHz can maintain most high-frequency components in spike waveforms while achieving satisfactory spike SNR. Therefore, we typically set the amplifier's fH at 5 kHz for spike recordings.
Second, let's explore the selection of the low-frequency cutoff (fL). In wideband recordings, low-frequency field potentials can overshadow unit spikes (see Fig. 4.2, top left), making it difficult to detect spikes directly using a threshold method. Therefore, we typically filtered out low-frequency signals before spike detection. As shown in the bottom row of Fig. 4.2, a bandpass filter (300-3000 Hz) can remove low-frequency signals with the fL = 300 Hz. Both the fH and fL cutoffs can be achieved by either analog filters in an amplifier or digital filters in software. We usually set fH in the amplifier to eliminate high-frequency noise and avoid the need of a higher ADC sampling frequency, which could limit simultaneous multi-channel sampling. On the other hand, we typically set the low-frequency cutoff in the amplifier to 0.1 or 0.3 Hz to eliminate zero drift and record low-frequency LFPs. These settings allowed us to capture a wide range of neural electrical activity. After signal collection, we used a digital filter to remove low-frequency potentials for spike extraction. The following analysis thus focuses on how the fL setting in digital filtering affects spike waveforms.
Again, we analyzed the spikes from both interneurons and pyramidal neurons in the rat hippocampal CA1 region. The amplifier was set to a frequency band of 0.3 Hz to 5 kHz. According to the Nyquist frequency principle, a 20 kHz sampling frequency would have been sufficient; however, we sampled the signals at 100 kHz to obtain smooth spike waveforms. Then, the 2-min recordings were high-pass filtered using the Kaiser window filter in LabChart software with a cutoff frequency (fL) increasing from 100 to 900 Hz in 100 Hz increments to show how the fL setting affected spike waveforms and their SNRs.
Figure 4.5A shows typical examples of noise-free spike waveforms for the two types of neurons, obtained by the averaging method described above. The wideband real waveforms are shown in red, while the other waveforms at nine different fL settings are in blue. The waveforms at fL = 900 Hz notably differed from the real waveforms. The superimposed plot of all the 10 waveforms shows how they changed as fL increased: both their negative peak and peak-to-peak amplitudes gradually decreased, while a new positive peak emerged before the negative peak. In the pyramidal neuron spikes, the smooth posterior inflection (denoted by the black arrows in Fig. 4.5A) progressively sharpened into a positive peak. This change caused the spikes to lose their wide opening, making them increasingly similar to interneuron spikes. Both types of spikes showed a greater decrease in negative peak amplitude than in peak-to-peak amplitude, particularly at higher fL values (Fig. 4.5B).
Fig. 4.5
Effects of low-frequency cutoff (fL) on the two types of neuronal spikes. A Noise-free spike waveforms from two distinct neurons, including their wideband real waveforms (red) and waveforms at 9 different fL settings (blue). B Changes in spike negative peak and peak-to-peak amplitudes against fL. The amplitudes were normalized to the corresponding amplitude of real spike waveform. C Changes in spike CV against fL. D Changes in spike SNR against fL.
The CV values of the spike waveforms at each fL were calculated by using the real waveforms as a reference. As shown in Fig. 4.5C, the CV gradually increased as fL increased. Notably, pyramidal neurons showed significantly higher CV values than interneurons across the fL range of 100–900 Hz. This difference resulted from the more low-frequency components in pyramidal neuron spikes. These CV values were calculated using spike waveforms spanning 3 ms for interneurons and 4 ms for pyramidal neurons, as shown in Fig. 4.5A, which were different from the 1 ms span shown in Fig. 4.4B.
Figure 4.5D shows how the SNR values of the two types of spikes changed with fL. Spikes of pyramidal neurons had higher SNRs in the fL range of 400-600 Hz, while those of interneurons had higher SNRs in the fL range of 500–800 Hz. The standard deviations of these SNRs were similar to those shown in Fig. 4.4E, influenced by the various peak-to-peak amplitudes of spikes. For clearly displaying the SNR trends, the standard deviation error bars were omitted in Fig. 4.5D.
These results showed that the fL affected the spike waveforms of pyramidal neurons more significantly than those of interneurons. ThefL range for maximum SNR was also different between the two types of spikes. Notably, waveform distortions were already evident at the fL ranges that produced maximum SNRs. For instance, at fL = 600 Hz, the pyramidal neuron spikes showed a negative peak amplitude of only ~ 60% of the real spike value due to the loss of low-frequency components, while the peak-to-peak amplitude was ~ 85%. At fL = 800 Hz, the interneuron spikes maintained higher fidelity, with the negative peak amplitude at ~ 80% of the real spike value and the peak-to-peak amplitude at ~ 90% (Fig. 4.5B).
For any spike signals, a high-pass filter with a higher fL can produce oscillations immediately before and after the spikes (Wiltschko et al. 2008). Figure 4.6 shows a burst from a pyramidal neuron. While the interval potentials between spikes were relatively flat in the original wideband signal, they became as oscillations after high-pass filtering with fL = 500 Hz. It is important to distinguish these filter-produced oscillations from real neural rhythms in hippocampal LFP—such as ripples at 140–200 Hz or even 300–600 Hz (Buzsáki 2006).
Fig. 4.6
Oscillations before and after spike waveforms caused by the removal of low-frequency components by high-pass filtering
A proper frequency band setting is essential for accurate spike recording and detection. In theory, a higher fH in amplifiers is preferable for recording complete spike waveforms. However, the magnitude of electron thermal noise in electrodes and recording instruments is directly proportional to the frequency bandwidth (Bretschneider and de Weille 2006). When the high-frequency band is widened, it can at least increase by several kilohertz, causing a dramatic increase in noise. Our findings showed that at fH = 5 kHz, the loss in spike peak-to-peak amplitude was only ~ 5%, the waveform CV was only ~ 2%, and the spike SNR reached its maximum (Fig. 4.4C–E). At fH = 3 kHz, although waveform distortion increased, the SNR remained comparable to that at 5 kHz. Therefore, for detecting spikes to obtain neuronal firing sequences (Lewicki 1998), setting the fH (the low-pass cutoff) between 3 and 5 kHz is suitable. However, for analyzing subtle features of spike waveforms (Henze et al. 2000) or using them for spatial localization of cell current sources (Lee et al. 2007), a higher fH can be required to retain higher frequency components. Actually, in such cases, both the high and low-frequency components of the spikes are required to preserve as much as possible.
A high SNR is crucial for accurate spike detection using methods like threshold detection (Musial et al. 2002), where spike distortion is a secondary concern. Due to the neuronal morphology and the formation mechanism of action potentials (Gold et al. 2007), pyramidal neuron (Pyr) spikes contain more low-frequency components than interneurons (IN) spikes. This leads to greater peak loss and SNR decrease at higher fL values in Pyr spikes. As a result, Pyr spikes showed maximum SNR in an fL range of 400–600 Hz, while IN spikes had a different fL range of 500–800 Hz (Fig. 4.5D). For detecting both types of spikes, an optimal fL can be set at 500–600 Hz.
Each recording can typically contain spikes from multiple neurons, making spike sorting necessary after obtaining spike waveforms (refer to Sect. 4.1.4). This process relies on the prerequisite that spikes from the same neuron have similar waveforms, while those from different neurons are distinct—with greater differences being preferable. Sorting accuracy depends on factors such as spike SNR and waveform fidelity. Because noise can cause variations in spike waveforms from an identical neuron, spikes with a low SNR create a more scattered distribution in the clustering space, making accurate sorting difficult. Similarly, waveform distortions—such as an increased similarity between different spikes caused by high-pass filtering (Fig. 4.5A)—can also complicate the sorting process (Feng et al. 2012).
In summary, this section explores the changes in spike waveforms from two types of neurons under different frequency cutoffs. The choice of frequency range depends on factors including the features of spike waveforms and the purpose of spike usage. In our studies on neuromodulation by electrical stimulations—covered in Part II of this book, we needed to accurately detect spikes, classify them, and distinguish their neuron types. We also needed to simultaneously record local field potentials and stimulus-evoked potentials, such as APS and OPS. For these purposes, we configured the amplifier to a wideband of 0.3 Hz to 5 kHz, used a 20 kHz sampling frequency to collect signals, and then applied digital high-pass filter in LabChart to remove low-frequency components (with an fL typically set at 500 Hz), which produced clear spikes for subsequent detection and sorting.
Additionally, neuron types can be distinguished based on their spike waveforms and firing patterns. Our method for distinguishing pyramidal neurons from interneurons in the hippocampal region was based on the rising phase width of spike waveforms from the original wideband signals. Spikes with a rising phase wider than 0.7 ms were classified as from pyramidal neurons (Fig. 4.1C), while those narrower than 0.4 ms were considered from interneurons (Barthó et al. 2004). Figure 4.5A demonstrates that high-pass filtering, commonly used in spike detection, can distort spike rising phases—particularly narrowing Pyr spikes. Therefore, when identifying neuron types, we should use the original spike waveforms from wideband signals. Furthermore, as shown in Fig. 4.3, using averaged, noise-free waveforms can produce more accurate measurements.
4.1.3 Effects of Analog-to-Digital Conversion on Spike Waveforms
Modern data acquisition systems for electrophysiological signals rarely use analog devices such as magnetic tape recorders. Instead, they perform real-time ADC to sample amplified signals and store them digitally. ADC has two key specifications: sampling frequency (or sampling rate) and resolution. The sampling frequency (fs) determines the time accuracy, which must be at least twice the highest frequency in the signal (the Nyquist frequency). In practice, an fs of about four times or higher is typically used. Neuronal spikes require a high fs due to their brief duration (~ 1 ms) and high frequency components.
ADC resolution (or quantization level) determines the voltage accuracy in the sampled signal. Spikes require high ADC resolution due to their small amplitudes, typically at tens to hundreds of microvolts. This resolution becomes especially critical when simultaneously recording other signals with larger amplitudes, such as population spikes (PS) above 10 mV and slow waves of spreading depression (Fig. 3.16). A 16-bit ADC converter provides 65,536 quantization levels. At a recording range of ± 20 mV, the ADC resolution is 625nV, allowing a 50 μV spike to occupy about 82 quantization levels. If the recording range is increased to ± 100 mV, the ADC resolution decreases to 3.125 μV, reducing the quantization levels for the same spike to only 16.
Let's examine the spike waveform from a pyramidal neuron shown in Fig. 4.7. The upper left plot shows the waveform with dense data points, captured at fs = 100 kHz with a 0.3 Hz–5 kHz wideband. The remaining plots in the top row, enclosed in dashed boxes, display the same waveform sampled at progressively decreased fs of 20, 10, and 5 kHz. The corresponding plots in the bottom row overlay these waveforms on the 100 kHz sampling waveform (in grey) to highlight differences. At 20 and 10 kHz, the spike waveforms are well-preserved. However, at 5 kHz, the spike negative peak degrades significantly. The steep falling phase of this spike lasts only about 0.3 ms, as shown by the shadow in the upper left plot. At 20 kHz, six data points are captured in the falling phase, while at 10 and 5 kHz, only 3 and 2 data points are captured, respectively. In the bottom left plot, even at fs = 100 kHz, reducing the resolution to 10 μV results in the entire waveform to occupy only 18 quantization levels—appearing as “ladders” with a significant loss of details. Yet for spike detection, where the main goal is to determine spike timings, a lower resolution usually doesn't impact results significantly. For comparison, the resolution of the other waveforms in Fig. 4.7 is 625nV, allowing the spike to span approximately 280 quantization levels.
Fig. 4.7
Effects of ADC sampling frequency and resolution on the recorded waveforms of a same spike. The top row displays waveform data points of the same spike sampled at 100, 20, 10, and 5 kHz (from left to right). The bottom row, within dashed boxes, overlays each waveform from the top row onto the 100 kHz sampling waveform (in grey). The waveform in the bottom left corner has an ADC resolution of 10 μV (at 100 kHz sampling frequency), while the others have a resolution of 625 nV
Spike detection is to extract individual spikes from a recording signal, while spike sorting is to determine which neuron generated each spike. Each electrode contact can typically capture spikes from multiple nearby neurons. To determine the firing sequences of distinct neurons, we need to identify the origin of individual spikes based on their unique waveforms—a process known as spike sorting. Both detection and sorting are essential for obtaining the neuronal firing sequences (or neural coding information) in response to external stimuli. An electrode contact with a larger area can record more neurons simultaneously, but this creates challenges for spike analysis. When multiple neurons emit action potentials simultaneously, their spikes overlap, making extraction difficult. The more neurons recorded and the higher their firing rates, the greater the probability of producing overlapped spikes. Conversely, with fewer neurons recorded, overlapped spikes become minimal and negligible. Additionally, the contact surface acts as an equipotential conductor. If its area is too large, it can create a short-circuiting effect on the surrounding electrical fields, including those formed by spike currents. This makes it difficult to measure large spikes with such electrodes. Given these reasons, an electrode with a smaller contact is more suitable for recording spikes (refer to Sect. 3.4.1).
1.
Methodsfor Spike Detection
One common method used to extract spikes from recordings is the threshold method. Other methods include the window method and template matching method.
(1)
Thresholdmethod for spike detection
Figure 4.8 shows an original wideband recording and its spike signal obtained by removing low-frequency potentials by digital high-pass filtering (with a cutoff frequency of 500 Hz). This filtered signal contains spikes from multiple nearby neurons, known as multiple unit activity (MUA). The spikes in MUA are clearly distinguishable. Most spikes have a negative peak greater than their positive peak. Therefore, a negative threshold can be set to capture spikes with negative peaks below it. However, setting an appropriate threshold is practically challenging. If the threshold (absolute value) is too small, noises may be mistaken as spikes. Conversely, if the threshold is too large, small spikes may be missed. It is critical to set a threshold that can minimize both errors. A common algorithm for automatic spike detection is to set the threshold at 3–5 times the standard deviation of noise or the MUA signals, sometimes with manual adjustments. Additionally, some spikes can have positive peaks greater than negative peaks. To reduce missed detections, both positive and negative thresholds can be set simultaneously.
Fig. 4.8
Original wideband signal (top) and MUA signal (bottom) obtained after high-pass filtering of the original recording
A window method enables direct spike detection in original wideband recordings that contain low-frequency potentials. The method can be performed using a peak-to-peak amplitude threshold to extract spikes. To do it, a time window with a fixed width moves along the recording signal. The difference between the maximum and minimum values within the window at each position is calculated. When this difference exceeds the pre-set threshold, a putative spike is captured and its time span is then determined. The width of time window can be set to ~ 1 ms, matching typical spike widths. Using the peak-to-peak threshold, this method can evaluate both amplitude and slope changes within the signal segment in each narrow window. This effectively excludes low-frequency waves that have large amplitudes but small slopes, enabling direct spike detection from wideband signals.
When using a window method, it is critical to avoid duplicate spike detections. If the division between two adjacent window falls in the middle of a spike waveform, the peak-to-peak values in both windows may reach the threshold, causing a single spike to be mistakenly detected twice. To prevent this, a minimum time interval threshold between adjacent spike peaks can be set to eliminate any duplicate detections that occur too close together.
Figure 4.9A shows a recording during antidromic high-frequency stimulation (A-HFS) on the alveus in the rat hippocampal CA1 region. The A-HFS was a biphasic pulse train with an intensity of only 0.05 mA and a pulse interval of 10 ms (corresponding to 100 Hz). Each pulse triggered a population spike (APS). Upon the rising phase of many APSs, an interneuron spike appeared superimposed (indicated by a blue dot). To detect these spikes using a threshold method, the stimulus artifacts were first removed from the original signal (Fig. 4.9B, see Sect. 4.5.2 for details). Then, the low-frequency potentials were removed using a high-pass filter to obtain the MUA signal shown in Fig. 4.9C. Although spikes during non-stimulation periods were readily detected by a threshold method, the high-pass filtering produced oscillations around the APS waveforms during stimulation, obscuring the following interneuron spikes and making detection difficult. To solve this problem, either remove the APS waveforms before high-pass filtering as reported (Feng et al. 2013), or detect spikes directly using a window method on the original wideband signal (Fig. 4.9A), as described in Sect. 4.1.5.
Fig. 4.9
Detection of spikes occurring immediately following APSs during A-HFS. A Original wideband recording with stimulus artifacts. B Signal with stimulus artifact removed. C MUA signal generated by high-pass filtering of the artifact-free signal. Blue dots in (A) and (B) denote the spikes of an interneuron
A template matching method can detect and classify spikes in the recording signal. For details, please refer to the spike sorting section below.
2.
Aligning and Extracting Spike Waveforms
Threshold and window methods for spike detection only provide approximate time spans of spike waveforms. Before proceeding to spike sorting, the entire spike waveforms must be extracted by determining their start and end points. This process is known as spike alignment, which requires a reference point—typically either the negative peak or the first data point that crosses the detection threshold.
When aligning based on negative peaks, deviations may occur in the extracted spike waveforms due to differences between sampled peaks and actual peaks caused by limited sampling frequency. This issue also occurs when aligning based on threshold points. The actual intersection between the spike waveform and the threshold line may fall between two sampled points rather than exactly on one. Therefore, aligning based on the first sampled point crossing the threshold can cause deviations in extracted waveforms due to differences between the sampled points and the threshold line. To improve accuracy, the precise intersection point between each spike waveform and the threshold line can be calculated by an interpolation algorithm before alignment. Nevertheless, these alignment methods—based solely on a single sampled point—are inevitably affected by noise and limited sampling frequency. An alternative approach uses multiple data points from the major spike portion to calculate a “gravity center” point as the alignment reference, which can reduce deviations.
3.
Spike Sorting
Spike sorting is to classify spikes to their source neurons based on the fact that spikes from the same neuron have similar waveforms. The two main spike sorting algorithms are the parameter method, which uses waveform parameters for sorting, and the template matching method, which compares each waveform with pre-set spike templates.
(1)
Parameter method
The waveform parameters commonly used in spike sorting include amplitude measurements, such as peak-to-peak amplitude, positive peak amplitude, and negative peak amplitude (Fig. 4.10A), as well as time parameters like spike width. Figure 4.10B shows a sorting example using a single parameter—peak-to-peak amplitude (App). TheApp data from all spikes are plotted in a histogram with its vertical axis showing the count of spikes falling in each small App bin. The peaks in the histogram represent spikes from different neurons. When the detection threshold is set low, noise can be mistakenly detected as spikes, forming a “noise” cluster in the small amplitude range (Fig. 4.10B). These noise artifacts can be easily removed during the classification.
Fig. 4.10
Schematic diagram of spike sorting based on spike waveform parameters. A A typical spike waveform drawn by connecting sampling points (20 kHz), along with three amplitude measurements. B Example of a peak-to-peak amplitude histogram created from a spike recording. The four areas separated by red dashed lines represent the clusters of noise and three distinct spike types
Parameter selection is crucial when sorting spikes based on their waveform parameters. Let's take the MUA signal shown in Fig. 4.11A as an example. It contains four distinct types of spikes. However, creating a histogram using positive peak amplitude alone yields only a single peak and fails to provide proper classification (Fig. 4.11B). This occurs because the positive peak amplitudes of the four spike types are too similar to be distinguished from one another. A histogram using peak-to-peak amplitude alone can classify only three types of spikes (Fig. 4.11C), as the amplitudes of the third and fourth spike types overlap considerably. Using multiple parameters together can improve the classifications. Figure 4.11D shows a two-dimensional scatter plot using two parameters: peak-to-peak amplitude and negative peak amplitude. It clearly distinguishes all four types of spikes (encircled by red dashed ellipses). Furthermore, a three-dimensional scatter plot incorporating three parameters: peak-to-peak amplitude, negative peak amplitude, and positive peak amplitude, provides a clearer visualization of the differences among these spike types (Fig. 4.11E).
Fig. 4.11
Example of spike sorting using distinct waveform parameters. A A segment of MUA signal with enlarged insets showing four spike types. B and C Histograms created using single spike parameter: positive peak amplitude (B) and peak-to-peak amplitude (C). D Two-dimensional scatter plot created using two spike parameters of negative peak amplitude and peak-to-peak amplitude, with four spike types indicated by red dashed ellipses. E Three-dimensional scatter plot created using positive peak amplitude, peak-to-peak amplitude, and negative peak amplitude. Green ellipsoids denote the four spike types.
Although intuitive parameters like amplitude and width are common choices, they are not always optimal. Using all sampling points from spike waveforms as high-dimensional data for classification can yield better sorting results—though this approach requires intensive computation. Principal component analysis (PCA) offers a solution by transforming this high-dimensional data into a lower-dimensional one while preserving essential information. PCA can arrange the principal components by their variances, which correspond to component's energy and amplitude. Using the first few principal components with highest variances can achieve effective spike sorting.
(2)
Template matching method
Spike sorting by template matching involves two main steps. First, waveform templates are created for each spike type. Second, the recorded signals are scanned and compared with each template, while the root mean square (RMS) of differences between signal sampling points in the scan window and template points is calculated at each scan movement. When the RMS value falls below a preset threshold, the signal in the scan window is identified as a spike matching the template type. This method can achieve both spike detection and sorting simultaneously on either MUA signals or original wideband signals. It can also be used on extracted spike waveforms to reduce computational cost.
A template matching method can achieve real-time spike detection and sorting during signal collection (Schaffer et al. 2021), although it requires substantial computational resources, precise spike templates, and an appropriate preset fitting threshold. In addition, the method can, to some extent, classify overlapped spikes occurring almost simultaneously from different neurons (Mokri et al. 2017). Furthermore, it can improve the detection and sorting of spikes with gradually varying amplitudes, such as in bursts (Shabestari et al. 2021).
4.
Multi-Channel Spike Detection and Sorting
It is difficult to correctly achieve spike sorting based solely on a single channel recording signal. Each electrode contact can simultaneously capture spikes from multiple nearby neurons. For a same type of neurons at similar distances from a contact, the amplitudes and waveforms of their recorded spikes are similar. It becomes difficult to determine whether these spikes originate from one or multiple neurons based solely on the single recording. Therefore, spikes recorded simultaneously across multiple channels on an array microelectrode should be used to determine spike origins.
Figure 4.12A shows three channel recordings (Ch1-3) from an array microelectrode (A2 × 2-tet-3 mm-150–150-312, NeuroNexus) with a diamond-shape arrangement of groups of four contacts (Fig. 3.12B). The eight spikes recorded in Ch1 are too similar to distinguish when viewed alone. However, when examining all three channel recordings together, we can clearly identify that these spikes come from two distinct neurons (indicated by purple and red triangles above the signals). The spikes with red triangles show large amplitudes across all three channels, while those with purple triangles appear small on both Ch2 and Ch3, indicating that this neuron was close to contact 1 but far from the other two contacts.
Fig. 4.12
Spike signals recorded simultaneously by densely arranged contacts on two types of array microelectrodes. A and B Examples of MUA signals recorded by contacts in diamond-shape (A) and dual column (B) arrangements
Figure 4.12B shows another example of 4-channel MUA signals from a dual column array (A1 × 16-Poly2-5mm-50s-177, NeuroNexus). Colored triangles and blue dots above the signals indicate three types of spikes obtained through four-channel spike sorting for the adjacent channels (Ch4-7). When using Ch4 alone, only two spike types can be distinguished, as it cannot differentiate between the two types of triangular-marked spikes that show substantial differences on Ch6. The spikes marked by red triangles appear larger on Ch6, suggesting that the neuron was closer to the contact 6 on the array. Conversely, the neuron producing spikes with purple triangles was far from the contact 6 because its spikes hardly appear on Ch6. Obviously, the three spike types can be effectively sorted using just the data of a single parameter—the peak-to-peak amplitudes from the four channel recordings.
One common type of traditional recording array is the tetrode, which can be assembled by four microwires glued together (Fig. 4.13). Each wire is insulated except for the measuring contact at its tip. The amplitudes of spikes from a same neuron can vary across the four recording channels due to different distances between the neuron and the contacts. Using MUA signals from all four channels recorded simultaneously can substantially improve spike detection and sorting (Buzsáki 2004). The Neuronexus planar array electrode shown in Fig. 4.12A imitates this tetrode contact arrangement. The manufacturer, therefore, names it “tetrode” (see website: http://neuronexus.com/). The accuracy of spike sorting can be improved when multiple contacts with sufficient spatial density are used. In our laboratory, we commonly used dual column array electrodes (Fig. 4.12B). With such an electrode, MUA signals from any four adjacent channels can be used to classify spikes. Additionally, with its vertically linear arrangement spanning up to 350 μm, this type of electrodes can simultaneously record evoked potentials at different hippocampal layers, such as population spikes at the soma layer and postsynaptic potentials at the dendritic layer (Fig. 3.6).
Fig. 4.13
Schematic diagram showing a tetrode made of four thin wires surrounded by neurons. Triangles represent pyramidal neurons, while circles represent interneurons. The yellow tips represent the exposed contacts. The green and pink spheres represent the spherical surfaces centered at the left and right electrode tips, respectively. Neurons of a same type—when locating along the same spherical surface with similar distances from a contact—produce similar spike waveforms, making it impossible to differentiate these neurons using single-channel spike sorting
The following are the main steps for spike detection and sorting by using multi-channel signals. First, apply a threshold method to each channel individually to detect spikes. The detection results are then merged since the number of detected spikes can vary across channels. As spikes from a same neuron can have different amplitudes across channels, spikes missed on channels with smaller amplitudes may still be detected on channels with larger amplitudes. To avoid noise, you can set a higher threshold based on the channel with larger spike amplitudes—for example, a threshold of 5 times or above the signal standard deviation. This higher threshold can reduce false positives without increasing missed detections. By combining all detected spikes from the channels and removing repeated detections based on spike timing, you can maximize spike detection. As shown in Fig. 4.12B, the spikes marked by red triangles can be detected in Ch4, Ch5, and Ch6. A merging algorithm is needed to remove repeated spikes.
After detection, proper parameters of each spike waveform are extracted for spike sorting. For instance, we employed a custom MATLAB program to extract the first principal components and the peak-to-peak amplitudes of spike waveforms from four adjacent channels to combine into eight parameters for sorting. The sorting was performed in SpikeSort3D, an open-source platform from Neuralynx Inc. (www.Neuralynx.com), which integrates the KlustaKwik clustering program (http://klustakwik.sourceforge.net/)—a widely used spike sorting tool that can also be used independently (Harris et al. 2000; Wild et al. 2012). Figure 4.14 shows an example of our sorting results in SpikeSort3D. The four sections in the middle of the figure display the overlapped spike waveforms in four channels respectively. This SpikeSort3D user interface allows for manual adjustments to improve sorting accuracy.
Fig. 4.14
Example of four-channel spike sorting displayed in the user interface of SpikeSort3D software
In our laboratory, after collecting neural signals from the rat hippocampus using a PowerLab recorder (see Sect. 3.5.3), we selected four adjacent channels for spike detection and sorting. The main process includes: (1) Obtain MUA signals. High-pass filter the original wideband signals to produce MUA signals in LabChart software, with a cutoff frequency typically set to 500 Hz. Export the four-channel MUA signals into a MATLAB data file (.mat). (2) Detect spikes and extract parameters of spike waveforms. Run our custom MATLAB program to read the MUA data file, apply a threshold method to detect spikes, and extract the amplitudes and the first PCA components of each spike waveform across four channels. Generate a Spikesort3D data file (.ntt) consisting of these 8 parameters from all spikes. (3) Perform spike sorting. Open the.ntt file in Spikesort3D, adjust settings accordingly, and select the Klustakwik program for classification (Fig. 4.14). The classification can yield the spike sequences of individual neurons. Export these sequences from Spikesort3D into a text file for subsequent analyses. (4) Verify the spike sorting results. Combine the spike sequences with the original recording signals and MUA signals to form a LabChart file (.bin). Opening this file in LabChart as shown in Fig. 4.15 to visually check the sorting results. The left window in this figure spans ~ 4.12 s, while the enlarged right window shows ~ 0.28 s. The top four rows show the original recording signals from the four adjacent channels on an array electrode as shown in Fig. 4.12B. Spikes appear riding on ~ 4 Hz rhythmic field potentials in the left window and become clearer in the enlarged signals in the right window. The middle four rows show the MUA signals with distinct spikes. The bottom four rows show parts of the sorting results—the spike sequences of four neurons, in which each vertical line (with a constant height) represents a spike whose occurrence timing aligns to the upper channels. Using the scalable display in LabChart, it is easy to examine the details of spike waveforms to verify the sorting results.
In addition to the spike detection and sorting methods described above, we have developed other approaches, including the window-based spike detection introduced in the next section.
4.1.5 Window-Based Spike Detection
Neuronal unit spikes are typically much smaller than the low-frequency field potentials. Thus, the field potentials are usually filtered out by a high-pass filter before using a threshold to detect spikes. However, a challenge can arise when the original recording contains other large potentials with a spectrum overlapping with that of spikes, such as population spikes (PS) from synchronized neuronal firing. In such case, filtering cannot remove PS waveforms without losing unit spikes, and may even introduce additional interference (see Fig. 4.9C). To solve this problem, we developed a window-based method for detecting spikes in the presence of PSs during high-frequency stimulation (HFS) (Wang et al. 2016). Its algorithm steps are as follows.
(1)
Use a time window with a fixed width to segment the original signal. Set the window width (w) at 1.2 ms, which includes 25 sampling points at 20 kHz, approximately one spike width. Other window widths, such as a smaller width matching the spike falling phase, can also work.
(2)
Set lower and higher amplitude thresholds for spike detection. Calculate the mean standard deviation of all window signals. Set the lower amplitude threshold (AL) at 1.5 times the mean value. To eliminate large PS waveforms and HFS artifacts, set the higher amplitude threshold (AH) at 0.6 mV or above. Note that both thresholds can be adjusted accordingly. This window-based algorithm can be used directly on original recording signals with stimulation artifacts, or on signals after artifact removal, as shown in Fig. 4.9A, B.
(3)
Determine the data points of spike negative peaks. Scan the data in each window sequentially. Search for the minimum data in each window and measure the data range in a 0.3 ms period (i.e., 6 sampling points) before the minimum data, denoted as A0.3. If the A0.3 falls between the lower and higher thresholds set in step 2 (i.e., AL < A0.3 < AH), the 0.3 ms signal is assumed to contain the falling phase of a spike. If the minimum data within the 0.3 ms is not located at the window right boundary, then this minimum data is the negative peak point of the spike. Otherwise, continue to search into the next window until reach the negative peak. If this negative peak is the minimum data in the next window, skip the next window to avoid repeated detection of the same spike.
(4)
Use the negative peak point as the spike occurrence timing to create a spike sequence.
(5)
For multi-channel signals, repeat the above four steps on each channel. Then merge their spike sequences to a final sequence by removing any repeated detections (Wang and Feng 2009).
Figure 4.16A and B show recording examples during O-HFS and A-HFS in the rat hippocampal CA1 region. Removing low-frequency field potentials with a high-pass filter can cause oscillations near the evoked PS waveforms, which obscure nearby spikes (as indicated by the red dots in the figure). This makes spike detection difficult using a threshold method. Additionally, the filtering-produced oscillations may cross the threshold and be misidentified as spikes.
Fig. 4.16
Spike detection during O-HFS (A) and A-HFS (B) in the rat hippocampal CA1 region with evoked PSs. Red arrows above the signals denote removed stimulation artifacts. Black and red dots indicate the spikes that become highlighted and submerged, respectively, after high-pass filtering. To make small spikes visible, large-amplitude PS waveforms in both wideband and high-pass filtered signals are truncated.
As shown in Fig. 4.17, the window-based algorithm enables direct spike detection on wideband signals after removing stimulus artifacts. The blue dashed lines represent window segmentations. In each window, the minimum data is initially assumed as the negative peak point of a putative spike. Then, the thresholds AL and AH filter out non-spike signals. The two red circles mark putative spikes with an A0.3 between these thresholds, while the two red boxes mark a field potential with a small A0.3 belowAL and a PS falling phase with a large A0.3 above AH.
Fig. 4.17
Spike detection using a window-based algorithm directly to a wideband signal.
The window-based algorithm can directly detect spikes in wideband signals without the need to filter out low-frequency field potentials while effectively eliminating interference from large PSs. For spike detection during HFS periods, removing stimulation artifacts beforehand is optional. When running the algorithm directly on signals containing artifacts, the artifacts can be eliminated by properly setting the high threshold (AH), since artifacts are typically much larger than spikes. Even if artifacts are occasionally misidentified as spikes, they can be easily excluded during spike sorting due to their narrow waveforms from ~ 100μs pulses commonly used in brain stimulations. This window-based algorithm is thus useful for detecting spikes and studying individual neuron activity, especially in recordings containing PS waveforms during HFS or epileptiform discharges. As detailed in Sect. 5.4, this method was used to analyze interneuron firing during A-HFS.
4.1.6 An Algorithm for Four-Channel Spike Detection and Sorting
Many algorithms have been developed for spike detection and sorting (Pachitariu et al. 2024; Meyer et al. 2023; Zhang et al. 2023; Carlson and Carin 2019; Lefebvre et al. 2016). We also developed an algorithm specifically for four-channel spike sorting. It combined the spikes from all four channels to create composite waveforms, which were then used to calculate PCA components for spike clustering (Wang and Feng 2009), as described below.
Since determining the true number and waveforms of various spikes in real recordings is challenging, to verify the algorithm, we created four-channel simulated data by combining spike waveforms with Gaussian white noise. The spike waveform vs(t) was produced using a combination of sinc and exponential functions:
By adjusting the constants a, b and c, and setting the range of time variable t, we created spike waveforms matching real ones. Figure 4.18 shows the two distinct types of waveforms designed to simulate spikes from two neurons. We then constructed four-channel spike signals by adding Gaussian white noise. Each channel contained spikes from both neurons, but with different amplitudes.
Fig. 4.18
Simulated spike waveforms, four-channel MUA signals and the creation of composite waveform.
We created ten sets of four-channel simulated data with different SNR values based on the SNR range in real recordings. Figure 4.19 shows one set of the simulated data, including spikes from Neuron-1 (Sp1) and Neuron-2 (Sp2). Sp1 had larger amplitudes in Ch1 and Ch3, while Sp2 had smaller amplitudes across all four channels, particularly in Ch1 and Ch3. This made Sp2 difficult to detect in Ch1 and Ch3. The amplitudes of Sp1 and Sp2 were similar in Ch2 and Ch4, making them difficult to distinguish in these channels. Although the amplitude difference between the two spike types existed in Ch3, using the Ch3 signal alone for spike sorting was not feasible due to noise, as shown in the lower right of Fig. 4.19. This scatter plot was created using the first three PCA components (pc1, pc2 and pc3) of Ch3 spikes. All the 173 detected spikes were scattered and not able to cluster.
Fig. 4.19
Comparison between multi-channel and single-channel spike sorting by using four-channel simulated spike data.
For the same data set, using all four-channel signals was able to detect an additional 34 spikes, increasing the total spike count to 207. We then performed PCA analysis on their composite spikes (as shown in Fig. 4.18). The scatter plot of the first three PCA components clearly differentiated between the two spike types (Fig. 4.19, upper right). For visualization, both scatter plots in Fig. 4.19 show only the first three PCA components. However, we actually used more PCA components— achieving a cumulative contribution rate over 90%—to perform the spike sorting.
We also compared single-channel and four-channel spike sorting for experimental recordings from the rat hippocampal CA1 region. Figure 4.20 shows an example of MUA signals recorded by four contacts on a tetrode array (Fig. 4.20A). Figure 4.20B shows the superimposed spikes identified through each single-channel analysis, while Fig. 4.20C shows the results of four-channel analysis using composite spikes and their PCA components.
Fig. 4.20
Results of spike detection and sorting using single-channel and four-channel methods for experimental data. A Four-channel MUA signals recorded using a tetrode array. B Superimposed spikes from individual single-channel analyses. C Results of four-channel analysis using composite spike waveforms for spike sorting. Numbers in parentheses are spike counts.
Through careful visual inspection (see Fig. 4.15 for methodology), we identified a total of 912 spikes in the four-channel signals. These spikes originated from five distinct neurons, labeled Sp1–Sp5 with the following counts: 625 (Sp1), 133 (Sp2), 140 (Sp3), 9 (Sp4), and 5 (Sp5). Notably, Sp5 might be an overlapped waveform resulting from simultaneous firing of two neurons. Using these manual analysis results as reference, we compared single-channel and four-channel automatic analyses with a detection threshold of five times the standard deviation of the MUA signal. Table 4.1 shows the detection accuracy, classification accuracy, and number of identified neurons for both methods.
Table 4.1
Comparisons of the detection and classification from single-channel and four-channel analyses for the experimental recordings shown in Fig. 4.20A
In the single-channel analyses, using Ch1 alone missed spikes across all five neurons, particularly Sp3 spikes with small amplitudes. Only three spike types were identified, with the remaining two types merged into others (Fig. 4.20B). However, these merged types contained few spikes, minimally impacting classification accuracy. Using Ch2 alone resulted in a high detection accuracy, but failed to distinguish between Sp1 and Sp3 due to their similar amplitudes and waveforms. Sp2 was incorrectly divided into two types, resulting in low classification accuracy. Using Ch3 alone yielded the lowest detection accuracy, because Sp3 amplitudes were too small to detect and many Sp2 spikes were also missed. Approximately one-quarter of the total spikes were undetected. Although the classification accuracy was not low, the Ch3 analysis identified only four spike types, with one being misclassified and another partially confused. Using Ch4 alone resulted in a high detection accuracy, but similar amplitudes across the five spike types led to significant confusion, resulting in the lowest classification accuracy.
The multi-channel analysis achieved the highest detection accuracy, missing only 3 out of the total 912 spikes. These missed spikes were all Sp3 type with small amplitudes across all four channels. The analysis successfully identified all five spike types and achieved the highest classification accuracy. Note: the classification accuracy here referred to the percentage of correctly classified spikes among detected spikes, excluding missed ones.
The multi-channel method for spike detection and sorting can be used with signals from two or more channels. To record spikes simultaneously from same neurons across multiple channels, electrode contacts must be closely spaced. When a contact is within 50 μm distance from a neuronal soma, the measured spike amplitude can exceed 60 μV, facilitating detection. Contacts placed 200 μm or more apart can rarely record spikes from a same neuron (Buzsáki 2004; Blanche et al. 2005). As shown in Fig. 4.12, high-density array electrodes with closely arranged contacts can effectively record spikes from same neurons. By combining waveforms from multiple channels into composite spikes, even small or absent spikes in some channels can contribute to the distinctive features of these composite waveforms. As a result, the multi-channel sorting using PCA components can improve classification accuracy, making the method significantly superior to single-channel methods.
Note that the experimental spike waveforms in the above example were extracted from the high-frequency filtered MUA signals (Fig. 4.20A), not directly from the original wideband recordings. The filtering can distort spikes (Fig. 4.5), which may affect classification. Using original spike waveforms may improve spike sorting.
4.2 Spike Sequence Analyses
Spike timing sequences of individual neurons, also known as single unit activity (SUA), can be produced after spike detection and sorting. These sequences present firing patterns that contain both neuronal responses to external events and intrinsic neuronal characteristics. Since spike sequences act like point processes with inherent randomness, they require statistical analysis (Brown et al. 2004; Bretschneider and de Weille 2006). There are many methods to analyze these sequences to reveal distinct neuronal firing patterns, including inter-spike interval histograms and autocorrelation histograms. In addition, cross-correlation histograms can reveal relationships between different neurons, showing their interconnections and signal communications. These methods are introduced below.
4.2.1 Inter-Spike-Interval Histogram
An inter-spike-interval (ISI) histogram can help verify spike sorting results and determine neuron types, such as pyramidal neurons and interneurons. Gerstein and colleagues defined the ISI histogram mathematically as follows (Gerstein and Kiang 1960; Rodieck et al. 1962).
The spike sequence can be represented as the sum of impulse functions with a unit area:
where \(\delta (t)\) is the unit impulse function, t represents time, tk represents the occurrence time of kth spike, and N represents the total number of spikes in the sequence. The ISI histogram, ISI(τ), is then represented as
Discretize the continuous time variable \(\tau\) into \(\tau_{j}\), where j = 1, 2, 3,…. Any \(\tau\) falling within \(\tau_{j} \le \tau < \tau_{j + 1}\) is measured as \(\tau_{j}\). The bin size \(\tau_{j + 1} - \tau_{j} \equiv \Delta \tau\) determines the time resolution of the histogram. In this context, ISI(τ) represents the number of intervals (tk − tk–1) falling within the \(\tau_{j}\).
Figure 4.21A shows two episodes of spike sequences respectively from a pyramidal neuron and an interneuron in the rat hippocampus. Each small bar in these raster plots represents a spike. Figure 4.21B, C are the ISI histograms revealing their firing features: (1) The action potential's refractory period appears as an absence of spikes near zero time. An absence of this gap suggests incorrect spike sorting—spikes from multiple neurons may have been grouped together. (2) These histograms show distinct firing patterns between pyramidal neurons and interneurons. The histogram of pyramidal neuron has peaks around ± 3 ms (Fig. 4.21B), signifying a burst pattern—multiple spikes firing rapidly in clusters (see the spikes indicated by red triangles in Fig. 4.12A, B). In contrast, the histogram of interneuron is relatively flat without sharp peaks (Fig. 4.21C), indicating a random and isolated firing pattern (see the spikes indicated by blue dots in Fig. 4.12B).
Fig. 4.21
Examples of ISI histograms from a pyramidal neuron and an interneuron in the rat hippocampus. A Raster plots showing distinct firing patterns of two neurons. B and C ISI histograms of a pyramidal neuron (B) and an interneuron (C)
For principal neurons involved in signal transmission, burst firing can enhance reliability by increasing neurotransmitter release. Isolated spikes can be treated as noise in some brain regions through a synaptic “filtering” effect, while burst spikes act as transmissible signals carrying information (Lisman 1997). ISI histograms can also feature other firing patterns, such as those induced by high-frequency stimulations with a phase-locked feature (see Sect. 5.3).
4.2.2 Autocorrelation Histogram of Spike Sequences
An ISI histogram is essentially a component in the autocorrelation function of a spike sequence. For the spike sequence described by Eq. (4.5), its autocorrelation function is (Gerstein and Kiang 1960):
where each term corresponds to let l = k, l = k − 1, l = k − 2, … in Eq. (4.7). Therefore, the autocorrelation function is still a sequence of δ functions. Discretize the continuous time τ into \(\tau_{j}\), j = 1, 2, 3, …. All τ values that satisfy \(\tau_{j} \le \tau < \tau_{j + 1}\) are measured as \(\tau_{j}\). Thus \(\tau_{j + 1} - \tau_{j} \equiv \Delta \tau\) defines a time bin that determines the resolution. Consequently, all δ functions of \(\varphi_{ff}\) falling between \(\tau_{j}\) and \(\tau_{j + 1}\) are summed to yield the value of the autocorrelation histogram at \(\tau_{j}\).
The first term (where l = k) in Eq. (4.8) represents the constant N at \(\tau = 0\), which is the total number of spikes in the sequence. When the sequence duration is known, this term reflects the average spike firing rate. The second term (where l = k − 1) represents the intervals between two adjacent spikes—the kth and (k − 1)th, which forms the ISI histogram represented by Eq. (4.6). The third term (where l = k − 2) is another interval histogram measuring intervals between every other spikes—the k-th and (k − 2)th (see Fig. 4.22). It is known as the second-order interval histogram. All subsequent terms represent interval histograms for higher-order intervals in the spike sequence.
Fig. 4.22
Schematic diagram of the definitions of spike intervals at various orders
The autocorrelation function of a spike sequence can reveal both the refractory period and rhythms in neuron firing. For example, when a hippocampal neuron fires at θ rhythms, the autocorrelation function of its spike sequence can exhibit θ rhythms.
4.2.3 Cross-Correlation Histogram of Spike Sequences
The relationship between spike sequences of two neurons, or between a spike sequence and an external event sequence, can be analyzed using a cross-correlation function. The definition of this function resembles the above-mentioned autocorrelation function. Let the spike sequence of neuron-A be
It is still a sequence of δ functions. By discretizing the continuous time τ into small bins \(\tau_{j}\) (j = 1, 2, 3, …), we can create a cross-correlation histogram. As shown in Fig. 4.23, using neuron-A sequence as the reference, count the intervals between neuron-B spikes and each reference spike that fall within each ∆τ to form the histogram. Its x-axis represents time, while its y-axis represents spike count. Dividing the spike count by the total spike number yields neuron-B firing probability against τ, producing a histogram showing how neuron-B fires in relation to neuron-A's firing.
Fig. 4.23
Schematic diagram showing the creation of a cross-correlation histogram from the spike sequences of two neurons
When the spike sequences of both neurons are independent, the expected value for each ∆τ of the cross-correlation histogram is E = NANB∆τ/T, where NA and NB represent the total spike numbers of the two neurons, and T represents the recording duration.
A cross-correlation histogram of spike sequences can reveal direct synaptic connections between a neuron pair (Barthó et al. 2004). When a connection exists, the firing of the presynaptic neuron can either excite or inhibit the postsynaptic neuron after a delay of a few milliseconds caused by axonal conduction and synaptic transmission. For example, an excitatory connection from a presynaptic neuron (reference) to a postsynaptic neuron (target) can produce a histogram with a prominent peak around 2 ms which can represent an interneuron's firing triggered by a pyramidal neuron. In contrast, an inhibitory connection can result in a distinct gap after time zero in the histogram which indicates that the target neuron's firing is suppressed immediately following the reference neuron's firing. In addition, bidirectional synaptic connections between two neurons—where an interneuron (reference) inhibits a pyramidal neuron (target) while the latter excites the former—can show a peak to the left and a gap to the right of time zero in the histogram. This pattern reflects mutual synaptic connections, such as the local feedback inhibitory circuits in the hippocampus (see Sect. 2.3).
Nevertheless, in paired neurons with direct synaptic connections, not every spike of the presynaptic neuron can trigger or suppress the firing in the postsynaptic neuron. This is because each neuron typically has thousands of synapses receiving inputs from many other neurons. To produce an action potential, it typically requires simultaneous excitatory inputs from multiple synapses. The activation from a single presynaptic neuron can only increase or decrease the firing probability of the postsynaptic neuron. This probabilistic nature of synaptic transmission results in peaks or gaps in cross-correlation histograms.
If the reference sequence \(f(t)\) is not a neuronal spike sequence but rather a series of external stimuli (e.g., a pulse train), the relationship between the spike sequence \(g(t)\) and the external events \(f(t)\) can also be analyzed using the cross-correlation function—Eq. (4.10). The equation can be rewritten as
On the right side of this equation, the first term in the square brackets represents the cumulative count of intervals between each spike in \(g(t)\) and its nearest preceding stimulus in \(f(t)\) that fall within each ∆τ, i.e., \(t_{k} < t_{l} < t_{k + 1}\). The second term represents the cumulative count of intervals between each spike and all other stimuli that fall within each ∆τ, i.e., \(t_{l} \ge t_{k + 1}\) or \(t_{l} \le t_{k}\).
When the time interval between adjacent applied stimuli is sufficiently long, the effect of one stimulus on neuronal firing can completely dissipate before the next stimulus arrives. In this case, the first term in Eq. (4.11) represents the post-stimulus time histogram (PSTH), also known as the “peri-stimulus time histogram”, which is the sum of spike histograms generated by NA repeated stimuli. A clear peak in the PSTH indicates that the neuron fires in relation to the stimulation. Conversely, a flat and uniform PSTH suggests that the neuronal firing occurs randomly, unrelated to the stimulation. The PSTH is one of the principal methods for analyzing neuronal responses to external stimuli which will be introduced in the next section, along with other methods including joint peri-stimulus scatter diagram (JPSSD) and joint peri-stimulus time histogram (JPSTH).
4.2.4 Analyses of Neuronal Responses to External Stimuli
1.
Peri-stimulus Time Histogram (PSTH)
As defined by the first term of Eq. (4.11), the PSTH calculation involves two main steps: (1) Divide the time axis (x-axis) evenly into small bins with a resolution of ∆τ, using the stimulus timing as zero; (2) Count the spikes that fall into each ∆τ bin across all stimulation cycles to create the histogram (Rolls et al. 1989). Figure 4.24 illustrates the responses of a neuron to 50 cycles of a 100 Hz pulse stimulation. It shows both the raster plot of neuronal firing (upper) and its PSTH (bottom). The red arrow marks the zero time point when each pulse occurred. Using a bin size of Δτ = 0.5 ms, this PSTH reveals the temporal relationship between the neuronal spikes and the stimulation pulses, with a peak appeared at 7–7.5 ms, indicating the response latency. Notably, not every pulse triggered a spike. The PSTH can also be presented as a curve instead of a bar plot as in this figure. Additionally, the y-axis can display either spike count or firing probability—known as the post-stimulus probability distribution.
Fig. 4.24
Creation of a PSTH histogram showing neuronal responses during 50 cycles of 100 Hz pulse stimulation
When the firing of Neuron-1 and -2 are both related to a same stimulation, their relationship can be described using a joint peri-stimulus scatter diagram (JPSSD). Figure 4.25 shows the definitions of two interval variables—IN1S and IN2S (left), and the creation of JPSSD as a two-dimensional scatter plot using these variables (right). The IN1S (y-axis) represents the intervals between spikes of Neuron-1 and stimulus-S, while the IN2S (x-axis) represents the intervals between spikes of Neuron-2 and stimulus-S. With the stimulus time set as t = 0, when Neuron-1 has a spike at time tN1 and Neuron-2 has a spike at time tN2, draw a dot at position (tN1, tN2) on the two-dimensional plot. Draw all dots sequentially within one stimulus cycle and then repeat for other cycles. The collection of all these dots forms the JPSSD.
Fig. 4.25
Creation of JPSSD. Left: Definition of variables IN1S and IN2S, which respectively represent intervals between stimulus-S and the spike sequences of Neuron-1 and -2 during a stimulus cycle. Right: JPSSD scatter plot created using IN1S and IN2S variables.
The following JPSSD examples show various relationships between the stimulation S and the spike sequences of two neurons (N1 and N2). The JPSSDs can be analyzed along with the cross-correlation histograms of the two neurons and their respective PSTHs (Gerstein and Perkel 1972).
(1)
When the two neurons fire independently and are unaffected by the stimulation, the JPSSD appears as uniformly distributed dots. In such case, the cross-correlation histogram between N1 and N2 and their PSTHs all appear flat, lacking any significant peaks.
(2)
When both neurons fire independently but N2 is excited by the stimulation, a high-density band appears on the JPSSD parallel to the y-axis, indicating an increase of N2's firing with a latency. This excitatory effect also produces a peak on the N2 PSTH, while the N1 PSTH and the cross-correlation histogram between the two neurons remain flat. Similarly, when the stimulation excites both neurons (with no direct connection between them), high-density bands appear parallelly to both the y-axis and x-axis. Correspondingly, peaks appear on both neurons’ PSTHs, and a peak appears near the zero time on their cross-correlation histogram, suggesting that both neurons are simultaneously controlled by the same input.
(3)
When stimulation has no effect on either neuron, but N2 acts on N1 through excitatory synapses, the JPSSD displays no bands parallel to the coordinate axes but shows a high-density diagonal band parallel to the main diagonal, slightly offset to the left, indicating the synaptic connection. The band offset and width reflect the latency and duration of synaptic actions, respectively. In the cross-correlation histogram, a peak occurs near zero, which is unrelated to the stimulation input. The PSTHs of both neurons remain flat. If a third neuron simultaneously acts on the two neurons through excitatory synapses, while the stimulation remains no effect on these neurons, a high-density diagonal band will also appear, along with a peak in the cross-correlation histogram.
(4)
When the stimulation excites both neurons, and N2 acts on N1 through excitatory synapses, high-density bands appear parallelly to both coordinate axes, together with a high-density diagonal band. These combined effects result in evident peaks in the cross-correlation histogram and the PSTHs of both neurons.
In summary, the JPSSD of two neurons can reveal the effects from both external stimulation and neuronal interconnections. High-density bands parallel to the coordinate axes represent excitatory stimulation effects on neurons, while a high-density diagonal band parallel to main diagonal represents synchronous firing of both neurons. A narrow diagonal band indicates a direct excitatory synapse connection between the two neurons, whereas a wide and sparse diagonal band indicates both neurons being affected by a third source.
3.
Joint Peri-Stimulus Time Histogram (JPSTH)
Both cross-correlation histogram and JPSSD can reveal the relationships between the spike sequences of two neurons. However, a cross-correlation histogram only shows the average result of entire spike sequences. Although it can reveal whether one neuron's firing leads or lags another's, it cannot pinpoint when this relationship occurs—whether throughout the entire sequence or only during specific periods. A joint peri-stimulus time histogram (JPSTH) based on JPSSD can offer more details of dynamic changes in the neuronal relationships and in the effects of external stimulation (Gerstein et al. 1989).
4.3 Spectral Analysis and Its Applications
Frequency spectrum analysis, also known as spectral analysis, can reveal the frequency components of a signal in the frequency domain. For signals with inherent randomness, such as EEG and LFP, a spectrum can be estimated using either parametric or non-parametric methods. The non-parametric method, also called classical spectrum estimation, is widely used and employs two basic approaches (Shiavi 2007). The first one, known as the direct or periodogram method, produces a spectrum from the Fourier transform of a sampled signal based on Parseval’s theorem. The second one, the indirect method, produces a power spectrum based on the principle that the power spectral density is the Fourier transform of signal's autocorrelation function. We have been using the LabChart software to calculate the spectra of hippocampal field potentials. This software provides a “Spectrum” window, which uses the periodogram method for spectral analysis. The following sections will explain the basic principle of periodogram method and then discuss the parameter settings and applications of LabChart spectrum analysis.
4.3.1 Periodogram Method for Spectrum Analysis
Let x(n) be the discrete signal produced by ADC with a sampling frequency of fs and a corresponding sampling period of ΔT = 1/fs. As a sequence of N samples, x(n) can be written as x(1), x(2), …, x(N). Its discrete Fourier transform (DFT) is:
The frequency range of X(f) is -fs/2 ≤ f ≤ fs/2, with a resolution of Δf = 1/(NΔt). The X(f) is a discrete sequence of N data points: X(1), X(2), …, X(N), evenly spaced by Δf. The plot of X(f) mode (|X(f)|) against frequency is known as amplitude spectrum. Squaring |X(f)| produces the energy spectrum. Then, dividing the energy by the signal duration NΔt produces the power spectrum. Finally, power spectral density (PSD) is the power per unit frequency. Thus, a spectrum can be expressed in four forms: amplitude, energy, power, and PSD. For a real sequence x(n) (e.g., an actual sampled signal), the negative half of its frequency spectrum mirrors the positive half, making it sufficient to calculate only the positive half.
For a random signal, estimating its spectrum from a single signal episode can yield unreliable results due to high variance. Fortunately, periodogram averaging—also known as the Bartlett approach—can effectively reduce the variance. This method divides a signal of N sampled data into K segments of length M, calculates the spectrum of each segment separately, and then averages the results. This process can reduce the variance of spectrum estimation to 1/K (Shiavi 2007).
The duration of a signal used to calculate the discrete Fourier transform determines the spectral frequency resolution. When the signal is segmented, it becomes shorter, resulting in a decreased spectrum resolution. Therefore, it is crucial to compromise on both spectral variance and resolution when setting the segment number. To enhance spectral resolution, segments can be overlapped and reused to yield longer segments, resulting in the modified Welch method. It divides the signal into segments with M sampled data, where the starting points of adjacent segments are apart by only D sampled data, less than M. The number of segments becomes K = (N − M)/D + 1, as shown in Fig. 4.26. The overlap ratio is (M-D)/M × 100%. Increasing this ratio can either raise the segment number K (with a fixed M) or extend the segment length M (with a fixed K), or increase bothK and M. However, an excessively high overlap ratio cannot further improve the spectrum variance. Typically, the overlap ratio is set at about 50%.
Fig. 4.26
Schematic diagram of segmentation for signalx(n). The shading represents the overlapping area with an overlap ratio of (M − D)/M
A sampled signal has resolution and range (or duration) in both its frequency and time domains. Understanding these parameters and their relationships is essential. In frequency domain, the frequency resolution of spectrum is determined by the duration of the signal used to calculate the Fourier transform in the time domain (i.e., the signal after segmentation). This resolution is the reciprocal of the signal duration. For example, a 10-s signal gives a frequency resolution of 0.1 Hz, while a 0.1-s signal only achieves 10 Hz—waveforms below 10 Hz cannot be accurately captured in such a short time window. Additionally, the spectrum repeats periodically with a period equal to the sampling frequency (fs). For real signals, the basic positive frequency range is from 0 to fs/2. For instance, with fs = 1000 Hz, the spectrum upper limit is 500 Hz, as waveforms with a frequency beyond this limit cannot be fully captured. In the time domain, the signal resolution (sampling period) is ΔT = 1/fs—the reciprocal of the spectral period, while the signal duration is the reciprocal of the frequency resolution. These relationships between time and frequency domains exhibit symmetry.
Spectral leakage is another issue to consider when using the periodogram method for spectrum estimation. Extracting a segment from a recorded signal is equivalent to applying a rectangular window to the signal. The spectrum of this window has large sidelobes, leading to leakage and thus deviation in the estimated spectrum. To reduce the leakage, a common approach is to multiply each signal segment by a non-rectangular window with smaller sidelobes—such as Hamming or Hanning windows—before calculating the spectrum.
Popular signal processing software like MATLAB can easily calculate spectra of brain signals such as EEG and LFP. For example, MATLAB function “pwelch” can compute the PSD using the Welch periodogram method. The function's calling format is:
In the parameter list on the right side, “x” represents the sampled signal, “window” is the chosen window with an equal length to the signal segment, “noverlap” is the overlap ratio between adjacent segments, “nfft” is the number of data points used for the Fourier transform, and “fs” is the sampling frequency of signal x. This pwelch function uses the Fast Fourier Transform (FFT) algorithm to speed up computation when “nfft” is a power of 2. Note that the window length must not exceed “nfft” to avoid errors. In the return list on the left side, “Pxx” represents the PSD of signal x, while “f” is the corresponding frequency vector. Additionally, the pwelch can provide confidence intervals for the spectrum estimation. For more details, refer to the MATLAB help documentation.
Figure 4.27 shows examples of PSD calculations for EEG signals collected from the central (C3 and C4) and occipital (O1 and O2) areas of an awake, resting adult subject with closed eyes. The EEG signals were 10 s in length with a sampling frequency of 250 Hz. Their spectra were estimated using the Welch periodogram method, with a segment length of 256 data points, a Hanning window, and a 50% overlap. When the subject was awake and quiet (Fig. 4.27A), the EEG signals showed prominent α rhythms in the 8–13 Hz range, which produced clear peaks in their power spectra (Fig. 4.27C). In contrast, when the subject performed complex mental arithmetic (Fig. 4.27B), the α rhythms were suppressed, resulting in a significant decrease in the power of α frequency range (Fig. 4.27D).
Fig. 4.27
Examples of EEG signals and their PSDs from an adult subject. A and B 10-s EEG recordings from the central (C3 and C4) and occipital (O1 and O2) areas during eyes-closed resting state under two conditions: task-free (A) and complex mental arithmetic (B). C and D PSDs of the EEG signals shown in (A) and (B), respectively
After obtaining the PSD, the mean power in each rhythmic range can be calculated based on the definitions of rhythmic frequency ranges for EEG and LFP (Feng and Zheng 2004a). For example, we can estimate the power of δ (0.5–4 Hz), θ (4–8 Hz), α (8–13 Hz), and β (14–30 Hz) rhythms. From this, the amplitude of individual rhythms can be determined. An alternative approach is to calculate the ratio of power in each rhythm range to the total signal power. This method can eliminate individual variations, facilitating comparisons among different subjects.
Long recordings of spontaneous EEG and LFP signals are typically non-stationary, changing with the behaviors and mental states of humans or animals. The above-mentioned spectral estimations are only suitable for stationary signals. Time–frequency analyses—such as short-time Fourier transform (STFT) and wavelet transform (WT)—are more suitable for non-stationary signals. STFT analyzes a signal using a shifting window with a fixed length, exhibiting time–frequency features in a two-dimensional plot. However, STFT has a trade-off: shorter signals result in poorer frequency resolution, making it impossible to achieve high resolutions in both time and frequency domains simultaneously. Unlike STFT, WT can decompose a signal using basic wavelets with varying displacement and scale factors. By using larger windows for lower frequency components and shorter ones for higher frequency components, WT can meet resolution requirements in both time and frequency domains (Clark et al. 1995; Feng 2003; Feng and Zheng 2004b). In MATLAB, the “spectrogram” function can calculate STFT, while its Wavelet Toolbox provides various functions for performing wavelet transforms.
4.3.2 Spectral Analyses in LabChart
We used a PowerLab recorder to collect signals in the rat brain (see Sect. 3.5.3). This recorder comes with the LabChart software, which offers spectrum analysis using the periodogram method. It employs FFT to calculate the discrete Fourier transform (Eq. (4.12)). FFT requires the number of data points to be a power of 2. As shown in Fig. 4.28, the “FFT size” option in the LabChart settings dialog provides options including 32, 64… 1 K (1024), 2 K (2048)…to 128 K (131,072) in the drop-down menu, all powers of 2. This FFT size corresponds to the data length M shown in Fig. 4.26. Note that this M is the length of divided signal segments, not the total signal length. The M is crucial as it determines the spectral frequency resolution. For example, using the default FFT size of 1 K (1024 sampled data points) for a signal sampled at a 20 kHz frequency results in a spectral resolution of only 20000 Hz/1024 = 19.531 Hz. This means that the spectrum of low-frequency field potentials below ~ 20 Hz cannot be obtained. Increasing the FFT size to 32 K (32,768) or 64 K (65,536) can improve the spectral resolution to 0.610 Hz or 0.305 Hz.
Fig. 4.28
Settings dialog for spectrum analysis in LabChart software
The “Data window” option in the settings dialog allows user to choose a window applied to each signal segment to reduce leakage error. Available windows include Bartlett, Hamming, and Hanning windows. The “Window overlap” represents the overlap ratio between adjacent signal segments—as shown in Fig. 4.26. The “Mode” option sets the spectrum form, with options including amplitude, power, and power density.
In the cortex and hippocampus of a urethane-anesthetized rat, the recorded LFP signals typically exhibit large-amplitude slow waveforms of δ rhythms. However, when a small clip is used to slightly clamp the rat's tail, the LFPs can quickly shift to a signal dominated by small-amplitude θ rhythms (Buzsáki et al. 1983). Here, I use such a recording as an example to demonstrate LabChart spectral analysis. The upper row of Fig. 4.29A shows an LFP signal from the rat hippocampus, which spanning ~ 867 s and containing two tail-clamping events. The expanded view below clearly shows the LFP change caused by the first tail clamping.
Fig. 4.29
Analysis of the frequency spectra for LFP signals recorded from rat hippocampus using LabChart. A Original recording of ~ 867 s (top) and its enlarged ~ 33 s segment (bottom). B Time–frequency PSD of the entire signal in A, with an enlarged segment showing the period from 143 to 182 s. C Mean PSDs for the LFP signals before (orange) and during tail clamping (green), marked by ① and ② in A and B
Before entering the PowerLab recorder for sampling, the signal was magnified 100-fold by the pre-amplifier (Model 3600) with a frequency range of 0.3–5000 Hz (see Sect. 3.5 for details). Therefore, a ± 1 mV signal appears as ± 100 mV in Fig. 4.29A.
To perform the STFT spectral analysis in LabChart, set the FFT size to 128 K—M = 131,072. With a sampling frequency of 20 kHz, this FFT size produces a signal segment of 6.5536 s, yielding a spectral frequency resolution of 0.153 Hz. Using a Hamming window with 50% overlap can produce a time resolution of 6.5536 s/2 = 3.2768 s for the time–frequency spectrum. Figure 4.29B shows the PSD of the entire signal shown in Fig. 4.29A, demonstrating that both tail clamping events shifted the LFP from δ rhythm (~ 0.76 Hz) to θ rhythm (~ 3.5 Hz) dominance. The expanded view below focuses on the period from 143 to 182 s, clearly showing discrete spectral data with a time resolution of about 3.3 s. The large-amplitude δ rhythms (yellow) before tail clamping and the small-amplitude θ rhythms (green) during tail clamping are distinctly visible.
Figure 4.29C shows the mean PSDs of the two signals: one before tail clamping (~153 s) and the other during tail clamping (~ 262 s), marked by ① and ② in Figure 4.29A, B. The pre-clamping PSD (orange), calculated from 47 signal segments (K = 47), shows a δ peak at 0.76 Hz. The during-clamping PSD (green), calculated from 78 signal segments (K = 78), shows a θ peak at 3.1 Hz. The δ peak (0.19mV2/Hz) is approximately 14 times that of the θ peak (0.014mV2/Hz), indicating a 3.7:1 amplitude ratio in the original recordings. Note: the θ rhythm frequency in rat LFPs under urethane anesthesia is about 2–5 Hz, lower than the 6-9 Hz observed during awake state (Buzsáki 2002).
We have used the power spectrum analysis to study various neurophysiological phenomena in rats, including exploring changes in cortical electroencephalogram (ECoG) across different sleep stages and at various depths of anesthesia (Feng 2003; Feng and Zheng 2004a), as well as analyzing changes in hippocampal field potentials in response to high-frequency pulse stimulations (Yu et al. 2016; Ma et al. 2019).
4.4 Current Source Density Analysis
Neurons can produce electrical activity through transmembrane currents. In extracellular space, these currents create “sources” where they flow out of membrane and “sinks” where they enter membrane, as illustrated in Fig. 2.5C. Analyzing the spatiotemporal distribution of the current sources and sinks can provide insights into neuronal activity and explore the initiation and propagation of neuronal firing. However, extracellularly recorded field potentials cannot directly reflect neuronal current flow. In 1975, Nicholson and Freeman proposed a theorem of current source density (CSD) to estimate current sources and sinks using field potentials (Nicholson and Freeman 1975). The CSD calculation involves the second-order differences of a series of LFP recordings along a specific spatial axis. In early studies, when glass pipette or metal wire microelectrodes with only a single measuring contact were used for extracellular recordings, researchers had to move the electrode step-by-step to measure LFPs at different depths. This method required the LFPs to be repeatable after each electrode movement. It was therefore primarily used for analyzing repetitive evoked potentials (López-Aguado et al. 2000; Heynen and Bear 2001), not for random spontaneous potentials. This limitation has been overcome with the introduction of array microelectrode.
A linear array with multiple contacts can simultaneously record field potentials at different depths, enabling CSD analysis. This technique is widely used to analyze neural signals in both animals and humans (Townsend et al. 2002; Csercsa et al. 2010). The algorithm for estimating CSD from LFPs is essentially a “reverse problem” that requires additional constraints to solve (Pettersen et al. 2012). Let V(t, x, y, z) be the LFP recorded at time t at extracellular site (x, y, z), and let σx, σy, and σz be the conductivity in the x, y, and z directions, respectively. The CSD at site (x, y, z) at time t is
A negative CSD value indicates current flowing into the cell—extracellularly forming a sink, while a positive value indicates current flowing out of the cell—extracellularly forming a source. In brain regions with regularly arranged neurons in well-defined layers, such as the hippocampal CA1 region, one-dimensional CSD parallel to the neuronal soma-dendritic axis (z-axis) can be calculated to analyze transmembrane currents at each layer during synchronous firing of a neuron population. The impact of extracellular conductivity changes on CSD is minimal. The conductivity values can be considered constant (Kloosterman et al. 2001; Richardson et al. 1987). Additionally, when only relative CSD values are needed for comparisons, conductivity values can be omitted. Thus, the calculation of one-dimensional CSD(t, z) in the hippocampal CA1 region can be simplified to the following second-order difference:
where V(t, z) is the LFP at depth z at time t. ∆z is the spacing between adjacent recording channels in a vertically arranged array (e.g., 50 µm), which determines the CSD spatial resolution. When N is set to 2, the LFP sampling spacing becomes 100 µm, a spacing suitable for CSD calculation (Pettersen et al. 2012).
As shown in Fig. 4.30A, we used a 16-channel array with 50 μm spacing to record the LFPs in rat hippocampal CA1 region for analyzing the initiation and propagation of the APSs evoked by alveus stimulations and the OPSs evoked by Schaffer collateral stimulations (see Sect. 2.3 for details). Signals from 9 channels (Fig. 4.30B1), spanning a ± 200 μm range around the soma layer, were used to calculate the CSD across the CA1 region—from the basal dendrite layer (so), through the soma layer (pcl), to the apical dendrite layer (sr) (Fig. 4.30B2). The APS current sink initiated above the soma layer, then propagated downward to the soma and apical dendrites while simultaneously propagated upward from the soma to the basal dendrites (Fig. 4.30B2 left). In contrast, the OPS current sink began in the apical dendrite layer and then propagated sequentially to the soma and basal dendrite layers (Fig. 4.30B2 right). During APS generation, its negative CSD sink represents the current component from action potentials. Unlike APS, OPS is evoked by excitatory synaptic inputs on the apical dendrites of pyramidal neurons. The accompanying EPSPs produce an fEPSP current sink in the far apical dendrite layer and a passive current source near the soma layer (refer to Fig. 2.5C). Thus, the OPS current sink (indicated by the grey shadings in Fig. 4.30B2 right) rides on the fEPSP current source. These results are consistent with other reports (Kloosterman et al. 2001). Using CSD analysis, we examined how action potentials generated and propagated during high-frequency stimulation of alveus axons (see Sect. 5.2.3 for details).
Fig. 4.30
CSD analyses of antidromic and orthodromic evoked potentials in the peri-somatic area of rat hippocampal CA1 region. A Schematic diagram illustrating the positions of a recording array and two stimulation electrodes. B Recordings of the evoked potentials (B1) and their corresponding CSDs (B2). The site of measuring contact at the soma layer—the pyramidal cell layer (pcl)—is set as the z-axis zero point. Red inverted triangles denote 0.3 mA stimulus pulses (i.e., the truncated pulse artifacts). Grey shadings in B2 represent current sinks of PSs, and red dashed lines with arrows indicate the directions of current sink propagation.
Part II of this book will explore the effects of external electrical stimulations on neurons and their networks in the rat brain. Brain tissue acts as a volume conductor. When electrical stimulation is applied through implanted electrodes, it can generate an electric field within the brain. The strength of this field decreases rapidly over distance. When measuring neuronal responses to electrical stimulation in the brain, the recorded potentials can contain stimulation artifacts if the recording site lies within the produced electric field.
Brain tissue is not purely resistive but has passive electrical properties of both resistance and capacitance. It also has active electrical properties formed by ion channels on neuronal membranes. These electrical properties vary across anatomical structures—cell bodies (somata), axons, dendrites, and cerebrospinal fluid in the extracellular space. Therefore, brain tissue acts as a non-uniform conductor, which can be simulated by circuits with varying resistance and capacitance. When considering electrical stimulation as input and the recorded stimulation artifact as output, the artifact can typically differ from the original input waveform due to these complex tissue circuits. This difference is especially pronounced for stimulation waveforms with higher frequency components like narrow pulses. Additionally, the recorded stimulation artifacts depend on other factors, such as the structure of stimulation electrode, the stimulation site, its distance from the recording electrode, and the sampling frequency.
A stimulation artifact can serve as a useful time reference for determining the latency and timing of evoked neuronal responses. However, dense artifacts can interfere with neural signal detection and analysis. The following examples demonstrate stimulation artifacts recorded in the rat hippocampal region during sinusoidal and pulse electrical stimulations, along with methods for their removal.
4.5.1 Removing Sinusoidal Stimulation Artifacts
To investigate how the waveforms of stimulation artifacts change with the relative position and distance between stimulation and recording electrodes, we designed a simple setup to imitate stimulation and recording in rat brain. As shown in Fig. 4.31A, we filled a glass dish (75 mm diameter, 15 mm height) with physiological saline and inserted two electrodes: a bipolar concentric stimulation electrode (CBCSG75) and a 16-channel array recording electrode (A1 × 16-Poly2-5 mm-50 s-177). We connected a 50 Hz sinusoidal signal with a 5 V peak-to-peak amplitude from a signal generator (Model DG1000Z, RIGOL Technologies) to a Model 2200 analog stimulator with electrical isolation (see Sect. 3.5.4). Then, the stimulator's output—current sine waves—was connected to the stimulation electrode, with its inner pole serving as anode and outer pole as cathode.
Fig. 4.31
Changes in recorded signals on an array electrode during sinusoidal current application via a stimulation electrode in physiological saline. A Schematic diagram of the experimental setup. B Signals recorded with the recording array placed close to the stimulation electrode, where the 16 contacts vertically spanned both the inner and outer poles of the stimulation electrode, and with the stimulation intensity set at 5 μA. C Signals recorded with the recording array positioned slightly above the stimulation electrode tip, with the stimulation intensity set at 50 μA
We set the stimulator output to a 5μA peak-to-peak amplitude and placed the recording array near the stimulation electrode, allowing the recording contacts to span both poles of the stimulation electrode (Fig. 4.31A). The recorded signals closely matched the sine waves from both the signal generator and stimulator outputs, without significant distortions (Fig. 4.31B). The phase of recorded sine waves on each channel aligned with its nearer stimulation pole. We then increased the stimulator output from 5 to 50 μA peak-to-peak sine waves and moved the recording array about 1 mm away and above the stimulation electrode. As all the recording channels were now closer to the cathode pole, the recorded sine waves aligned with the cathode pole phase, opposing to the original stimulator output signal. Additionally, the recorded waveforms became distorted.
We also used this experimental setup to explore artifact waveforms from pulse stimulations, though details are omitted here. Note that this saline model cannot fully replicate the electrical properties of brain tissue. Stimulation artifacts recorded in-vivo in rat hippocampal regions can be more complex.
Figure 4.32 shows a recording with a 2 Hz sinusoidal current stimulation (1-min, 40 μA peak-to-peak amplitude) applied to the Schaffer collaterals of rat hippocampal CA1 region. The signal was recorded in the CA1 pyramidal layer downstream of the stimulation site. The electrode placements were same as shown in Fig. 4.30A. The enlarged insets in Fig. 4.32 show that the recording during stimulation contained clear 2 Hz sinusoidal artifacts which were absent during baseline period before stimulation. These artifacts were removed by a 2 Hz notch filter, as shown in the figure. The sinusoidal stimulation produced a clear 2 Hz rhythm in neuronal firing, particularly visible in the MUA signal produced after 500 Hz high-pass filtering (Fig. 4.32, lower right), demonstrating the effect of stimulation modulation.
Fig. 4.32
Signal example during sinusoidal stimulation in rat hippocampal CA1 region. The red signal represents the applied sinusoidal current stimulation, i.e., the stimulator output
The sinusoidal artifact appeared as a continuous signal coexisting with neuronal responses throughout the stimulation period. In contrast, a transient narrow pulse can trigger neuronal responses with a time delay (latency), as shown by the single-pulse and paired-pulse evoked population spikes in Sect. 2.2. Even though stimulation pulses and evoked responses occur at different times, artifact removal can still be required for detecting certain neuronal signals, such as unit spikes (see Fig. 4.9). Unlike sinusoidal artifacts—which can be removed using a notch filter, pulse artifacts have a broader spectrum with high-frequency components that overlap with spike spectrum. Pulse artifacts cannot be simply filtered out (Heffer and Fallon 2008; Wichmann 2000). The next section will introduce the artifacts of narrow pulses and their removal methods.
4.5.2 Removing Artifacts of High-Frequency Pulse Stimulation
Many neuromodulation therapies, including deep brain stimulation (DBS), use pulse electrical stimulations, which often creating large-amplitude artifacts in recordings. The waveform and amplitude of these artifacts depend on multiple factors, including the structure of stimulation electrodes, the pulse waveform, intensity and frequency (rate), the relative positions of recording and stimulation electrodes, as well as the features and settings of amplifiers and stimulators. Electrical isolation between stimulation and recording circuits can greatly reduce the artifacts. With proper isolation, most stimulation current can loop through the stimulation circuit, with minimal invasion into the recording circuit. Additionally, using a bipolar stimulation electrode with two closely spaced poles (millimeter or sub-millimeter) can confine the stimulation current to a small brain area. This can also minimize stimulation artifacts in recordings, provided the stimulation site is sufficiently distant from the recording site. However, stimulation artifacts recorded by nearby electrodes can still disturb neuronal signals. This interference is particularly problematic when detecting unit spikes, which typically have only tens to hundreds of microvolts in amplitude—much smaller than stimulation artifacts. The magnitude difference between stimulation artifacts and neuronal signals can reach 4–5 orders (Wagenaar and Potter 2002).
For example, in our in-vivo experiments of electrical stimulations in rat hippocampal regions, the recording and stimulation sites were about 1–2 mm apart. Using a Model 3800 stimulator with isolators and a Model 3600 amplifier (see Sect. 3.5 for details), we applied narrow current pulses with a width of 100 μs and intensity of ~ 0.3 mA. This stimulation usually produced artifacts with several millivolts in amplitude—far greater than both unit spikes and normal field potentials. The artifacts were sometimes even larger than the population spikes (PS) generated by synchronized neuronal firing.
Large-amplitude stimulation artifacts can interfere with both neural signal display and signal extraction. Especially during high-frequency stimulation (HFS), the dense artifacts can obscure neural signals. Methods have been designed to eliminate pulse artifacts, including template subtraction, waveform fitting, and linear interpolation (Erez et al. 2010; Wagenaar and Potter 2002; Hashimoto et al. 2002). The template subtraction method involves obtaining an artifact template, which is then subtracted from the recorded signal wherever artifacts are identified. This method can recover neural signals superimposed on artifacts, provided that the recording is not truncated by amplifier saturations. In other words, the amplitudes of recorded signals with artifacts must stay within the amplifier range.
In addition, the template method requires artifact waveforms to remain constant, which is challenging in practice. First, the electrical properties of brain tissue—particularly impedance values—can change, especially during sustained HFS. This can lead to variations in artifact waveforms. Second, for narrow pulses, additional factors affect the recorded artifact waveforms, including the limitation of ADC sampling rate and the clock timing difference between the recorder ADC and stimulator.
Figure 4.33 illustrates the impact of a clock difference by an example of sampling a 10 kHz sine wave (0.1 ms cycles, the orange curve). Based on the sampling theorem, the signal is sampled at 20 kHz, yielding two samples per cycle. Assume that the clock controlling the ADC for sampling does not exactly synchronize with the clock of digital signal generator that produces the original sine wave. Taking the clock of signal generator as reference, let the actual sampling rate of sampler be 20.83 kHz rather than exact 20 kHz. This discrepancy can result in oscillation waves in the sampled data with amplitudes varying periodically at 0.83 kHz (black dots and lines in Fig. 4.33). This example exaggerates the clock difference to illustrate potential changes in sampled artifacts. In practice, clock differences between instruments are typically very small and negligible. Nevertheless, in long recording, even small differences can lead to significant changes in sampled stimulation artifacts, as shown in the following example.
Fig. 4.33
A segment of 10 kHz sinusoidal signal (orange) and its sampled signal at 20.83 kHz (black). The black dots represent the sampled data
We used a Model 3800 stimulator to generate HFS pulses applied into the rat brain. A PowerLab recorder sampled the signals collected by a recording electrode (see Fig. 3.17). Figure 4.34A shows a signal recorded in the hippocampal CA1 soma layer during a 1-min HFS of biphasic current pulses applied on the alveus. The pulses had an intensity of 0.3 mA, width of 100 μs per phase, and frequency of 200 Hz. We set the amplifier frequency band at 0.3 Hz–5 kHz and used a 20 kHz sampling rate. The dense stimulation artifacts in the original recording obscured most of the neural signal, except for the large APSs at the onset of HFS (Fig. 4.34A). The artifacts created a periodic oscillation envelope due to the clock difference between the 3800 stimulator and PowerLab sampler. This envelope had a period of about 4 s, corresponding a frequency difference of 0.25 Hz—a minuscule 0.00125% of the 20 kHz sampling rate. However, this small difference caused significant changes in pulse artifacts. With the 20 kHz sampling rate and 100 μs pulse width, the recorder captured only a few samples per pulse artifact. In the enlarged insets in Fig. 4.34B, the sampled artifact data are shown in sparse red dots. Due to the clock difference, the sampling positions on the artifacts constantly shifted, causing varying artifact waveforms and amplitudes.
Fig. 4.34
Variations in pulse artifacts caused by sampling rate limitation and clock discrepancy. A Example signal recorded from the hippocampal CA1 soma layer during 1-min biphasic pulse stimulation at 200 Hz, sampled at 20 kHz. B Signal from (A) displayed in LabChart “Show Points as Dots” mode, with enlarged insets below. C Signal after artifact removal using linear interpolations
By the way, the LabChart software of PowerLab recorder can display sampled signals in two modes: “Join Points with Line” and “Show Points as Dots”. Figure 4.34A used the former, while the upper plot of Fig. 4.34B used the latter. The dot display mode can allow clear visualization of neural signals and on-line observation of changes in evoked potentials (APSs) during HFS. Even with HFS at a 200 Hz pulse frequency as in this example, the biphasic pulse artifacts (with a total width of ~ 0.2 ms) occupy only a small fraction of time. The artifacts contain far fewer sample data than neural signals, enabling the dot display to effectively reveal the neural signals.
These results show that sampled artifacts of narrow pulses can vary over time, even when the actual stimulation artifacts remain constant. This variation makes artifact removal using template methods difficult. To address artifact interference, researchers have had to compromise by either reducing stimulation intensity or inferring neuronal activity during stimulation by examining signals immediately after stimulation ends (Rosa et al. 2012).
We used bipolar stimulation electrodes to confine the stimulation area in our rat experiments. However, large stimulation artifacts were still captured by nearby recording electrodes, affecting the detection of unit spikes. Figure 4.35A shows a brief segment of the original wideband recording (0.3–5000 Hz) with 100 Hz 0.3 mA HFS pulses. The pulse artifacts had a large amplitude of about 15 mV. Unit spikes with an amplitude of ~ 0.2 mV (indicated by blue dots) were only visible in the enlarged signal. These spikes were superimposed on low-frequency field potentials which needed to be removed by a high-pass filter before using a threshold method to detect the spikes. However, while filtering removed low-frequency potentials, it also altered the artifacts, making it difficult to identify spikes near the artifacts, as shown in the bottom of Fig. 4.35A. In Fig. 4.35B, each artifact segment in the original signal was replaced with a straight line connecting its endpoints before high-pass filtering was applied. This process resulted in a MUA signal with clear spikes. Figure 4.35C shows overlaid plots of the filtered signals both with and without artifacts, highlighting their differences. High-pass filtering with artifacts caused oscillations around the artifacts and interfered with spike detection. The artifact-free signal in Fig. 4.34C was also produced by this artifact removal process. The method is suitable for HFS with narrow pulses, as the artifact duration is minimal. We used it to process recordings with various high-frequency pulse stimulations reported in Part II of this book (Chaps. 5–8).
Fig. 4.35
Linear interpolation for removing stimulation artifacts of narrow pulses. A From top to bottom: a brief recording from the rat hippocampal CA1 region during 100 Hz 0.3 mA pulse stimulation, its longitudinally expanded signal (blue dots indicating unit spikes), and its high-pass filtered signal (with truncated artifacts). B The signal after artifact removal together with its MUA signal after high-pass filtering. In the dashed ellipse, the enlarged inset displays a red interpolated line replacing an artifact segment, followed immediately by a spike. C Overlaid plots of the filtered signals both with and without artifacts
Removing an artifact by replacing it with a straight line can be accomplished by a linear interpolation algorithm, which can be implemented using a MATLAB program. Its algorithm consists of two main steps:
(1)
Identify stimulation artifacts. Pulse artifacts can be detected by setting an amplitude threshold when their magnitude significantly exceeds neural signals. However, artifacts may vary in amplitude and waveform due to multiple factors, even within a same stimulation trial, as shown in Fig. 4.34A. Narrow pulse artifacts typically have a much steeper slope than neural signals. For example, Fig. 4.36 shows a recording containing an evoked APS following a biphasic-pulse artifact. Each blue dot on the recording represents a sampled datum at 20 kHz. Let an instantaneous slope represent the potential difference between adjacent data. Although an APS, formed by synchronous neuronal firing, has steep phases with notably great slopes compared to other neural signals, a pulse artifact typically exhibits even greater slopes with its maximum instantaneous slope significantly exceeding that of APS. Therefore, the instantaneous slope can be used to identify artifacts as following. First, calculate the instantaneous slope (the absolute value of the first-order difference of the sampled data). Second, identify stimulation artifacts using a preset slope threshold. Finally, determine the start and end points of the artifacts.
Fig. 4.36
Comparison of slopes between a pulse artifact and a neural signal (APS). Note: blue dots represent sampled data taken at 20 kHz, with 0.05 ms intervals between adjacent data
Replace the artifact segment with linearly interpolated data—a straight line connecting the two ends of the artifact. The interpolated data are calculated as
where \(x_{{0}}\) and \(x_{{N - {1}}}\) represent the sampled data at the interpolation starting and ending points, N is the number of data on the interpolation line, and \(x_{n}\) represents the n-th interpolated data, n = 1, 2, …, N − 2. The length of the interpolation segment (N) needs to be determined from the actual recorded signal. Besides the above-mentioned sampling limitations that can result in pulse artifacts different completely from the applied pulses (as shown in Figs. 4.34B and 4.36), additional factors can distort pulse artifacts and extend their duration, including transient amplifier saturation caused by excessive artifact amplitudes and the volume conductor effect of neural tissue. Consequently, the interpolation segment for artifact removal can be slightly longer than the width of applied pulse, but typically narrower than spikes (Fig. 4.35) and evoked population potentials (Fig. 4.36).
The linear interpolation method for artifact removal has a disadvantage: it can lead to neural signal loss during the artifact-occupied period. However, when the pulse amplitude exceeds the amplifier's range—causing saturation, the signal during the artifact is already truncated by the amplifier. In this case, artifact removal will not worsen the existing signal loss. Such signal truncations commonly occurred during pulse periods in our experimental recordings. High-quality neural signal recordings require a high ADC resolution (see Sect. 3.5.3). This means that the amplifier range should be set to match the maximum amplitude of neural signals, which can inevitably lead to larger stimulation artifacts being truncated (see Fig. 3.25).
4.6 Summary
This chapter first introduces methods for detecting and analyzing extracellularly recorded action potentials of individual neurons—unit spikes. Since these spike signals contain high-frequency components, their accurate recording needs an appropriate amplifier frequency band, as well as suitable sampling frequency and resolution. Different neuron types produce distinct spike waveforms, which can be used to distinguish neuron categories such as pyramidal neurons and interneurons. The amplitude and waveform of spikes also vary with the electrode position relative to the recorded neuron. These variations enable spike sorting to determine spike origin. Spike detection in recording signals can be performed using threshold, window or template methods, while spike sorting can be conducted using parameter and template methods. Accurate spike sorting requires multi-channel recordings, typically involving four-channel signals from closely spaced contacts.
The chapter also provides concrete examples of spike detection and sorting using custom-designed window method and four-channel algorithm. Additionally, it covers analysis methods for spike sequences of individual neurons, including ISI histogram, autocorrelation histogram, and cross-correlation histogram. It also explains PSTH, JPSSD and JPSTH histograms for analyzing neuronal responses to external stimulations.
This chapter then introduces spectrum analysis methods for LFP and EEG signals. Specifically, it explains the periodogram spectrum estimation method (Welch method) for random signals, discusses the relationships between resolution and range in both time and frequency domains, and demonstrates spectrum calculations using MATLAB functions and LabChart software.
Finally, the chapter introduces the current source density analysis for tracking transmembrane currents during neuron activations. It also presents methods for removing artifacts caused by electrical stimulations, including both sinusoidal and pulse artifacts. It shows how these artifacts affect spike detection during high-frequency pulse stimulations and provides their removal methods.
These approaches will be applied in later chapters to investigate the neuromodulation effects and mechanisms of electrical stimulations.
Open Access This chapter is licensed under the terms of the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License (http://creativecommons.org/licenses/by-nc-nd/4.0/), which permits any noncommercial use, sharing, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license and indicate if you modified the licensed material. You do not have permission under this license to share adapted material derived from this chapter or parts of it.
The images or other third party material in this chapter are included in the chapter's Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the chapter's Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder.
Barthó P, Hirase H, Monconduit L et al (2004) Characterization of neocortical principal cells and interneurons by network interactions and extracellular features. J Neurophysiol 92(1):600–608CrossRef
Blanche TJ, Spacek MA, Hetke JF et al (2005) Polytrodes: high-density silicon electrode arrays for large-scale multiunit recording. J Neurophysiol 93(5):2987–3000CrossRef
Bretschneider F, de Weille JR (2006) Introduction to electrophysiological methods and instrumentation. Elsevier, Amsterdam
Brown EN, Kass RE, Mitra PP (2004) Multiple neural spike train data analysis: state-of-the-art and future challenges. Nat Neurosci 7(5):456–461
Buzsáki G, Leung LW, Vanderwolf CH (1983) Cellular bases of hippocampal EEG in the behaving rat. Brain Res Rev 6(2):139–171CrossRef
Buzsáki G (2002) Theta oscillations in the hippocampus. Neuron 33(3):325–340CrossRef
Buzsáki G (2004) Large-scale recording of neuronal ensembles. Nat Neurosci 7(5):446–451CrossRef
Buzsáki G (2006) Rhythms of the Brain. Oxford University Press, OxfordCrossRef
Carlson D, Carin L (2019) Continuing progress of spike sorting in the era of big data. Curr Opin Neurobiol 55:90–96CrossRef
Clark I, Biscay R, Echeverría M et al (1995) Multiresolution decomposition of non-stationary EEG signals: a preliminary study. Comput Biol Med 25(4):373–382CrossRef
Csercsa R, Dombovári B, Fabó D et al (2010) Laminar analysis of slow wave activity in humans. Brain 133(9):2814–2829CrossRef
Csicsvari J, Hirase H, Czurko A et al (1998) Reliability and state dependence of pyramidal cell-interneuron synapses in the hippocampus: An ensemble approach in the behaving rat. Neuron 21(1):179–189CrossRef
Erez Y, Tischler H, Moran A et al (2010) Generalized framework for stimulus artifact removal. J Neurosci Methods 191(1):45–59CrossRef
Feng Z (2003) Analysis of rat electroencephalogram during slow wave sleep and transition sleep using wavelet transform. Acta Biochim Biophys Sin 35(8):741–746
Feng Z, Guang L, Zheng X et al (2007) Recordings of the hippocampal field potentials and unit activity by using linear silicon electrode array. Prog Biochem Biophys 34(4):401–407 (in Chinese)
Feng Z, Wang J, Wang Y et al (2012) Selection of filtering frequencies for neuronal spike signals. J Zhejiang Univ (Eng Sci) 46(2):351–358 (in Chinese)
Feng Z, Xiao Q, Hu Z (2013) Detecting neuronal unit spikes during electrical stimulation periods. Chin J Bio Eng 32(4):403–410 (in Chinese)
Feng Z, Zheng X (2004a) The dynamic change of rat EEG’s complexity and power spectrum under different anesthetized depths. Chin J Biomed Eng 23(1):87–91 (in Chinese)MathSciNet
Feng Z, Zheng X (2004b) Using the multi-resolution wavelet decomposition to analyze the sleep spindle in rat EEG. Chin J Biomed Eng 23(2):103–108 (in Chinese)
Gerstein GL, Bedenbaugh P, Aertsen MH (1989) Neuronal assemblies. IEEE Trans Biomed Eng 36(1):4–14CrossRef
Gerstein GL, Kiang NYS (1960) An approach to the quantitative analysis of electrophysiological data from single neurons. Biophys J 1(1):15–28CrossRef
Gold C, Henze DA, Koch C et al (2006) On the origin of the extracellular action potential waveform: a modeling study. J Neurophysiol 95(5):3113–3128CrossRef
Gold C, Henze DA, Koch C (2007) Using extracellular action potential recordings to constrain compartmental models. J Comput Neurosci 23(1):39–58MathSciNetCrossRef
Harris KD, Henze DA, Csicsvari J et al (2000) Accuracy of tetrode spike separation as determined by simultaneous intracellular and extracellular measurements. J Neurophysiol 84(1):401–414
Hashimoto T, Elder CM, Vitek JL (2002) A template subtraction method for stimulus artifact removal in high-frequency deep brain stimulation. J Neurosci Methods 113(2):181–186
Heffer LF, Fallon JB (2008) A novel stimulus artifact removal technique for high-rate electrical stimulation. J Neurosci Methods 170(2):277–284CrossRef
Henze DA, Borhegyi Z, Csicsvari J et al (2000) Intracellular features predicted by extracellular recordings in the hippocampus in vivo. J Neurophysiol 84(1):390–400CrossRef
Heynen AJ, Bear MF (2001) Long-term potentiation of thalamocortical transmission in the adult visual cortex in vivo. J Neurosci 21(24):9801–9813CrossRef
Hochberg LR, Serruya MD, Friehs GM et al (2006) Neuronal ensemble control of prosthetic devices by a human with tetraplegia. Nature 442(7099):164–171CrossRef
Horváth C, Tóth LF, Ulbert I et al (2021) Dataset of cortical activity recorded with high spatial resolution from anesthetized rats. Sci Data. 8(1):180CrossRef
Huberfeld G, Menendez de la Prida L, Pallud J et al (2011) Glutamatergic pre-ictal discharges emerge at the transition to seizure in human epilepsy. Nat Neurosci 14(5):627–634CrossRef
Joshua M, Elias S, Levine O et al (2007) Quantifying the isolation quality of extracellularly recorded action potentials. J Neurosci Methods 163(2):267–282CrossRef
Kloosterman F, Peloquin P, Leung LS (2001) Apical and basal orthodromic population spikes in hippocampal CA1 in vivo show different origins and patterns of propagation. J Neurophysiol 86(5):2435–2444CrossRef
Lee CW, Dang H, Nenadic Z (2007) An efficient algorithm for current source localization with tetrodes. Annu Int Conf IEEE Eng Med Biol Soc 2007:1282–1285
Lefebvre B, Yger P, Marre O (2016) Recent progress in multi-electrode spike sorting methods. Journal of Physiology-Paris 110(4):327–335CrossRef
Lewicki MS (1998) A review of methods for spike sorting: The detection and classification of neural action potentials. Network 9(4):R53–78
Lisman JE (1997) Bursts as a unit of neural information: making unreliable synapses reliable. Trends Neurosci 20(1):38–43
López-Aguado L, Ibarz JM, Herreras O (2000) Modulation of dendritic action currents decreases the reliability of population spikes. J Neurophysiol 83(2):1108–1114CrossRef
Ma W, Feng Z, Wang Z et al (2019) High-frequency stimulation of afferent axons alters firing rhythms of downstream neurons. J Integr Neurosci 18(1):33–41CrossRef
Maccione A, Gandolfo M, Massobrio P et al (2009) A novel algorithm for precise identification of spikes in extracellularly recorded neuronal signals. J Neurosci Methods 177(1):241–249CrossRef
Meyer LM, Samann F, Schanze T (2023) Dualsort: online spike sorting with a running neural network. J Neural Eng 20(5):056031CrossRef
Mokri Y, Salazar RF, Goodell B et al (2017) Sorting overlapping spike waveforms from electrode and tetrode recordings. Front Neuroinform 11:53CrossRef
Nelson MJ, Pouget P, Nilsen EA et al (2008) Review of signal distortion through metal microelectrode recording circuits and filters. J Neurosci Methods 169(1):141–157CrossRef
Nicholson C, Freeman JA (1975) Theory of current source-density analysis and determination of conductivity tensor for anuran cerebellum. J Neurophysiol 38(2):356–368CrossRef
Obien MEJ, Deligkaris K, Bullmann T et al (2015) Revealing neuronal function through microelectrode array recordings. Front Neurosci 8:423CrossRef
Pachitariu M, Sridhar S, Pennington J et al (2024) Spike sorting with Kilosort4. Nat Methods 21(5):914–921CrossRef
Pettersen KH, Lindén H, Dale AM, et al. (2012) Extracellular spikes and current-source density. In: Brette R, Destexhe A (eds) Handbook of neural activity measurement. Cambridge University Press.
Richardson TL, Turner RW, Miller JJ (1987) Action-potential discharge in hippocampal CA1 pyramidal neurons: current source-density analysis. J Neurophysiol 58(5):981–996CrossRef
Rodieck RW, Kiang NYS, Gerstein GL (1962) Some quantitative methods for the study of spontaneous activity of single neurons. Biophys J 2(4):351–368CrossRef
Rolls ET, Miyashita Y, Cahusac PMB et al (1989) Hippocampal-neurons in the monkey with activity related to the place in which a stimulus is shown. J Neurosci 9(6):1835–1845CrossRef
Rosa M, Giannicola G, Marceglia S et al (2012) Neurophysiology of deep brain stimulation. Int Rev Neurobiol 107:23–55CrossRef
Schaffer L, Nagy Z, Kincses Z et al (2021) Spatial information based OSort for real-time spike sorting using FPGA. IEEE Trans Biomed Eng 68(1):99–108CrossRef
Shabestari PS, Buccino AP, Kumar SS et al (2021) A modulated template-matching approach to improve spike sorting of bursting neurons. IEEE Biomed Circuits Syst Conf 2021:9644995
Shiavi R (2007) Introduction to applied statistical signal analysis: guide to biomedical and electrical engineering applications (3rd ed.). Academic
Somogyvári Z, Zalányi L, Ulbert I et al (2005) Model-based source localization of extracellular action potentials. J Neurosci Methods 147(2):126–137CrossRef
Stevenson IH, Kording KP (2011) How advances in neural recording affect data analysis. Nat Neurosci 14(2):139–142CrossRef
Townsend G, Peloquin P, Kloosterman F et al (2002) Recording and marking with silicon multichannel electrodes. Brain Res Protoc 9(2):122–129CrossRef
Wagenaar DA, Potter SM (2002) Real-time multi-channel stimulus artifact suppression by local curve fitting. J Neurosci Methods 120(2):113–120CrossRef
Wang J, Feng Z (2009) A novel method for multi-channel neuronal spike detection and classification. Prog Biochem Biophys 36(5):641–647 (in Chinese)CrossRef
Wang Z, Feng Z, Yu Y et al (2016) Spike potential detection method for broadband-frequency recording signals. Chinese Journal of Scientific Instrument 37(3):481–489 (in Chinese)
Wichmann T (2000) A digital averaging method for removal of stimulus artifacts in neurophysiologic experiments. J Neurosci Methods 98(1):57–62CrossRef
Wild J, Prekopcsak Z, Sieger T et al (2012) Performance comparison of extracellular spike sorting algorithms for single-channel recordings. J Neurosci Methods, 203(2):369–376
Xu Y, Feng Z, Yuan Y et al (2023) Effects on somata by high-frequency electrical stimulation at the axons of hippocampal pyramidal neurons. Prog Biochem Biophys 50(3):561–572 (in Chinese)
Yu Y, Feng Z, Cao J et al (2016) Modulation of local field potentials by high-frequency stimulation of afferent axons in the hippocampal CA1 region. J Integr Neurosci 15(1):1–17MathSciNetCrossRef
Yuan X, Hierlemann A, Frey U (2021) Extracellular recording of entire neural networks using a dual-mode microelectrode array with 19584 electrodes and high SNR. IEEE J Solid-State Circuits 56(8):2466–2475CrossRef
Zhang T, Rahimi Azghadi M, Lammie C et al (2023) Spike sorting algorithms and their efficient hardware implementation: A comprehensive survey. J Neural Eng 20(2):021001CrossRef