Skip to main content

Single trial EEG pipeline at the Neurocognitive Psychology Lab, Humboldt-Universität zu Berlin

Project description

hu-neuro-pipeline

PyPI PyPI - Python Version GitHub

Single trial EEG pipeline at the Neurocognitive Psychology lab, Humboldt-Universität zu Berlin

Based on Frömer, R., Maier, M., & Abdel Rahman, R. (2018). Group-level EEG-processing pipeline for flexible single trial-based analyses including linear mixed models. Frontiers in Neuroscience, 12, 48. https://doi.org/10.3389/fnins.2018.00048

1. Installation

1.1 For Python users

Install the pipeline via pip from the Python Package Index (PyPI):

python3 -m pip install hu-neuro-pipeline

1.2 For R users

First install reticulate and Miniconda for being able to import Python packages into R:

install.packages("reticulate")
reticulate::install_miniconda()

Then install the pipeline via pip from the Python Package Index (PyPI):

reticulate::py_install("hu-neuro-pipeline", pip = TRUE, python_version = "3.8")

2. Usage

Pipeline inputs

Pipeline outputs

3. Examples

3.1 For Python users

This is a fairly minimal example for a (fictional) N400/P600 experiment with two experimental factors: semantics (e.g., 'related' vs. 'unrelated') and emotional Context (e.g., 'negative' vs. 'neutral'). We need to specify the paths to the raw EEG data, the behavioral log files, the output directory, and the BESA files for ocular correction (though we could also choose an ICA method like 'fastica'). Four different EEG triggers correspond to each of the four different cells in the 2 × 2 design. The log files might contain additional rows (i.e., trials) from a 'filler' condition which we want to skip because they don't have corresponding EEG triggers. We want to compute mean ERP amplitudes for pre-specified time windows and regions of interest corresponding to the N400 and P600 components. In addition, we want to obtain by-participant averages for each condition (for the main effects) and each combination of conditions (for the interaction effect), as specified with average_by.

from pipeline import group_pipeline

trials, evokeds = group_pipeline(
    vhdr_files='Results/EEG/raw',
    log_files='Results/RT',
    output_dir='Results/EEG/export',
    ocular_correction='Results/EEG/cali',
    triggers=[201, 202, 211, 212],
    skip_log_conditions={'semantics': 'filler'},
    components={'name': ['N400', 'P600'],
                'tmin': [0.3, 0.5],
                'tmax': [0.5, 0.9],
                'roi': [['C1', 'Cz', 'C2', 'CP1', 'CPz', 'CP2'],
                        ['Fz', 'FC1', 'FC2', 'C1', 'Cz', 'C2']]},
    average_by=['semantics', 'Context', 'semantics/Context'])

3.2 For R users

Here's the same example as above but for using the pipeline from R:

# Import Python module
pipeline <- reticulate::import("pipeline")

# Run the group level pipeline
res <- pipeline$group_pipeline(
    vhdr_files = "Results/EEG/raw",
    log_files = "Results/RT",
    output_dir = "Results/EEG/export",
    ocular_correction = "Results/EEG/cali",
    triggers = c(201, 202, 211, 212),
    skip_log_conditions = list("semantics" = "filler"),
    components = list(
        "name" = c("N400", "P600"),
        "tmin" = c(0.3, 0.5),
        "tmax" = c(0.5, 0.9),
        "roi" = list(
            c("C1", "Cz", "C2", "CP1", "CPz", "CP2"),
            c("Fz", "FC1", "FC2", "C1", "Cz", "C2")
        )
    ),
    average_by = c("semantics", "Context", "semantics/Context")
)

# Extract results
trials <- res[[1]]
evokeds <- res[[2]]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hu-neuro-pipeline-0.2.5.tar.gz (28.3 kB view hashes)

Uploaded Source

Built Distribution

hu_neuro_pipeline-0.2.5-py3-none-any.whl (22.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page