psiaudio.efr module
- efr_bs_verhulst(arrays, fs, fm, n_harmonics=None, n_bootstrap=20, n_draw=None, rng=None, window=None, max_harmonic=None)
Calculate the EFR amplitude using a boostrapping algorithm
- Parameters:
arrays (array or list of arrays) – Signal to compute PSD noise floor over. Must be trial x time. If a list of arrays is provided (e.g., one for each stimulus polarity), n_draw will be balanced across the arrays.
fs (float) – Sampling rate of signal.
fm (float) – Modulation frequency.
n_harmonics (int) – Number of harmonics (including fundamental) to sum. If None, all harmonics up to max_harmonic are summed. An error is raised if both n_harmonics and max_harmonic is set to None.
n_bootstrap (int Number of bootstrap cycles. n_draw : {None, int}) – Number of trials to draw (with replacement) on each bootstrap cycle. If None, set to the total number of trials provided.
rng (instance of RandomState) – If provided, this will be used to drive the bootstrapping algorithm. Useful when you need to “freeze” results (e.g., for publication).
window ({None, string}) – Type of window to use when calculating bootstrapped PSD.
max_harmonic (float) – Maximum harmonic frequency to compute up to. This can be set to the Nyquist frequency.
Result
------
efr_amplitude (pd.Series) – Pandas series indexed by bootstrap cycle. Contains EFR amplitude defined as the peak relative to the noise floor.
harmonics (pd.DataFrame) – Pandas DataFrame containing amplitude, noise floor, phase and normalized amplitude. Indexed by harmonic and bootstrap cycle. Norm amplitude is amplitude minus noise floor.
psd (pd.DataFrame) – Pandas DataFrame containing the PSD of each bootstrap cycle. Columns are frequency and rows are bootstrap cycle.
Notes
This implements the EFR analysis algorithm first described in Vasilkov et al. 2021.