gastropy.mean_phase_per_window

gastropy.mean_phase_per_window#

gastropy.mean_phase_per_window(complex_signal, windows)[source]#

Compute mean phase angle within each time window.

For each window, computes the mean of the complex analytic signal and extracts its phase angle. This is used for per-epoch or per-volume phase extraction.

Parameters:
  • complex_signal (array_like) – Complex analytic signal (from instantaneous_phase).

  • windows (list of tuple) – List of (start_idx, end_idx) pairs defining each window.

Returns:

phases – Phase angle (radians) per window. NaN for empty or out-of-bounds windows.

Return type:

np.ndarray

Examples

>>> import numpy as np
>>> from gastropy.signal import instantaneous_phase, mean_phase_per_window
>>> sig = np.sin(2 * np.pi * 0.05 * np.arange(0, 100, 0.1))
>>> _, analytic = instantaneous_phase(sig)
>>> windows = [(0, 50), (50, 100), (100, 150)]
>>> phases = mean_phase_per_window(analytic, windows)