This repository provides a modular and reusable pipeline for preprocessing and analyzing EEG (Electroencephalography) data using MNE-Python. Developed as part of a project within the DIΒ²SΒ²C unit at the CRPN research center, this package is designed to streamline EEG workflowsβfrom raw signal cleaning to power spectral analysis and condition-based statistical comparisons.
The goal is to address a common limitation in EEG research: the lack of standardized, flexible pipelines that can adapt to different experiments while maintaining reproducibility. This tool supports:
- Event-based preprocessing with filtering, ICA, and epoching
- Condition-wise power spectral density (PSD) computation
- Group-level statistical contrasts with cluster-based permutation testing
- SLURM-compatible execution for high-performance computing environments
Whether you're working on cognitive neuroscience, clinical EEG, or mental imagery experiments, this pipeline provides a solid foundation for scalable, interpretable EEG data analysis.
To install the package, we will create a python virtual environment. It is an important tool for anyone developing code in Python. It makes defining and managing code that depends on multiple software packages easier to install by preventing software conflicts, it can also help performing tests, debugging, and collaborating with other developers.
For the creation of python virtual environment and installation of the MNE package, we will be using a python package called UV. It is a single tool to replace pip, pip-tools, pipx, poetry, pyenv, twine, virtualenv, and more. It allows the installation of packages while automatically checking and installing the dependencies (and recursively for sub-packages). Hence, speeding up installations of main packages such as MNE which uses approximately 60 - 100 sub-packages depending on the requirement (signal processing, visualization, etc.), which would require manual operations if UV was not used.
Download the latest release of the mnedisc package from the dev_mith/hands_on branch of the MNEDISC project.
How to download?
- On the repository page, click the blue Code button (top-right).
- In the dropdown, click Download ZIP.
- Once downloaded, unzip the archive.
- Rename the folder from
mnedsic-dev_mith/hands_ontomnedsic. - Place the
mnedsicfolder in your working directory (for example:desktop/mnedisc).
You can now continue with Step 2 to create and activate the virtual environment inside this folder.
2. π§ Install UV
Open your terminal and run the following commands based on your operating system:
ππ§ MAC/LINUX With curl
curl -LsSf https://astral.sh/uv/install.sh | shππ§ MAC/LINUX With wget
wget -qO- https://astral.sh/uv/install.sh | shπͺ Windows
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"cd mnediscuv venv .mnedisc_venv --python 3.12.7Add uv to your system PATH so it can be accessed from any terminal session.
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc && source ~/.zshrcππ§ Mac/Linux
source .mnedisc_venv/bin/activateπͺ Windows
.mnedisc_venv\Scripts\activateuv pip install -r requirements.txtSome dependencies (for example, MNE or NumPy builds) require CMake.
If you see errors like this during installation:
CMake is required to build some of the extensions
Install CMake using Homebrew:
brew install cmakeAfter installation, try running the dependency installation again:
uv pip install -r requirements.txtWhen using uv to install dependencies, you might see this warning during installation:
warning: The package typer==0.15.2 does not have an extra named allThis happens because uv may internally reference an optional extras group (typer[all]) that no longer exists in version 0.15.2.
β You can safely ignore this warning. Typer and other required dependencies will still install correctly.
python test_venv.pyuv pip install -e .uv pip show mnedisc9. Ensure the config files are placed at the correct directories and the variables are set as desired with the help of:
10. Ensure the data is structured in BIDS format. Help on how to prepare the data can be found here:
python main_python_scripts/main_Pre_processing.pypython main_python_scripts/main_Analysis.pyπ‘ Tip: To deactivate the virtual environment enter:
deactivate
To speed up processing, especially when handling multiple EEG subjects or running computationally intensive statistical analysis, you can execute the pipeline on a computing cluster using SLURM job scheduling.
Cluster execution allows:
- Parallel subject-wise preprocessing using job arrays
- Efficient use of CPU and memory resources
β Important: Before running these scripts on the cluster, make sure you have cloned this repository on the cluster or recreated the same directory structure as your local setup.
π Config Template for .slurm
sbatch main_python_scripts/run_eeg_pre_processing.slurmπ‘ Note: Results saved in
main_python_scripts/Cluster_Logs/Pre_processing_logs/logs
sbatch main_python_scripts/run_eeg_analysis.slurmπ‘ Note: Results saved in
main_python_scripts/Cluster_Logs/Analysis_logs/logs
π‘ Tip: Check the batch status with the keyword:
squeue
This software is distributed under the terms of the GNU General Public License as published by the Free Software Foundation. Further details on the GPLv3 license can be found at http://www.gnu.org/copyleft/gpl.html.
FOR RESEARCH PURPOSES ONLY. THE SOFTWARE IS PROVIDED "AS IS," AND IN THE HOPE THAT IT WILL BE USEFUL BUT WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, NOR DO THEY ASSUME ANY LIABILITY OR RESPONSIBILITY FOR THE USE OF THIS SOFTWARE.
