Getting started

Thank you so much for trying MEDUSA©, you will not regret!


For MEDUSA© Kernel 1.3

If you have any questions that are beyond the scope of this help file, please feel free to ask for help in the forum or contact with us.


MEDUSA© Kernel is a Python package that contains ready-to-use methods for analyzing brain signals, including advanced signal processing, machine learning, deep learning, and miscellaneous high-level analyses. It also includes logical functions and classes to handle different biosignals, such as electroencephalography (EEG) and magnetoencephalography (MEG), save experimental data or implement standalone processing pipelines. The first step is to install the latest stable version of the package executing the following command in your Python environment:

pip install medusa-kernel

The included functions can be categorized according to their different levels of abstraction. The first level is composed of low-level functions, which are generic methods that can be used to process signals in many scenarios, including the following:

  • Temporal filters: configurable infinite impulse response (IIR) and finite impulse response (FIR) filters.
  • Spatial filters: common average reference (CAR), laplacian filter, multi-class common spatial patterns (CSP) and canonical correlation analysis (CCA).
  • Local activation metrics: including spectral metrics, such as band power, median frequency or Shannon entropy; and non-linear features, such as central tendency measure, sample entropy, multiscale entropy, Lempel-Ziv’s complexity and Multiscale Lempel-Ziv’s complexity.
  • Connectivity metrics: amplitude-based metrics, such as amplitude correlation envelope (AEC) and instantaneous amplitude correlation (IAC), and phase metrics, such as phase locking value (PLV), phase-based lag index (PLI) and weighted PLI (wPLI).

In a higher level of abstraction, there are functions that apply a processing pipeline to the input data to analyze certain features. MEDUSA© Kernel does not assume the nature of the input data in low-level functions, but most of the high-level analysis that are currently implemented are designed to work with EEG and MEG recordings. In short, high-level functions use the low-level methods to implement specific use-cases. These functions include signal processing algorithms for BCIs based on:

  • P300 potentials: complete classification pipelines including regularized linear discriminant analysis (rLDA), EEGNet and EEG-Inception that can be applied in offline and online experiments; P300 analysis and charts; and specialized data structures and functions for command decoding.
  • Motor imagery: complete classification pipelines including CSP combined with rLDA, EEGNet, EEG-Inception and EEGSym that can be applied in offline and online modes; MI analysis charts; and specialized data structures for MI decoding.
  • c-VEPs: offline and online circular-shifting reference pipeline based on CCA; c-VEP analysis and charts; raster latencies correction; filter banks; and maximal length sequences (i.e., m-sequences) generation through linear feedback shift registers (LSFR) for binary and p-ary bases.
  • Neurofeedback (NF): battery of high-level models based on spectral and connectivity metrics ready to be applied in online and offline apps.

This modular architecture, organized in levels of abstraction, guarantees independence between the different components of the library. Additionally, the package includes classes and functions to import data from other toolboxes (e.g., MATLAB, MNE), define the data format of signals and experiments, save recordings to several file types (e.g., bson, json, mat) and implement custom real-time signal processing pipelines. Furthermore, some of the functions, including the BCI models, can be applied in both online and offline experiments. Therefore, MEDUSA© Kernel can be used for offline analysis of previously recorded data, such as public databases, or in real-time tasks. In fact, MEDUSA© Platform relies on this package for signal processing. This is an interesting feature that allows reproducing the exact same results achieved in an online experiment during subsequent offline analyses, thus facilitating experimental reproducibility. Finally, it is worth mentioning that community contributions to this package are welcome.