PyRASA - Spectral parametrization in python based on IRASA

PyRASA - Spectral parametrization in python based on IRASA - Published in JOSS (2025)

https://github.com/schmidtfa/pyrasa

Science Score: 93.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README and JOSS metadata
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Keywords

aperiodic-exponent eeg electrophysiology meg neuroscience oscillations power-spectral-density time-frequency-analysis

Scientific Fields

Mathematics Computer Science - 84% confidence
Last synced: 6 months ago · JSON representation

Repository

a package for spectral parametrization in python based on the IRASA algorithm

Basic Info
Statistics
  • Stars: 17
  • Watchers: 4
  • Forks: 2
  • Open Issues: 2
  • Releases: 1
Topics
aperiodic-exponent eeg electrophysiology meg neuroscience oscillations power-spectral-density time-frequency-analysis
Created almost 2 years ago · Last pushed 6 months ago
Metadata Files
Readme Contributing License

README.md

PyRASA - Spectral parametrization in python based on IRASA

Project Status: Active – The project has reached a stable, usable state and is being actively developed. License Checked with mypy Coverage Status

PyRASA is a Python library designed to separate and parametrize aperiodic (fractal) and periodic (oscillatory) components in time series data based on the IRASA algorithm (Wen & Liu, 2016).

Features

  • Aperiodic and Periodic Decomposition: Utilize the IRASA algorithm to decompose power spectra into aperiodic and periodic components, enabling better interpretation of neurophysiological signals.
  • Time Resolved Spectral Parametrization: Perform time resolved spectral parametrizazion, allowing you to track changes in spectral components over time.
  • Support for Raw and Epoched MNE Objects: PyRASA provides functions designed for both continuous (Raw) and event-related (Epochs) data, making it versatile for various types of EEG/MEG analyses.
  • Consistent Ontology: PyRASA uses the same jargon to label parameters as specparam, the most commonly used tool to parametrize power spectra, to allow users to easily switch between tools depending on their needs, while keeping the labeling of features consistent.
  • Custom Aperiodic Fit Models: In addition to the built-in "fixed" and "knee" models for aperiodic fitting, users can specify their custom aperiodic fit functions, offering flexibility in how aperiodic components are modeled.

Documentation

Documentation for PyRASA, including detailed descriptions of functions, parameters, and tutorials is available here.

Installation

To install the latest stable version of PyRASA, you can soon use pip:

bash $ pip install pyrasa

or conda

bash $ conda install -c conda-forge pyrasa

Dependencies

PyRASA has the following dependencies: - Core Dependencies: - numpy - scipy - pandas

  • Optional Dependencies for Full Functionality:
    • mne: Required for directly working with EEG/MEG data in Raw or Epochs formats.

Example Usage

Decompose spectra in periodic and aperiodic components If you want to reproduce the example below checkout example

```python from pyrasa.irasa import irasa

irasaout = irasa(sig, fs=fs, band=(.1, 200), nperseg=durationfs, noverlap=durationfs*overlap, hsetinfo=(1, 2, 0.05))

```

image info

Extract periodic parameters

```python

irasaout.getpeaks()

``` | ch_name | cf | bw | pw | |----------:|-----:|--------:|-------:| | 0 | 10.0 | 1.1887 | 0.4950 |

Extract aperiodic parameters

```python

irasaout.fitaperiodicmodel(fitfunc='knee').aperiodic_params

```

| Offset | Knee | Exponent1 | Exponent2 | fittype | Knee Frequency (Hz) | tau | chname | |---------:|-------:|-------------:|-------------:|:-----------|----------------------:|----------:|----------:| | 4.3299e-17 | 62.1060 | 0.0552 | 1.4602 | knee | 13.8547 | 0.0115 | 0 |

And the goodness of fit

```python

irasaout.fitaperiodicmodel(fitfunc='knee').gof

```

| mse | rsquared | BIC | AIC | fittype | ch_name | |------------:|------------:|---------:|---------:|:-----------|----------:| | 0.000088 | 0.999303 | -31.9892 | -47.9550 | knee | 0 |

How to Contribute

