arista.processing.gain
Linear-fit gain per recording across the stimulus-response steps.
Reproduces Kossen 2019 Fig 27: for each recording, fit a line through
all (delta_target_c, dfbf_response_median) points and use the
slope as the cell’s ΔF/F-per-°C gain. CC cells produce negative slope
(cold → high response), HC cells produce positive slope; the absolute
value is comparable across cell types.
Gains are computed on demand from the stimulus_responses table —
not persisted alongside adaptation_fits because each fit is two
np.polyfit calls and the full corpus completes in well under a
second. Persisting would add schema surface and a migration without
saving any meaningful time at figure-render time.
Functions
|
Per-recording gains across an already-fetched response frame. |
|
Linear fit slope of ΔF/F vs Δ target temperature. |
Classes
|
One linear-gain fit for a single recording. |
- class arista.processing.gain.RecordingGain(slope, intercept, r_squared, n_points)[source]
Bases:
objectOne linear-gain fit for a single recording.
- arista.processing.gain.compute_gains_table(response_df, *, min_steps=3, group_keys=('recording_id', 'strain_name', 'cell_type', 'hemisphere'))[source]
Per-recording gains across an already-fetched response frame.
- Parameters:
response_df (pandas.DataFrame) – Output of
arista.viz.response_curves.fetch_response_data()— one row per (recording, step) with all v_recordings metadata joined in.min_steps (int) – Drop recordings with fewer than this many valid steps (default 3 — needed for a meaningful linear fit).
group_keys (tuple[str, ...]) – Columns that uniquely identify one recording’s row group. Must include
recording_id.
- Returns:
DataFrame with one row per recording carrying the group keys plus
slope,intercept,r_squared,n_points.- Return type:
- arista.processing.gain.compute_recording_gain(steps_df)[source]
Linear fit slope of ΔF/F vs Δ target temperature.
- Parameters:
steps_df (pandas.DataFrame) – One recording’s rows from
stimulus_responses, withdelta_target_canddfbf_response_mediancolumns.- Returns:
RecordingGain.slopeandr_squaredare NaN when fewer than 2 finite points are available or when every x-value is identical (no spread to fit through).- Return type: