Transform your EEG data into source-localized representations using the Desikan-Killiany atlas regions with ease and efficiency
AutoClean EEG2Source is a specialized Python package designed for neuroscientists and researchers working with high-density EEG data. It provides a robust, memory-efficient pipeline for converting EEG epochs to source-localized data using brain regions from the Desikan-Killiany atlas.
Powered by MNE-Python: Our package builds upon the excellent MNE-Python framework, the leading open-source solution for analyzing EEG, MEG, and other neurophysiological data. We gratefully acknowledge the MNE development team for creating this exceptional foundation.
Whether you're analyzing individual recordings or processing large datasets, AutoClean EEG2Source offers the tools you need to transform scalp-level electrical activity into meaningful brain source estimations, with automatic error recovery, parallel processing, and GPU acceleration capabilities.
Designed with beginners in mind, the package features straightforward command-line and Python interfaces, detailed documentation, and optimized performance even on modest hardware.
Source localization illustration (image from MNE-Python)
Convert EEG epochs to source-localized data with 68 regions from the Desikan-Killiany atlas.
Parallel processing, GPU acceleration, and memory-efficient operations for handling large datasets.
Automatic error recovery mechanisms to handle common issues with EEG data.
Simple command-line interface and Python API designed for both beginners and experts.
Works with standard EEGLAB .set/.fdt file formats, maintaining workflow compatibility.
Built-in performance measurements to help optimize processing for your specific hardware.
AutoClean EEG2Source can be installed using UV or pip. UV is recommended for its faster installation speed and better dependency resolution.
# Install UV if you don't have it
pip install uv
# Install AutoClean EEG2Source with UV
uv pip install autoclean-eeg2source
For development installation:
# Clone the repository
git clone https://github.com/cincibrainlab/autoclean-eeg2source.git
cd autoclean-eeg2source
# Install in development mode with UV
uv pip install -e .
# With development dependencies
uv pip install -e ".[dev]"
# Install with pip
pip install autoclean-eeg2source
# Clone the repository
git clone https://github.com/cincibrainlab/autoclean-eeg2source.git
cd autoclean-eeg2source
# Install from source
pip install .
# Or with UV (recommended)
uv pip install .
First, check information about your EEG file:
autoclean-eeg2source info path/to/your/eegfile.set
Ensure your file is suitable for processing:
autoclean-eeg2source validate path/to/your/eegfile.set --check-montage
Run the source localization process:
autoclean-eeg2source process path/to/your/eegfile.set --output-dir ./output
Your source-localized data is now available in the output directory:
*_dk_regions.set
- Source-localized data with 68 DK atlas regions*_region_info.csv
- Metadata for brain regionsfrom autoclean_eeg2source import SequentialProcessor, MemoryManager
# Initialize components
memory_manager = MemoryManager(max_memory_gb=4)
processor = SequentialProcessor(
memory_manager=memory_manager,
montage="GSN-HydroCel-129",
resample_freq=250
)
# Process a file
result = processor.process_file("input.set", "./output")
if result['status'] == 'success':
print(f"Output saved to: {result['output_file']}")
else:
print(f"Processing failed: {result['error']}")
Imagine you have completed an EEG study with 30 participants, each with preprocessed and epoched data in EEGLAB format. You now want to conduct source-level analysis using the Desikan-Killiany atlas regions.
autoclean-eeg2source validate /path/to/study/data --recursive --check-montage --save-validation
autoclean-eeg2source process /path/to/study/data \
--output-dir ./source_data \
--parallel --n-jobs 8 \
--optimized-memory --max-memory 16.0 \
--recursive \
--robust \
--save-summary
Once processed, you can load the source-localized data in EEGLAB or use your own analysis scripts to work with the 68 brain regions. Here's a simple Python example to get you started:
import mne
import pandas as pd
import matplotlib.pyplot as plt
# Load source-localized data
epochs = mne.io.read_epochs_eeglab('./source_data/sub01_dk_regions.set')
# Load region metadata
regions = pd.read_csv('./source_data/sub01_region_info.csv')
# Plot the average activity across all epochs for a specific region
region_name = 'bankssts-lh' # Example region
region_idx = regions[regions['names'] == region_name].index[0]
plt.figure(figsize=(10, 5))
plt.plot(epochs.times, epochs.get_data().mean(axis=0)[region_idx])
plt.title(f'Average activity in {region_name}')
plt.xlabel('Time (s)')
plt.ylabel('Source strength (A·m)')
plt.show()
Before processing a large dataset, it's helpful to determine which processing method will be most efficient for your specific hardware configuration.
autoclean-eeg2source benchmark /path/to/sample/data --test-all --max-files 2
Based on the benchmark results, choose the most efficient processor for your system. For example, if the GPU processor showed the best performance:
autoclean-eeg2source process /path/to/study/data \
--output-dir ./source_data \
--gpu --gpu-backend auto \
--enable-cache \
--recursive
Alternatively, if parallel processing was faster:
autoclean-eeg2source process /path/to/study/data \
--output-dir ./source_data \
--parallel --n-jobs -1 \
--batch-processing \
--enable-cache \
--recursive
Current Development: We are actively working on several important enhancements to make AutoClean EEG2Source even more versatile and user-friendly:
These features are part of our commitment to making advanced neuroimaging techniques accessible to researchers of all experience levels. Stay updated by following our GitHub repository.
We welcome contributions and feedback from the community! There are several ways to get involved:
For questions and support, please reach out through the GitHub repository or contact the authors directly.
AutoClean EEG2Source is built upon the MNE-Python ecosystem and utilizes many of its powerful source localization algorithms. We are deeply grateful to the MNE development team and the broader MNE community for creating and maintaining this essential neuroimaging toolkit.
When using AutoClean EEG2Source, please also cite the MNE-Python publications: