arista.processing.adaptation
Fit a·exp(-t/τ) + c to the post-onset segment of an adaptation trace.
Kossen 2019 §3.2 (Fig. 21) characterised the time course of Ca²⁺ adaptation in HC and CC cells using long-step protocols (HotAdapt to 26 °C, ColdAdapt to 18 °C). The published τ values span four orders of magnitude (163 s in HC under HotAdapt → 17 414 s in HC under ColdAdapt, essentially “no decay”), so the fit must accept both fast-decay and near-flat cases without blowing up.
Robustness measures:
scipy.optimize.curve_fit()with bounded parameters so the rate constantbstays non-negative and the asymptote stays in a physically plausible range.Initial guesses derived from the first and last samples of the fit window so the optimiser starts close to the data.
Failure modes (no convergence,
b ≤ 0,R² < 0) returnNonerather than raising — callers iterate over many recordings and a single bad fit shouldn’t abort the batch.
Functions
|
Fit |
Classes
|
One exponential-decay fit, destined for |
- class arista.processing.adaptation.AdaptationFit(tau_s, amplitude, asymptote, r_squared, fit_window_start_s, fit_window_end_s, n_points)[source]
Bases:
objectOne exponential-decay fit, destined for
adaptation_fits.- Parameters:
- arista.processing.adaptation.fit_adaptation(samples_df, *, fit_start_s=75.0, fit_end_s=None, min_points=30)[source]
Fit
a·exp(-b·t) + cand return τ + R² + asymptote.- Parameters:
samples_df (pandas.DataFrame) – One recording’s samples (same columns as for
compute_stimulus_responses()).fit_start_s (float) – Where to start the fit window. Default
arista.constants.ADAPTATION_FIT_START_S(75 s, the end of the canonical pre-stimulus baseline).fit_end_s (float | None) – End of the fit window.
Noneuses the recording’s last time stamp.min_points (int) – Refuse to fit on fewer than this many in-window samples — 30 is enough to constrain three parameters with confidence.
- Returns:
AdaptationFiton success,Noneif the curve_fit fails to converge, if too few points lie in the window, or if the fitted decay rate is non-positive (degenerate / no decay captured bya · exp(-b·t)with this parameterisation).- Return type:
AdaptationFit | None