gastropy.band_power

Contents

gastropy.band_power#

gastropy.band_power(freqs, psd, band, total_range=(0.01, 0.2))[source]#

Compute power metrics for a specific frequency band.

Parameters:
  • freqs (array_like) – Frequency values in Hz (from PSD computation).

  • psd (array_like) – Power spectral density values.

  • band (GastricBand) – Frequency band to analyze.

  • total_range (tuple of float, optional) – (f_lo, f_hi) defining the total frequency range for proportion and ratio calculations. Default is (0.01, 0.2).

Returns:

Dictionary with keys:

  • peak_freq_hz : Peak frequency in the band (Hz).

  • max_power : Maximum power in the band.

  • mean_power : Mean power in the band.

  • prop_power : Proportion of total power in the band.

  • mean_power_ratio : Ratio of band mean to total mean power.

All values are NaN if the band has no frequency coverage.

Return type:

dict

Examples

>>> from gastropy.signal import psd_welch
>>> from gastropy.metrics import band_power, NORMOGASTRIA
>>> freqs, psd = psd_welch(signal, sfreq=10.0, fmin=0.01, fmax=0.2)
>>> info = band_power(freqs, psd, NORMOGASTRIA)
>>> info["peak_freq_hz"]
0.05