timescales.fit.ACF
timescales.fit.ACF¶
- class timescales.fit.ACF(lags=None, corrs=None, fs=None)[source]¶
Autocorrelation function class.
- Parameters
- lags1d array
Time lag definitions.
- corrs1d or 2d array
Autocorrelation coefficients.
- fsfloat
Sampling rate, in Hz.
Notes
Parameters may be set on initialization or using the compute_acf method.
- Attributes
- corrs_fit1d array
Autocorrelation full fit.
- params1d array
Optimized parameters.
- param_nameslist of str
Parameter names in order of params.
- rsqfloat
R-squared of the full fit.
- guesslist, optional, default: None
Estimated parameters as either: [tau, height, offset] when with_cos is False, or [exp_tau, osc_tau, osc_gamma, osc_freq, amp_ratio, height, offset].
- boundslist, optional, default: None
Methods
__init__
([lags, corrs, fs])Initialize object.
compute_acf
(sig, fs[, nlags, normalize, ...])Compute autocorrelation.
fit
([lags, corrs, gen_fits, gen_components, ...])Fit without an oscillitory component.
gen_corrs_fit
([gen_components])Generate fit and r-squared.
plot
([ax, title])Plot ACF.
- compute_acf(sig, fs, nlags=None, normalize=True, from_psd=False, psd_kwargs=None, n_jobs=- 1, progress=None)[source]¶
Compute autocorrelation.
- Parameters
- sig1d or 2d array
Voltage time series or spike counts.
- fsfloat
Sampling rate, in Hz.
- nlagsint, optional, default: None
Number of lags to compute. None defaults to the sampling rate, fs.
- normalizebool, optional, default: True
Normalizes from zero to one when True.
- from_psdbool, optional, default: False
Compute correlations from the inverse FFT of the PSD.
- psd_kwargsdict, optional, default: None
Compute spectrum kwargs. Only used if from_psd is True.
- n_jobsint, optional, default: -1
Number of jobs to run in parralel, when corrs is 2d. Default is equal to multiprocessing’s cpu_count().
- progress{None, ‘tqdm’, ‘tqdm.notebook’}
Specify whether to display a progress bar. Uses ‘tqdm’, if installed.
- fit(lags=None, corrs=None, gen_fits=True, gen_components=False, with_cos=False, guess=None, bounds=None, maxfev=1000, n_jobs=- 1, progress=None)[source]¶
Fit without an oscillitory component.
- Parameters
- lags1d array
Time lag definitions.
- corrs1d or 2d array
Autocorrelation coefficients.
- gen_fitsbool, optional, default: False
Generates fit array and r-squared when True. Does not generate full fits when False to prevent OOM.
- gen_componentsbool, optional, default: False
When gen_fits and with_cos are True, the exponential decay and cosine components are be generated separately when this parameter is True.
- with_cosbool, optional, default: False
Includes oscillatory component as a damped cosine.
- guesslist, optional, default: None
Estimated parameters as either: [tau, height, offset] when with_cos is False, or [exp_tau, osc_tau, osc_gamma, osc_freq, amp_ratio, height, offset].
- boundslist, optional, default: None
- maxfevint
Maximum number of fitting iterations.
- n_jobsint
Number of jobs to run in parralel, when corrs is 2d.
- progress{None, ‘tqdm’, ‘tqdm.notebook’}
Specify whether to display a progress bar. Uses ‘tqdm’, if installed.