Contributions to PyRASA are welcome! Whether it's raising issues, improving documentation, fixing bugs, or adding new features, your help is appreciated.

To file bug reports and/or ask questions about this project, please use the Github issue tracker.

Please refer to the CONTRIBUTING.md file for more information on how to get involved.

Reference

If you are using IRASA please cite the smart people who came up with the algorithm:

Wen, H., & Liu, Z. (2016). Separating fractal and oscillatory components in the power spectrum of neurophysiological signal. Brain topography, 29, 13-26. https://doi.org/10.1007/s10548-015-0448-0

If you are using PyRASA it would be nice, if you could additionally cite us (whenever the paper is finally ready):

Schmidt F., Hartmann T., & Weisz, N. (2025). PyRASA - Spectral parametrization in python based on IRASA.

Owner

  • Name: Fabi
  • Login: schmidtfa
  • Kind: user

I'm a phd student in cognitive neuroscience interested in [auditory] perception, speech processing and [a-]periodic [brain] activity.

JOSS Publication

PyRASA - Spectral parametrization in python based on IRASA
Published
May 17, 2025
Volume 10, Issue 109, Page 7852
Authors
Fabian Schmidt ORCID
Paris-Lodron-University of Salzburg, Department of Psychology, Centre for Cognitive Neuroscience, Salzburg, Austria
Nathan Weisz ORCID
Paris-Lodron-University of Salzburg, Department of Psychology, Centre for Cognitive Neuroscience, Salzburg, Austria, Neuroscience Institute, Christian Doppler University Hospital, Paracelsus Medical University, Salzburg, Austria
Thomas Hartmann ORCID
Paris-Lodron-University of Salzburg, Department of Psychology, Centre for Cognitive Neuroscience, Salzburg, Austria
Editor
Charlotte Soneson ORCID
Tags
spectral parametrization 1/f aperiodic oscillations electrophysiology time frequency analysis electroencephalography EEG magnetoencephalography MEG

GitHub Events

Total
  • Issues event: 16
  • Watch event: 10
  • Delete event: 5
  • Issue comment event: 17
  • Push event: 45
  • Pull request event: 25
  • Fork event: 1
  • Create event: 16
Last Year
  • Issues event: 16
  • Watch event: 10
  • Delete event: 5
  • Issue comment event: 17
  • Push event: 45
  • Pull request event: 25
  • Fork event: 1
  • Create event: 16

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 29
  • Total pull requests: 50
  • Average time to close issues: 16 days
  • Average time to close pull requests: 2 days
  • Total issue authors: 4
  • Total pull request authors: 4
  • Average comments per issue: 1.28
  • Average comments per pull request: 0.36
  • Merged pull requests: 37
  • Bot issues: 0
  • Bot pull requests: 8
Past Year
  • Issues: 11
  • Pull requests: 22
  • Average time to close issues: 24 days
  • Average time to close pull requests: 3 days
  • Issue authors: 4
  • Pull request authors: 4
  • Average comments per issue: 1.45
  • Average comments per pull request: 0.14
  • Merged pull requests: 16
  • Bot issues: 0
  • Bot pull requests: 7
Top Authors
Issue Authors
  • schmidtfa (15)
  • thht (5)
  • wmvanvliet (5)
  • OleBialas (4)
Pull Request Authors
  • schmidtfa (23)
  • thht (18)
  • dependabot[bot] (8)
  • csoneson (1)
Top Labels
Issue Labels
enhancement (6) bug (2) random thoughts (1)
Pull Request Labels
dependencies (8) github_actions (4)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 25 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 3
  • Total maintainers: 2
pypi.org: pyrasa

Spectral parametrization based on IRASA

  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 25 Last month
Maintainers (2)
Last synced: 6 months ago

Dependencies

.github/workflows/test.yml actions
  • actions/checkout v4 composite
  • coverallsapp/github-action v2 composite
  • prefix-dev/setup-pixi v0.8.1 composite
pyproject.toml pypi
  • numpy *
  • pandas *
  • scipy >=1.12
simulations/environment.yml pypi
  • obob_mne *
  • plus_slurm *
  • pymatreader *