pyrasa.irasa.irasa_sprint#

pyrasa.irasa.irasa_sprint(data: ~numpy.ndarray, fs: int, ch_names: ~numpy.ndarray | None = None, band: tuple[float, float] = (1.0, 100.0), win_duration: float = 0.4, overlap_fraction: float = 0.9, 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) IrasaTfSpectrum[source]#

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

This function is useful for analyzing how the aperiodic and periodic components of the power spectrum change over time, providing a time-frequency decomposition of the signal.

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.

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

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

  • win_duration (float, optional) – Duration of the window in seconds used for the short-time Fourier transforms (STFTs). Default is 0.4 seconds.

  • overlap_fraction (int, optional) – The overlap between the STFT sliding windows as fraction. Default is .99 of the windows.

  • win_func (Callable, optional) – Window function to be used in computing the time frequency spectrum. 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.

  • time: np.ndarray

    Time bins in seconds associated with the (a-)periodic spectra.

  • raw_spectrum: np.ndarray

    The raw time-frequency 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:

IrasaTfSpectrum

Notes

This function performs a time-frequency decomposition of the input data, allowing for a time-resolved analysis of the periodic and aperiodic components of the signal. The STFT is computed for each time window, and IRASA is applied to separate the spectral components.

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