arista.processing.stimulus_response

Compute the per-step median response for a thermal-step recording.

Reproduces _legacy/oldScripts/tempFileIO.py::calcResponse: for each step in the stimulus protocol’s target sequence, take every frame where the sensor temperature lies within ±``STIMULUS_RESPONSE_WINDOW_C`` of the step’s target. The median ΔF/F across those frames is the cell’s response to that step.

Step dispatch uses the time window [baseline_duration_s + k·step_duration_s, baseline_duration_s + (k+1)·step_duration_s) to assign each frame to a step, then the sensor-T tolerance picks out the in-target frames within that window. This matches Kossen’s pytci protocol design (75 s baseline + 8 × 60 s steps).

Kossen’s calcResponse also keyed off targetTemp == step_target exact equality. We omit that constraint because our preprocess pipeline linearly interpolates target_t_c to fill DAQ gaps, which produces float values like 22.0000001 that fail exact equality on a non-trivial fraction of frames. Pytci’s alignTemperature2Frame uses per-frame medians without interpolation so its exact equality is well-behaved; ours is not. Time + sensor tolerance produces the same set of in-window frames as Kossen’s pipeline up to float-precision noise.

Functions

compute_stimulus_responses(samples_df, ...)

Median ΔF/F per step for a thermal-step recording.

Classes

StimulusResponseRow(step_index, ...)

One row destined for the stimulus_responses table.

class arista.processing.stimulus_response.StimulusResponseRow(step_index, target_temp_c, delta_target_c, observed_temp_median, dfbf_response_median, n_frames_in_window)[source]

Bases: object

One row destined for the stimulus_responses table.

Parameters:
  • step_index (int)

  • target_temp_c (float)

  • delta_target_c (float)

  • observed_temp_median (float)

  • dfbf_response_median (float)

  • n_frames_in_window (int)

delta_target_c: float
dfbf_response_median: float
n_frames_in_window: int
observed_temp_median: float
step_index: int
target_temp_c: float
arista.processing.stimulus_response.compute_stimulus_responses(samples_df, stimulus_protocol_name, *, window_c=0.5)[source]

Median ΔF/F per step for a thermal-step recording.

Parameters:
Returns:

One StimulusResponseRow per step that yielded at least one in-window frame. Empty list for stimuli without a target_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:

list[StimulusResponseRow]