arista.processing
Post-ingest computation on samples already in the DB.
- class arista.processing.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:
- class arista.processing.ProcessingStats(inserted_responses=0, inserted_adaptations=0, skipped_already_done=0, failed_adaptations=0)[source]
Bases:
objectTally for one
process_allrun.- Parameters:
- class arista.processing.RecordingGain(slope, intercept, r_squared, n_points)[source]
Bases:
objectOne linear-gain fit for a single recording.
- class arista.processing.SigmoidFit(bottom, top, midpoint_c, slope, r_squared, n_points)[source]
Bases:
objectOne 4PL sigmoid fit.
- Parameters:
- class arista.processing.StimulusResponseRow(step_index, target_temp_c, delta_target_c, observed_temp_median, dfbf_response_median, n_frames_in_window)[source]
Bases:
objectOne row destined for the
stimulus_responsestable.- Parameters:
- arista.processing.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.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:
- arista.processing.compute_stimulus_responses(samples_df, stimulus_protocol_name, *, window_c=0.5)[source]
Median ΔF/F per step for a thermal-step recording.
- Parameters:
samples_df (pandas.DataFrame) – One recording’s samples as returned by
arista.preprocess.io.read_recording_csv()or by reading thesamplestable. Must carrytime_s,sensor_t_c,target_t_c,dfbf(and optionallydfbf_drift_corrected) columns.stimulus_protocol_name (str) – Canonical name from
arista.constants.STIMULUS_PROTOCOLS.window_c (float) – Sensor-T tolerance half-width, defaults to
arista.constants.STIMULUS_RESPONSE_WINDOW_C.
- Returns:
One
StimulusResponseRowper step that yielded at least one in-window frame. Empty list for stimuli without atarget_sequence(mechanical Bending, the open-ended HotAdapt / ColdAdapt, Laurin’s step / long pilots) — those protocols don’t have a finite discrete step structure to median over.- Return type:
- arista.processing.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
- arista.processing.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_fitmaxfevceiling.
- Returns:
SigmoidFiton convergence,Nonewhen the data is too sparse (<4 points), perfectly flat, or whencurve_fitraises.- Return type:
SigmoidFit | None
- arista.processing.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:
response_df (pandas.DataFrame) – Output of
arista.viz.response_curves.fetch_response_data().group_keys (tuple[str, ...]) – Columns to group by (default per strain × cell-type).
min_points (int) – Skip groups with fewer than this many finite points.
- Returns:
DataFrame with one row per group carrying
bottom,top,midpoint_c,slope,r_squared,n_pointsplus the group key columns. Groups whose fit failed are omitted.- Return type:
- arista.processing.four_pl(x, bottom, top, midpoint, slope)[source]
Four-parameter logistic.
bottomandtopare the left/right asymptotes,midpointis the x-value at the curve’s inflection, andslopeis the curve’s slope at the midpoint (units: 1/°C).- Parameters:
x (numpy.ndarray)
bottom (float)
top (float)
midpoint (float)
slope (float)
- Return type:
- arista.processing.process_all(conn, *, progress=None, reprocess=False)[source]
Compute aggregates for every recording missing them.
- Parameters:
conn (Connection) – Open SQLite connection to a populated
arista.db.progress (bool | None) – tqdm visibility (None = auto-detect TTY, True = force on, False = force off).
reprocess (bool) – If
Truedrop existing aggregates before recomputing. Useful after fixing the response formula.
- Returns:
ProcessingStatswith counts of inserted / already-done / failed-adaptation recordings.- Return type:
Modules
Fit |
|
Linear-fit gain per recording across the stimulus-response steps. |
|
Batch driver that fills |
|
Four-parameter logistic (4PL) fit of ΔF/F vs Δ target temperature. |
|
Compute the per-step median response for a thermal-step recording. |