gastropy.egg_process

Contents

gastropy.egg_process#

gastropy.egg_process(data, sfreq, band=None, method='fir', **filter_kwargs)[source]#

Process an EGG signal through the full analysis pipeline.

Applies bandpass filtering, Hilbert phase extraction, cycle detection, and metric computation. Returns a DataFrame of processed signals and a metadata dictionary.

Parameters:
  • data (array_like) – Raw EGG signal (1D array).

  • sfreq (float) – Sampling frequency in Hz.

  • band (GastricBand, optional) – Target gastric band. Default is NORMOGASTRIA.

  • method (str, optional) – Filter method: "fir" (default) or "iir".

  • **filter_kwargs – Additional arguments passed to egg_clean.

Returns:

  • signals (pd.DataFrame) – DataFrame with columns:

    • raw : Original signal.

    • filtered : Bandpass-filtered signal.

    • phase : Instantaneous phase (radians).

    • amplitude : Instantaneous amplitude envelope.

  • info (dict) – Processing metadata including:

    • sfreq : Sampling frequency.

    • filter : Filter parameters.

    • peak_freq_hz : Peak frequency in the target band.

    • cycle_durations_s : Detected cycle durations.

    • cycle_stats : Cycle duration statistics.

    • instability_coefficient : IC value.

    • proportion_normogastric : Fraction of normogastric cycles.

    • band_power : Power metrics for the target band.

See also

egg_clean

Bandpass filter an EGG signal.

Examples

>>> import numpy as np
>>> import gastropy as gp
>>> t = np.arange(0, 300, 0.1)
>>> sig = np.sin(2 * np.pi * 0.05 * t) + 0.1 * np.random.randn(len(t))
>>> signals, info = gp.egg_process(sig, sfreq=10.0)
>>> info["peak_freq_hz"]
0.05