This repository documents the preprocessing pipeline applied to EEG data for HEP (heartbeat-evoked potential) analysis.
This preprocessing pipeline relies on modified versions of toolboxes such as EEGLAB and HEPLAB. Please note that downloading these toolboxes directly from their official websites will not ensure compatibility. The custom modifications are essential for the automated functionality of this pipeline.
🔌 System Compatibility
The entire pipeline is specifically tailored for EEG data acquired using a 128-channel EGI system with .mff file formats. If you are using a different EEG system or data structure, modifications will be necessary:
- Some scripts contain hardcoded references to 128 channels — these must be updated to match your system's configuration.
- The pipeline assumes
.mffinput files and uses the corresponding EEGLAB import plugins. You will need to replace or modify these import steps if your data format differs.
📁 File Naming Convention Raw EEG data files are expected to follow this structure:
subjectNumber_task_date_time.mff
If your raw data adheres to this convention, no modifications will be required in the subject loading and naming steps.
The pipeline uses the underscore ('_') as a delimiter to parse and rename datasets. To ensure seamless loading and compatibility across scripts, we strongly recommend following this file naming format.
Make sure to contact us for the toolboxes, adapt the importing function, and file naming logic to your specific dataset if it diverges from these defaults.
Following EEG acquisition, the raw data undergoes a comprehensive 12-step preprocessing procedure. The goal is to retain only high-fidelity neural signals synchronized with cardiac events.
Each step was carefully chosen to prepare the data for robust HEP detection and analysis:
-
📉 Loading and Downsampling
Load data and set the data sampling rate to 512hz to optimize processing without loss of relevant information. -
🫀 Manual ECG Noise Rejection
Visual inspection and manual exclusion of segments with excessive ECG or hardware noise. -
🎚 Filtering
Apply appropriate bandpass filters to isolate HEP-relevant frequency bands. -
⚡ Zapline-plus Noise Removal
Automatic removal of frequency-specific line noise using Zapline-plus 1. -
🧼 Artifact Subspace Reconstruction (ASR)
Clean transient, high-amplitude artifacts using ASR to preserve valid EEG activity. -
📉 Bad Channel Removal
Identify and exclude consistently noisy or disconnected channels. -
🔌 Re-referencing
Re-reference the EEG signal (e.g., average or mastoid) to reduce spatial bias. -
💓 R-Peak Detection with HEPLAB
Detect heartbeat R-peaks using the HEPLAB toolbox 2. (Modified Toolbox to run automaticly across subjects) -
👁 Visual Inspection and Correction of R-Peaks
Manually verify and correct any inaccurate R-peak detections. -
🧠 AMICA Decomposition & Eye Artifact Removal
Apply Adaptive Mixture ICA (AMICA) 3 to isolate and remove ocular and muscle artifacts. -
⏱ Epoching
Segment EEG into epochs time-locked to R-peaks for subsequent averaging and analysis. -
🧹 Epoch Rejection (Statistical)
Discard outlier epochs based on amplitude, variance, or statistical criteria.
- Cleaned and epoched EEG data ready for HEP analysis
- ICA component maps and removed components log
- Event markers for validated R-peaks
- MATLAB / EEGLAB
- Zapline-plus
- HEPLAB (modified version)
- AMICA
- Custom preprocessing scripts
Pull requests are welcome! If you have improvements for preprocessing, visualization, or HEP analysis methods, feel free to contribute.
This project is licensed under the MIT License. See the LICENSE file for details.
If you use this preprocessing pipeline in your research, please cite the repository as follows:
Fraile, M., Salamone, P., Zoltowski, A., Quackenbush, W., Keceli-Kaysili, B., & Cascio, C. J. (2025). HEP_Preprocessing: EEG Preprocessing Pipeline for Heartbeat-Evoked Potentials (HEP) Analysis. https://github.com/casciolab/HEP_Preprocessing
For LaTeX users:
@misc{fraile2025hep,
author = {Fraile-Vazquez, Matias E.; Salamone, Paula; Zoltowski, Alisa; Quackenbush, William; Keceli-Kaysili, Bahar; Cascio, Carissa J.},
title = {HEP_Preprocessing: EEG Preprocessing Pipeline for Heartbeat-Evoked Potentials (HEP) Analysis},
year = {2025},
howpublished = {\url{https://github.com/casciolab/HEP_Preprocessing}},
note = {Version 1.0}
}Footnotes
-
Klug, Marius, and Niels A. Kloosterman. "Zapline‐plus: A Zapline extension for automatic and adaptive removal of frequency‐specific noise artifacts in M/EEG." Human Brain Mapping 43.9 (2022): 2743-2758. ↩
-
Perakakis, P. (2022). HEPLAB: An open-source MATLAB toolbox for heartbeat-evoked potential analysis ↩
-
Palmer, Jason A., Ken Kreutz-Delgado, and Scott Makeig. "AMICA: An adaptive mixture of independent component analyzers with shared components." Swartz Center for Computatonal Neursoscience, University of California San Diego, Tech. Rep (2012): 1-15. ↩