ffrprep.analysis.compute_pitch_and_conf¶
- ffrprep.analysis.compute_pitch_and_conf(evoked, win_dur=0.04, hop_dur=0.01, fmin=60, fmax=200, strength_thresh=0.15, smooth_k=3)[source]¶
Compute the pitch (f0) and confidence metrics for an Evoked response.
- Parameters:
evoked (mne.Evoked) – Evoked object containing averaged M/EEG data.
win_dur (float, default=0.040) – Duration of the sliding window (in seconds) used for pitch estimation.
hop_dur (float, default=0.010) – Step size (in seconds) for sliding the window across the signal.
fmin (float, default=60) – Minimum frequency (in Hz) to consider for pitch estimation.
fmax (float, default=200) – Maximum frequency (in Hz) to consider for pitch estimation.
strength_thresh (float, default=0.15) – Minimum normalized autocorrelation strength required to consider a pitch estimate valid.
smooth_k (int, default=3) – Kernel size for smoothing the pitch estimates (in number of windows).
- Returns:
A dictionary with the following keys:
'times'— array of time points corresponding to the center of each window.'pitch_hz'— array of pitch estimates (in Hz) for each window.'pitch_hz_smooth'— smoothed pitch estimates (in Hz) for each window.'peak_strength'— array of normalized autocorrelation strengths for each window.'conf_rmax'— array of maximum normalized autocorrelation values for each window.'conf_pnr'— array of pitch-to-noise ratios for each window.'conf_z'— array of z-scores for the maximum autocorrelation values for each window.
- Return type:
Examples
Compute pitch and confidence metrics for an Evoked response with default parameters.
>>> results = compute_pitch_and_conf(evoked) >>> print(results['times']) [0.02 0.03 0.04 ... 0.98 0.99 1.00] >>> print(results['pitch_hz']) [120.0 125.0 130.0 ... 110.0 115.0 120.0] >>> print(results['conf_rmax']) [0.8 0.85 0.9 ... 0.75 0.8 0.82]