incubodac / PyDeconv

PyDeconv: A Python library for deconvolving ERP responses from EEG and MEG data using linear models. Enhance your neuroimaging analyses with efficient and accurate deconvolution techniques.
MIT License
0 stars 0 forks source link

PyDeconv

PyDeconv is an open-source Python package for empowering neuroimaging with ERP deconvolution for EEG and MEG data. It includes modules for creating linear models based on experimental features, allowing for the inclusion of interactions and non-linear contributions modeled via B-Splines. Additionally, PyDeconv provides tools to estimate collinearity between features using the VIF module.

Documentation

Find detailed tutorials and examples in the documentation.

Installation

Follow the installation guide in the documentation to get started with PyDeconv.

Dependencies

The minimum required dependencies to run PyDeconv examples are:

Usage

The main class PyDeconv takes three arguments:

  1. The parsed configurations from config.py,
  2. A pandas.DataFrame with columns labeled for event types and predictors,
  3. EEG data as an mne raw object.

To use PyDeconv, ensure that the configuration file and data are properly set up as shown below.

Example Scripts

example_script.py

The example_script.py demonstrates basic functionalities of PyDeconv. It applies a simple model to example data, It takes the configuration parameters from the config.py file , defines the model and fit it to the data, and then prints out the analysis results.

Example Notebook

Additionally, you can use the provided example notebook to run a simple model on a sample dataset, illustrating the entire workflow.

Example Plots

Here are some example plots generated by running the example_script.py:

rERPs activation plot
ERP activation example

Configuration File (config.py)

The config.py file defines the key parameters required to run PyDeconv. Formulas for the deconvolution models should follow Wilkinson notation, and the predictor variables must match the column labels in the feature DataFrame. The solver can be any linear model compatible with scikit-learn, as described in the scikit-learn linear model documentation:


# Example config.py
events_of_interest = {
    "first_intercept_event_type": "fixation",
    "second_intercept_event_type": "saccade",
    "second_delay": None
}

model = {
    "model_name": "targMin",
    "formula": "y ~  1 + ontarget + scrank*mss", 
    "second_formula": "y ~ 1 + saccade_amplitude",
    "tmin": -0.2,
    "tmax": 0.6,
    "use_splines": 5,
    "solver": "ridge",
    "scoring": "rms",
    "second_delay": None ,
    "eeg_chns": 64
}