June 6th, 2025
This protocol presents PIPEMAT-RS, a standardized MATLAB-based preprocessing pipeline for resting-state EEG data. It ensures artifact removal, improves signal quality, and enhances data reproducibility across studies. The pipeline automates key preprocessing steps, including filtering, independent component analysis (ICA), and artifact classification, facilitating consistent and reliable EEG analysis for neurophysiological research.
We developed a standardized EEG pre-processing pipeline to improve signal quality, reduce noise, and support consistent neurophysiological research across diverse clinical and experimental data sets. Recent pipelines like RELAX and Automagic offer automated EEG cleaning, but often lack flexibility or clear documentation for researchers and students who need transparency and consistency of results. We use EEG, Matlab, EEG lab, and ICA-based artifact rejection combined with automated classifiers, like ICLabel to enhance data quality and streamline pre-processing workflows. It has been found that PIPEMAT-RS improves EEG signal quality, increased SNR, and support robust biomarkers in stroke, fibromyalgia, and chronic pain studies. This protocol addresses the lack of a predictable, well-documented, and standardized pipeline for resting state EEG that is both consistent and accessible for researchers worldwide.
[Presenter] To begin, open MATLAB and navigate to the directory containing the raw electroencephalogram data files. Define the directory path to the raw data files and create a list containing the subjects. Load the raw data file using the load function for .mat files and save each file in .mat format, ensuring data integrity and retaining all relevant metadata. Open MATLAB and navigate to the directory containing the MATLAB files. Use the pop load set function from the EEG lab toolbox to load each subject's EEG dataset. Ensure the appropriate electrode location file corresponding to the EEG cap configuration is available in the working directory. Use the pop_chanedit function to apply the electrode locations. Visually inspect the channel layout using the EEG labs GUI to confirm the correct positions of all electrodes. Save the updated EEG dataset using the pop_saveset function. If required, reduce the sampling rate of the EEG data to 250 hertz using the pop resample function. Apply a band pass filter from one hertz to 50 hertz to channels one to 128 using the pop basicfilter function with a Butterworth design and filter order of two. Use zero phase forward and reverse filtering to prevent phase distortion. Apply a notch filter at 50 or 60 hertz to channels one through 64 using pop basic filter with the PM notch design and a filter order of 180. For the artifact rejection, use the clean raw data function with the given parameters to automatically detect and remove flatline channels, noisy segments, and low frequency drifts. Visually inspect the EEG data using EEG plot from EG lab to identify any residual artifacts missed by the automated method. Manually mark and remove the remaining artifacts to ensure high data quality. Use pop_reref to re-reference the EEG signals to the average of all electrodes, ensuring the original reference electrode is retained. Load the file with the suffix, loc_filt_cleanraw_reref.set using pop loadset. Run independent component analysis or ICA using the pop runica function with the runica algorithm to decompose the EEG data into independent components. Save the new data set with the suffix, loc_filt_cleanraw_reref_ICA using pop_saveset to indicate ICA completion. Import the ICA data set using pop loadset. Run the pop ICA label function with the default model to classify independent components into brain and artifact categories. Identify all components with brain activity probability above 0.7. Use the pop subcomp function to remove all components with IC label brain probability below 0.7. Retain only components with a brain activity probability above 0.7 to preserve genuine signals while ensuring the effective removal of artifacts. Save the clean dataset with the suffix, loc_filt_cleanraw_reref_ac_cleaned using pop_saveset. Finally, import the dataset with artifact-free ICA components using the pop loadset function and save the fully pre-processed and normalized dataset with the suffix, loc_filt_cleanraw_reref_ICA_Normalized using pop_saveset. The initial state of the EEG dataset prior to any pre-processing, including both the raw signal traces and their corresponding spectral characteristics is illustrated in this figure. The raw EEG data exhibited high levels of noise and irregular signal traces across multiple channels, compromising clarity and interpretability. Manual cleaning of the EEG data reduced signal artifacts and improved waveform uniformity, but some residual noise and inconsistencies remained visible. Data processed with PIPEMAT-RS displayed the cleanest EEG waveforms with consistent signal structure and minimal visible artifacts across channels.
View the full transcript and gain access to thousands of scientific videos
This article details the development of PIPEMAT-RS, a MATLAB-based preprocessing pipeline designed for resting-state EEG data. It focuses on improving signal quality and data reproducibility through automated steps like filtering and artifact classification, aiming to support consistent findings in neurophysiological research.