ffrprep.analysis.stim_to_resp_xcorr¶
- ffrprep.analysis.stim_to_resp_xcorr(stim, resp, sfreq, lag_range_ms=None)[source]¶
Maximum stimulus-to-response cross-correlation (coefficient form).
Both inputs must share the sampling rate
sfreqand be already cropped to the analysis windows (e.g. stimulus vowel 50-170 ms vs. response 60-180 ms). The cross-correlation is normalized like MATLAB’sxcorr(..., 'coeff'): divided bysqrt(sum(stim**2) * sum(resp**2))with no mean removal. The reported value is the maximum over lags (optionally restricted tolag_range_ms).- Parameters:
stim (array-like) – 1-D stimulus and response waveforms sampled at
sfreq.resp (array-like) – 1-D stimulus and response waveforms sampled at
sfreq.sfreq (float) – Sampling frequency in Hz.
lag_range_ms (tuple of (float, float), optional) – Inclusive lag window in ms in which to search for the maximum. Positive lag means the response is delayed relative to the stimulus.
Nonesearches all lags.
- Returns:
r (float) – Maximum correlation coefficient within the searched lags.
z (float) – Fisher r-to-z transform of
r(arctanh).lag_ms (float) – Lag in ms at which the maximum occurs.