Spectral parametrization based on IRASA
Project description
PyRASA - Spectral parameterization in python based on IRASA
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:
$ pip install pyrasa
or conda
$ conda install pyrasa
Dependencies
PyRASA has the following dependencies:
-
Core Dependencies:
-
Optional Dependencies for Full Functionality:
- mne: Required for directly working with EEG/MEG data in
Raw
orEpochs
formats.
- mne: Required for directly working with EEG/MEG data in
Example Usage
Decompose spectra in periodic and aperiodic ccomponents
from pyrasa.irasa import irasa
irasa_out = irasa(sig,
fs=fs,
band=(.1, 200),
psd_kwargs={'nperseg': duration*fs,
'noverlap': duration*fs*overlap
},
hset_info=(1, 2, 0.05))
Extract periodic parameters
irasa_out.get_peaks()
ch_name | cf | bw | pw |
---|---|---|---|
0 | 9.5 | 1.4426 | 0.4178 |
Extract aperiodic parameters
irasa_out.fit_aperiodic_model(fit_func='knee').aperiodic_params
Offset | Knee | Exponent_1 | Exponent_2 | fit_type | Knee Frequency (Hz) | tau | ch_name |
---|---|---|---|---|---|---|---|
1.737402e-16 | 60.942144 | 0.039556 | 1.472746 | knee | 14.131277 | 0.011263 | 0 |
And the goodness of fit
irasa_out.fit_aperiodic_model(fit_func='knee').gof
mse | r_squared | BIC | AIC | fit_type | ch_name |
---|---|---|---|---|---|
0.000051 | 0.999751 | -3931.840246 | -3947.806104 | 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. (2049). PyRASA - Spectral parameterization in python based on IRASA. SOME JOURNAL THAT LIKES US
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pyrasa-1.0.0.tar.gz
.
File metadata
- Download URL: pyrasa-1.0.0.tar.gz
- Upload date:
- Size: 3.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 338fb9709cd0c2c7baa2536b12894df33d7333f8f8775a222a8bedf83956aa48 |
|
MD5 | b913c333c597e64e9b4238e1c7568f3b |
|
BLAKE2b-256 | b7dd3a5cbf0afc94c3175c10508d6835084ee298162e75f1bb5bd73d8cecb655 |
File details
Details for the file pyrasa-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: pyrasa-1.0.0-py3-none-any.whl
- Upload date:
- Size: 37.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd981129fa71d409883ca9ad88a23b9646684b0be0cbe2f8944a54036895ee3b |
|
MD5 | 00a38323a8323f0e828dc2395ee53066 |
|
BLAKE2b-256 | 50e47769338f87ea51e599856d07eb0049d757745d53f9fbbd166255bf0fd74b |