gastropy.select_peak_frequency

gastropy.select_peak_frequency#

gastropy.select_peak_frequency(data, sfreq, band=None, fmin=0.0, fmax=0.1)[source]#

Find the peak frequency in the gastric band from a single channel.

Uses scipy.signal.find_peaks for robust local-maximum detection. Falls back to argmax if no local peaks are found.

Parameters:
  • data (array_like) – Single-channel EGG signal (1D array).

  • sfreq (float) – Sampling frequency in Hz.

  • band (GastricBand, optional) – Frequency band to search. Default is NORMOGASTRIA.

  • fmin (float, optional) – Minimum frequency for PSD computation. Default is 0.0.

  • fmax (float, optional) – Maximum frequency for PSD computation. Default is 0.1.

Returns:

  • peak_freq_hz (float) – Peak frequency in the target band (Hz). NaN if no valid peak.

  • freqs (np.ndarray) – Frequency values from PSD.

  • psd (np.ndarray) – PSD values.

Examples

>>> import numpy as np
>>> from gastropy.egg import select_peak_frequency
>>> sig = np.sin(2 * np.pi * 0.05 * np.arange(0, 300, 0.1))
>>> peak_freq, freqs, psd = select_peak_frequency(sig, sfreq=10.0)