arista.preprocess.align

Frame-align a sensor record against a Fiji ΔF/F trace.

Stages from [[Preprocessing Pipeline]]:

  • A — collapse_to_frames: group continuous sensor log rows by their imaging frame number and take the per-frame mean

  • B — arista.preprocess.interpolate.interpolate_missing_frames(): fill any frames the DAQ dropped

  • C — assemble_recording: cut the sensor record down to the imaged window, merge with the Fiji ΔF/F trace, convert MATLAB datenums to elapsed seconds

The implementation matches the legacy _legacy/aristaSingleCellData.py behaviour: per-frame mean (not median), pandas interpolate (not scipy interp1d), so byte-level regression against legacy outputs holds within float tolerance.

Functions

assemble_recording(fiji, sensor)

Run stages A + B + C and return a frame-aligned Recording.

collapse_to_frames(sensor)

Group the continuous sensor log by frame, take the per-frame mean.

arista.preprocess.align.assemble_recording(fiji, sensor)[source]

Run stages A + B + C and return a frame-aligned Recording.

Drift correction is not applied here — that is arista.preprocess.drift’s job. The returned recording has dfbf_drift_corrected = None and drift_method = "none".

The output length is the intersection of the Fiji frame range and the (post-collapse, post-interp) sensor frame range. Any Fiji frames without a matching sensor frame are dropped silently — this matches legacy behaviour and only ever clips a handful of trailing frames in well-formed recordings.

Parameters:
Returns:

A Recording aligned to Fiji’s frame numbers.

Return type:

Recording

arista.preprocess.align.collapse_to_frames(sensor)[source]

Group the continuous sensor log by frame, take the per-frame mean.

Sensor rows where frame == 0 are pre-stimulus calibration data and dropped (matches the frame > 0 cut in the legacy pipeline). Frame numbers are decremented by 1 so the result is 0-indexed, aligning with Fiji’s frame numbering.

Parameters:

sensor (SensorRecord) – Raw SensorRecord straight from arista.preprocess.io.read_sensor_mat().

Returns:

A DataFrame indexed by integer 0-based frame number, with columns epoch_time, sensor_t_c, target_t_c, drive_t_c. NaN-padded over any missing intermediate frames so interpolate_missing_frames() can fill them.

Return type:

pandas.DataFrame