pyrasa.irasa.irasa#

pyrasa.irasa.irasa(data: ~numpy.ndarray, fs: int, band: tuple[float, float], psd_kwargs: dict, ch_names: ~numpy.ndarray | None = None, win_func: ~collections.abc.Callable = <function hann>, win_func_kwargs: dict | None = None, dpss_settings_time_bandwidth: float = 2.0, dpss_settings_low_bias: bool = True, dpss_eigenvalue_weighting: bool = True, filter_settings: tuple[float | None, float | None] = (None, None), hset_info: tuple[float, float, float] = (1.05, 2.0, 0.05), hset_accuracy: int = 4) IrasaSpectrum[source]#

Computes the aperiodic and periodic components of the power spectrum from a time series using the Irregular Resampling Autocorrelation (IRASA) algorithm.

The IRASA algorithm allows for the decomposition of neural signals into fractal (aperiodic) and oscillatory (periodic) components, providing insight into the underlying dynamics of the data.

Parameters:
  • data (np.ndarray) – Time series data, where the shape is expected to be either (Samples,) or (Channels, Samples).

  • fs (int) – Sampling frequency of the data in Hz.

  • band (tuple[float, float]) – The frequency range (lower and upper bounds in Hz) over which to compute the spectra.

  • psd_kwargs (dict) – Keyword arguments to be passed to the scipy.signal.welch function for PSD estimation.

  • ch_names (np.ndarray | None, optional) – Channel names associated with the data, if available. Default is None.

  • win_func (Callable, optional) – Window function to be used in Welch’s method. Default is dsp.windows.hann.

  • win_func_kwargs (dict | None, optional) – Additional keyword arguments for the window function. Default is None.

  • dpss_settings_time_bandwidth (float, optional) – Time-bandwidth product for the DPSS windows if used. Default is 2.0.

  • dpss_settings_low_bias (bool, optional) – Keep only tapers with eigenvalues > 0.9. Default is True.

  • dpss_eigenvalue_weighting (bool, optional) – Whether or not to apply eigenvalue weighting in DPSS. If True, spectral estimates weighted by the concentration ratio of their respective tapers before combining. Default is True.

  • filter_settings (tuple[float | None, float | None], optional) – Cutoff frequencies for highpass and lowpass filtering to avoid artifacts in the evaluated frequency range. Default is (None, None).

  • hset_info (tuple[float, float, float], optional) – Tuple specifying the range of the resampling factors as (min, max, step). Default is (1.05, 2.0, 0.05).

  • hset_accuracy (int, optional) – Decimal precision for the resampling factors. Default is 4.

Returns:

An object containing the following attributes:
  • freqs: np.ndarray

    Frequencies corresponding to the computed spectra.

  • raw_spectrum: np.ndarray

    The raw power spectrum.

  • aperiodic: np.ndarray

    The aperiodic (fractal) component of the spectrum.

  • periodic: np.ndarray

    The periodic (oscillatory) component of the spectrum.

  • ch_names: np.ndarray

    Channel names if provided.

Return type:

IrasaSpectrum

Notes

This function provides fine-grained control over the IRASA parameters. For users working with MNE-Python, the irasa_raw and irasa_epochs functions from pyrasa.irasa_mne are recommended, as they handle additional preprocessing steps.

References

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