### Install MOABB and Run Benchmark Example Source: https://github.com/neurotechx/moabb/blob/develop/README.md Installs the MOABB library and demonstrates a basic benchmark setup using a specific dataset, paradigm, and pipeline. Ensure you have the necessary dependencies installed. ```shell pip install moabb ``` ```python import moabb from moabb.datasets import BNCI2014_001 from moabb.evaluations import CrossSessionEvaluation from moabb.paradigms import LeftRightImagery from moabb.pipelines.features import LogVariance from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA from sklearn.pipeline import make_pipeline moabb.set_log_level("info") pipelines = {"LogVar+LDA": make_pipeline(LogVariance(), LDA())} dataset = BNCI2014_001() dataset.subject_list = dataset.subject_list[:2] paradigm = LeftRightImagery(fmin=8, fmax=35) evaluation = CrossSessionEvaluation(paradigm=paradigm, datasets=[dataset]) results = evaluation.process(pipelines) print(results.head()) ``` -------------------------------- ### Quickstart: Complete BCI Benchmark Example Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/llms.txt A full working example demonstrating how to set up a BCI benchmark using MOABB. It includes selecting a paradigm, dataset, defining pipelines, running an evaluation, and printing results. ```python from moabb.datasets import BNCI2014_001 from moabb.evaluations import CrossSessionEvaluation from moabb.paradigms import LeftRightImagery from moabb.pipelines.features import LogVariance from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA from sklearn.pipeline import make_pipeline # 1. Pick a paradigm (defines the task and preprocessing) paradigm = LeftRightImagery(fmin=8, fmax=35) # 2. Pick datasets (BNCI2014_001 has 9 subjects, 2 sessions, 4 MI classes) dataset = BNCI2014_001() dataset.subject_list = dataset.subject_list[:2] # limit subjects for speed # 3. Define pipelines as a dict of {name: sklearn_pipeline} pipelines = {"LogVar+LDA": make_pipeline(LogVariance(), LDA())} # 4. Run evaluation evaluation = CrossSessionEvaluation(paradigm=paradigm, datasets=[dataset]) results = evaluation.process(pipelines) # 5. Results is a pandas DataFrame print(results[["dataset", "subject", "session", "pipeline", "score"]]) ``` -------------------------------- ### Install MOABB from Local Clone Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/install/install_source.rst Install MOABB from a local clone of the repository. This command installs MOABB for general usage without modifying the code. ```bash pip install . ``` -------------------------------- ### Install MOABB Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/install/install_pip.rst Use this command to install the base MOABB package from PyPI. ```bash pip install moabb ``` -------------------------------- ### Install MOABB with Optional Dependencies Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/install/install_pip.rst Install MOABB along with specific optional dependency groups like deep learning, carbon emission tracking, or documentation. ```bash pip install moabb[deepleaning,carbonemission,docs] ``` -------------------------------- ### Install Pre-commit Hooks Source: https://github.com/neurotechx/moabb/blob/develop/CONTRIBUTING.md Install pre-commit and its hooks to automatically run code quality checks before committing. Your first commit will trigger the download of these tools. ```bash pip install pre-commit ``` ```bash pre-commit install ``` -------------------------------- ### Minimal Benchmark Example Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/api.rst This is the simplest way to run a benchmark. It downloads data, executes pipelines, and returns results. Ensure the specified paths for pipelines, evaluations, datasets, and results are correctly configured. ```python from moabb import benchmark results = benchmark( pipelines="./pipelines", evaluations=["WithinSession"], paradigms=["LeftRightImagery"], include_datasets=[BNCI2014_001(), PhysionetMI()], exclude_datasets=None, results="./results/", overwrite=True, plot=True, output="./benchmark/", n_jobs=-1, ) ``` -------------------------------- ### Editable Installation Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/install/install_source.rst Perform an editable installation of MOABB from a local clone. This mode ensures that any local changes to the code are immediately reflected without needing reinstallation. ```bash pip install -e . ``` -------------------------------- ### Install Latest Development Version Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/install/install_source.rst Install the latest development version of MOABB directly from its GitHub repository. Use this if you want the newest features without cloning the repository. ```bash pip install https://github.com/NeuroTechX/moabb/archive/refs/heads/develop.zip ``` -------------------------------- ### Verify MOABB Installation Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/install/install_source.rst Run the pytest command to verify that MOABB is installed correctly and all tests pass. This command checks the installed package and its test suite. ```console pytest moabb/tests --verbose ``` -------------------------------- ### Clone MOABB Repository Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/install/install_source.rst Clone the MOABB repository from GitHub and navigate into the project directory. This is the first step for installing from source. ```bash git clone https://github.com/neurotechx/moabb.git cd moabb ``` -------------------------------- ### Editable Installation with Optional Dependencies Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/install/install_source.rst Install MOABB in editable mode with a specified set of optional dependencies. This is useful for development that requires specific features like deep learning or testing tools. ```bash pip install -e .[deeplearning,carbonemission,docs,optuna,tests,external] ``` -------------------------------- ### Cross-Subject Transfer Learning Example Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/llms-full.txt Demonstrates setting up and running a cross-subject evaluation using a specific paradigm and dataset. Ensure the dataset supports cross-subject evaluation and the paradigm matches the dataset's characteristics. ```python from moabb.datasets import BNCI2014_001 from moabb.evaluations import CrossSubjectEvaluation from moabb.paradigms import LeftRightImagery from moabb.pipelines.features import LogVariance from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA from sklearn.pipeline import make_pipeline paradigm = LeftRightImagery(fmin=8, fmax=32) dataset = BNCI2014_001() pipelines = {"LogVar+LDA": make_pipeline(LogVariance(), LDA())} evaluation = CrossSubjectEvaluation(paradigm=paradigm, datasets=[dataset]) results = evaluation.process(pipelines) # Each row: train on all-but-one subject, test on held-out subject ``` -------------------------------- ### Compare Pipelines Across Multiple Datasets Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/llms-full.txt Benchmark and compare different pipelines (e.g., LogVar+LDA vs. LogVar+SVM) across multiple datasets using `WithinSessionEvaluation`. This example utilizes parallel processing with `n_jobs=4`. ```python from moabb.datasets import BNCI2014_001, Cho2017, PhysionetMI from moabb.evaluations import WithinSessionEvaluation from moabb.paradigms import LeftRightImagery from moabb.pipelines.features import LogVariance from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA from sklearn.svm import SVC from sklearn.pipeline import make_pipeline paradigm = LeftRightImagery(fmin=8, fmax=32) pipelines = { "LogVar+LDA": make_pipeline(LogVariance(), LDA()), "LogVar+SVM": make_pipeline(LogVariance(), SVC()), } evaluation = WithinSessionEvaluation( paradigm=paradigm, datasets=[BNCI2014_001(), Cho2017(), PhysionetMI()], n_jobs=4, ) results = evaluation.process(pipelines) ``` -------------------------------- ### P300 Evaluation with Xdawn+MDM Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/llms-full.txt Conduct a P300 event-related potential evaluation using `WithinSessionEvaluation`. This example demonstrates a pipeline combining Xdawn covariance estimation and Minimum Distance to Mean classification. ```python from moabb.datasets import BNCI2014_008 from moabb.evaluations import WithinSessionEvaluation from moabb.paradigms import P300 from pyriemann.estimation import XdawnCovariances from pyriemann.classification import MDM from sklearn.pipeline import make_pipeline paradigm = P300(fmin=1, fmax=24) dataset = BNCI2014_008() pipelines = {"Xdawn+MDM": make_pipeline(XdawnCovariances(nfilter=2), MDM())} evaluation = WithinSessionEvaluation(paradigm=paradigm, datasets=[dataset]) results = evaluation.process(pipelines) ``` -------------------------------- ### Get Raw Data for Custom Analysis Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/llms-full.txt Access preprocessed epoch data directly using the `get_data` method of a paradigm object, bypassing the standard evaluation process. This is useful for custom analysis workflows. ```python # Get preprocessed epoch data directly (bypass evaluation) X, y, metadata = paradigm.get_data(dataset, subjects=[1, 2]) # X: ndarray (n_epochs, n_channels, n_times) # y: ndarray of string labels (e.g. ["left_hand", "right_hand", ...]) # metadata: DataFrame with subject, session, run columns ``` -------------------------------- ### Generate Documentation Locally Source: https://github.com/neurotechx/moabb/blob/develop/CONTRIBUTING.md Navigate to the 'docs' directory and use 'make html' to build a local version of the project documentation. ```bash cd docs make html ``` -------------------------------- ### Benchmark Pipeline in 3 Lines Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/_static/social_card_gen.html This snippet demonstrates the minimal code required to set up and run a benchmark evaluation for a given pipeline using MOABB. Ensure pipelines and evaluation strategies are defined beforehand. ```python paradigm = LeftRightImagery() evaluation = CrossSessionEvaluation(paradigm=paradigm) results = evaluation.process(pipelines) ``` -------------------------------- ### Conditional Export of Neural Signature Functions Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/whats_new.rst The `generate_neural_signature` and `neural_signature_html` functions are conditionally exported from `moabb.analysis` when the `plotly` library is installed. ```python from moabb.analysis import generate_neural_signature, neural_signature_html ``` -------------------------------- ### Get Raw Epoch Data Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/llms.txt Retrieves raw epoch data for custom analysis using a specified paradigm and dataset. Returns features (X), labels (y), and metadata. ```python # Get raw epoch data for custom analysis X, y, metadata = paradigm.get_data(dataset, subjects=[1, 2]) ``` -------------------------------- ### Minimal Left/Right Motor Imagery Benchmark Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/llms-full.txt Perform a basic benchmark for left/right motor imagery using `CrossSessionEvaluation`. This example uses a subset of subjects for a faster demonstration. ```python from moabb.datasets import BNCI2014_001 from moabb.evaluations import CrossSessionEvaluation from moabb.paradigms import LeftRightImagery from moabb.pipelines.features import LogVariance from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA from sklearn.pipeline import make_pipeline paradigm = LeftRightImagery(fmin=8, fmax=35) dataset = BNCI2014_001() dataset.subject_list = dataset.subject_list[:2] # fast demo pipelines = {"LogVar+LDA": make_pipeline(LogVariance(), LDA())} evaluation = CrossSessionEvaluation(paradigm=paradigm, datasets=[dataset]) results = evaluation.process(pipelines) print(results[["subject", "session", "pipeline", "score"]]) ``` -------------------------------- ### Compare Multiple Pipelines and Datasets Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/llms.txt Demonstrates how to compare several scikit-learn pipelines across multiple MOABB datasets. Includes parallel processing using n_jobs. ```python # Compare multiple pipelines on multiple datasets from moabb.datasets import BNCI2014_001, Cho2017, PhysionetMI from sklearn.svm import SVC pipelines = { "LogVar+LDA": make_pipeline(LogVariance(), LDA()), "LogVar+SVM": make_pipeline(LogVariance(), SVC()), } evaluation = CrossSessionEvaluation( paradigm=paradigm, datasets=[BNCI2014_001(), Cho2017()], n_jobs=4, # parallelize ) results = evaluation.process(pipelines) ``` -------------------------------- ### MOABB Benchmark Function Parameters Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/llms-full.txt Configure and run benchmarks using the `benchmark` function. Specify pipeline directories, evaluation types, paradigms, and output locations. Set `n_jobs` to -1 to utilize all available CPU cores. ```python moabb.benchmark( pipelines="./pipelines/", # Dir of YAML files, single file, or list of dicts evaluations=None, # ["WithinSession", "CrossSession", "CrossSubject"] paradigms=None, # ["LeftRightImagery", "MotorImagery", "P300", ...] results="./results/", # Directory for cached results output="./benchmark/", # Directory for analysis output overwrite=False, n_jobs=-1, # -1 = all cores include_datasets=None, # List of dataset codes to include exclude_datasets=None, # List of dataset codes to exclude n_splits=None, # CV splits for CrossSubjectEvaluation plot=False, # Generate analysis plots ) -> pd.DataFrame ``` -------------------------------- ### SSVEP Evaluation with Filter Banks Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/llms-full.txt Perform Steady-State Visual Evoked Potential (SSVEP) evaluation using `WithinSessionEvaluation` and a filter bank approach. This example uses `Covariances` for estimation and `MDM` for classification. ```python from moabb.datasets import Wang2016 from moabb.evaluations import WithinSessionEvaluation from moabb.paradigms import FilterBankSSVEP from pyriemann.estimation import Covariances from pyriemann.classification import MDM from sklearn.pipeline import make_pipeline paradigm = FilterBankSSVEP(n_classes=4) dataset = Wang2016() dataset.subject_list = dataset.subject_list[:5] pipelines = {"Cov+MDM": make_pipeline(Covariances("oas"), MDM())} evaluation = WithinSessionEvaluation(paradigm=paradigm, datasets=[dataset]) results = evaluation.process(pipelines) ``` -------------------------------- ### Instantiate Dataset with Subject/Session Filtering Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/whats_new.rst Filter datasets at instantiation time by specifying subject and session IDs. This allows for targeted data loading. ```python PhysionetMI(subjects=[1, 2, 3]) ``` -------------------------------- ### BaseParadigm Constructor Parameters Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/llms-full.txt Parameters common to all paradigm constructors. Use these to configure filtering, event selection, epoching, and channel selection. ```python BaseParadigm( filters, # List of [fmin, fmax] tuples for bandpass filtering events=None, # List of event names; None = all dataset events tmin=0.0, # Epoch start (seconds) relative to event onset tmax=None, # Epoch end (seconds); None = dataset default interval baseline=None, # Tuple (a, b) for baseline correction, or None channels=None, # List of channel names; None = all EEG channels resample=None, # Target sampling rate in Hz; None = no resampling overlap=None, # Sliding window overlap 0-100 (%); None = no overlap scorer=None, # sklearn scorer string/callable; None = paradigm default ) ``` -------------------------------- ### Search for Compatible Datasets Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/llms.txt Find datasets programmatically based on paradigm and session requirements. Useful for identifying suitable data for specific BCI tasks. ```python from moabb.datasets.utils import dataset_search # All motor imagery datasets with >= 2 sessions datasets = dataset_search(paradigm="imagery", multi_session=True) # All P300 datasets with at least 10 subjects datasets = dataset_search(paradigm="p300", min_subjects=10) ``` -------------------------------- ### Utility Functions Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/api.rst General utility functions for configuring the library, setting random seeds, managing download directories, and processing pipelines. ```APIDOC ## Utility Functions ### Description Provides essential utility functions for configuring and managing the MOABB environment and operations. ### Functions - **set_log_level**: Configures the logging level for the MOABB library. - **setup_seed**: Sets the random seed for reproducible results. - **set_download_dir**: Specifies the directory for downloading datasets. - **make_process_pipelines**: A utility for processing and managing evaluation pipelines. ``` -------------------------------- ### Running an Evaluation Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/llms-full.txt How to process pipelines using an evaluation object and the expected return type. ```APIDOC ## Running an Evaluation ```python results = evaluation.process(pipelines) # pipelines: dict of {"name": sklearn_pipeline_or_estimator} # returns: pandas DataFrame ``` ``` -------------------------------- ### Speech Imagery Paradigm Constructor Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/llms-full.txt Constructor for Speech Imagery tasks, using broadband defaults. ```python SpeechImagery(n_classes=None, fmin=1, fmax=100, events=None, **kwargs) # Broadband defaults for imagined speech. ``` -------------------------------- ### Load Data with All Modalities Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/whats_new.rst Utilize the `return_all_modalities` parameter to retain non-EEG channels (e.g., EOG, EMG, ECG) when loading data. This parameter accepts True or a dictionary for fine-grained control. ```python dataset.get_data(return_all_modalities=True) ``` ```python dataset.get_data(return_all_modalities=dict(eeg=True, eog=True)) ``` -------------------------------- ### BaseParadigm Parameters Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/llms-full.txt Common parameters for all paradigm constructors, used for filtering, epoching, and channel selection. ```APIDOC ## BaseParadigm Parameters All paradigms inherit from `BaseParadigm` and share these parameters: ```python BaseParadigm( filters, # List of [fmin, fmax] tuples for bandpass filtering events=None, # List of event names; None = all dataset events tmin=0.0, # Epoch start (seconds) relative to event onset tmax=None, # Epoch end (seconds); None = dataset default interval baseline=None, # Tuple (a, b) for baseline correction, or None channels=None, # List of channel names; None = all EEG channels resample=None, # Target sampling rate in Hz; None = no resampling overlap=None, # Sliding window overlap 0-100 (%); None = no overlap scorer=None, # sklearn scorer string/callable; None = paradigm default ) ``` ``` -------------------------------- ### MOABB Software Citation (BibTeX) Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/cite.rst Use this BibTeX entry to cite the MOABB software, referencing its Zenodo DOI. Ensure the version and URL are up-to-date if necessary. ```bibtex @software{Aristimunha_Mother_of_all, author = {Aristimunha, Bruno and Carrara, Igor and Guetschel, Pierre and Sedlar, Sara and Rodrigues, Pedro and Sosulski, Jan and Narayanan, Divyesh and Bjareholt, Erik and Barthelemy, Quentin and Schirrmeister, Robin Tibor and Kobler, Reinmar and Kalunga, Emmanuel and Darmet, Ludovic and Gregoire, Cattan and Abdul Hussain, Ali and Gatti, Ramiro and Goncharenko, Vladislav and Andreev, Anton and Tates, Alberto and Kojima, Simon and Thielen, Jordy and Hajhassani, Davoud and Begany, Katelyn and Moreau, Thomas and Roy, Yannick and Jayaram, Vinay and Barachant, Alexandre and Chevallier, Sylvain}, title = {Mother of all BCI Benchmarks}, year = 2026, publisher = {Zenodo}, version = {1.5.0}, url = {https://github.com/NeuroTechX/moabb}, doi = {10.5281/zenodo.10034223}, } ``` -------------------------------- ### SSVEP Paradigms Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/llms-full.txt Constructors for SSVEP paradigms, including SSVEP and FilterBankSSVEP, with options for class limits and filter bank configuration. ```APIDOC ## SSVEP Specific Paradigms ```python SSVEP(fmin=7, fmax=45, n_classes=None, **kwargs) # n_classes: limit number of frequency classes. Cannot pass filters parameter. # Scorer: roc_auc if 2 classes, accuracy otherwise. FilterBankSSVEP(filters=None, n_classes=None, **kwargs) # If filters=None, auto-creates [f-0.5, f+0.5] for each stimulus frequency. ``` ``` -------------------------------- ### Instantiate Evaluation with CodeCarbon Configuration Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/whats_new.rst Allow CodeCarbon script-level configurations when instantiating a `BaseEvaluation` child class. This enables detailed tracking of computational costs. ```python evaluation = MyEvaluation(codecarbon_configure=True) ``` -------------------------------- ### Pushing and Pull Request Source: https://github.com/neurotechx/moabb/blob/develop/CONTRIBUTING.md Push your feature branch to the origin and submit a pull request against the 'develop' branch. ```bash git push origin my-new-feature ``` -------------------------------- ### Export Raw EEG to BIDS Format Source: https://github.com/neurotechx/moabb/blob/develop/docs/source/whats_new.rst Use the `convert_to_bids` method to export raw EEG datasets to BIDS-compliant directory structures. This method ensures clean filenames without processing-pipeline hashes. ```python dataset.convert_to_bids(output_path) ```