arista.processing.sigmoid

Four-parameter logistic (4PL) fit of ΔF/F vs Δ target temperature.

Reproduces Kossen 2019 Fig 24 / 25: for each (strain × cell-type) group, pool every recording’s per-step response and fit a sigmoid

y = bottom + (top - bottom) / (1 + exp(-slope · (x - midpoint)))

CC cells produce a descending curve (more positive Δtarget → less ΔF/F): the fit recovers this either via slope < 0 or via bottom > top depending on the initial guess. Either parameterisation describes the same curve, so we let scipy.optimize.curve_fit settle on whichever the data prefers — no bounds.

Fits are computed on demand (one curve_fit per group, milliseconds) rather than persisted alongside adaptation_fits: the fit is a pooled-group statistic, not a per-recording one, so it doesn’t fit the per-recording schema.

Functions

fit_sigmoid(deltas, responses, *[, ...])

Fit a 4PL to pooled (Δtarget, ΔF/F) points.

fit_sigmoids_by_group(response_df, *[, ...])

Run fit_sigmoid() over each group in a response frame.

four_pl(x, bottom, top, midpoint, slope)

Four-parameter logistic.

Classes

SigmoidFit(bottom, top, midpoint_c, slope, ...)

One 4PL sigmoid fit.

class arista.processing.sigmoid.SigmoidFit(bottom, top, midpoint_c, slope, r_squared, n_points)[source]

Bases: object

One 4PL sigmoid fit.

Parameters:
bottom: float
midpoint_c: float
n_points: int
r_squared: float
slope: float
top: float
arista.processing.sigmoid.fit_sigmoid(deltas, responses, *, max_iterations=5000)[source]

Fit a 4PL to pooled (Δtarget, ΔF/F) points.

Parameters:
  • deltas (np.ndarray | pd.Series) – x-values (Δ target temperature in °C).

  • responses (np.ndarray | pd.Series) – y-values (median ΔF/F per step).

  • max_iterations (int) – curve_fit maxfev ceiling.

Returns:

SigmoidFit on convergence, None when the data is too sparse (<4 points), perfectly flat, or when curve_fit raises.

Return type:

SigmoidFit | None

arista.processing.sigmoid.fit_sigmoids_by_group(response_df, *, group_keys=('strain_name', 'cell_type'), min_points=4)[source]

Run fit_sigmoid() over each group in a response frame.

Parameters:
Returns:

DataFrame with one row per group carrying bottom, top, midpoint_c, slope, r_squared, n_points plus the group key columns. Groups whose fit failed are omitted.

Return type:

pandas.DataFrame

arista.processing.sigmoid.four_pl(x, bottom, top, midpoint, slope)[source]

Four-parameter logistic.

bottom and top are the left/right asymptotes, midpoint is the x-value at the curve’s inflection, and slope is the curve’s slope at the midpoint (units: 1/°C).

Parameters:
Return type:

numpy.ndarray