retrofit#
Reconstruct AcquisitionManifests for legacy mesofield sessions.
Mesofield only started writing a mesokit_schema.AcquisitionManifest once the Procedure._write_acquisition_manifest hook landed. Sessions acquired before that have no manifest, which means downstream tools (datakit, databench) cannot ingest them through the contract path.
This module walks a BIDS-laid-out session directory (or an experiment root containing many sessions) and synthesizes a manifest from what is already on disk:
subject / session from the BIDS path (sub-X/ses-Y/)
task from the filename suffix (…_task-Z_…)
per-producer output_path, bids_type, file_type from the file tree
started_at / ended_at from the session’s *_timestamps.csv
frame-metadata sidecars (*_frame_metadata.json) attached to their tiff
Fields that the legacy filesystem does not carry (hardware calibration, mesofield_version, per-producer sampling_rate) are written as their empty/default values. The manifest still gates ingest, but downstream analyses that need calibration will need it filled in by hand.
Multi-task sessions get one manifest per task, written as manifest_task-<T>.json; single-task sessions write manifest.json.
- mesofield.utils.retrofit.discover_sessions(root)[source]#
Yield session directories (…/sub-X/ses-Y/) under root.
Accepts either a session dir, an experiment root containing data/, or any ancestor that contains BIDS-laid-out sessions.