Closed Loop¶
The closest closed-loop or optogenetic pilot stack in this repository is opto_pilot/.
This directory is more script-like than the passive and single-interval projects, but it clearly contains the building blocks for opto versus control comparisons aligned to imaging and behavior.
Main entry points¶
opto_pilot/main_opto.pyopto_pilot/modules/Trialization_Opto.pyopto_pilot/modules/FlirFrames.pyopto_pilot/modules/Alignment.pyopto_pilot/modules/ReadResults.pyopto_pilot/plot/
What main_opto.py does¶
main_opto.py is a monolithic analysis script that:
- reads a processed session directory and restores
ops.npy - loads masks,
dff, significance labels, raw voltages, and Bpod data - reads or constructs
neural_trials - separates control and opto trials
- plots mean trajectories and heatmaps
- identifies opto-responsive neurons with threshold-based heuristics
- writes report-style figures
The code currently uses hard-coded local paths, which suggests it is intended for targeted analysis runs rather than batch execution on arbitrary datasets.
Module roles¶
Trialization_Opto.py¶
Specialized trial segmentation for optogenetic sessions, likely extending the shared trialization logic with opto-specific state handling.
FlirFrames.py¶
Helpers for working with FLIR timing or frame alignment. This is notable because the preprocessing voltage files also preserve FLIR-related channels.
Alignment.py¶
Reusable event-alignment helpers for constructing trial-locked neural activity sequences.
ReadResults.py¶
Readers for masks, ΔF/F, raw voltages, ROI labels, motion offsets, and Bpod session data.
plot/¶
Contains analysis and figure helpers for:
- basic alignments
- short/long comparisons
- raw traces
- calcium transients
- coactivation fractions
- model-style summaries
Relationship to the shared pipeline¶
Like the other experiment directories, opto_pilot/ assumes the shared preprocessing and postprocessing layers have already produced:
- Suite2p outputs
- voltage sidecars
- ROI masks and labels
- ΔF/F traces
The opto-specific work then starts from those files and focuses on trial alignment and response comparison.
Current maturity¶
Compared with passive_interval_oddball_202412/ and single_interval_discrimination_202505/, the closed-loop stack is less standardized:
- fewer reusable top-level config objects
- more hard-coded local paths
- more notebook or script-like execution style
That said, the core module split is already visible and would support future cleanup into a more reusable pipeline.