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 constant b stays 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, < 0) return None rather than raising — callers iterate over many recordings and a single bad fit shouldn’t abort the batch.

Functions

fit_adaptation(samples_df, *[, fit_start_s, ...])

Fit a·exp(-b·t) + c and return τ + R² + asymptote.

Classes

AdaptationFit(tau_s, amplitude, asymptote, ...)

One exponential-decay fit, destined for adaptation_fits.

class arista.processing.adaptation.AdaptationFit(tau_s, amplitude, asymptote, r_squared, fit_window_start_s, fit_window_end_s, n_points)[source]

Bases: object

One exponential-decay fit, destined for adaptation_fits.

Parameters:
amplitude: float
asymptote: float
fit_window_end_s: float
fit_window_start_s: float
n_points: int
r_squared: float
tau_s: float
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) + c and 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. None uses 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:

AdaptationFit on success, None if 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 by a · exp(-b·t) with this parameterisation).

Return type:

AdaptationFit | None