yasa.irasa#
- yasa.irasa(data, sf=None, ch_names=None, band=(1, 30), hset=[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'}, verbose=True)#
Separate the aperiodic (= fractal, or 1/f) and oscillatory component of the power spectra of EEG data using the IRASA method.
Added in version 0.1.7.
- Parameters:
- data
numpy.ndarrayormne.io.BaseRaw 1D or 2D EEG data. If
datais array_like, unit must be uV. Ifdatais aBaseRawinstance,data,sf, andch_nameswill be automatically extracted, anddatawill be automatically converted from Volts (MNE) to micro-Volts (YASA).- sffloat
The sampling frequency of data AND the hypnogram if
datais array_like. Should be omitted ifdatais a :py:class:~`mne.io.BaseRaw`.- ch_nameslist
List of channel names, e.g. [‘Cz’, ‘F3’, ‘F4’, …], if
datais array_like. If None, channels will be labelled [‘CHAN000’, ‘CHAN001’, …]. Should be omitted ifdatais aBaseRaw.- bandtuple or None
Broad band frequency range. Default is 1 to 30 Hz.
- hsetlist or
numpy.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.welchfunction.- verbosebool or str
Verbose level. Default (False) will only print warning and error messages. The logging levels are ‘debug’, ‘info’, ‘warning’, ‘error’, and ‘critical’. For most users the choice is between ‘info’ (or
verbose=True) and warning (verbose=False).
- data
- Returns:
- freqs
numpy.ndarray Frequency vector.
- psd_aperiodic
numpy.ndarray The fractal (= aperiodic) component of the PSD.
- psd_oscillatory
numpy.ndarray The oscillatory (= periodic) component of the PSD.
- fit_params
pandas.DataFrame(optional) Dataframe of fit parameters. Only if
return_fit=True.
- freqs
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:
Compute the original power spectral density (PSD) using Welch’s method.
Resample the EEG data by multiple non-integer factors and their reciprocals (\(h\) and \(1/h\)).
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.
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 raphaelvallat/yasa
For an article discussing the challenges of using IRASA (or fooof) see [5].
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