arista.preprocess.io
File I/O for raw inputs and preprocessed outputs.
This module replaces the I/O sprinkled across _legacy/pytci/tempFileIO.py
and _legacy/aristaSingleCellData.py with pure functions that return
typed dataclasses instead of mutating self.
Three input formats are accepted for Fiji ΔF/F exports:
X,Yheader (Alex Busch’s older fixtures)Frame,Meanheader (Alex Busch’s later fixtures)frame,df/fheader (legacy aristaSingleCellData.py output)
All three collapse to the same FijiRecording dataclass.
Functions
|
Read a Fiji ΔF/F₀ ROI export into a |
|
Re-read a canonical |
|
Read a MATLAB |
|
Persist a |
Classes
|
Raw Fiji ROI export — one ΔF/F₀ value per imaging frame. |
|
Frame-aligned, optionally drift-corrected Ca²⁺ recording. |
|
Raw MATLAB sensor record — continuously logged 5-column array. |
- class arista.preprocess.io.FijiRecording(frame, dfbf)[source]
Bases:
objectRaw Fiji ROI export — one ΔF/F₀ value per imaging frame.
- Parameters:
frame (numpy.ndarray)
dfbf (numpy.ndarray)
- dfbf: numpy.ndarray
- frame: numpy.ndarray
- class arista.preprocess.io.Recording(frame, time_s, sensor_t_c, target_t_c, drive_t_c, dfbf, dfbf_drift_corrected=None, drift_method='none', recording_date=None)[source]
Bases:
objectFrame-aligned, optionally drift-corrected Ca²⁺ recording.
One row per imaging frame. Matches the column layout of the
samplestable in [[Database Schema]] so the ingester can bulk-insert directly.dfbf_drift_correctedisNonewheneverdrift_method == "none".recording_dateis the calendar date the recording started, extracted from the first sensor MAT epoch during alignment. The ingester uses it to populateanimals.recording_date.- Parameters:
- dfbf: np.ndarray
- frame: np.ndarray
- sensor_t_c: np.ndarray
- target_t_c: np.ndarray
- time_s: np.ndarray
- class arista.preprocess.io.SensorRecord(epoch_time, frame, sensor_t_c, target_t_c, drive_t_c)[source]
Bases:
objectRaw MATLAB sensor record — continuously logged 5-column array.
Each MAT file holds a
datamatrix whose columns are, in order: epoch_time (MATLAB serial datenum), frame index (1-based!), sensor_T (°C, actually measured), target_T (°C, set-point) and drive_T (°C, applied to the Peltier element). The log rate is higher than the imaging rate so multiple sensor rows share the same frame number;arista.preprocess.align()collapses them.- Parameters:
epoch_time (numpy.ndarray)
frame (numpy.ndarray)
sensor_t_c (numpy.ndarray)
target_t_c (numpy.ndarray)
drive_t_c (numpy.ndarray)
- drive_t_c: numpy.ndarray
- epoch_time: numpy.ndarray
- frame: numpy.ndarray
- sensor_t_c: numpy.ndarray
- target_t_c: numpy.ndarray
- arista.preprocess.io.read_fiji_csv(path)[source]
Read a Fiji ΔF/F₀ ROI export into a
FijiRecording.Accepts any of the three header conventions documented in the module docstring. Header is required (no headerless CSV support; that would silently re-interpret the first frame as a column name and corrupt downstream alignment).
- Parameters:
- Returns:
Frozen
FijiRecordingwith frame and dfbf as numpy arrays.- Raises:
ValueError – If neither a frame-like nor a value-like column is present, or if frame indices are not monotonically increasing.
- Return type:
- arista.preprocess.io.read_recording_csv(path)[source]
Re-read a canonical
write_recording_csv()output.
- arista.preprocess.io.read_sensor_mat(path)[source]
Read a MATLAB
temperature_data_*.matsensor record.The MAT file must contain a top-level variable
datashaped(n_samples, 5):[epoch_time, frame, sensor_T, target_T, drive_T].- Parameters:
- Returns:
Frozen
SensorRecordwith the five columns as separate arrays.- Raises:
KeyError – If the MAT file lacks a
datavariable.ValueError – If the
datamatrix is not 5 columns wide.
- Return type:
- arista.preprocess.io.write_recording_csv(recording, path)[source]
Persist a
Recordingto disk as a canonical CSV.Column order matches the
samplestable in [[Database Schema]] soarista-ingestcanCOPY-style load without remapping. Two#-prefixed header lines carry recording-level provenance:# drift_method: <method>— which drift correction was applied# recording_date: <YYYY-MM-DD>— calendar date of frame 0, omitted when the recording carries no date