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
|
Median ΔF/F per step for a thermal-step recording. |
Classes
|
One row destined for the |
- 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:
objectOne row destined for the
stimulus_responsestable.- Parameters:
- 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:
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: