ffrprep.analysis.harmonic_amplitudes

ffrprep.analysis.harmonic_amplitudes(evoked, f0=100.0, n_harmonics=10, bin_hz=60.0, tmin=0.06, tmax=0.18, pad_pow=2, ch_name=None, unit_scale=1000000.0)[source]

Spectral amplitude of the fundamental and its harmonics in an FFR.

The steady-state portion of the response (tmin-tmax) is Fourier transformed with zero padding to 2 ** (ceil(log2(L)) + pad_pow) points (L = window length in samples), converted to single-sided amplitude 2 * |FFT| / L and, for harmonic k (k = 1 .. n_harmonics, harmonic 1 = f0), averaged over all FFT points within k * f0 +/- bin_hz / 2. The defaults reproduce the /da/ (100 Hz F0) F0 / upper-harmonic measure of Whiteford et al. (2025), which is computed on the sum of the two polarity averages.

Parameters:
  • evoked (mne.Evoked) – Response to analyze (in Volts), e.g. the sum of the per-polarity averages.

  • f0 (float, default=100.0) – Fundamental frequency of the stimulus in Hz.

  • n_harmonics (int, default=10) – Number of harmonics (including the fundamental) to evaluate.

  • bin_hz (float, default=60.0) – Full width of the averaging band centred on each harmonic, in Hz.

  • tmin (float) – Analysis window in seconds relative to the Evoked time axis (inclusive at both ends).

  • tmax (float) – Analysis window in seconds relative to the Evoked time axis (inclusive at both ends).

  • pad_pow (int, default=2) – Extra powers of two of zero padding beyond the next power of two.

  • ch_name (str, optional) – Channel to analyze. Defaults to the first channel.

  • unit_scale (float, default=1e6) – Multiplier applied to the data before the FFT (1e6 -> microvolts).

Returns:

result – "harmonics" : ndarray of shape (n_harmonics,) with the band- averaged amplitude of each harmonic; "f0" : amplitude of the first harmonic; "upper_harmonics" : sum of harmonics 2 to n_harmonics (0.0 if n_harmonics is 1).

Return type:

dict