Skip to main page content
U.S. flag

An official website of the United States government

Dot gov

The .gov means it’s official.
Federal government websites often end in .gov or .mil. Before sharing sensitive information, make sure you’re on a federal government site.

Https

The site is secure.
The https:// ensures that you are connecting to the official website and that any information you provide is encrypted and transmitted securely.

Access keys NCBI Homepage MyNCBI Homepage Main Content Main Navigation
. 2025 Feb 21:19:1522675.
doi: 10.3389/fnins.2025.1522675. eCollection 2025.

osl-ephys: a Python toolbox for the analysis of electrophysiology data

Affiliations

osl-ephys: a Python toolbox for the analysis of electrophysiology data

Mats W J van Es et al. Front Neurosci. .

Abstract

We describe OHBA Software Library for the analysis of electrophysiology data (osl-ephys). This toolbox builds on top of the widely used MNE-Python package and provides unique analysis tools for magneto-/electro-encephalography (M/EEG) sensor and source space analysis, which can be used modularly. In particular, it facilitates processing large amounts of data using batch parallel processing, with high standards for reproducibility through a config API and log keeping, and efficient quality assurance by producing HTML processing reports. It also provides new functionality for doing coregistration, source reconstruction and parcellation in volumetric space, allowing for an alternative pipeline that avoids the need for surface-based processing, e.g., through the use of Fieldtrip. Here, we introduce osl-ephys by presenting examples applied to a publicly available M/EEG data (the multimodal faces dataset). osl-ephys is open-source software distributed on the Apache License and available as a Python package through PyPi and GitHub.

Keywords: M/EEG; MNE-Python; analysis; electroencephalography (EEG); electrophysiology; magnetoencephalography (MEG); python; toolbox.

PubMed Disclaimer

Conflict of interest statement

The authors declare that the research was conducted in the absence of any commercial or financial relationships that could be construed as a potential conflict of interest.

Figures

LISTING 1A
LISTING 1A
Example API in the preprocessing module. The config specifies the processing recipe applied to the input. Preprocessed data are saved in the processed/subject001 directory. Note that the source reconstruction module works similarly (see section “Examples”).
LISTING 1B
LISTING 1B
As in 1a, but now including a custom written function. The function is defined at the top, and takes as input “dataset” (a dictionary containing the MNE-Python objects, e.g., Raw), and a “userargs” dictionary (containing the function variable specifications). The function is included in the config, and supplied to chain function as a list of extra functions in the “extra_funcs” input variable.
LISTING 2
LISTING 2
Osl-ephys batch preprocessing script.
Figure 1
Figure 1
The output directory structure of run_proc_batch. All outputs are saved in the general output directory specified in the function call (“processed”). Within this, a subdirectory is created for each subject/session that contains the preprocessed data, as well as logs, and preproc_report directories, containing the relevant files for all subjects.
Figure 2
Figure 2
Example of the preprocessing subject report. This HTML page contains tabs for different aspects of QA for each subject/session. The user can browse between tabs on the left for each subject/session in the list on the right. Each tab contains quantitative and qualitative information regarding the preprocessing output.
Figure 3
Figure 3
Example of the preprocessing summary report. Contains summary information and quantitative metrics of all files processed. The Preproc Summary table is interactive and can guide the user to specific subjects/sessions which might require further attention.
Figure 4
Figure 4
Interactive labelling of independent components (ICs) using the osl_ica_label tool. The weights and time courses for each IC are shown as rows. Bad ICs are indicated as coloured the time courses (i.e., other than black, see types on the right); annotations in the time courses indicate bad segments.
Figure 5
Figure 5
Example of the source_recon subject (top) and summary (bottom) report. The subject report contains figures showing the extracted surfaces, the parcel power spectra, and interactive figures showing the coregistration. The summary report contains summary information and quantitative metrics of all processed files, including interactive tables that can guide the user to specific subjects/sessions which might require further attention.
Figure 6
Figure 6
Pictures of real faces elicit statistically different event-related fields than pictures of scrambled faces. (A) example of a first level (session) design matrix, with three regressors and two contrasts. (B) The second level (group) design contains 19 subject regressors, and one mean contrast. (C) The group Faces – Scrambled contrast. Coloured lines show individual parcels, with colours in an anterior–posterior gradient (inset). Shaded areas show significant time periods, and topographies the mean t-statistic in each period. (D) Extent of significant times periods.

Similar articles

Cited by

References

    1. Ågren W. (2023). Neurocode. Available at: https://github.com/neurocode-ai/neurocode/tree/main?tab=MIT-1-ov-file (Accessed February, 2025).
    1. Brodbeck C., Das P., Brooks T. L., Reddigari S. (2023). Eelbrain. Available at: https://pypi.org/project/eelbrain/ (Accessed February 2025).
    1. Colclough G. L., Brookes M. J., Smith S. M., Woolrich M. W. (2015). A symmetric multivariate leakage correction for MEG connectomes. NeuroImage 117, 439–448. doi: 10.1016/j.neuroimage.2015.03.071, PMID: - DOI - PMC - PubMed
    1. Dask Development Team (2016). Dask: library for dynamic task scheduling. Available at: http://dask.pydata.org (Accessed February, 2025).
    1. Delorme A., Makeig S. (2004). EEGLAB: an open source toolbox for analysis of single-trial EEG dynamics including independent component analysis. J. Neurosci. Methods 134, 9–21. doi: 10.1016/j.jneumeth.2003.10.009, PMID: - DOI - PubMed

LinkOut - more resources