A subscription to JoVE is required to view this content. Sign in or start your free trial.
The BrainBeats toolbox is an open-source EEGLAB plugin designed to jointly analyze EEG and cardiovascular (ECG/PPG) signals. It includes heartbeat-evoked potentials (HEP) assessment, feature-based analysis, and heart artifact extraction from EEG signals. The protocol will aid in studying brain-heart interplay through two lenses (HEP and features), enhancing reproducibility and accessibility.
The interplay between the brain and the cardiovascular systems is garnering increased attention for its potential to advance our understanding of human physiology and improve health outcomes. However, the multimodal analysis of these signals is challenging due to the lack of guidelines, standardized signal processing and statistical tools, graphical user interfaces (GUIs), and automation for processing large datasets or increasing reproducibility. A further void exists in standardized EEG and heart-rate variability (HRV) feature extraction methods, undermining clinical diagnostics or the robustness of machine learning (ML) models. In response to these limitations, we introduce the BrainBeats toolbox. Implemented as an open-source EEGLAB plugin, BrainBeats integrates three main protocols: 1) Heartbeat-evoked potentials (HEP) and oscillations (HEO) for assessing time-locked brain-heart interplay at the millisecond accuracy; 2) EEG and HRV feature extraction for examining associations/differences between various brain and heart metrics or for building robust feature-based ML models; 3) Automated extraction of heart artifacts from EEG signals to remove any potential cardiovascular contamination while conducting EEG analysis. We provide a step-by-step tutorial for applying these three methods to an open-source dataset containing simultaneous 64-channel EEG, ECG, and PPG signals. Users can easily fine-tune parameters to tailor their unique research needs using the graphical user interface (GUI) or the command line. BrainBeats should make brain-heart interplay research more accessible and reproducible.
For a long time, the reductionist approach has dominated scientific inquiry in human physiology and cognition. This approach involved dissecting complex bodily and mental processes into smaller, more manageable components, allowing researchers to focus on individual systems in isolation. This strategy arose due to the challenges in studying the intricate and interconnected nature of the human body and mind1. Reductionism has been instrumental in understanding individual subsystems in isolation, such as elucidating the role of ion channels and action potentials for neural2 or cardiac3 communication. However, a significant gap remains in our understanding of how these isolated systems interact on a larger spatial and temporal scale. The multimodal (integrative or ecological) framework considers the human body a complex multidimensional system, where the mind is seen not as a product of the brain but as an activity of the living being, an activity that integrates the brain within the everyday functions of the human body4. The multimodal and reductionist approaches are not exclusive, just like we cannot study one neuron without the whole brain or the whole brain without understanding individual neuron properties. Together, they pave the way for a more comprehensive, synergetic understanding of human health, pathology, cognition, psychology, and consciousness. The present method aims to ease the multimodal investigation of the interplay between the brain and the heart by providing joint analysis of electroencephalography (EEG) and cardiovascular signals, namely electrocardiography (ECG) and photoplethysmography (PPG). This toolbox, implemented as an EEGLAB plugin in MATLAB, addresses existing methodological limitations and is made open source to facilitate accessibility and reproducibility in the scientific area. It implements the latest guidelines and recommendations into its design and default parameters to encourage users to follow known best practices. The proposed toolbox should be a valuable resource for researchers and clinicians interested in 1) studying heartbeat-evoked potentials , 2) extracting features from EEG and ECG/PPG signals, or 3) removing heart artifacts from EEG signals.
Heart-brain research
The relationship between the heart and the brain has been historically studied via neuroimaging methods such as functional magnetic resonance imaging (fMRI) and positron emission tomography (PET). Using these tools, researchers highlighted some brain regions associated with cardiovascular control (e.g., manipulation of heart rate and blood pressure5), showed the influence of heart rate on the BOLD signal6, or identified potential brain-body pathways contributing to coronary heart disease (i.e., stress-evoked blood pressure7). While these studies have significantly advanced our understanding of the complex interplay between the central nervous system (CNS) and cardiovascular function, these neuroimaging techniques are expensive, have limited availability, and are confined to controlled laboratory settings, which restricts their practicality for real-world and large-scale applications.
In contrast, EEG and ECG/PPG are more affordable and portable tools that offer the potential for studying brain-heart interactions in more diverse settings and populations or over longer periods, providing new opportunities. ECG measures the electrical signals generated by each heartbeat when the heart contracts and relaxes via electrodes placed on the skin (usually on the chest or arms)8. PPG measures blood volume changes in the microvascular tissues (i.e., blood flow and pulse rate) using a light source (e.g., LED) and a photodetector (commonly placed on a fingertip, wrist, or forehead), relying on how blood absorbs more light than the surrounding tissue9. Both methods provide valuable information about cardiovascular function but serve different purposes and offer distinct data types. Like ECG, EEG records the electrical fields generated by the synchronized activity of thousands of cortical neurons that propagate through the extracellular matrix, tissues, skull, and scalp until they reach the electrodes placed on the scalp's surface10. As such, the use of EEG and ECG/PPG holds great promise for advancing our understanding of the physiological, cognitive, and emotional processes underlying brain-heart interactions and their implications for human health and well-being. Therefore, capturing heart-brain interplay from EEG, ECG/PPG signals with the BrainBeats toolbox may be particularly useful for the following scientific areas: clinical diagnostic and forecasting, big data machine learning (ML), real-world self-monitoring11, and mobile brain/body imaging (MoBI)12,13.
Two approaches for jointly analyzing EEG and ECG signals
There are two main approaches to studying interactions between EEG and cardiovascular signals:
The heartbeat-evoked potentials (HEP) in the time domain: event-related potentials (ERP), and the heartbeat-evoked oscillations (HEO) in the time-frequency domain: event-related spectral perturbations (ERSP) and inter-trial coherence (ITC). This approach examines how the brain processes each heartbeat. With millisecond (ms) accuracy, this method requires that both time series are perfectly synchronized and the heartbeats to be marked in the EEG signals. This approach has gained interest in recent years14,15,16,17,18,19.
Feature-based approach: this approach extracts EEG and heart-rate variability (HRV) features from continuous signals and examines associations between them. This has been done independently for EEG (often termed quantitative EEG or qEEG20), ECG21,22,23, and PPG24,25,26. This approach presents promising applications by capturing both state- and trait-related variables. Note that, for both EEG and cardiovascular signals, the longer the recording, the more dominant the trait variable27,28,29. Thus, the applications depend on the recording parameters. Feature-based analyses are gaining growing interest, providing new quantitative metrics for forecasting the development of mental and neurological disorders, treatment-response, or relapse30,31,32,33,34,35. This approach is especially compelling with large and real-world datasets (e.g., clinic, remote monitoring), which can be more easily obtained thanks to the recent innovations in wearable neurotechnology11. A less explored application is the identification of associations between specific brain and heart features, highlighting potential underlying central nervous system dynamics. Heart rate variability (HRV) can be calculated from both ECG and PPG signals. It provides information about the autonomous nervous system (ANS) by measuring the variations in time intervals between heartbeats (i.e., the normal-to-normal intervals)27. Increased sympathetic (SNS) activity (e.g., during stress or exercise) typically reduces HRV, while parasympathetic (PNS) activity (e.g., during relaxation) increases it. A slower breathing rate generally increases HRV due to enhanced PNS activity, especially for short recordings (<10 min)27. Higher HRV scores generally suggest a more resilient and adaptable ANS, while a lower HRV can indicate stress, fatigue, or underlying health issues. Long HRV recordings (i.e., at least 24 h) provide a predictive prognosis for various health conditions, including cardiovascular diseases, stress, anxiety, and some neurological conditions27. Measures like blood pressure, heart rate, or cholesterol levels give information about the cardiovascular system's status. In contrast, HRV adds a dynamic aspect, showing how the heart responds to and recovers from stress.
BrainBeats' advantages over existing methods
While tools exist, as reviewed below, to process cardiovascular and EEG signals independently from each other, they cannot be jointly analyzed. Furthermore, most available means to process cardiovascular signals involve costly licensing, do not allow automated processing (especially beneficial for large datasets), have proprietary algorithms that prevent transparency and reproducibility, or require advanced programming skills by not providing a graphical user interface (GUI)36. To our knowledge, four open-source MATLAB toolboxes support HEP/HEO analysis with a GUI: the ecg-kit toolbox37, the BeMoBIL pipeline38, the HEPLAB EEGLAB plugin39, and the CARE-rCortex toolbox40. While HEPLAB, BeMoBIL, and ecg-kit facilitate HEP analysis by detecting heartbeats and marking them in the EEG signals, they do not provide statistical analysis or are limited to the time domain (i.e., HEP). The CARE-rCortex plugin addressed these issues by supporting ECG and respiratory signals, time-frequency domain analysis, statistics, and advanced baseline normalization and correction methods adapted to HEP/HEO analysis. However, it uses the Bonferroni method for statistical correction of the type 1 error (i.e., false positives), which is too conservative and not physiologically sound for EEG applications, leading to an increase in type II errors (i.e., false negatives)41. Furthermore, the toolbox does not offer command-line access for automation. Finally, recent studies recommend against baseline correction methods42,43,44, as they reduce the signal-to-noise ratio (SNR) and are statistically unnecessary and undesirable.
To address these limitations, we introduce the BrainBeats toolbox, currently implemented as an open-source EEGLAB plugin in the MATLAB environment. It incorporates the following advantages over previous methods:
1) An easy-to-use GUI and command-line capabilities (for programmers aiming to perform automated processing). 2) Validated algorithms, parameters, and guidelines for processing cardiovascular signals, such as detecting R peaks, interpolating RR artifacts, and computing HRV metrics (e.g., implanting guidelines for windowing, resampling, normalization, etc.27,45,46). This is important because Vest et al. demonstrated how modest differences in these processing steps can lead to divergent results, contributing to the lack of reproducibility and clinical applicability of HRV metrics46. 3) Validated algorithms, default parameters, and guidelines for processing EEG signals, including filtering and windowing44,47, re-referencing48,49, removal of abnormal channels and artifacts50,51,52, optimized ICA decomposition and classification of independent components53,54,55,56. The users can fine-tune all preprocessing parameters or even preprocess their EEG data with their preferred method before using the toolbox to match their needs (e.g., with EEGLAB clean_rawdata plugin50,52, the BeMoBIL pipeline38, the PREP pipeline57, etc.). 4) Heartbeat-evoked potentials (HEP, i.e., time domain) and oscillations (HEO; event-related spectral perturbations with wavelet or FFT methods, and inter-trial coherence are available through the standard EEGLAB software) from ECG signals. Parametric and nonparametric statistics with corrections for type 1 errors are available via EEGLAB's standard software. Nonparametric statistics include permutation statistics and spatiotemporal corrections for multiple comparisons (e.g., spatiotemporal clustering or threshold-free cluster enhancement)58,59. Users can use the LIMO-EEG plugin to implement hierarchical linear modeling, which accounts well for within and between-subjects variance and implements an assumption-free mass-univariate approach with robust control for type I and II errors60,61. The HEP/HEO data statistical analyses can be performed in the channel and independent component domains. 5) HEP/HEO and HRV analysis from PPG signals (for the first time for HEP/HEO). 6) Supports the joint extraction of EEG and HRV features for the first time. 7) The toolbox provides various data visualizations to inspect signals at various necessary processing steps and outputs at the subject level.
Method | Detect R-peaks from ECG | Detect R-waves from PPG | HEP/HEO | EEG & HRV features | Remove heart artifacts from EEG | GUI | Command line |
ecg-kit | X | X | X | X | |||
BeMoBIL | X | X | X | ||||
HEPLAB | X | X | X | X | |||
CARE-rCortex | X | X | X | X | |||
BrainBeats | X | X | X | X | X | X | X |
TABLE 1: Novelties brought by BrainBeats relative to pre-existing, similar methods.
Information to help readers decide whether the method is appropriate for them
This toolbox is appropriate for any researcher or clinician with EEG and ECG/PPG data. The plugin does not yet support importing EEG and ECG/PPG signals from separate files (although this feature will be available soon). The toolbox is appropriate for anyone aiming to perform HEP/HEO analysis, extract EEG and/or HRV features with standardized methods, or simply remove heart artifacts from EEG signals. See Figure 1 for a block diagram summarizing BrainBeats' overall flow and methods.
FIGURE 1. Block diagram summarizing BrainBeats' overall architecture and flow. The operations that are common across the three methods are brown. Operations specific to heartbeat-evoked potentials (HEP) and oscillations (HEO) are green. Operations specific to the extraction of EEG and HRV features are blue. Operations specific to removing heart artifacts from the EEG signals are red. Please click here to view a larger version of this figure.
Informed consent was obtained from each participant, and the Ural Federal University ethics committee approved the experimental protocol.
1. BrainBeats requirements
2. Heartbeat-evoked potentials (HEP) and oscillations (HEO)
3. Extracting EEG and HRV features
4. Extract heart artifacts from EEG signals.
First, the BrainBeats plugin was used to preprocess EEG and ECG data, identify and remove artifacts, and analyze heartbeat-evoked potentials (HEP) and oscillations (HEO). BrainBeats successfully detected the RR intervals from the ECG signal and some RR artifacts (Figure 2). BrainBeats also reported in the command window that 11/305 (3.61%) of the heartbeats were flagged as artifacts and interpolated. The average signal quality index (SQI) of the RR intervals (before interpolation) has a valu...
Critical steps in the protocol
Critical steps are described in steps 1.1-1.4. Warnings and error messages are implemented at various places in the toolbox to help users understand why they may encounter issues (e.g., electrode locations not loaded in the EEG data, file length being too short for calculating a reliable measure of ultra-low frequency HRV, signal quality being too low for any reliable analysis, etc.). Each function is documented for advanced users, and the parameters can be easily fin...
The authors have nothing to disclose.
The Institute of Noetic Sciences supported this research. We thank the developers of the original open-source algorithms that were adapted to develop some of BrainBeats' algorithms.
Name | Company | Catalog Number | Comments |
EEGLAB | Swartz Center for Computational Neuroscience (SCCN) | Free/Open-source | |
MATLAB | The Mathworks, Inc. | Requires a license | |
Windows PC | Lenovo, Inc. |
Request permission to reuse the text or figures of this JoVE article
Request PermissionThis article has been published
Video Coming Soon
Copyright © 2025 MyJoVE Corporation. All rights reserved