yasa.irasa

yasa.irasa(data, sf=None, ch_names=None, band=(1, 30), hset=array([1.1, 1.15, 1.2, 1.25, 1.3, 1.35, 1.4, 1.45, 1.5, 1.55, 1.6, 1.65, 1.7, 1.75, 1.8, 1.85, 1.9 ]), return_fit=True, win_sec=4, kwargs_welch={'average': 'median', 'window': 'hamming'})[source]

Separate the aperiodic (= fractal, or 1/f) and oscillatory component of the power spectra of EEG data using the IRASA method.

New in version 0.1.7.

Parameters
datanumpy.ndarray or mne.io.BaseRaw

1D or 2D EEG data. Can also be a mne.io.BaseRaw, in which case data, sf, and ch_names will be automatically extracted, and data will also be converted from Volts (MNE default) to micro-Volts (YASA).

sffloat

The sampling frequency of data AND the hypnogram. Can be omitted if data is a mne.io.BaseRaw.

ch_nameslist

List of channel names, e.g. [‘Cz’, ‘F3’, ‘F4’, …]. If None, channels will be labelled [‘CHAN001’, ‘CHAN002’, …]. Can be omitted if data is a mne.io.BaseRaw.

bandtuple or None

Broad band frequency range. Default is 1 to 30 Hz.

hsetnumpy.ndarray

Resampling factors used in IRASA calculation. Default is to use a range of values from 1.1 to 1.9 with an increment of 0.05.

return_fitboolean

If True (default), fit an exponential function to the aperiodic PSD and return the fit parameters (intercept, slope) and \(R^2\) of the fit.

The aperiodic signal, \(L\), is modeled using an exponential function in semilog-power space (linear frequencies and log PSD) as:

\[L = a + \text{log}(F^b)\]

where \(a\) is the intercept, \(b\) is the slope, and \(F\) the vector of input frequencies.

win_secint or float

The length of the sliding window, in seconds, used for the Welch PSD calculation. Ideally, this should be at least two times the inverse of the lower frequency of interest (e.g. for a lower frequency of interest of 0.5 Hz, the window length should be at least 2 * 1 / 0.5 = 4 seconds).

kwargs_welchdict

Optional keywords arguments that are passed to the scipy.signal.welch() function.

Returns
freqsnumpy.ndarray

Frequency vector.

psd_aperiodicnumpy.ndarray

The fractal (= aperiodic) component of the PSD.

psd_oscillatorynumpy.ndarray

The oscillatory (= periodic) component of the PSD.

fit_paramspandas.DataFrame (optional)

Dataframe of fit parameters. Only if return_fit=True.

Notes

The Irregular-Resampling Auto-Spectral Analysis (IRASA) method is described in Wen & Liu (2016). In a nutshell, the goal is to separate the fractal and oscillatory components in the power spectrum of EEG signals.

The steps are:

  1. Compute the original power spectral density (PSD) using Welch’s method.

  2. Resample the EEG data by multiple non-integer factors and their reciprocals (\(h\) and \(1/h\)).

  3. For every pair of resampled signals, calculate the PSD and take the geometric mean of both. In the resulting PSD, the power associated with the oscillatory component is redistributed away from its original (fundamental and harmonic) frequencies by a frequency offset that varies with the resampling factor, whereas the power solely attributed to the fractal component remains the same power-law statistical distribution independent of the resampling factor.

  4. It follows that taking the median of the PSD of the variously resampled signals can extract the power spectrum of the fractal component, and the difference between the original power spectrum and the extracted fractal spectrum offers an approximate estimate of the power spectrum of the oscillatory component.

Note that an estimate of the original PSD can be calculated by simply adding psd = psd_aperiodic + psd_oscillatory.

For an example of how to use this function, please refer to https://github.com/raphaelvallat/yasa/blob/master/notebooks/11_IRASA.ipynb

References

1

Wen, H., & Liu, Z. (2016). Separating Fractal and Oscillatory Components in the Power Spectrum of Neurophysiological Signal. Brain Topography, 29(1), 13–26. https://doi.org/10.1007/s10548-015-0448-0

2

https://github.com/fieldtrip/fieldtrip/blob/master/specest/

3

https://github.com/fooof-tools/fooof

4

https://www.biorxiv.org/content/10.1101/299859v1