Medicine, Faculty of
DSpace
UBCV
Gupta, Kumar Pankaj
Doctor of Philosophy - PhD
University of British Columbia
Understanding how the brain learns and adapts to behavioral demands requires precise experimental control and computational frameworks capable of revealing large-scale neural dynamics. This thesis presents two complementary approaches: (1) the development of a closed-loop experimental platform for real-time neurofeedback and movement feedback in mice, and (2) a biologically constrained recurrent neural network (RNN) framework to model cortical interactions during learning tasks. First, I developed an open-source system, Closed-Loop-Py (CLoPy), enabling closed-loop neurofeedback (CLNF) and closed-loop movement feedback (CLMF) with low-latency auditory feedback (~63â67 ms). In CLNF experiments, dorsal cortical activity was monitored using widefield GCaMP6s calcium imaging, allowing mice to learn to modulate specific cortical regions of interest (ROIs) to obtain rewards. Both sensory and motor cortices supported learning, with animals adapting to changing task rules over training days (Repeated Measures ANOVA p = 8.3 Ã 10â»Â¹â°). In CLMF experiments, auditory feedback was based on limb movement, and mice rapidly improved performance compared to controls (RM ANOVA p = 9.6 Ã 10â»â·). Learning was accompanied by reduced task latency and focal cortical activity, suggesting greater behavioral and neural efficiency. These results establish CLoPy as a flexible and accessible platform for studying brain-behavior coupling through real-time feedback. Building on this foundation, I developed CorNet RNN, a modular, biologically inspired computational model for exploring how cortical networks coordinate behavior. Using simulated multi-region datasets, the model accurately recovered hidden inter-regional inputs. When trained on the Allen Instituteâs Visual Behavior 2P (VB2P) calcium imaging dataset, CorNet RNN reproduced empirically observed temporal dynamics and connectivity patterns. The network employed correlation-based weight initialization reflecting biological connectivity and was trained with GPU-accelerated backpropagation to match recorded activity. Applying CorNet RNN to in-house CLMF datasets revealed that task engagement reshaped both intra- and inter-regional neural interactions, reflecting adaptive cortical reorganization. Together, these experimental and computational advances demonstrate how closed-loop paradigms, when integrated with biologically constrained neural modeling, can elucidate the principles of learning and cortical coordination. This framework lays the groundwork for future studies linking mesoscale dynamics, neural computation, and behavior in health and disease.
Open-source real-time feedback system for shaping cortical and behavioral motor dynamics in mice reveal altered cortical networks and behavior with closed-loop training by Kumar Pankaj Gupta MSc., Trinity College Dublin, 2012 A THESIS SUBMITTED IN PARTIAL FULFILLMENT OF THE REQUIREMENTS FOR THE DEGREE OF DOCTOR OF PHILOSOPHY in THE FACULTY OF GRADUATE AND POSTDOCTORAL STUDIES (NEUROSCIENCE) THE UNIVERSITY OF BRITISH COLUMBIA (Vancouver) October 2025 © Kumar Pankaj Gupta, 2025 ii The following individuals certify that they have read, and recommend to the Faculty of Graduate and Postdoctoral Studies for acceptance, the dissertation entitled: Open-source real-time feedback system for shaping cortical and behavioral motor dynamics in mice reveal altered cortical networks and behavior with closed-loop training submitted by Kumar Pankaj Gupta in partial fulfilment of the requirements for the degree of Doctor of Philosophy in Neuroscience Examining Committee: Dr. Timothy H. Murphy, Professor, Psychiatry, UBC Supervisor Dr. Mark S. Cembrowski, Associate Professor, Cellular and Physiological Sciences, UBC Supervisory Committee Member Dr. Naznin Virji-Babul, Associate Professor, Physical Therapy, UBC University Examiner Dr. Robert Xiao, Associate Professor, Computer Science, UBC University Examiner Dr. Francesco Saverio Pavone, Professor, University of Florence External Examiner Additional Supervisory Committee Members: Dr. Lara Boyd, Professor, Physical Therapy, UBC Supervisory Committee Member Dr. Jeremy Seamans, Professor, Psychiatry, UBC Supervisory Committee Member iii Abstract Understanding how the brain learns and adapts to behavioral demands requires precise experimental control and computational frameworks capable of revealing large-scale neural dynamics. This thesis presents two complementary approaches: (1) the development of a closed-loop experimental platform for real-time neurofeedback and movement feedback in mice, and (2) a biologically constrained recurrent neural network (RNN) framework to model cortical interactions during learning tasks. First, I developed an open-source system, Closed-Loop-Py (CLoPy), enabling closed-loop neurofeedback (CLNF) and closed-loop movement feedback (CLMF) with low-latency auditory feedback (~63â67 ms). In CLNF experiments, dorsal cortical activity was monitored using widefield GCaMP6s calcium imaging, allowing mice to learn to modulate specific cortical regions of interest (ROIs) to obtain rewards. Both sensory and motor cortices supported learning, with animals adapting to changing task rules over training days (Repeated Measures ANOVA p = 8.3 Ã 10â»Â¹â°). In CLMF experiments, auditory feedback was based on limb movement, and mice rapidly improved performance compared to controls (RM ANOVA p = 9.6 Ã 10â»â·). Learning was accompanied by reduced task latency and focal cortical activity, suggesting greater behavioral and neural efficiency. These results establish CLoPy as a flexible and accessible platform for studying brain-behavior coupling through real-time feedback. iv Building on this foundation, I developed CorNet RNN, a modular, biologically inspired computational model for exploring how cortical networks coordinate behavior. Using simulated multi-region datasets, the model accurately recovered hidden inter-regional inputs. When trained on the Allen Instituteâs Visual Behavior 2P (VB2P) calcium imaging dataset, CorNet RNN reproduced empirically observed temporal dynamics and connectivity patterns. The network employed correlation-based weight initialization reflecting biological connectivity and was trained with GPU-accelerated backpropagation to match recorded activity. Applying CorNet RNN to in-house CLMF datasets revealed that task engagement reshaped both intra- and inter-regional neural interactions, reflecting adaptive cortical reorganization. Together, these experimental and computational advances demonstrate how closed-loop paradigms, when integrated with biologically constrained neural modeling, can elucidate the principles of learning and cortical coordination. This framework lays the groundwork for future studies linking mesoscale dynamics, neural computation, and behavior in health and disease. v Lay Summary This dissertation presents an open-source system that provides real-time feedback to train brain activity and behavior in mice. Using two feedback approachesâclosed-loop neurofeedback (CLNF), based on brain activity, and closed-loop movement feedback (CLMF), based on motion trackingâthe system enabled mice to learn tasks by linking their neural or behavioral activity to rewards. Mice receiving graded feedback learned faster and showed more focused brain activation over time, reflecting improved neural efficiency. In addition, recurrent neural network (RNN) models were developed to analyze large-scale brain activity from distinct cell types. These models revealed differences in learning complexity among neuron classes and showed that certain inhibitory cells (VIP and SST) process the same stimuli with distinct timing. Together, these experimental and computational advances provide new insights into how brain regions and cell types coordinate during learning and establish accessible tools for closed-loop neuroscience research. vi Preface This dissertation presented here is original, and all methods and interventions were approved by the University of British Columbiaâs Animal Care Committee (A22-0054). ChatGPT was used for text condensation, proofreading, and syntax refinement. Chapter 1 lays background introduction to key ideas in this dissertation. Chapter 2 includes work from two related experiments employing the setup we developed. A version of this chapter has been resubmitted and under revision. Gupta Pankaj K, Murphy Timothy H (2025) Real-Time Closed-Loop Feedback System for Mouse Mesoscale Cortical Signal And Movement Control: CLoPy eLife 14:RP105070. I developed the hardware and software system, conducted all the experiments, and developed analysis source code for all the data. Dr. Timothy Murphy and I wrote the manuscript. Chapter 3 is part of an unpublished manuscript from a collaboration work with Dr. Adrienne Fairhall, Dr. Timothy Murphy, and I. The data employed was 1) Allen Instituteâs Visual Behavior 2P (M. Garrett et al. 2020; Groblewski et al. 2020; Hu et al. 2021; de Vries et al. 2019), 2) Closed-loop Movement Feedback dataset that I collected and discussed in chapter 2. Dr. Adrienne Fairhall helped discuss the idea and analysis, Dr. Timothy Murphy and I analyzed the data and wrote the manuscript. vii Table of Contents Abstract .......................................................................................................................................... iii Lay Summary .................................................................................................................................. v Preface............................................................................................................................................ vi Table of Contents .......................................................................................................................... vii List of Tables ............................................................................................................................... xiii List of Figures .............................................................................................................................. xiv List of Abbreviations ................................................................................................................... xvi Glossary ........................................................................................................................................ xx Acknowledgements ..................................................................................................................... xxv Dedication ................................................................................................................................. xxvii Chapter 1: Introduction to closed-loop systems and shaping ................................................... 1 1.1 Overview of closed-loop systems ............................................................................... 3 1.2 Historical context of closed-loop research in neuroscience ........................................ 4 1.3 Applications in motor control and brain-computer interfaces (BCIs) ........................ 5 1.4 Significance for motor learning in rehabilitation ........................................................ 7 1.5 Advantages of closedâloop setups in neuroscience ..................................................... 9 viii 1.6 Challenges in closedâloop neuroscience systems ..................................................... 11 1.7 Types of closed-loop designs .................................................................................... 13 1.8 Neurofeedback and movement feedback in rodents ................................................. 15 1.9 Shaping in mice: Behavioral conditioning and training paradigms .......................... 15 1.9.1 Key factors influencing shaping success .......................................................... 16 1.10 Future Directions and Emerging Technologies ........................................................ 18 1.11 Widefield Calcium imaging ...................................................................................... 20 1.12 Optical Calcium imaging and real-time widefield imaging in mice ......................... 22 1.13 The CLoPy platform: Closed-loop neurofeedback and movement feedback ........... 23 1.14 Modeling multi-region cortical dynamics ................................................................. 24 1.14.1 Need for data-constrained modeling ................................................................. 24 1.14.2 RNN modeling approach .................................................................................. 24 1.15 Significance and broader implications of this study ................................................. 26 1.16 Thesis outline ............................................................................................................ 28 1.16.1 Chapter 1: Introduction ..................................................................................... 28 1.16.2 Chapter 2: Platform for closed-loop neurofeedback and movement feedback . 28 1.16.3 Chapter 3: Modelling multi-region cortical interactions using RNNs .............. 29 1.16.4 Chapter 4: Conclusion and future work ............................................................ 29 ix Chapter 2: Platform for closed-loop neurofeedback and movement feedback ....................... 31 2.1 Introduction ............................................................................................................... 31 2.2 Methods..................................................................................................................... 39 2.2.1 Animals ............................................................................................................. 39 2.2.2 Animal surgery, chronic transcranial window preparation ............................... 39 2.2.3 Water deprivation and habituation to experiments ........................................... 41 2.2.4 CLNF, CLMF setup and behavior experiments ................................................ 42 2.2.5 Key configuration parameters ........................................................................... 50 2.2.6 CLoPy platform ................................................................................................ 53 2.2.7 Comparison with existing closed-loop platforms ............................................. 53 2.2.8 Graded feedback (Online ÎF/F0-Audio mapping) ............................................ 54 2.2.9 Checking the dynamic range of graded auditory feedback ............................... 55 2.2.10 Determining reward threshold based on a baseline session .............................. 56 2.2.11 Determining ROI(s) for changes in CLNF task rules. ...................................... 57 2.2.12 Online ÎF/F0 calculation ................................................................................... 57 2.2.13 Offline ÎF/F0 calculation .................................................................................. 60 2.2.14 Seed-pixel correlation matrices......................................................................... 61 2.2.15 Data and code availability ................................................................................. 61 x 2.2.16 Statistics ............................................................................................................ 62 2.2.17 CLNF rules........................................................................................................ 66 2.2.18 CLMF rules ....................................................................................................... 68 2.3 Results ....................................................................................................................... 72 2.3.1 Mice can explore and learn an arbitrary task, rule, and target conditions. ....... 82 2.3.2 Mice can rapidly adapt to changes in the task rule. .......................................... 90 2.3.3 Graded feedback helps in task exploration during learning .............................. 92 2.3.4 Cortical responses became focal and more correlated in CLMF ...................... 94 2.3.5 Distinct task- and reward-related cortical dynamics ......................................... 99 2.4 Discussion ............................................................................................................... 118 2.4.1 Flexible, cost-effective, and open-source system ........................................... 118 2.4.2 Importance of closed-loop feedback systems ................................................. 120 2.4.3 Neuroplasticity and Cortical Dynamics .......................................................... 121 2.4.4 Value of the CLoPy platform in systems neuroscience .................................. 122 2.4.5 Positioning within the open-source neuroscience community ........................ 123 2.4.6 Experimental applications and implications ................................................... 124 2.4.7 Future directions and broad impact................................................................. 126 Chapter 3: Modelling multi-region cortical interactions using data-constrained RNNs ...... 128 xi 3.1 Introduction ............................................................................................................. 128 3.2 Methods................................................................................................................... 130 3.2.1 Data and code availability ............................................................................... 130 3.2.2 Data-constrained RNN modeling of multi-region interactions ....................... 130 3.2.3 Inferring directional inputs from trained CorNet RNN .................................. 132 3.2.4 Validation of CorNet with simulated data ...................................................... 135 3.2.5 Multi-region visual behavior 2P (VB2P) dataset ............................................ 137 3.2.6 CLMF dataset.................................................................................................. 140 3.2.7 Phase shift analysis of VB2P cortical activity across neuronal subtypes ....... 141 3.3 Results ..................................................................................................................... 143 3.3.1 CorNet accurately replicates simulated neural dynamics ............................... 143 3.3.2 Cell-type specific neural responses to image changes vary ............................ 147 3.3.3 Model training performance on simulated and experimental data .................. 156 3.3.4 Inferred directional inputs reveal region-specific functional roles ................. 158 3.3.5 Cell-type-specific connectivity patterns inferred from CorNet model ........... 163 3.3.6 CorNet inferred task relevant inputs from CLMF dataset .............................. 168 3.4 Discussion ............................................................................................................... 172 3.4.1 Interpretability and biological relevance ........................................................ 173 xii 3.4.2 Dynamics of task-dependent connectivity ...................................................... 173 3.4.3 Challenges and limitations .............................................................................. 174 3.4.4 Future Directions ............................................................................................ 175 Chapter 4: Conclusion .......................................................................................................... 177 4.1 Contributions to the field ........................................................................................ 178 4.2 Strengths and Limitations ....................................................................................... 180 4.3 Future Research Directions ..................................................................................... 182 4.4 Final remarks .......................................................................................................... 187 References ................................................................................................................................... 188 xiii List of Tables Table 1.1 Challenges in closed-loop systems neuroscienceâ¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦. 12 Table 2.1 Comparison of closed-loop feedback systemsâ¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦.. 37 Table 2.2 Key configuration parameters in CLoPyâ¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦.. 51 Table 2.3 List of statistical tests performedâ¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦.. 62 Table 2.4 List of CLNF task rules with their descriptionâ¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦. 66 Table 2.5 List of CLMF task rules with their descriptionâ¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦. 67 Table 2.6 List of mice â CLNFâ¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦. 69 Table 2.7 List of mice â CLMFâ¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦.71 xiv List of Figures Figure 1.1 Illustration of a closed loop neurofeedback systemâ¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦.. 2 Figure 2.1 Setup of real-time feedback for GCaMP6 cortical activity and movementsâ¦â¦â¦... 33 Figure 2.2 Schematic of the closed-loop feedback training systemâ¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦. 74 Figure 2.3 Experimental protocol and trial structureâ¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦ 79 Figure 2.4 Closed-loop feedback helped mice learn the taskâ¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦... 84 Figure 2.5 Change in data distribution with training and before, after the rule changeâ¦â¦â¦... 86 Figure 2.6 CLNF: Cortical activity during the closed-loop-neurofeedback trainingâ¦â¦â¦â¦â¦89 Figure 2.7 CLMF: Speed of the tracked target body part and cortical activityâ¦â¦â¦â¦â¦â¦â¦ 93 Figure 2.8 CLMF: Correlation matrix showing pairwise correlations of speed profilesâ¦â¦â¦.. 96 Figure 2.9 Cortical dynamics and network changes during longitudinal CLMF trainingâ¦â¦â¦ 97 Figure 2.10 CLMF cortex-wide seed pixel correlation mapsâ¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦. 100 Figure 2.11 Average reward centered activity in ROIs for 2-ROI experimentâ¦â¦â¦â¦â¦â¦...102 Supplementary Figure 2.1 Method for calculating feedback and reward delay in CLNF and CLMF setupsâ¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦103 Supplementary Figure 2.2 Verification of generated audio tone frequenciesâ¦â¦â¦â¦â¦â¦...106 Supplementary Figure 2.3 Learning progression was similar in male and female mice, and even similar between 1ROI and 2ROI experimentsâ¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦. 108 Supplementary Figure 2.4 CLMF behavior tracesâ¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦ 110 xv Supplementary Figure 2.5 CLMF Seed pixel correlation maps during rewarded trial, rest periods, and their differenceâ¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦ 112 Supplementary Figure 2.6 CLNF, CLMF command line operation and preview stepsâ¦â¦... 114 Supplementary Figure 2.7 Visual representation of 1 ROI and 2 ROI rules in CLNF experimentâ¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦116 Supplementary Figure 2.8 Example trials along with audio feedback during CLNF and CLMF trainingâ¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦. 117 Figure 3.1 Training data-constrained RNN modelâ¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦. 133 Figure 3.2 Multi-region interactions using data-constrained RNN modelsâ¦â¦â¦â¦â¦â¦â¦â¦ 138 Figure 3.3 CorNet replicates simulated neural dynamicsâ¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦... 144 Figure 3.4 Visual Behavior 2P experiment setup by Allen Institute for Brain Sciencesâ¦â¦â¦ 146 Figure 3.5 Visual Behavior 2P neural and behavior dataâ¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦... 150 Figure 3.6 Cell-type specific neural responses to image change are unique across cortical regions and across the cell-typesâ¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦.. 152 Figure 3.7 Phase shift analysis of cortical activity across the Cre linesâ¦â¦â¦â¦â¦â¦â¦â¦â¦. 154 Figure 3.8 Training loss on simulated and VB2P datasetâ¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦... 157 Figure 3.9 CorNet inferred directional inputs indicate region specific roleâ¦â¦â¦â¦â¦â¦â¦... 159 Figure 3.10 Distribution of synaptic weights in CorNet RNN models trained on the VB2P datasetâ¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦.. 164 Figure 3.11 CorNet inferred inputs applied on CLMF (Chapter 2) widefield calcium imaging datasetâ¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦.. 170 xvi List of Abbreviations AAV - Adeno associated virus aBC - Anterior barrel cortex ALM - Anterior lateral motor cortex AIBS - Allen Institute for Brain Science ANOVA - Analysis of variance BBB - Blood brain barrier BORIS - Behavioral Observation Research Interactive Software Ca2+ - Calcium CAD - Computer aided design CaM - Calmodulin CAMKII - Calmodulin-dependent protein kinase II CCD - Charge coupled device Cm - Centimeter cp - Circularly permuted CMOS - Complementary metal-oxide-semiconductor d - Day Deg - Degree DLC - DeepLabCut dF/F0 - Change in fluorescence over mean fluorescence xvii FOV - Field of view fps - Frames per second iGLuSnFR - Intensity-based glutamate sensing fluorescent reporter GABA - Gamma-aminobutyric acid GcaMP - Genetically encoded calcium sensor GECI - Genetically encoded calcium indicator GFP - Green fluorescent protein h - Hour HL - Hindlimb hSyn - Human synapsin Hz - Hertz kHz - kiloHertz kg - kilogram LED - Light emitting diode LSM - Laser scanning microscope M1 - Primary motor cortex M2 - Secondary motor cortex mg - Milligram min - Minute mL - Milliliter mm - Millimeter xviii ms - Millisecond MHz - Megahertz mW - Milliwatt NA - Numerical Aperture Nm - Nanometer pBC - Posterior barrel cortex PBS - Phosphate buffered saline PCC - Pearsonâs correlation coefficient PCR - Polymerase chain reaction PFA - Paraformaldehyde PFC - Prefrontal cortex PMT - Photomultiplier tube PTA - Parietal cortex RGB - Red, green, blue RM ANOVA - Repeated measures analysis of variance ROI - Region of interest RS - Retrosplenial cortex s - Second SD - Standard deviation SNR - Signal to noise ratio SPC - Seed pixel correlation xix SST - Somatostatin std - Standard deviation SVD - Singular value decomposition tTA - Tetracycline controlled transactivator TTL - Transistor-transistor logic tet-O - Tetracycline operator um - Micrometer UMAP - Uniform Manifold Approximation and Projection USD - United States Dollar UV - Ultraviolet V1 - Primary visual cortex VIP - Vasoactive intestinal pedtide VISp - Primary visual area (also called V1) VISal - Anterolateral visual area VISam - Anteromedial visual area VISl - Lateral visual area VSD - Voltage sensitive dye wM1 - Whisker primary motor cortex WPRE - Woodchuck hepatitis virus post-transcriptional regulatory element WT - Wild type xx Glossary Backpropagation: The core learning algorithm in deep learning, used to compute gradients and update weights based on loss minimization. Backpropagation Through Time (BPTT): A training algorithm for RNNs that involves unfolding the network over time and computing gradients for weight updates. BCI (Brain-Computer Interface): A technology that enables direct communication between brain activity and an external device, often used in neurofeedback or prosthetic control. Bimodal Distribution: A distribution with two distinct peaks, possibly indicating segregation of excitatory and inhibitory influences or mixed connectivity motifs. CLNF (Closed-Loop Neurofeedback): A system where real-time neural activity (e.g., GCaMP fluorescence) is measured and used to modulate feedback provided to the subject. CLMF (Closed-Loop Movement Feedback): A system where behavioral data (e.g., limb movement) is tracked in real-time and mapped to feedback to influence ongoing behavior. xxi Closed-Loop System: A system in which real-time feedback is continuously adjusted based on sensor input, enabling dynamic interaction with the biological system. Correlation Matrix: A symmetric matrix showing pairwise correlations between neurons, often used to initialize or compare network structures. Delta-F over F0 (ÎF/F0): A measure of relative change in fluorescence, often used in calcium imaging to infer neural activity. DLC (DeepLabCut): A deep learning-based tool used to track animal body parts in behavioral experiments. DLC-Live: The real-time implementation of DeepLabCut that can be used for closed-loop experiments by providing real-time pose tracking. Excitatory Neurons: Neurons that increase the likelihood of firing in downstream neurons, often using glutamate as a neurotransmitter. GCaMP: A genetically encoded calcium indicator used for monitoring neural activity via fluorescence in vivo. xxii Graphics Processing Unit (GPU): A specialized hardware unit for accelerating neural network computations, especially for training large models in PyTorch. Hebbian Learning: A biological learning rule suggesting that synaptic strength increases when the presynaptic and postsynaptic neurons are activated together. Latency (in Feedback): Time delay between the event detection and the feedback delivery in a closed-loop system. Mesoscale Imaging: Calcium imaging at the scale of large brain areas, capturing the activity of neural populations across cortex. Multiview Tracking: A behavioral monitoring method that uses mirrors or multiple cameras to capture body part trajectories from different angles for 3D inference. Nvidia Jetson: NVIDIA Jetson is a platform with developer kits for creating AI products, AI learning, and more across all industries. Raspberry Pi: Small, compact, single-board computers (SBCs) capable of running Python-based real-time inference for closed-loop experiments, for our use case. xxiii Recurrent Neural Network (RNN): A class of artificial neural networks where connections between nodes form directed cycles, enabling modeling of temporal sequences. Somatostatin-Expressing (SST) Interneurons: Inhibitory neurons that often target dendrites and are associated with lateral inhibition and gain control. Spatiotemporal Motif: A recurring pattern in neural activity that has both spatial and temporal structure, often detected in calcium imaging data. Tensor: A multi-dimensional array used in PyTorch to represent data and model parameters. Two-Photon (2P) Imaging: A fluorescence microscopy technique that enables imaging of individual neurons with cellular resolution in vivo. Unimodal Distribution: A distribution with one peak or mode. For example, a centered unimodal distribution may indicate balanced excitatory/inhibitory input. Vasoactive Intestinal Peptide (VIP)-Expressing Interneurons: Inhibitory interneurons that often disinhibit pyramidal cells by inhibiting other inhibitory neurons, such as SST neurons. xxiv Weight Matrix (W): A matrix representing the strength of connections between units in a neural or artificial network. In trained RNNs, it reflects functional connectivity patterns. xxv Acknowledgements First and foremost, I would like to express my deepest gratitude to my supervisor, Prof. Timothy Murphy, for his unwavering support â both professionally and personally. His guidance has been instrumental in shaping my scientific thinking and encouraging guided exploration, creativity, and independence. Being part of his lab has not only equipped me with invaluable skills but also allowed me to form lifelong friendships and mentorships that I will always cherish. I am equally grateful to my supervisory committee: Prof. Lara Boyd, Prof. Jeremy Seamans, and Prof. Mark Cembrowski. Throughout my graduate journey, each of them provided thoughtful insights, critical feedback, and encouragement that kept me grounded and on track. Their expertise and advice helped me navigate many of the complex challenges I encountered. A heartfelt thank you to the past and present members of the Murphy Lab â an exceptional group of colleagues from whom I have learned so much. I am truly fortunate to have been part of this vibrant community. This work would not have been possible without the generous help of Pumin Wang, who supported surgical procedures, and Cindy Jiang, who expertly managed the animal colony, lab reagents, staining, and histology. Iâm also grateful to Jeff LeDue, Nicholas Michelson, and Jamie Boyd for their invaluable technical support over the years. I would like to thank Prof. Adrienne Fairhall at the University of Washington for her mentorship and for hosting me during a collaborative project in her lab. I am also thankful to the xxvi International Network for Bio-Inspired Computing (IN-BIC) AccelNet program for their generous support, and to UBCâs Dynamic Brain Circuits in Health and Disease Research Cluster for the opportunity to participate in the Databinge platform. This work was made possible through the support of the Canadian Institutes of Health Research (CIHR) foundation grant FDN-143209 and project grant PJT-180631, as well as resources from the Djavad Mowafaghian Centre for Brain Health. I also express my gratitude to Advanced Research Computing (ARC) at UBC for their computational resources. To my family and friends â thank you for being my constant support system. Iâm especially grateful to my father Bijali Prasad, my mother Pramila Devi, my brothers Manish Gupta and Deepak Gupta, and my close friend Tosif Ahamed for their encouragement, care, and belief in me through every stage of life who all have supported me both morally and financially. To my partner Nidhi Sah, thank you for your love, patience, and unwavering support. Finally, I respectfully acknowledge that this work was conducted at the University of British Columbia, which is located on the traditional, ancestral, and unceded territory of the Musqueam people. xxvii Dedication To dad1 Chapter 1: Introduction to closed-loop systems and shaping In systems neuroscience, especially when probing motor control, brain-computer interfaces, or neuromodulation, a closed-loop system is a feedback guided experimental setup where the brainâs output actively influences its future input. This enables self-regulating, adaptive interactions, akin to how natural sensorimotor systems operate (Zanos 2019; Belkacem et al. 2023; Moritz, Perlmutter, and Fetz 2008; Widge and Moritz 2014; Fetz 1969a). In a closedâloop system, target output (e.g., neural activity or behavior) is continuously monitored and used to adjust inputs in real time, creating a feedback loop between brain and stimulus delivery (Figure 1.1) (Zrenner et al. 2016; Levi et al. 2018). In contrast, in openâloop designs, stimuli are preprogrammed by the experimenter and ongoing activity does not affect future stimuli and the output remains independent of the input. Unlike open-loop approaches, which deliver the same stimulus irrespective of the ongoing activity, closed-loop systems can continuously monitor and adapt in real time. By doing so, they can be used to precisely alter neural activity based on behavioral or physiological feedback, creating a dynamic interaction between the brain and the experimental apparatus (Zanos 2019). By pairing continuous behavioral readouts with rapid neural perturbations, closed-loop systems offer a nuanced view of how the motor cortex orchestrates and refines skilled actions (Ethier et al. 2012; OâDoherty et al. 2011). Such approaches enable researchers to dissect the building blocks of motor control and kinematic primitives involved in behavior. Ultimately, closed-loop systems not only improve our understanding of normal motor function but can also 2 Figure 1.1 Schematic of a closedâloop neurofeedback (brainâcomputer interface) system. Neural activity is recorded from the brain (brain â computer device) and transmitted to an external computing unit, which processes and decodes it to generate control signals for an actuator (e.g. cursor or robotic device). The feedback of the movement (actuator â sensory feedback), which is perceived by the user via sensory feedback pathways (sensory feedback â brain), completing the loop. inspire targeted therapies and rehabilitative strategies for motor disorders (Guggenmos et al. 2013; Ethier et al. 2012). This paradigm enables shaping, a technique in behavioral psychology that reinforces incremental steps toward a desired action at the level of neural activity itself (McGreevy and Boakes 2011; Ferster and Skinner 1957). Such neural shaping allows the investigation of how animals learn to volitionally control specific brain circuits and how those circuits change during learning. In this thesis, I focus on two major areas of closed-loop neuroscience: (1) the design, implementation, and validation of a unified, open-source platform for closed-loop neurofeedback (CLNF) and closed-loop movement feedback (CLMF) in mice, called CLoPy (Gupta and Murphy 3 2025). This system leverages real-time brain imaging and pose estimation to deliver rapid feedback, allowing both neural and behavioral shaping in head-fixed animals. (2) the use of computational modeling to build modular recurrent neural networks (RNNs) to characterize cortical dynamics from large-scale imaging data. Together, these approaches offer a new window into features of brain-wide cortical activity and behavior. In the current chapter, I provide a general background on the closed-loop systems, their applications, and challenges, to lay motivation for this thesis work. 1.1 Overview of closed-loop systems Closed-loop systems are ubiquitous in engineering, biology, and computational sciences. In neuroscience, they are characterized by a cyclical structure: sensory input is captured, processed in real time, and used to modulate subsequent output or stimulation based on a preset rule (Fetz 1969a; Moritz, Perlmutter, and Fetz 2008). This fundamental cycleâSense â Analyze â Act â Sense Againâmirrors biological processes of error correction and motor planning (Cowan et al. 2014; El Hady 2016) and is key for understanding how the brain plans, executes, and refines complex movements (Belkacem et al. 2023; Zrenner et al. 2016). In brain-computer interface (BCI) applications, closed-loop systems have been used to analyse neural activity and directly translate it into control signals for external devices (Carmena et al. 2003; Ethier et al. 2012). These systems have seen success in both non-human primates and human patients, enabling prosthetic limb control and, more recently, rudimentary communication in locked-in patients (Willett et al. 2021). 4 In animal models, closed-loop systems allow temporally precise interventions, such as optogenetic stimulation or real-time feedback based on motion tracking, pupil size, or neural activity (Gupta and Murphy 2025; Grosenick, Marshel, and Deisseroth 2015; Zrenner et al. 2016). Closed-loop paradigms thus offer powerful tools for dissecting circuit function, understanding learning, and building translational systems for rehabilitation. 1.2 Historical context of closed-loop research in neuroscience Closed-loop neuroscience has roots in early BCI studies in non-human primates (Fetz 1969a; Moritz, Perlmutter, and Fetz 2008), where neuron-triggered feedback enabled animals to control a meter or audio. These early systems were technically challenging but proved that volitional control over brain activity was feasible and could be reinforced. By the early 2000s, closed-loop BCIs had advanced substantially, enabling primates to control robotic arms using neural signals from motor cortex (Carmena et al. 2003; Nicolelis 2001). These experiments proved that real-time decoding and feedback could be used to map neural activity to behavior in a causal loop. Similar paradigms were extended to humans with spinal cord injuries, restoring movement through neural decoding and prosthetic control (Hochberg et al. 2012; Pandarinath et al. 2017). In parallel, as recording and stimulation technologies improved, rodent research began adapting closed-loop methods to examine learning and neural circuit dynamics with increasing precision. The advent of optogenetics (Boyden et al. 2005) and high-resolution calcium imaging 5 (Tsien 1981; Grynkiewicz, Poenie, and Tsien 1985; Miyawaki et al. 1997; J. Nakai, Ohkura, and Imoto 2001; Tian et al. 2009; Akerboom et al. 2012; T.-W. Chen et al. 2013; Dana et al. 2019; Packer, Roska, and Häusser 2013; Clancy, Orsolic, and Mrsic-Flogel 2019; Grosenick, Marshel, and Deisseroth 2015; Karvat et al. 2020; Boyden et al. 2005) made it possible to observe and manipulate population activity at unprecedented spatial and temporal resolution. These tools allowed neuroscientists to build closed-loop systems that targeted defined cell types and cortical layers with precise temporal control using real-time photostimulation (Aravanis et al. 2007), electrical microstimulation (Zanos 2019), and calcium imaging (Prsa, Galiñanes, and Huber 2017; Clancy et al. 2014; Clancy and Mrsic-Flogel 2021; Gupta and Murphy 2025; Grosenick, Marshel, and Deisseroth 2015). The integration of open-source platforms (e.g., Bonsai (Lopes and Monteiro 2021), DeepLabCut (Kane et al. 2020; Forys et al. 2020)) further expanded accessibility, making closed-loop behavioral paradigms more widespread in systems neuroscience. 1.3 Applications in motor control and brain-computer interfaces (BCIs) Motor control is perhaps the most thoroughly studied domain in closed-loop research. A growing body of work suggests that complex movements are not produced as monolithic actions but are instead composed of smaller, stereotyped units of motion. These basic units, each with their own characteristic kinematic patterns, can be flexibly combined, scaled, and timed to generate diverse motor behaviors. This idea forms the basis of theories of motor primitives, which propose that such modular components serve as the building blocks of movement (Giszter 2015; Merel, Botvinick, and Wayne 2019), much like words or syllables in language. Everyday actions like 6 reaching for a glass of water or a rodentâs grooming sequence can be decomposed into these smaller, repeating elements (Miranda et al. 2018). For example, a mouse performing center-out forelimb reach tasks, or precisely controlled tongue licks, exhibits these primitives as identifiable, quantifiable kinematic components (Bollu et al. 2019). Using closed-loop feedback, researchers have shown that cortical regions contribute differentially to these primitives, with some modulating velocity (gain) and others timing or direction (Bollu et al. 2021). For instance, if a rodent undershoots a target when its motor cortex is photoinhibited at the exact moment of primitive generation, the immediate behavioral outcome informs us of how much that brain region contributes to the amplitude or velocity of the movement. Because closed-loop experiments are triggered at precisely controlled behavioral or neural states, they give clean insight into whether a particular neural circuit is responsible for initiating a primitive, sustaining it, or terminating it. In the forelimb research described, investigators found that cortical inactivation did not disrupt the overall timing or sequence composition of these primitives but instead uniformly reduced their maximum speed (Shadmehr 2017; Overduin et al. 2015; Stroud et al. 2018). This discovery directly supports the idea that cortical drive is essential for scaling the amplitude (or velocity âgainâ) of primitives, even if the brainstem or spinal circuits continue generating the fundamental structure. Such mechanistic insights are only possible with real-time, precisely timed interventionsâa hallmark of closed-loop methods. 7 1.4 Significance for motor learning in rehabilitation The integration of closed-loop systems into fundamental motor control research offers significant translational potential beyond basic neuroscience. At its core, motor learning is an iterative, feedback-driven process, where actions are shaped by ongoing sensory feedback and error signals, functions intrinsic to the learning mechanisms in the central nervous system (Shadmehr, Smith, and Krakauer 2010; Wolpert, Diedrichsen, and Flanagan 2011). Closed-loop experimental paradigms, which mimic this sensorimotor loop, allow researchers to dissect the mechanisms of error correction, adaptive plasticity, and motor refinement in a controlled setting (Clancy et al. 2014; Orsborn and Carmena 2013). This approach has profound implications for neurorehabilitation. For example, stroke or spinal cord injury often disrupts the brain's ability to engage in error-based learning, leading to persistent motor deficits. Closed-loop systems, such as brainâcomputer interfaces (BCIs) or activity-dependent neuromodulation, are now being investigated to reintroduce structured feedback during rehabilitation, thereby enhancing neuroplasticity and recovery (Marquez-Chin, Kapadia-Desai, and Kalsi-Ryan 2021; Tonin, Menegatti, and Coyle 2021; Cantillo-Negrete et al. 2025; Guggenmos et al. 2013; Allegra Mascaro et al. 2019; Conti et al. 2022). One of the key concepts emerging from both animal and human studies is the importance of movement scaling, which is the ability to appropriately adjust the amplitude and force of movement, and is often impaired in patients with motor dysfunction. Rodent studies using optogenetic and widefield imaging techniques have identified specific cortical circuits involved in 8 modulating movement gain (Musall et al. 2019; Salkoff et al. 2020). These findings suggest that targeted cortical stimulation (Conti et al. 2022), guided by real-time feedback, might help restore normal movement amplitude in humans. The translational relevance of these findings is supported by the work of Dr. Lara Boyd, who has extensively studied the neurobiological mechanisms of motor learning and recovery after stroke. Boyd's research emphasizes the individual variability in neuroplastic responses and the importance of task-specific, feedback-rich training protocols for maximizing recovery (Boyd et al. 2007; Boyd and Winstein 2004; Boyd, Vidoni, and Wessel 2010). Furthermore, real-time feedback systems are increasingly being incorporated into prosthetic and assistive technologies. For instance, adaptive prosthetic limbs that employ closed-loop feedback to adjust their movement in response to the userâs intent or residual muscle activity have shown promise in improving motor control, embodiment, and user satisfaction (Dosen et al. 2015; Antfolk et al. 2013). Such devices reduce the cognitive load and increase the sense of agency, enabling more naturalistic use. In sum, closed-loop systems not only provide a framework for probing the neural basis of motor control and learning but also pave the way for precision rehabilitation strategies. By incorporating findings from animal models, human neuroimaging, and individualized brain stimulation approaches, researchers are better equipped to design therapies that capitalize on neural plasticity to restore motor function (Allegra Mascaro et al. 2019; Conti et al. 2022). This convergence of basic and translational neuroscience offers a powerful avenue for improving the lives of individuals with motor impairments. 9 1.5 Advantages of closedâloop setups in neuroscience Closedâloop systems are increasingly central to neuroscience research and clinical neuroengineering because they try to leverage the brainâs natural feedback-driven dynamics. By continuously monitoring neural activity in the form of spikes, local field potentials, or imaging signals and adjusting stimulation in real time, these systems provide precise causal control over neural circuits, enabling researchers to link specific brain states to outcomes. This adaptive modulation is similar to real-world sensorimotor and cognitive environments (Farkhondeh Tale Navi et al. 2022), enhancing ethological validity and experimental rigor. In natural settings, organisms continuously adjust their behavior in response to moment-to-moment internal states and external stimuli. Closed-loop paradigms emulate this dynamic by allowing neural activity to influence ongoing feedback, thereby approximating the tight perception-action loops observed in ecological contexts. Moreover, by reinforcing or suppressing targeted neural activity, closedâloop designs actively engage neuroplastic mechanisms, supporting learning, rehabilitation, and circuit remodeling (Belkacem et al. 2023). Importantly, in therapeutic contexts like adaptive deep brain stimulation or responsive transcranial stimulation, this responsive feedback approach has demonstrated improved symptom control and reduced side effects compared to fixed openâloop interventions (Soleimani et al. 2023). 10 Closed-loop approaches provide distinct advantages over open-loop methods when investigating how the brain controls movement. One key benefit is the ability to implement real-time error correction. By continuously monitoring an animal's behavior, closed-loop systems can detect deviations from a desired trajectory or target and deliver corrective feedback immediately. This mimics the brainâs own capacity for error correction and adaptive control during movement execution (He et al. 2020; Sehara et al. 2021; Forys et al. 2020). Such dynamic feedback is particularly valuable for studying motor learning and how the nervous system responds to changing task demands. Another powerful advantage is the capacity for precise perturbations. In closed-loop designs, neural interventionsâsuch as optogenetic stimulation or inhibitionâcan be timed to occur during specific behavioral states or at defined kinematic thresholds. This level of precision enables researchers to causally dissect the contribution of specific neural circuits to discrete components or primitives of movement, such as reach initiation, grasp, or correction (Newman et al. 2015; Srinivasan et al. 2018; Gonzalez et al. 2024). As a result, closed-loop methods allow for highly targeted and temporally specific manipulation of neural activity, revealing mechanistic insights that are often inaccessible with traditional open-loop paradigms. These strengths make closed-loop paradigms particularly suitable for investigating the building blocks of movement (Bollu et al. 2024; Merel, Botvinick, and Wayne 2019). Within these frameworks, researchers can tease apart how speed, direction, and trajectory shapes emerge from modular components and how each component is affected by cortical inactivation or neural circuit manipulation. 11 1.6 Challenges in closedâloop neuroscience systems Closed-loop neuroscience systems face a complex array of challenges spanning signal acquisition, real-time data processing, stimulation delivery, artifact management, and overall loop architecture. At the core, selecting appropriate neural biomarkers such as spikes, LFPs, or behavioral metrics is critical yet difficult, especially in psychiatric or clinical contexts where signals predictive of symptom changes may not be well-defined (Soleimani et al. 2023; Lo and Widge 2017; Ganzer et al. 2018). Processing demands require ultraâlow latency algorithms and embedded hardware that can decode and respond to the neural state rapidly, while managing terabytes of data generated by high-density recordings (Z. S. Chen and Pesaran 2021). Delivering precise stimulation in the form of electrical, optogenetic, or sensory response poses spatial targeting challenges and raises issues such as scattering or inconsistent expression of opsins in optogenetics (Datta-Chaudhuri 2021). Stability over time, especially in chronic human implants, is often compromised by signal degradation, movement artifacts, and stimulation-induced interference; systems in nonhuman primates and rodents are less constrained but lack long-term stability concerns (Grani et al. 2022; Krook-Magnuson et al. 2015). The key challenges in the context of animal and human research are summarized in the table below. 12 Table 1.1 Challenges in closed-loop systems neuroscience Component Description Animal research Human research Signal detection Determine robust biomarkers (spikes, LFPs, fluorescence) Can be invasive, multiregional, cellular, richer but less generalizable and interpretable Clinical signals limited, stability and invasiveness checks, experimental biomarkers unavailable Processing and latency Real-time processing, low latency, on-board processing, increasing volumes of data and limited power supply Rigs based systems can process high channel data but miniaturization for implant is a challenge Implanted human devices limited by power, size, wireless constraints in addition to need for on-device processing Effectors / stimulation Precise targeting is prone to variability in channel placement, opsin expression, stimulation parameters, off-target activation Subcellular precision possible in animals but suffer from personalized targeting and variability in spatial spread of expression Human stimulation via electrodes or non-invasive modes lack cellular specificity, and artifact interference is very common Stability and artifacts Chronic implants degrade over time, recorded signals prone to movement or stimulation artifacts Rodent and non-human-primate implants exhibit relatively consistent signal quality Long-term human implants suffer electrode breakdown, tissue growth, signal decline, artifact overlap and mitigation strategies are an engineering challenge Loop design and observability The brain is partially observable and non-linear, behaviors are complex. Closed loop design can lead to differences in interpretability. Animal studies can implement embodied loops (e.g virtual) with complete control over variables. Human systems often rely on brain-state only loops, embodiment is limited, making real-world behavior integration and interpretation tough 13 1.7 Types of closed-loop designs Closed-loop systems in neuroscience have emerged as powerful tools for probing causal relationships between neural activity, behavior, and environmental context. These systems dynamically integrate neural signals or behavioral outputs with real-time feedback, enabling adaptive experimental paradigms that move beyond static or open-loop designs. Broadly, closed-loop systems can be classified into two major categories: brain-state-based (stateless) loops and behavior-environment-based (embodied) loops (Zrenner et al. 2016). In brain-state-based or stateless loops, feedback or stimulation is delivered directly in response to specific features of ongoing neural activity. These systems do not take into account previous neural history or behavioral context, instead operating on instantaneous signals. A prominent example includes triggering transcranial magnetic stimulation (TMS) pulses based on phase or amplitude of an EEG oscillation (Bergmann et al. 2012), or delivering optogenetic stimulation in rodents when calcium signals from specific neuronal populations cross a threshold (Clancy et al. 2014; Grosenick, Marshel, and Deisseroth 2015; Prsa, Galiñanes, and Huber 2017). Such designs have been crucial in testing hypotheses about oscillatory phase-dependent plasticity, attention, and motor preparation (Thut et al. 2017; Siegle and Wilson 2014). They are often employed in clinical brain-computer interface (BCI) applications, where real-time decoding of neural patterns enables assistive communication or control (Wolpaw et al. 2002; Schalk et al. 2004; Hochberg et al. 2006, 2012). 14 In contrast, behavior-environment-based or embodied loops incorporate not only neural signals but also the animal's behavior and its interaction with the environment. Here, the brain is embedded in a feedback-rich sensory context, and actions taken by the animal influence sensory inputs that further shape future actions. This loop structure captures the inherently dynamic and reciprocal relationship between the nervous system and its surroundings (Clark 1998; OâRegan and Noë 2001). For instance, virtual reality (VR) environments where animals navigate and receive sensory consequences based on movement (Harvey et al. 2009; Dombeck et al. 2010), or real-world behavioral setups where neural signals modulate the environment in real time (Fiser et al. 2016; Pinto et al. 2019), represent this design. These systems are particularly well-suited for studying learning, decision-making, and sensorimotor integration under naturalistic conditions (Krakauer et al. 2017; Buonomano and Maass 2009). Overall, the distinction between stateless and embodied closed-loop systems underscores differing experimental philosophies: one seeks to probe isolated causal mechanisms by controlling neural activity in tightly defined settings, while the other embraces the complex, time-evolving nature of neural control over behavior. Both approaches have contributed profoundly to our understanding of brain function, and the line between them is increasingly blurred in modern experimental paradigms that integrate real-time neural decoding, adaptive control, and behaviorally contingent feedback (Carmena et al. 2003). The closed-loop setup in this study is an embodied system where neural as well as behavioral feedback is given via an auditory sensory modality. 15 1.8 Neurofeedback and movement feedback in rodents In rodents, closed-loop paradigms have been employed to investigate the role of sensorimotor cortex in skill learning (Koralek et al. 2012), decision-making (Erlich et al. 2015), and neural adaptation (Clancy et al. 2014). Most studies used real-time analysis of neural activity âstatelessâ via electrophysiology or calcium imaging to trigger contingent feedback (e.g., reward delivery, light stimulation). Neurofeedback involves mapping neural signals to a controllable feedback modality (like sound), which animals learn to modulate. Movement feedback (embodied) systems instead monitor behavior using real-time pose estimation and reward specific motor outputs. These approaches allow researchers to dissect brain-behavior relationships and adaptation mechanisms with fine-grained control. Our work built upon these developments to implement and test a âdual-mode closed-loop systemâ (neurofeedback + movement feedback) using widefield calcium imaging and real-time behavioral tracking. We demonstrated that mice could learn to modulate activity in specified cortical regions or adjust motor outputs (e.g., forelimb movements) based on feedback, and thereby validating the framework for studies of cortical dynamics and motor learning. 1.9 Shaping in mice: Behavioral conditioning and training paradigms Shaping refers to the gradual training of complex behavior by positively reinforcing incremental steps (McGreevy and Boakes 2011; Staddon 2016; Fetz 1969a). In rodent research, this technique 16 is widely used for operant conditioning, skilled reaching, and sensorimotor learning (Crawley 2007; Zeiler and Krakauer 2013). With closed-loop systems, shaping extends beyond overt behavior to internal states such as specific patterns of neural activation. For example, in closed-loop neurofeedback, mice can be trained to increase activity in a particular cortical area, guided by real-time feedback (Ganguly and Carmena 2009; Clancy et al. 2014; Prsa, Galiñanes, and Huber 2017; Gupta and Murphy 2025). Similarly, movement shaping via closed-loop feedback enables animals to learn forelimb or facial movements in response to cues, tracked by pose estimation tools (Forys et al. 2020; Kane et al. 2020; Lopes and Monteiro 2021). In our system, shaping was essential for both the neurofeedback and movement feedback paradigms. Mice were gradually introduced to task contingencies and feedback rules. Our results show that shaping with real-time, graded auditory feedback results in faster learning and more reliable performance in motor training tasks. In this thesis, I expand the concept of shaping to both movement and cortical activity, demonstrating that mice can flexibly learn and adapt to dynamic rules, with rapid feedback driving both forms of plasticity. 1.9.1 Key factors influencing shaping success Shaping behavioral responses in animals is a fundamental component of operant conditioning and requires careful consideration of multiple interdependent factors. One of the most crucial elements is the reinforcement schedule, which dictates both the timing and type of reinforcement used to 17 guide behavior. In the initial stages of shaping, continuous reinforcement, where a reward is provided after every correct behavior, is highly effective in establishing the desired response. Over time, this is typically transitioned to partial or intermittent reinforcement, which not only strengthens the learned behavior but also increases its resistance to extinction (Ferster and Skinner 1957; Skinner 1990). The nature of the reinforcement itself, whether as a primary reinforcer like food or water, or a more advanced method like optogenetic stimulation of reward pathways, can significantly influence learning efficiency (S.-Y. Kim et al. 2013; Witten et al. 2010). Another central factor is task complexity. Effective shaping relies on the principle of successive approximations, where the animal is rewarded for behaviors that increasingly resemble the target action. Gradually increasing task difficulty ensures that each step is achievable and that the animal can form a clear association between its actions and the outcome. If the transition between steps is too abrupt or challenging, animals may fail to make the appropriate connection, resulting in confusion, frustration, or even extinction of the behavior (Miltenberger 2001; Izquierdo and Belcher 2012). Well-structured shaping protocols thus require careful calibration of task demands to maintain engagement and learning momentum. Motivation is also a vital determinant of shaping success. In rodent models, animals are often placed under mild food or water restriction prior to behavioral training to elevate their motivation to perform the task for a reward. While this method is effective in enhancing task engagement, it must be balanced with ethical considerations to ensure that animals do not suffer from excessive deprivation. Guidelines for ethical animal use stress the importance of maintaining minimal thresholds for body weight 18 and hydration, as well as providing ample recovery time between sessions (Toth and Gardiner 2000; National Research Council et al. 2011). Lastly, individual variability plays a significant role in shaping outcomes. Factors such as baseline behavioral activity levels, stress responsiveness, cognitive flexibility, and innate temperament can differ widely between animals, even within the same strain. These differences can influence how quickly an animal learns a task or how consistently it performs over time. As such, personalized or adaptive training paradigms may be necessary to accommodate slower learners or animals with higher anxiety levels (Crawley 2007; Wahlsten et al. 2003; Sorge et al. 2014). Monitoring behavioral and physiological indicators throughout training can help optimize protocols for each individual subject. Shaping remains a key part of behavioral training and research in mice, enabling researchers to study a wide range of cognitive, motor, and neural processes. Its applications span diverse fields, from basic neuroscience to translational research on neurological disorders. Despite recent advances in automation and neurofeedback, these processes need further characterization and wider accessibility of these tools can further expand its utility in modern neuroscience. 1.10 Future Directions and Emerging Technologies As closed-loop systems continue to evolve, emerging technologies are poised to expand their scope and precision in neuroscience research. Advanced imaging and sensing tools such as two-photon microscopy (Yu et al. 2021; Bouchard et al. 2015; Hontani, Xia, and Xu 2021), miniature head-19 mounted microscopes (Skocek et al. 2018; Aharoni and Hoogland 2019; Zong et al. 2022), and large-scale electrophysiological electrode arrays (Jun et al. 2017; Steinmetz et al. 2021), paired with advances in brain stimulation methods and genetic engineering approaches for optical stimulation can be integrated into closed-loop pipelines to enable real-time monitoring and manipulation of neural activity at cellular resolution. These approaches promise to couple neural population imaging with immediate behavioral feedback, opening new frontiers in systems neuroscience. Concurrently, machine learning algorithms, particularly deep neural networks, have already demonstrated their ability to extract subtle features from movement kinematics, such as tongue and limb motions. Future closed-loop frameworks will likely incorporate more advanced models capable of inferring movement intent directly from neural signals before overt action occurs, paving the way for anticipatory feedback systems. The range of behavioral paradigms is also expanding beyond simple forelimb or licking tasks, closed-loop designs may soon incorporate whisker-based sensing, trunk dynamics, or coordinated multi-limb movements. These more complex tasks will allow researchers to probe whether motor primitives are conserved across different effectors and action sequences. Importantly, while rodent models continue to yield fundamental insights, translating these closed-loop paradigms to human contexts remains a critical goal. This transition may involve adapting rodent-based technologies such as high-speed tracking and online neural modulation to noninvasive or minimally invasive platforms suitable for humans, including transcranial magnetic stimulation or focused ultrasound, coupled with motion capture systems and wearable sensors. Together, these technological and conceptual innovations promise to deepen our understanding of motor control and enable new avenues for clinical translation. 20 1.11 Widefield Calcium imaging Widefield calcium imaging is a powerful mesoscale optical imaging technique that enables simultaneous monitoring of neural activity across large portions of the brain, particularly the cortex. It relies on genetically encoded calcium indicators (GECIs), such as GCaMP6 variants, which fluoresce upon binding to intracellular calcium, a signal that increases during neuronal firing (action potentials). In this approach, the recorded fluorescence arises predominantly from the apical dendrites and somas of neurons in superficial cortical layers, and by summing the signals from many such neurons within each pixel, widefield imaging provides a spatially resolved readout of population-level neural activity. While this technique is most commonly associated with imaging the dorsal surface of the cortex, its utility spans a broad range of applications. It has been employed to study large-scale network dynamics during sensory processing, decision-making, learning, and motor control. Widefield imaging can also be used to map functional connectivity across cortical areas, monitor brain-wide state transitions (e.g., sleepâwake cycles), and probe interhemispheric interactions. With adaptations, it can even be applied to image subcortical structures, cerebellar circuits, or hemodynamic responses when paired with dual-wavelength or transcranial imaging approaches. Its high temporal resolution and broad spatial coverage make it particularly suited for studying mesoscale dynamics that bridge single-cell and whole-brain levels of analysis. 21 In our experiments, we used widefield calcium imaging to monitor cortical activity in awake, head-fixed mice expressing the GCaMP6s indicator. To ensure cell-type specificity, GCaMP6s expression was driven in excitatory pyramidal neurons via a transgenic mouse line tetO-GCaMP6s x CAMK tTA (Wekselblatt et al. 2016). We chronically implanted a transparent cranial window over the dorsal cortex, allowing repeated access to the same regions across multiple sessions. The imaging system was built around a tandem-lens macroscope configuration optimized for calcium imaging in rodents, based on designs from the Murphy lab and others (Silasi et al. 2016; Hillman 2007). Excitation light (~470 nm) was delivered via high-power LEDs, and emitted fluorescence (~525 nm) was collected through long-pass and band-pass filters. A high-speed, high-sensitivity camera captured the emitted signal at frame rates of 15â30 Hz, providing a spatial resolution of ~50â100 µm per pixel. This setup allowed us to capture real-time cortical dynamics bilaterally, enabling us to link behavior and neural activity at the mesoscale with high temporal fidelity. A crucial consideration in widefield imaging is the presence of hemodynamic and autofluorescence signals, which can contaminate the calcium-dependent fluorescence. To address this, we employed dual-wavelength illumination and regression-based correction methods to isolate the calcium-related signal from vascular artifacts (Ma et al. 2016; Wekselblatt et al. 2016). Briefly, imaging was performed simultaneously with a calcium-sensitive (470 nm) and an isosbestic (447 nm) wavelength. The 447 nm signal, which reflects hemodynamic changes but not calcium dynamics, was used to regress out global and regional hemodynamic fluctuations from the calcium-dependent signal. Data were acquired and preprocessed using custom software in Python, which included motion correction, temporal detrending, and normalization (ÎF/F0). 22 Regions of interest (ROIs) spanning anatomically defined cortical areas (e.g., M1, S1, V1) were identified using landmarks or standard brain atlases (Allen CCF). Temporal activity traces were extracted from these ROIs for further analysis of cortical dynamics, behavior coupling, and inter-regional interactions (Gupta and Murphy 2025). Widefield calcium imaging offers several advantages over local recording methods: it provides a large field of view, allows observation of bilateral interactions, and is minimally invasive after initial window implantation. These properties make it particularly suitable for studies of sensorimotor integration, state transitions, and large-scale network dynamics during behavior. 1.12 Optical Calcium imaging and real-time widefield imaging in mice Optical calcium imaging has revolutionized in vivo neuroscience, allowing researchers to visualize large-scale neural population activity with cell-type specificity. Genetically encoded calcium indicators (e.g., GCaMP6) provide a fluorescent readout of neural activity, and can be targeted to specific neuron classes such as excitatory pyramidal cells or interneuron subtypes (Dana et al. 2014; Silasi et al. 2016; Wekselblatt et al. 2016; T.-W. Chen et al. 2013). When combined with widefield imaging, these indicators allow mesoscale readout of cortical population dynamics at high temporal resolution (~10â30 Hz) in head-fixed mice (Vanni and Murphy 2014; Wekselblatt et al. 2016). This method captures activity across multiple brain areas, making it ideal for studying inter-regional coordination during behavior (Makino et al. 2017; de Vries et al. 2019). Widefield calcium imaging provides an advantageous platform for closed-loop systems due to its unique combination of broad spatial coverage and fast acquisition speed, enabling real-time feedback 23 driven by distributed cortical activity. This modality offers several key benefits over traditional approaches such as electrophysiology, including a large field of view that spans multiple cortical areas, minimal invasiveness, and the ability to perform stable, long-term recordings essential for learning paradigms. Additionally, widefield imaging is well suited to head-fixed behavioral paradigms and sensory stimulation, making it ideal for integrative neuroscience studies. To leverage these advantages, we developed a real-time widefield imaging system termed âCLoPyâ (Gupta and Murphy 2025)âcapable of delivering auditory feedback based on neural signals extracted from one or two user-defined cortical regions of interest (ROIs). The system achieved a closed-loop latency of approximately 63-67 milliseconds from data acquisition to feedback delivery, allowing for high-speed, dynamic interaction between cortical activity and most behavioral outputs. 1.13 The CLoPy platform: Closed-loop neurofeedback and movement feedback In this thesis, I present CLoPy (Closed Loop in Python), a flexible and open-source platform for real-time feedback experiments in head-fixed mice. CLoPy is designed to interface with widefield calcium imaging and pose estimation systems, providing ~63-67 ms feedback latency via varying audio tones. In the closed-loop neurofeedback (CLNF) mode, mice receive feedback based on fluorescence signals in a target region of interest (ROI). The GCaMP6s (T.-W. Chen et al. 2013) fluorescence signal itself has inherent delay that arises from several biophysical and optical processes, and is different from the feedback latency mentioned above. In the closed-loop movement feedback (CLMF) mode, feedback is tied to movement parameters such as forelimb 24 speed, extracted via DeepLabCut -Live (Kane et al. 2020) These dual modalities enable both neural and behavioral shaping within the same platform. Over several days of training, mice learn to increase cortical activity in target ROIs or perform specific movements to earn rewards. They also demonstrate rapid adaptation to rule switches, such as changing the rewarded ROI or the trained body part. These findings show that both cortical and behavioral strategies can be flexibly modulated with closed-loop feedback. 1.14 Modeling multi-region cortical dynamics 1.14.1 Need for data-constrained modeling With the emergence of large-scale datasets (e.g., Allen Instituteâs Visual Behavior 2P, or VB2P), computational models are now essential to interpret complex, high-dimensional neural data. Traditional analyses often fall short in capturing the temporal and spatial dynamics across multiple brain regions (de Vries et al. 2019). Recurrent neural networks (RNNs) are a class of dynamical systems well-suited to model time-varying neural activity. When properly constrained by data, RNNs can be used to infer directional circuit connectivity, directional stimulus-evoked responses, and explore how inter-regional communication supports behavior (Yang and Wang 2020; Mante et al. 2013). 1.14.2 RNN modeling approach We developed a modular, data-constrained RNN architecture termed âCorNetâ. It is built on the principle of biologically inspired architectural constraints, where each subpopulation of recurrent 25 units represents a distinct cortical area. A key feature of the model is the initialization of recurrent weights using normalized correlation matrices derived from empirical recordings. This correlation-based initialization helps the model start with biologically plausible connectivity, enabling faster and more accurate convergence during training. Training of CorNet is performed using backpropagation through time (BPTT) and optimized via GPU acceleration in the PyTorch deep learning framework. The model is flexible and generalizable, capable of handling a variety of datasets, including two-photon calcium imaging data from the Allen Instituteâs Visual Behavior 2-Photon (VB2P) dataset (M. Garrett et al. 2020) as well as our own mesoscale widefield calcium imaging collected during CLMF (Gupta and Murphy 2025) tasks. This compatibility allows CorNet to bridge across modalities and resolutions of neural data. Similar data-driven RNN-based approaches have been employed in recent years to model latent neural dynamics and infer functional interactions, such as LFADS (Latent Factor Analysis via Dynamical Systems) (Pandarinath et al. 2018), which uses variational autoencoders to capture latent neural trajectories, and Neural Data Transformers (Chau et al. 2025; Ye et al. 2023), which apply transformer architectures to neural time series. Additionally, frameworks like CURBD (Perich et al. 2020) aim to reconstruct recurrent dynamics using constrained unit-wise parameterizations, though our model extends this line of work by incorporating modular spatial priors and more flexible recurrent connectivity patterns. Through the CorNet framework, we aim to uncover not only the population dynamics underlying cortical processing during behavior but also infer directed, region-specific functional interactions. The modular structure of the model 26 lends itself well to neuroscientific interpretability and facilitates comparisons across different cell types, cortical areas, and behavioral contexts. 1.15 Significance and broader implications of this study This thesis presents an integrated experimental and computational framework that advances the study of brain-behavior dynamics in rodents through both closed-loop control and interpretable modeling. At the experimental level, we developed and validated CLoPy (Gupta and Murphy 2025), a flexible, cost-effective, and open-source platform for conducting real-time closed-loop experiments in head-fixed mice. This system enables precise training and feedback based on either mesoscale cortical activity or multi-view body movements, expanding the scope of real-time feedback paradigms beyond traditional motor control tasks. Importantly, our work demonstrates that rodents can volitionally control both cortical activity and behavior in response to temporally precise feedback and can adapt rapidly to changes in task rules. This behavioral flexibility provides a unique window into how neural circuits reorganize in response to changing environmental contingencies. The implications of this system extend beyond behavioral training. By establishing a modular interface for closed-loop feedback, CLoPy enables diverse experimental paradigms aimed at probing mechanisms of neuroplasticity, motor learning, and sensorimotor integration. Furthermore, the systemâs compatibility with low-cost, GPU-based devices such as the Raspberry Pi and Nvidia Jetson makes it widely accessible for use in both basic and translational neuroscience settings. These advances provide a foundation for scalable, reproducible investigations into brain-27 behavior coupling, with potential applications in adaptive neurotechnologies and neurorehabilitation. On the computational side, this thesis introduces CorNet, a modular recurrent neural network (RNN) framework designed to model multi-region neural population dynamics in a data-constrained and interpretable manner. CorNet incorporates biologically meaningful priors by initializing network weights using normalized correlation matrices derived from real neural recordings. The architecture supports modular subpopulations corresponding to distinct cortical areas and is trained using GPU-accelerated backpropagation through time. Unlike purely data-driven models, CorNet is designed to be interpretable and extensible, enabling the inference of directional functional interactions between neural populations during behavior. We demonstrate the utility of CorNet across diverse neural datasets, including validation employing simulation data, two-photon recordings from VB2P (M. Garrett et al. 2020)and our own widefield calcium imaging data from CLMF experiments (Gupta and Murphy 2025). This integrative approachâcombining real-time behaviorally contingent manipulation of cortical activity with interpretable computational modeling bridges the gap between systems neuroscience and machine learning. By enabling the simultaneous shaping and modeling of neural activity, our work lays the groundwork for future studies of how neural circuits give rise to flexible behavior. Moreover, our results highlight the importance of feedback-driven plasticity in shaping cortical dynamics and underscore the role of inhibitory subtypes such as SST and VIP interneurons 28 in structuring inter-regional interactions. Together, these contributions advance our understanding of cortical interactions and provide tools for studying the neural basis of adaptive behavior in a closed-loop framework. 1.16 Thesis outline This thesis is structured as follows: 1.16.1 Chapter 1: Introduction This chapter introduces the concept of closed-loop systems in neuroscience, outlining their historical development, core principles, and recent technological advancements. It explores how these systems have been applied in brain-computer interface (BCI) research in both humans and animals, with a particular focus on rodent models. It also describes real-time mesoscale optical imaging techniques, especially widefield calcium imaging, and discusses how they facilitate closed-loop experimentation. The chapter concludes by identifying current limitations in the field and how this thesis addresses them through novel experimental platforms and computational modeling. 1.16.2 Chapter 2: Platform for closed-loop neurofeedback and movement feedback This chapter describes the development and validation of the CLoPy (Closed-Loop in Python) systemâan open-source, real-time feedback platform integrating widefield calcium imaging and behavior tracking in head-fixed mice. It covers the experimental design for both neurofeedback (CLNF) and movement feedback (CLMF) tasks, detailing the hardware, software, and control 29 logic of the closed-loop system. Results from behavioral shaping, adaptation to task rules, cortical activity changes, and performance metrics are reported. The chapter demonstrates how mice can learn to modulate either brain activity or movement using real-time auditory feedback. 1.16.3 Chapter 3: Modelling multi-region cortical interactions using data-constrained recurrent neural networks This chapter introduces a biologically inspired, modular recurrent neural network (RNN) framework designed to model multiregional cortical dynamics. The model is initialized using neural correlation structure and trained using backpropagation to replicate observed neural activity patterns. Data from both the Allen Instituteâs VB2P dataset and the CLMF experiments are used to constrain and test the model. Analyses include training convergence, comparison across genetically defined cell types, and phase-shift detection in trial-aligned responses. The chapter also explores functional connectivity changes during task performance using simulated inputs across cortical regions. 1.16.4 Chapter 4: Conclusion and future work This chapter summarizes the main findings of the thesis and highlights the contributions made to experimental neuroscience and computational modeling. It discusses the implications of closed-loop feedback on cortical plasticity and the utility of modular RNNs in modeling mesoscale dynamics. Future directions include scaling the CLoPy system for multi-animal and homecage setups, incorporating richer behavior and stimulus paradigms, enhancing model interpretability, 30 and translating insights from mice to higher-order organisms or clinical applications in neurorehabilitation. 31 Chapter 2: Platform for closed-loop neurofeedback and movement feedback 2.1 Introduction In neuroscience, brain activity and behavior are often studied as separate entities that do not interact in real time. Assessments are typically performed post hoc, and experimental designs rarely incorporate dynamic feedback based on ongoing neural activity. In contrast, closed-loop systems provide a framework where real-time interaction occurs between the brain, subject, and goal-directed outcomes, enabling precise modulation of neural and behavioral dynamics (Clancy et al. 2014). First introduced in the pioneering work of (Fetz 1969b), closed-loop feedback has since demonstrated significant potential in understanding and modulating brain-behavior relationships. There has been recent interest in its application to rodent models (Clancy and Mrsic-Flogel 2021; Clancy et al. 2014; Prsa, Galiñanes, and Huber 2017; Srinivasan et al. 2018; Knudsen and Wallis 2020; Paz et al. 2013; Ching et al. 2013; Rosin et al. 2011; Widge and Moritz 2014; Sun et al. 2022). Some related studies have demonstrated the feasibility of closed-loop feedback in rodents, including hippocampal electrical feedback to disrupt memory consolidation (Girardeau et al. 2009), optogenetic perturbations of somatosensory circuits during behavior (OâConnor et al. 2013), and more recent advances employing targeted optogenetic interventions to guide behavior (Abbasi et al. 2023). Opportunities also exist in extending real time pose classification (Forys et al. 2020; Kane et al. 2020) and movement perturbation (M. W. Mathis, Mathis, and Uchida 2017) to shape aspects of an animalâs motor repertoire. This gap is due, in part, to technical challenges such as the need for low-latency data acquisition and processing, compact, open-source and 32 portable hardware, and seamless integration with animal behavior. Moreover, the inherent complexity of rodent neurophysiology and behavior (e.g., undesired movements, variability in neural signals, and behavioral metrics) further complicates the implementation of closed-loop paradigms. Closed-loop systems are particularly promising for addressing critical questions in systems neuroscience, such as how brain activity dynamically adapts to feedback or how neural circuits reorganize during motor learning and recovery. Recent advancements, such as genetically encoded calcium indicators and mesoscopic imaging, have opened new avenues for studying these phenomena (Clancy and Mrsic-Flogel 2021; Clancy et al. 2014; Prsa, Galiñanes, and Huber 2017). However, many of the available closed-loop systems remain technically complex, expensive, or inaccessible to labs with limited resources. Additionally, most existing platforms focus on narrowly defined use cases, limiting their adaptability to diverse experimental paradigms. Nevertheless, recent work has demonstrated behavioral control through feedback, such as in (M. W. Mathis, Mathis, and Uchida 2017), where mice learned to pull a joystick to a target and adapt this motion under force perturbations. To address these gaps, we present CLoPy - a flexible, cost-effective, and open-source Python-based platform for closed-loop feedback experiments in neuroscience. CLoPy integrates real-time data acquisition, processing, and feedback delivery, providing researchers with a robust tool to study dynamic brain-behavior interactions in head-fixed mice. The platform supports two 33 Figure 2.1 Setup of real-time feedback for GCaMP6 cortical activity and movements A) GCaMP-based Closed-loop Feedback and Reward System: Mice expressing GCaMP6, with surgically implanted transcranial windows and a head-bar, were positioned beneath the imaging camera, with GCaMP6 excitation light at 470 nm. A secondary wavelength of 440 nm was used 34 for continuous reflectance signals to measure hemodynamic changes, which were then applied to correct the fluorescence signal. The RGB camera was equipped with bandpass filters that allowed only 520 nm epifluorescence and 440 nm reflectance to be simultaneously collected. i) Mice with transcranial windows were head-fixed beneath an imaging camera, with the cortical window illuminated using 440 nm (for reflectance signal used for hemodynamic correction) and 470 nm (for GCaMP excitation) light. Epifluorescence at 520 nm and reflectance at 440 nm were captured at 15 fps using a bandpass filter, integrated within the cortical imaging system. ii) The captured images were simultaneously saved and processed to compute ÎF/F0 in real-time using a Raspberry Pi 4B model. Pre-selected regions of interest (ROIs) were continuously monitored, and rule-specific activation was calculated based on the ÎF/F0 signal. The left panel displayed wide-field cortical GCaMP6 fluorescence (green) and reflectance (blue), while the right panel showed the real-time calculated and corrected ÎF/F0 map, generated using a moving average of the captured images. The target ROIs were marked as green (R1) and red (R2), although a single ROI could also be selected for monitoring. iii) For example, as shown on the ÎF/F0 map, ROIs R1 and R2 were continuously monitored, and the average activity across these ROIs was calculated. iv) When the task rule was defined as âR1 - R2 > thresholdâ, the difference between R1 and R2 activities was mapped to a non-linear function that generated graded audio tone frequencies (ranging from 1 kHz to 22 kHz), as illustrated in the figure. Task rules could be modified within the setup on any given day, and the corresponding activation levels were automatically mapped to the audio frequencies. The "threshold", expressed in ÎF/F0 units as a percent change, was adjustable based 35 on the experimental design. v) Upon reaching the rule-specific threshold for activity, in addition to the increase in audio tone frequency, a water reward was delivered to the head-fixed mouse. B) Closed-loop Behavior Feedback and Reward Setup: A specialized transparent head-fixation chamber was custom-designed using 3mm-thick plexiglass material (3D model available on GitHub link below) to enable multi-view behavioral imaging and real-time tracking of body parts. The rectangular chamber was equipped with two strategically positioned mirrorsâone at the bottom, angled at 45 degrees, and one at the front, angled at 30 degreesâfacilitating multi-view imaging of the head-fixed mouse with a single camera. i) A Dalsa CCD camera was connected to a PC for widefield cortical imaging during the session. An additional camera connected to a PC with a GPU was used to capture the behavior video stream of the headfixed mouse. ii) Video frames of the behavior were processed in real-time on a GPU (Nvidia Jetson Orin), which tracked the body parts using a custom trained DeepLabCut-Live(Kane et al. 2020) model. iii) Auditory feedback was provided using a non-linear function mapping paw speeds to corresponding audio tone frequencies. iv) The head-fixed mouse, positioned in the transparent chamber, was able to freely move its body parts, while its behavior was continuously recorded. This setup allowed for the capture of three distinct views of the mouseâside, front, and bottom profilesâand enabled the real-time tracking of multiple body parts, including the snout, left and right forelimbs, left and right hindlimbs, and the base of the tail. 36 modes of graded feedback: (1) Closed-Loop Neurofeedback (CLNF), which derives feedback from neuronal activity, and (2) Closed-Loop Movement Feedback (CLMF), which bases feedback on observed body movements. By combining genetically encoded calcium imaging with behavioral tracking, CLoPy enables researchers to explore questions such as how cortical dynamics contribute to motor learning or how feedback modulates neural plasticity in neurological models. Crucially, CLoPy is designed with accessibility and versatility in mind. The platform utilizes widely available hardware, including Raspberry Pi and Nvidia Jetson, and leverages Python-based open-source software libraries. These features make CLoPy an ideal resource for the broader open-source neuroscience community, particularly for labs seeking to implement closed-loop systems without substantial financial or technical barriers. Furthermore, CLoPy's modular design allows researchers to adapt it for a wide range of experimental paradigms, from studying cortical reorganization during motor learning to investigating sensory feedback mechanisms. By framing CLoPy within the context of accessible, open-source neuroscience tools, we aim to broaden its impact and utility across the systems neuroscience community. In this study, we demonstrate the implementation and efficacy of CLoPy in head-fixed mice (Figure 2.1), showcasing its ability to deliver precise, low-latency feedback. We provide all software, hardware schematics, and protocols necessary for its adaptation to various experimental scenarios, positioning CLoPy as a valuable tool for advancing closed-loop neuroscience research. Table 2.1 summarizes the main features of existing closed-loop systems for rodent experiments, highlighting the unique capabilities of our platform. 37 Table 2.1 Comparison of CLoPy with existing open-source and commercial closed-loop feedback systems System Open? Modalities Capability Latency Hardware / software Cost Strengths Limitations CLoPy (this work) â Yes Widefield Ca²âº imaging, DeepLabCut- behavior tracking, auditory feedback, GPIO Real-time closed-loop imaging + behavior; graded auditory feedback â30â67 ms (Pi/Jetson) Python (OpenCV, DLC-live, NumPy), Raspberry Pi 4 / Jetson GPU LowâMedium (<$3 k) Optical imaging; flexible; inexpensive; easy to extend Latency varies with hardware; limited vendor support Open Ephys (Siegle et al. 2017) â Yes Multichannel electrophysiology Real-time event detection + stimulation via plugins Low msâtens ms Acquisition boards + C++/Python plugins LowâMedium Mature community; plugin ecosystem Limited optical imaging integration Bonsai (Lopes et al. 2015) â Yes Cameras, audio, DAQ, sensors Event based real-time processing Tensâ100 ms Visual data flow (.NET) Medium Rapid prototyping for video + sensor tasks Limited GPU/deep-model integration 38 System Open? Modalities Capability Latency Hardware / software Cost Strengths Limitations pyControl (Akam et al. 2022) â Yes Behavioral task I/O Microcontroller-based closed-loop behavior Sub-msâms MicroPython controllers + PC GUI Medium Deterministic timing; simple hardware Not suited for high-dim imaging NeuroRighter (Newman et al. 2012) â Yes Electrophysiology + stimulation Real-time multichannel stimulation msâtens ms Custom hardware + software suite LowâMedium Proven closed-loop stim; low cost Electrical focus only TDT (Tucker-Davis Technologies, n.d.) â No Electrophysiology Real-time closed-loop Sub-msâms Dedicated DSPs + Synapse GUI High (>$25 k) Industrial-grade, robust, supported Proprietary; expensive Blackrock Neurotech â No Clinical/research electrophysiology Real-time neural decoding + stim Sub-msâms Integrated hardware/software High (>$30 k) Clinical reliability, support Closed ecosystem 39 2.2 Methods 2.2.1 Animals Mouse protocols were approved by the University of British Columbia Animal Care Committee (ACC) and followed the Canadian Council on Animal Care and Use guidelines (protocol A22-0054). A total of 56 mice (postnatal 104-140) were used in this study: 26 female and 30 male transgenic C57BL/6 mice expressing GCaMP6s were used. CLNF experiments (n=40, 17 females, 23 males) were done with tetO-GCaMP6s x CAMK tTA (Wekselblatt et al. 2016), and CLMF experiments (n=16, 9 females, 7 males) were done with Ai94 from the Allen Institute for Brain Science, crossed to Emx1âcre and CaMK2-tTA line (Jackson Labs) (Madisen et al. 2015). Mice were housed in a conventional facility in plastic cages with micro-isolator tops and kept on a normal 12 hr. light cycle with lights on at 7 AM. Most experiments were performed toward the end of the mouse light cycle. Mice that were unable to achieve a success rate of 70% after 7 days of training in CLNF experiments were excluded from the study (total 6 mice). 2.2.2 Animal surgery, chronic transcranial window preparation Animals were anesthetized with isoflurane, and a transcranial window was installed as previously described (Silasi et al. 2016; Vanni and Murphy 2014) and in an amended and more extensive protocol described here. A sterile field was created by placing a surgical drape over the previously cleaned surgical table, and surgical instruments were sterilized with a hot bead sterilizer for 20 s (Fine Science Tools; Model 18000â45). Mice were anesthetized with isoflurane (2% induction, 1.5% maintenance in air) and then mounted in a stereotactic frame with the skull level between 40 lambda and bregma. The eyes were treated with eye lubricant (Lacrilube; www.well.ca) to keep the cornea moist, and body temperature was maintained at 37°C using a feedback-regulated heating pad monitored by a rectal probe. Lidocaine (0.1 ml, 0.2%) was injected under the scalp, and mice also received a 0.5 ml subcutaneous injection of a saline solution containing buprenorphine (2 mg/ml), atropine (3 μg/ml), and glucose (20 mM). The fur on the head of the mouse (from the cerebellar plate to near the eyes) was removed using a fine battery-powered beard trimmer, and the skin was prepared with a triple scrub of 0.1% Betadine in water followed by 70% ethanol. Respiration rate and response to toe pinch were checked every 10â15 min to maintain the surgical anesthetic plane. Before starting the surgery, a cover glass was cut with a diamond pen (Thorlabs, Newton, NJ, USA; Cat#: S90W) to the size of the final cranial window (~9 mm diameter). A skin flap extending over both hemispheres approximately 3 mm anterior to bregma and to the posterior end of the skull and down lateral was cut and removed. A #10 scalpel (curved) and sterile cotton tips were used to gently wipe off any fascia or connective tissue on the skull surface, making sure it was completely clear of debris and dry before proceeding. The clear version of C and B-Metabond (Parkell, Edgewood, NY, USA; Product: C and B Metabond) dental cement was prepared by mixing 1 scoop of C and B Metabond powder (Product: S399), 7 drops of C and B Metabond Quick Base (Product: S398), and one drop of C and B Universal catalyst (Product: S371) in a ceramic or glass dish (do not use plastic). Once the mixture reached a consistency that makes it stick to the end of a wooden stir stick, a titanium fixation bar (22.2 Ã 2.7 Ã 3.2 mm) was placed so 41 that there was a 4 mm posterior space between the bar edge and bregma, by applying a small amount of dental cement and holding it pressed against the skull until the cement partially dried (1â2 min). With the bar in place, a layer of dental adhesive was applied directly on the intact skull. The precut cover glass was gently placed on top of the mixture before it solidified (within 1 min), taking care to avoid bubble formation. If necessary, extra dental cement was applied around the edge of the cover slip to ensure that all the exposed bone was covered, and that the incision site was sealed at the edges. The skin naturally tightens itself around the craniotomy, and sutures are not necessary. The mixture remains transparent after it solidifies, and one should be able to clearly see large surface veins and arteries at the end of the procedure. Once the dental cement around the coverslip is completely solidified (up to 20 min), the animal received a second subcutaneous injection of saline (0.5 ml) with 20 mM of glucose and was allowed to recover in the home cage with an overhead heat lamp and intermittent monitoring (hourly for the first 4 hr. and every 4â8 hr. thereafter for activity level). Then, the mouse was allowed to recover for 7 days before task training. 2.2.3 Water deprivation and habituation to experiments Around 10â21 days after the surgery, the animals were placed on a schedule of water deprivation. Given the variation in weight due to initial ad libitum water consumption, the mouse weight was defined 24 hr. after the start of water restriction. If mice did not progress well through training, they were still given up to 1 ml of water daily, there was also a 15% maximal weight loss criterion used for supplementation (see detailed protocol). All mice were habituated for 5 days before data 42 collection. Awake mice were head-fixed and placed in a dark imaging chamber for training and data collection for each session. We tried to not keep animals headfixed for more than 45 minutes in each session as they become less engaged with long duration headfixed sessions. After headfixing them, it takes about 15 minutes to get the experiment going and therefore 30 - 40 minutes long recorded sessions seemed appropriate before they stop being engaged or before they get satiated in the task. High performing animals were able to maintain body weight and gain weight towards pre-surgery and pre-water restriction values. 2.2.4 CLNF, CLMF setup and behavior experiments Our goal has been to deliver a robust, cross-platform, and cost-effective solution for closed-loop feedback experiments. We have designed and tested a behavioral paradigm where head-fixed mice learn an association between their cortical or behavioral activity, external feedback, and rewards. We tested our CLNF system on Raspberry Pi, and CLMF system on an Nvidia Jetson GPU device, for their compactness, general-purpose input/output (GPIO) programmability, and wide community support. While our investigations center around mesoscale cortical imaging of genetically encoded calcium sensors and behavior imaging, the approach could be adapted to any video or microscopy-dependent signal where relative changes in brightness or keypoint behavior are observed and feedback is given based on a specific rule. This system benefits from advances in pose estimation (Forys et al. 2020; Kane et al. 2020) and employs strategies to improve real-time processing of pre-defined keypoints on compact computers such as the Nvidia Jetson. We have constructed a software and hardware-based platform built around open-source components. 43 To examine the performance of the closed-loop system, we used water-restricted adult transgenic mice that expressed GCaMP6s widely in the cortex (details in the methods section and in Table 2.6 and Table 2.7). Using the transcranial window imaging technique, we assessed the ability of these animals to control brain regions of interest and obtain water rewards. After an initial period of habituation to manual head fixation, mice were switched to closed-loop task training. In training, we had two primary groups: 1) a single cortical ROI linked to water reward and the subject of auditory feedback (Animation 1A, 1B, 1C), or 2) a pairing between two cortical ROIs where auditory feedback and water rewards were given based on the difference in activity between sites (Animation 1D, 1E, 1F). For neurofeedback-CLNF, we calculate an online ÎF/F0 value (GCAMP signal) which represents a relative change of intensity in the region(s) of interest. In brief, a running baseline (F0) is computed at each sample point, subtracted and divided (ÎF/F0) from the raw fluorescence values; more details about online ÎF/F0 calculation are in the methods section. These calculations are made in near real-time on the Raspberry Pi and are used to control the GPIO output pins that provide digital signals for closed-loop feedback and water rewards to water-restricted mice. In 1-ROI experiments, we mapped the range of average ÎF/F0 values in the ROI (Figure 2.1) to a range of audio frequencies (1 kHz - 22 kHz), which acted as feedback to the animal. For 2-ROI experiments, the magnitude of the ÎF/F0 activity difference between the ROIs, based on the specified rule (e.g., ROI1-ROI2), was mapped to the range of audio frequencies. We confirmed 44 that these frequencies were accurately generated and mapped by audio recordings (Supplementary Figure 2.2 and see Methods) obtained at 200 kHz using an ultrasonic microphone (Dodotronic, Ultramic UM200K) positioned within the recording chamber â¼10âcm from the audio speaker. To confirm the timing of feedback latency, LED lights were triggered instead of water rewards (Supplementary Figure 2.1), and the delay was calculated between the detected event (green LED ON for CLNF and paw movement for CLMF) and the red LED flash. In the case of CLNF, the camera recording brain activity was used to record both the flashing green and red LEDs. Temporal traces of green and red LED pixels were extracted from the recorded video, and the average delay between the green and red LEDs becoming bright was calculated as the delay in closed-loop feedback for CLNF experiments. Performing this analysis indicated that the Raspberry Pi system could provide reliable graded feedback using GPIO within ~63 ± 15 ms for CLNF experiments. The GCaMP6s fluorescence signal itself has inherent delay that arises from several biophysical and optical processes, and is different from the feedback latency mentioned above. An imaging rig was developed using two Raspberry Pi 4B+ single-board computers, designated as "brain-pi" (master device for initiating all recordings) for widefield GCaMP imaging and "behavior-pi" (slave device waiting for a trigger to start recording) for simultaneous behavior recording. Both devices were connected to the internet via Ethernet cables and communicated with each other through 3.3 V transistor-transistor logic (TTL) via general-purpose input outputs (GPIOs). To synchronize session initiation, GPIO pin #17 on the brain-pi (configured as an output) was connected to GPIO pin #17 on the behavior-pi (configured as an input), allowing the brain-pi 45 to send a TTL signal to the behavior-pi at the start of each session. Additionally, frames were aligned based on a LED ON event for each session. Additional hardware components were integrated into the brain-pi setup. GPIO pin#27 (output) was connected to a solenoid (Gems Sensor, 45M6131) circuit to deliver water rewards, while GPIO pin#12 (output) was linked to a buzzer (Adafruit product #1739) positioned under the head-fixing apparatus to signal trial failures. GPIO pin#21 (output) was used to trigger a LED driver controlling both short blue (447 nm) and long blue (470 nm) LEDs, which were essential for cortical imaging. A speaker was connected to the brain-pi's 3.5 mm audio jack to provide auditory output (PulseAudio driver) during the experiments. Both the brain-pi and behavior-pi devices were equipped with compatible external hard drives, connected via USB 3.0 ports, to store imaging and behavioral data, ensuring reliable data capture throughout the experimental sessions. Mice with implanted transcranial windows on the dorsal cortex were head-fixed in a transparent acrylic tube (1.5-inch outer diameter, 1 â  inch inner diameter) and placed such that the imaging camera (RGB Raspberry Pi Camera, OmniVision OV5647 CMOS sensor) was above the transcranial window, optimally focused on the cortical surface for GCaMP imaging. The GCaMP imaging cameras had lenses with a focal length of 3.6 mm and a field of view of â¼10.2âÃâ10.2 mm, leading to a pixel size of â¼40 μm, and were equipped with triple-bandpass filters (Chroma 69013m), which allowed for the separation of GCaMP epifluorescence signals and 447 nm reflectance signals into the green and blue channels, respectively. The depth of field (~3 mm) 46 was similar to previous reports (Lim et al. 2012) which provided both a large focal volume over which to collect fluorescence and made the system less sensitive to potential changes in the z-axis position. To reduce image file size, we binned data at 256 Ã 256 pixels on the camera for brain imaging data. Brain images were saved as 8-bit RGB stacks in HDF5 file format. We manually fixed the camera frame rate to 15 Hz, turned off automatic exposure and auto white balance, and set white balance gains to unity. For both green epifluorescence and blue reflection channels, we adjusted the intensity of illumination so that all values were below 180 out of 256 grey levels (higher levels increase the chance of cross-talk and saturation). Mesoscale GCaMP imaging can often be performed with single-wavelength illumination (Gilad and Helmchen 2020; N. Nakai et al. 2023). However, in this experiment, we utilized dual-LED illumination of the cortex (Michelson et al. 2023). One LED (short-wavelength blue, 447 nm Royal Blue Luxeon Rebel LED SP-01-V4 paired with a Thorlabs FB 440/10 nm bandpass filter) monitored light reflectance to account for hemodynamic changes (Xiao et al. 2017), while the second LED (long-wavelength blue, 470 nm Luxeon Rebel LED SP-01-B6 combined with a Chroma 480/30 nm filter) was used to excite GCaMP for green epifluorescence. Both signals were captured simultaneously using an RGB camera. For each mouse, light from both the excitation and reflectance LEDs was channeled into a single liquid light guide, positioned to illuminate the cortex (Figure 2.1A-v) (Michelson et al. 2023). Further specifics are outlined in the accompanying Parts List and assembly instructions document. A custom-built LED driver, controlled by a Raspberry Pi, activated each LED at the beginning of the session and deactivated them at the session's end. 47 This on-off illumination shift was later used in post hoc analysis to synchronize frames from the brain and behavior cameras. Before initiating the experimental session, key session parameters were configured in the config.ini file, as detailed in the âKey Configuration Parametersâ section below. Additionally, we ensured that the waterspout was positioned appropriately for the mouse to access and consume the reward. To launch the experiment, open a terminal on the brain-pi (master) device, ensuring that the current directory is set to clopy/brain/. The experiment can be started by entering the command python3 <script_name>.py, where <script_name> corresponds to the appropriate Python script for the session (Supplementary Figure 2.7). We provide two pre-defined scripts in the codebase: one for 1ROI and another for 2ROI experiments. Both scripts are functionally similar. Upon execution, the script prompts for the "mouse_id," which can be entered as an array of characters, followed by pressing 'Enter.' Upon initialization, two preview windows appear. The first window displays live captured images with intensity values overlaid in the green and blue channels, which allow for adjustments to LED brightness levels. The second window displays real-time ÎF/F0 values overlaid on cortical locations, enabling brain alignment checks. These preview windows are used to assess imaging quality and ensure appropriate settings before starting the experiment (Supplementary Figure 2.6). Once all settings are confirmed, pressing the âEscâ key starts the experiment. At this point, only one window displaying incoming images is shown. The experiment begins with a rest period of duration specified in the config.ini file, followed by alternating trial 48 and rest periods. Data acquired during the session are saved in real-time on the device. For more details and the latest instructions on system setup, please refer to the projectâs GitHub page. An additional imaging rig for CLMF was developed utilizing an Nvidia-Jetson Orin device (8-core ARM Cortex CPU, 2048 CUDA cores, 64 GB memory), which served as the master device responsible for triggering all recordings. The Nvidia-Jetson was connected to an Omron Sentech STC-MCCM401U3V USB3 Vision camera for behavior imaging and real-time pose tracking. A personal computer (serving as the slave device) running EPIX software and frame grabber (PIXCI® E4 Camera Link Frame Grabber) was connected to a Pantera TF 1M60 CCD camera (Dalsa) for widefield GCaMP imaging. Both the Nvidia-Jetson and the EPIX PC were linked via transistor-transistor logic (TTL) for communication. For session synchronization, the GPIO pin #17 on the Nvidia-Jetson, configured as an output, was connected to the trigger input pin of the EPIX framegrabber E4DB. This configuration enabled the Nvidia-Jetson to send a TTL signal to initiate frame capture on the EPIX system at the start of each session. Additionally, this same pin was connected to an LED driver to trigger the activation of a long blue LED (470 nm) for GCaMP imaging simultaneously. Several hardware components were integrated into the Nvidia-Jetson setup to support experimental protocols. GPIO pin #13 (output) was linked to a solenoid circuit to deliver water rewards, while GPIO pin #7 (output) was connected to a buzzer placed under the head-fixation apparatus to signal trial failures. Auditory feedback during the experiments was provided through 49 a speaker connected to the Nvidia-Jetsonâs audio output. Both the Nvidia-Jetson and EPIX PC were equipped with sufficient storage space to ensure the reliable capture and storage of behavioral video recordings and widefield image stacks, respectively, throughout the experimental sessions. Mice, implanted with a transcranial window over the dorsal cortex, were head-fixed in a custom-made transparent, rectangular chamber (dimensions provided). The chamber was designed using CAD software and fabricated from a 3 mm-thick acrylic sheet via laser cutting. Complete model files, acrylic sheet specifications, and assembly instructions are available on the GitHub repository. A mirror was positioned at the bottom and front of the chamber (Figure 2.1B) to allow multiple views of the mouse for improved tracking accuracy. The Omron Sentech camera was equipped with an infrared (IR)-only filter to exclusively capture IR illumination, effectively blocking other light sources and ensuring consistent behavioral imaging for accurate pose tracking. For widefield GCaMP imaging, the Dalsa camera was equipped with two front-to-front lenses (50 mm, f/1.435 mm and f/2; Nikon Nikkor) and a bandpass emission filter (525/36 nm, Chroma). The 12-bit images were captured at a frame rate of 30 Hz (exposure time of 33.3 ms) with 8Ã8 on-chip spatial binning (resulting in 128x128 pixels) using EPIX XCAP v3.8 imaging software. The cortex was illuminated using a blue LED (473 nm, Thorlabs) with a bandpass filter (467â499 nm) to excite calcium indicators, and the blue LED was synchronized with frame acquisition via TTL signaling. GCaMP fluorescence image stacks were automatically saved to disk upon session completion. 50 Prior to starting a session, key experimental parameters were configured within the config.ini file (see "Key Configuration Parameters" below for details). The waterspout was positioned close to the mouse to allow easy access for licking and consuming rewards. To initiate the experiment on the Nvidia-Jetson (master device), the terminal's current directory was set to clopy/behavior/. The experiment was launched by executing the command python3 <script_name>.py, where <script_name> corresponds to the Python script responsible for running the experiment (Supplementary Figure 2.6). The provided script maps the speed of a specific control-point (FLL_bottom) to the audio feedback and executes 60 trials. Once launched, the program prompts for the "mouse_id," which could be entered as an array of characters, followed by pressing Enter. A preview window displaying a live behavioral view was then presented, allowing for adjustments of IR brightness levels and the waterspout (Supplementary Figure 2.6). Once imaging quality and settings were confirmed to be optimal, pressing the "esc" key started the experiment. During the experiment, the tracked points were overlaid on the real-time video, and the session alternated between rest and trial periods. All acquired data were saved locally on the Nvidia-Jetson during the experiment and automatically transferred to the EPIX PC after completion. Additional setup instructions and system details can be found on the associated GitHub page. 2.2.5 Key configuration parameters Prior to running the experiment script, session parameters were set in the config.ini file under a designated configuration section. This file contains multiple config sections, each tailored to a 51 different experiment type, such as brain-pi or behavior-pi. The appropriate config section is specified in the experiment script. Key parameters in this section are listed in the table 2.2 below. Table 2.2 Key configuration parameters in CLoPy Parameter Description vid_source Specifies the class responsible for the image stream, which may come from a programmable camera or another video source. data_root Directory path for saving the recorded sessions and current configuration. raw_image_file File name for saving the image stream. resolution Image stream resolution in (x, y) pixels. framerate Number of frames per second from the image stream. awb_mode Auto-white-balance mode (only used in CLNF, True for Behavior-Pi, False for Brain-Pi). shutter_speed Sets the camera sensor exposure. dff_history The duration (in seconds) used to calculate ÎF/F0, only used in CLNF. ppmm Pixels-per-mm value at the focal plane of the camera. bregma Y, X pixel coordinates of the bregma on the dorsal cortex in the image frame, only used in CLNF. seeds_mm List of cortical locations for inclusion in the closed-loop training rule, each defined by a name and coordinates relative to bregma (in mm), only used in CLNF. roi_operation Specifies the ROI(s) and operation (+ or -) for closed-loop training. roi_size Size of the ROI(s) in mm. n_tones Number of distinct audio frequencies for graded auditory feedback. 52 Parameter Description reward_delay Delay (in seconds) after crossing the threshold. reward_threshold Threshold value in terms of ÎF/F0, determined from baseline sessions. adaptive_threshold A setting for adjusting the reward threshold. If set to 0, the threshold remains constant throughout the session; if set to 1, the threshold increases or decreases by 0.02 steps based on the reward rate. total_trials Total number of trials in the session. max_trial_dur Maximum trial duration (in seconds). success_rest_dur Rest duration after a successful trial (in seconds). fail_rest_dur Rest duration after a failed trial (in seconds). initial_rest_dur Rest period at the beginning of the session before the first trial (in seconds). summary_file File name to save the experiment summary as comma-separated values (CSV). summary_header List of variable names to be saved in the summary file. dlc_model_path Path of the DeepLabCut-Live model for real time pose tracking (used only in CLMF). control_point Name of the tracked point for closed-loop feedback (used only in CLMF). speed_threshold Speed threshold for a success in a trial and receive reward (used only in CLMF). Further details on these parameters can be accessed via the GitHub repository. 53 2.2.6 CLoPy platform Closed-Loop Feedback Training System (CLoPy) is an open-source software and hardware system implemented in the Python (>=3.8) programming language. This work is accompanied by a package to replicate the system, reproduce figures in this publication, and an extensive supplemental guide with full construction illustrations and parts lists to build the platform used. See https://github.com/pankajkgupta/clopy for details and accompanying acquisition and analysis code. We also provide model files for machined and 3D-printed parts in the repository; links to neural and behavioral data can also be found at the federated research data repository- https://doi.org/10.20383/102.0400. While the presented CLNF experiments were conducted on a Raspberry Pi 4B+ device, the system can be used on any other platform where the Python runtime environment is supported. Similarly, CLMF experiments were conducted on an Nvidia Jetson Orin device, but it can be deployed on any other device with a GPU for real-time inference. For any programmable camera to be used with the system, one can implement a wrapper Python class that implements the CameraFactory interface functions for integration with the system. 2.2.7 Comparison with existing closed-loop platforms To contextualize CLoPy platform, we compared it with several established open-source and commercial closed-loop systems (Table 2.1). CLoPy was designed to address a gap between high-cost, proprietary electrophysiology, optical-physiology systems and highly specialized open 54 frameworks by providing a low-cost, lightweight, Python-native solution for optical imaging and behavior-based closed-loop control. In contrast to tools such as Open Ephys and NeuroRighter, which primarily target electrical recordings, or pyControl, which is optimized for deterministic behavioral input-output, CLoPy natively integrates mesoscale calcium imaging, DeepLabCut-based behavior tracking, and graded auditory feedback within a unified Python environment. Compared with Bonsai, which excels at visual data-stream prototyping, CLoPy offers code-level flexibility and GPU acceleration on single-board computers such as Raspberry Pi and NVIDIA Jetson. Although commercial systems (e.g., TDT Synapse, Blackrock Neurotech) may achieve sub-millisecond latencies with vendor support for select applications, their cost and closed architectures limit accessibility. Thus, CLoPy provides an open, adaptable, and cost-effective alternative for real-time closed-loop optical and behavioral neuroscience experiments. 2.2.8 Graded feedback (Online ÎF/F0-Audio mapping) The auditory feedback was proportional to the magnitude of the neural activity. We translated fluorescence levels into the appropriate feedback frequency and played the frequency on speakers mounted on two sides of the imaging platform. Frequencies used for auditory feedback ranged from 1 to 22 kHz in quarter-octave increments (Han et al. 2007; Clancy et al. 2014). When a target was hit, a circuit driven solenoid delivered a reward to mice. To map the fluorescence activity ð¹ to the quarter-octave index ð, we used linear scaling. Let ð¹ððð and ð¹ððð¥be the minimum and maximum fluorescence values.ðððð¥The maximum number of quarter-octave steps between 1 kHz and 22 kHz. 55 The number of quarter-octave steps between 1 kHz and 22 kHz can be calculated as: ðððð¥ = 4 â ððð2 (ðððð¥ðððð) where ðððð¥ = 22ðð»ð§ and ðððð = 1ðð»ð§ The quarter-octave index ð can be mapped linearly from fluorescence activity ð¹ as: ð =ð¹ â ð¹ðððð¹ððð¥ â ð¹ðððâ ðððð¥ Thus, the final equation mapping fluorescence activity to audio frequency is: ð(ð¹) = ðððð â 2(14â ð¹âð¹ðððð¹ððð¥âð¹ðððâ ðððð¥) where ðððð = 1ðð»ð§, ðððð¥ = 22ðð»ð§, and ðððð¥ = 4 â ððð2(22) â 13.45 This equation allows us to map any fluorescence activity ð¹ within the range [ð¹ððð, ð¹ððð¥] to a corresponding frequency within the 1â22 kHz range, in quarter-octave increments. 2.2.9 Checking the dynamic range of graded auditory feedback To assess the dynamic range of audio signals from the speakers, we used an Ultra microphone (Dodotronic) to record feedback signals generated during a session, detect the frequencies, and compare the detected frequencies through our speakers to what was commanded through the 56 program. We verified a linear relationship between 1 and 22 kilohertz (Supplementary Figure 2.2). Analysis of GCAMP imaging experiments indicated that baseline activity values were associated with mapped sounds in the 6±4 kHz range. At reward points, which are threshold-dependent (Delta F over F values), the commanded auditory feedback values were significantly higher (18±2 kHz range). A previous version of the CLNF system was found to have non-linear audio generation above 10 kHz, partly due to problems in the audio generation library and partly due to the consumer-grade speaker hardware we were employing. This was fixed by switching to the Audiostream (https://github.com/kivy/audiostream) library for audio generation and testing the speakers to make sure they could output the commanded frequencies (Supplementary Figure 2.2). 2.2.10 Determining reward threshold based on a baseline session Before starting the experiments, and after the habituation period, a baseline session (day 0) of the same duration as the experiments is recorded. This session is similar to the experimental sessions in the coming days, except that they do not receive any rewards. Offline analysis of this session is used to establish a threshold value for the target activity (see the target activity section to read more). In brief, for 1 ROI experiment, target activity is the average ÎF/F0 activity in that ROI. For 2 ROI experiments, target activity is based on the specified rule in the config.ini file. For example, target activity for the rule âROI1-ROI2â would be âaverage ÎF/F0 activity in ROI1 - average ÎF/F0 activity in ROI2.â 57 2.2.11 Determining ROI(s) for changes in CLNF task rules. Dorsal cortical widefield activity is dynamic, and ongoing spatiotemporal motifs involve multiple regions changing activity. Choosing ROI(s) for CLNF has some caveats and requires some considerations before choosing. It was relatively straightforward for initial training experiments where baseline (day 0) sessions were used to establish a threshold for the selected ROI on day 1. Mice learn to modulate the selected ROI over the training sessions. Interestingly, other cortical ROIs were also changing along with the target ROI as mice were learning the task. We were careful when changing the task rule ROI on day 11 because if we changed to an ROI that also changes along with the previous task rule ROI, mice could keep getting rewards without realizing any change. To address this issue, we analyzed the neural data from day 1 to day 10 and found potential ROIs for which the threshold crossings did not increase significantly or were not on par with the previous ROI, and one of these ROIs was chosen for the rule change. 2.2.12 Online ÎF/F0 calculation In calcium imaging, ÎF/F0 is often used to represent the change in fluorescence relative to a baseline fluorescence (F0), which helps in normalizing the data. For CLNF real-time feedback, we computed ÎF/F0 online, frame by frame. Let ð¹(ð¡) represent the fluorescence signal at time.ð¡. A running baseline ð¹0(ð¡)is estimated by applying a sliding window to the fluorescence signal to calculate a moving average over a window of size ð. 58 ð¹0(ð¡) =1ðâ ð¹(ð)ð¡ð=ð¡âð Once the running baseline.ð¹0(ð¡)is computed, the ÎF/Fâ at time ð¡ is calculated as: ð¥ð¹(ð¡)ð¹0(ð¡)=ð¹(ð¡) â ð¹0(ð¡)ð¹0(ð¡) Each incoming frame contained both a green channel (capturing GCaMP6s fluorescence) and a short blue channel (representing blood volume reflectance) (Ma et al. 2016; Wekselblatt et al. 2016; Valley et al. 2020). These frames were appended to a doubly-ended queue (deque), a Python data structure, for running baseline ð¹0(ð¡)The length of the deque.ð was defined by the product of two parameters from the configuration file: âdff_historyâ (in seconds) and âframerateâ (in frames per second), which determined the number of frames used for the running baseline. For the CLNF experiments, we used a dff_history of 6s (a dynamic baseline) and a framerate of 15 fps, resulting in a deque length of 90 frames. When the deque reached full capacity, appending a new frame automatically removed the oldest frame, ensuring an updated running ÎF/F0 throughout the experiment, regardless of session duration. This method effectively avoided memory limitations over time. We would like to emphasize that we are not directly averaging activity over 6 s to compare against the reward threshold. Instead, the preceding 6 s of activity is used solely to compute a dynamic baseline for ÎF/F0 (ÎF/F0 = (F â F0)/F0). Here, F0 is calculated as the mean fluorescence intensity over the prior 6 s window and is updated continuously throughout the session. This baseline is then subtracted from the instantaneous fluorescence signal to detect relative changes in activity. The reward threshold is therefore evaluated against these baseline-59 corrected ÎF/F0 values at the current time point, not against an average over 6 s. This moving-window baseline correction is a standard approach in calcium imaging analyses, as it helps control for slow drifts in signal intensity, bleaching effects, or ongoing fluctuations unrelated to the behavior of interest. Thus, the 6 s window is not introducing a temporal lag in reward assignment but is instead providing a reference to detect rapid increases in cortical activity. For each channel (green and blue), the running F0 was subtracted from each incoming frame to obtain ÎF, followed by ÎF/F0 calculations, applied per pixel as a vectorized operation in Python. To correct for hemodynamic artifacts (Ma et al. 2016), we subtracted the blue excitation and epifluorescence channel ÎF/F0 from the green channel ÎF/F0. It is important to note that while blood volume reflectance is typically captured using green light (Ma et al. 2016), we used short blue light due to technical constraints associated with the Raspberry Pi camera's rolling shutter which made strobing infeasible. The short blue light (447 nm) with a 440 ± 10 nm filter is close to the hemoglobin isosbestic point and has been shown to correlate well with the 530 nm green light signal as a proxy for hemodynamic activity (Michelson et al. 2023; Murphy et al. 2020). Additionally, the 447 nm LED would be expected to produce minimal green epifluorescence at the low power settings used in our experiments (Dana et al. 2014). Previous studies have evaluated and compared the performance of corrected versus uncorrected signals using this method (Xiao et al. 2017; Murphy et al. 2020). 60 2.2.13 Offline ÎF/F0 calculation For offline analysis of GCaMP6s fluorescence in CLNF experiments, the green and blue channels (Ma et al. 2016; Wekselblatt et al. 2016; Valley et al. 2020) were converted to ÎF/F0 values. For each channel, a baseline image (F0) was computed by averaging across all frames of the recording session. The F0 was then subtracted from each individual frame producing a difference image (ÎF). This difference was divided by F0, resulting in the fractional change in intensity (ÎF/F0) for each pixel as a function of time. To further correct for hemodynamic artifacts (Ma et al., 2016), the blue channel reflected light ÎF/F0 signal, reflecting blood volume changes, was subtracted from the green channel ÎF/F0 signal, isolating the corrected GCaMP6s fluorescence response from any potential confounding vascular contributions. Offline analysis of GCaMP6s fluorescence in CLMF experiments involved processing the green epifluorescence channel. We did not collect the hemodynamic signal in this experiment because we intended to employ the second channel for optogenetic stimulation (not included in this article). A baseline image (F0) was computed by averaging across all frames of the recording session. The F0 was then subtracted from each individual frame, producing a difference image (ÎF). This difference was divided by F0, resulting in the fractional change in intensity (ÎF/F0) for each pixel as a function of time. 61 2.2.14 Seed-pixel correlation matrices Widefield cortical image stacks were registered to the Allen Mouse Brain Atlas (Q. Wang et al. 2020; Chon et al. 2019) and segmented into distinct regions, including the olfactory bulb (OB), anterolateral motor cortex (ALM), primary motor cortex (M1), secondary motor cortex (M2), sensory forelimb (FL), sensory hind limb (HL), barrel cortex (BC), primary visual cortex (V1), and retrosplenial cortex (RS) in both the left and right cortical hemispheres. The average activity in a 0.4 x 0.4 mm² area (equivalent to a 10 x 10 pixel region) centered on these regions (also referred to as seed pixels) was calculated, representing the activity within each region. These signals were then used to generate temporal plots. The temporal plots were epoched into trial and rest conditions, and correlations between the regions were computed, resulting in correlation matrices for each condition across each day. Each element of the matrix represents the pairwise correlation between two cortical regions. For each pair of cortical regions, we obtained correlation values during both trial and rest periods for every session, creating a time series (over sessions) with two conditions (trial and rest). 2.2.15 Data and code availability The source data used in this paper is available here- https://doi.org/10.20383/103.01152. Code to replicate the system, recreate the figures, and associated pre-processed data are publicly available and hosted on GitHub - https://github.com/pankajkgupta/clopy. Any additional information required to reanalyze the data reported in this work is available from the lead contact upon request. 62 2.2.16 Statistics Various statistical tests were performed to support the analysis presented in accompanying figures. For p-value matrices in Figure 2.8B, C, a two-way repeated-measures ANOVA with Bonferroni post-hoc correction was used to test the significance of correlation changes across two factors: sessions (days 1â10) and condition (trial vs. rest). Significant changes in the correlation matrices along these two variables showed complementary patterns (Figure 2.8). Changes across sessions involved the bilateral M1, M2, FL, HL, and BC regions, while changes between the trial and rest conditions involved bilateral OB, ALM, V1, and RS regions. A list of statistical tests used in a figure, its purpose and data used are summarized in the table below. Table 2.3 List of statistical tests performed Figure Test name Purpose Arguments Figure 2.4A Mann-Kendall Test (pymannkendall package in Python) To determine a monotonic upward trend in the success rate of all CLNF mice before the rule change (from day 1 to day 10). Normalized success rate per mouse before the rule change (N=40) To determine a monotonic upward trend in the success rate of CLNF rule-change mice after the rule change (day 11 to day 19). Normalized success rate per mouse after the rule change (N=17) 63 Figure Test name Purpose Arguments Figure 2.4A RM-ANOVA (Pingouin package in Python) Test the significance of the success rate increase before the rule change in the CLNF No-rule-change group (Day 1 to Day 10). Normalized success rate per mouse in No-rule-change mice before the rule change (N=23) Test the significance of the success rate increase after the rule change in the CLNF Rule-change group (day 11 to day 19). Normalized success rate per mouse in Rule-change mice after the rule change (N=17) Figure 2.4A Two way RM-ANOVA (Pingouin package in Python) Test significance of day and group on the CLNF success rate before rule change (day 1 to day 10) Normalized success rate per mouse in Rule-change and No-rule-change mice before rule change, along with group labels. Figure 2.4A Mann-Whitney U-test with Benjamini-Hochberg correction (pymannkendall package in Python) Test the difference in the distribution of CLNF success rates between: day 1 no-rule-change and day 3 no-rule-change day 10 No-rule change and day 10 Rule change day 10 rule change and day 11 rule change day 10 rule change and day 19 rule change Normalized success rate per mouse in Rule-change and No-rule-change mice before rule change, along with group labels. 64 Figure Test name Purpose Arguments Figure 2.4B RM-ANOVA (Pingouin package in Python) Test the significance of the success rate increase before the rule change in the CLMF Rule-change group (Day 1 to Day 4). Test the significance of the success rate increase after the rule change in the CLMF Rule-change group (from day 5 to day 10). Test the significance of the success rate increase in the CLMF no-rule-change group (day 1 to day 10). Test significance of success rate increase in CLMF No-feedback group (day 1 to day 10). Normalized success rate per mouse in Rule-change and No-rule-change mice before rule change, along with group labels. Figure 2.5C Permutation Test (MMD function in hyppo package) Multivariate two-sample test to compare ROI1 vs ROI2 bivariate distribution on day 9 and day 19 Bivariate distribution of ROI1 and ROI2 on day 9 and day 19 Figure 2.9C Mann-Whitney, corrected for multiple comparisons with Benjamini-Hochberg (pymannkendall package in Python) Test the significance of the difference in ÎF/F0peak distribution between. Day 1 and day 4 in cortical OBL of CLMF rule-change mice. ÎF/F0peak values in named cortical regions on each day for all mice along with their group labels. 65 Figure Test name Purpose Arguments day 4 and day 5 in cortical OBL of CLMF rule-change mice Day 1 and Day 4 in cortical FLL of CLMF rule-change mice. day 4 and day 5 in cortical FLL of CLMF rule-change mice Day 1 and Day 4 in cortical V1L of CLMF rule-change mice. day 4 and day 5 in cortical V1L of CLMF rule-change mice Figure 2.10B, 2.10C Two-way RM-ANOVA, Bonferroni corrected for multiple comparisons (Pingouin package in Python) Test significant changes in seed pixel correlations over days and between trial and rest conditions for CLMF No-rule-change mice (Figure 2.10B) and for CLMF No-feedback mice (Figure 2.10C). Pairwise seed pixel correlation values for all combination of cortical seed locations over days for each mouse, along with group labels. Supplementary Figure 2.3A Mann-Whitney U-test with Benjamini-Hochberg correction (pymannkendall package in Python) Test the difference in the distribution of CLNF success rates between. day 1 male and day 3 male. Normalized success rate per mouse along with their sex labels 66 Figure Test name Purpose Arguments day 4 male and day 4 female. day 10 female and day 11 female Supplementary Figure 2.3B Mann-Whitney U-test with Benjamini-Hochberg correction (pymannkendall package in Python) Test the difference in the distribution of CLNF success rates between. day 1 single ROI and day 3 single ROI day 10 single ROI and day 10 dual ROI Normalized success rate per mouse along with their ROI-type of the experiment. 2.2.17 CLNF rules The task rules for CLNF experiments involved cortical activity at selected locations. These locations were standard Allen Mouse Brain Atlas (Q. Wang et al. 2020; Chon et al. 2019) CCF coordinates. The table 2.4 below lists all the task rules we tested and what they meant in the context of CLNF experiments. Table 2.4 List of CLNF task rules with their description CLNF rule name Description M1_L ÎF/F0 activity in left hemisphere primary motor area 67 CLNF rule name Description M1_R ÎF/F0 activity in right hemisphere primary motor area M2_L ÎF/F0 activity in left hemisphere secondary motor area HL_L ÎF/F0 activity in left hemisphere sensory hindlimb area RL_L ÎF/F0 activity in left hemisphere rostrolateral area of visual cortex RL_R ÎF/F0 activity in right hemisphere rostrolateral area of visual cortex V1_L ÎF/F0 activity in left hemisphere primary visual area PM_L ÎF/F0 activity in left hemisphere posterior medial area of visual cortex BC_L â BC_R ÎF/F0 activity in left hemisphere barrel cortex subtracted by ÎF/F0 activity in right hemisphere barrel cortex HL_L â HL_R ÎF/F0 activity in left sensory hindlimb area subtracted by ÎF/F0 activity in right hemisphere sensory hindlimb area BC_L â HL_L ÎF/F0 activity in left hemisphere barrel cortex subtracted by ÎF/F0 activity in left hemisphere sensory hindlimb area M1_L â HL_L ÎF/F0 activity in left hemisphere primary motor area subtracted by ÎF/F0 activity in left hemisphere sensory hindlimb area TR_L - M2_L ÎF/F0 activity in the left hemisphere rostral part of the temporal association area is subtracted by ÎF/F0 activity in the left hemisphere secondary motor area. V1_R - V1_L ÎF/F0 activity in the right hemisphere primary visual area subtracted from ÎF/F0 activity in the left hemisphere primary visual area. M2_L - TR_L ÎF/F0 activity in left hemisphere secondary motor area subtracted by ÎF/F0 activity in left hemisphere rostral part of temporal association area RFL_L â CFL_L ÎF/F0 activity in left hemisphere rostral forelimb area subtracted by ÎF/F0 activity in left hemisphere caudal forelimb area HL_L - M2_L ÎF/F0 activity in left hemisphere sensory hindlimb area subtracted by ÎF/F0 activity in left hemisphere secondary motor area 68 2.2.18 CLMF rules The task rules for CLMF experiments involved points on body parts that were tracked (listed in results section). Table 2.5 below lists the task rules (i.e. tracked points) we tested and what they meant in the context of CLMF experiments. Table 2.5 List of CLMF task rules with their description CLMF rule name Description FLL Speed of left forelimb in the bottom view of the camera FLR Speed of right forelimb in the bottom view of the camera 69 Table 2.6 List of mice â CLNF MouseID group ROIs initial_rule change_rule DoB Expt. Start date Age(days) Sex Reward rate genotype Day1 Day5 Day11 Day16 1 BM2 G1 2ROI BC_L â BC_R - 20220122 20220713 172 m 0.01 0.8 - - tta-gcamp6s 2 BM3 G1 2ROI BC_L â BC_R - 20220122 20220712 171 m 0.28 1 - - tta-gcamp6s 3 BM4 G1 2ROI BC_L â BC_R - 20220122 20220712 171 m 0.01 0.83 - - tta-gcamp6s 4 BG2 G1 2ROI HL_L â HL_R - 20210601 20211023 144 m 0.00 0.63 - - tta-gcamp6s 5 BG3 G1 2ROI HL_L â HL_R - 20210601 20211023 144 m 0.00 0.64 - - tta-gcamp6s 6 AC4 G1 2ROI HL_L - HL_R - 20210610 20211009 121 f 0.00 0.71 - - tta-gcamp6s 7 TW1 G1 1ROI RL_L - 20200729 20210113 168 m 0.00 0.35 - - tta-gcamp6s 8 FM1 G1 1ROI M1_L - 20190915 20200129 136 f 0.13 0.66 - - tta-gcamp6s 9 FM2 G1 1ROI M1_L - 20190915 20200129 136 f 0.03 1 - - tta-gcamp6s 10 FM3 G1 1ROI M1_L - 20190915 20200129 136 f 0.02 1 - - tta-gcamp6s 11 FM4 G1 1ROI M1_L - 20190915 20200129 136 f 0.25 1 - - tta-gcamp6s 12 CV2 G1 2ROI BC_L â HL_L - 20190815 20191205 112 m 0.01 0.72 - - tta-gcamp6s 13 CV3 G1 2ROI BC_L â HL_L - 20190815 20191205 112 m 0.01 1 - - tta-gcamp6s 14 DU1 G1 2ROI M1_L â HL_L - 20190719 20191205 139 f 0.01 1 - - tta-gcamp6s 15 DU3 G1 2ROI M1_L â HL_L - 20190719 20191205 139 f 0.02 0.39 - - tta-gcamp6s 16 BZ1 G1 2ROI TR_L - M2_L - 20190406 20190806 122 m 0.24 0.29 - - tta-gcamp6s 17 BZ2 G1 2ROI TR_L - M2_L - 20190406 20190806 122 m 0.02 0.32 - - tta-gcamp6s 18 DU1 G1 2ROI V1_R - V1_L - 20190217 20190807 171 f 0.00 1 - - tta-gcamp6s 19 DU2 G1 2ROI V1_R - V1_L - 20190217 20190807 171 f 0.00 0.46 - - tta-gcamp6s 20 BZ1 G1 2ROI M2_L - TR_L - 20181230 20190516 137 m 0.19 0.19 - - tta-gcamp6s 21 BZ2 G1 2ROI M2_L - TR_L - 20181230 20190516 137 m 0.02 0.71 - - tta-gcamp6s 22 BU2 G1 2ROI M2_L - TR_L - 20181219 20190517 149 m 0.20 1 - - tta-gcamp6s 23 BU3 G1 2ROI M2_L - TR_L - 20181219 20190517 149 m 0.01 0.61 - - tta-gcamp6s 70 MouseID group ROIs initial_rule change_rule DoB Expt. Start date Age(days) Sex Reward rate genotype Day1 Day5 Day11 Day16 24 BM1 G2 2ROI BC_L - BC_R RFL_L â CFL_L (Day11) 20220122 20220712 171 m 0.00 0.63 0.03 0.52 tta-gcamp6s 25 AC1 G2 2ROI BC_L - BC_R HL_L - HL_R (Day11) 20210610 20211009 121 f 0.27 0.41 0.12 1 tta-gcamp6s 26 AC2 G2 2ROI BC_L - BC_R HL_L - HL_R (Day11) 20210610 20211009 121 f 0.00 1 0.29 0.96 tta-gcamp6s 27 TW1 G2 1ROI RL_L HL_L (Day11) 20200802 20210113 129 m 0.01 0.58 0.00 0.71 tta-gcamp6s 28 TW2 G2 1ROI RL_L PM_L (Day11) 20200802 20210113 129 m 0.02 0.28 0.32 0.90 tta-gcamp6s 29 TW22 G2 1ROI RL_R RL_L (Day11) 20200730 20201119 112 m 0.10 0.48 0.35 0.60 tta-gcamp6s 30 TW11 G2 1ROI M2_L RL_L (Day11) 20200730 20201119 112 m 0.05 0.32 0.10 0.64 tta-gcamp6s 31 TW33 G2 1ROI M1_R RL_R (Day11) 20200730 20201119 112 m 0.02 0.41 0.40 0.60 tta-gcamp6s 32 FM3 G2 1ROI V1_L M1_R (Day11) 20190917 20200129 134 f 0.08 0.62 0.03 0.37 tta-gcamp6s 33 FM1 G2 1ROI M1_L V1_L (Day11) 20190917 20200129 134 f 0.00 0.65 0.02 0.61 tta-gcamp6s 34 FM2 G2 1ROI M1_L M1_R (Day11) 20190917 20200129 134 f 0.10 1 0.14 1 tta-gcamp6s 35 FM3 G2 1ROI M1_L V1_L (Day11) 20190917 20200129 134 f 0.03 0.63 0.20 0.46 tta-gcamp6s 36 FM4 G2 1ROI M1_L V1_L (Day11) 20190917 20200129 134 f 0.01 0.31 0.00 0.62 tta-gcamp6s 37 DR2 G2 2ROI M2_L - TR_L HL_L - M2_L (Day11) 20190401 20190806 127 m 0.09 1 0.01 1 tta-gcamp6s 38 DR3 G2 2ROI M2_L - TR_L HL_L - M2_L (Day11) 20190401 20190806 127 m 0.03 1 0.06 0.74 tta-gcamp6s 39 DR4 G2 2ROI M2_L - TR_L HL_L - M2_L (Day11) 20190401 20190806 127 m 0.00 0.64 0.02 1 tta-gcamp6s 40 DU3 G2 2ROI M2_L - TR_L V1_R - V1_L (Day11) 20190408 20190807 121 f 0.13 0.36 0.10 1 tta-gcamp6s 71 Table 2.7 List of mice â CLMF MouseID Group initial_rule change_rule DoB Exp. start Age(days) Sex Reward rate genotype Day1 Day4 Day5 Day10 1 FW2 Rule change FLL FLR (Day5) 20230209 20230713 154 f 0.30 0.60 0.21 0.95 Ai94 2 FW3 Rule change FLL FLR (Day5) 20230209 20230718 159 f 0.09 0.65 0.00 0.92 Ai94 3 FW22 Rule change FLL FLR (Day5) 20230209 20230719 160 f 0.25 0.70 0.44 1 Ai94 4 GT3 Rule change FLL FLR (Day5) 20230219 20230715 146 f 0.11 0.93 0.63 0.85 Ai94 5 GT33 Rule change FLL FLR (Day5) 20230219 20230719 150 f 0.12 0.78 0.00 0.87 Ai94 6 HA2 Rule change FLL FLR (Day5) 20230225 20230719 144 m 0.12 0.72 0.28 0.9 Ai94 7 GER2 Rule change FLL FLR (Day5) 20230823 20231228 127 m 0.34 0.95 0.50 0.83 Ai94 8 HYL3 Rule change FLL FLR (Day5) 20230827 20240103 129 m 0.33 0.93 0.60 0.91 Ai94 9 BR1 No rule change FLL - 20230729 20231201 125 m 0.11 0.58 0.97 1 Ai94 10 BR2 No rule change FLL - 20230729 20231201 125 m 0.38 1 0.84 0.82 Ai94 11 GER1 No rule change FLL - 20230811 20231228 139 f 0.35 0.88 0.84 0.82 Ai94 12 HYL2 No rule change FLL - 20240103 20240103 121 f 0.33 0.93 0.88 0.93 Ai94 13 GIL2 No feedback FLL - 20231219 20231219 112 m 0.09 0.52 0.28 0.95 Ai94 14 GIL3 No feedback FLL - 20231219 20231219 135 f 0.23 0.53 0.57 0.51 Ai94 15 GIL4 No feedback FLL - 20231219 20231219 135 f 0.19 0.63 0.60 0.69 Ai94 16 GER3 No feedback FLL - 20230811 20231219 130 m 0.08 0.48 0.43 0.75 Ai94 72 2.3 Results Consistent with prior studies demonstrating that mice can exert volitional control over their brain activity through feedback-based paradigms (Clancy et al. 2014; Luo et al. 2024; Neely, Koralek, et al. 2018; Clancy and Mrsic-Flogel 2021), our experiments show that mice learned to robustly modulate cortical signals when provided with closed-loop neurofeedback. Across training sessions, animals not only acquired the task (Figure 2.4A, initial rule RM ANOVA p=2.83e-5; Figure 2.4B, No-rule-change group RM-ANOVA p=9.6e-7), but also exhibited adaptability to altered feedback rules (Figure 2.4A, performance drop after rule change ANOVA, p=8.7e-9, new rule RM ANOVA p=8.3e-10), highlighting the flexibility of their learning. Removing the graded audio feedback on day 10 for CLMF mice (muted speaker, Figure 2.4B) did not affect their performance, indicating the feedback was not crucial once they learned the task. While feedback-driven brain control is well established, our work extends these findings by including multiple cortical regions, and by demonstrating that feedback based on movement-related signals can also drive learning despite the additional challenge of real-time behavioral tracking. In our closed-loop experiment, mice were trained to associate a specific body movement with a reward. Over the course of 10 training sessions, the mice progressively learned the task, as evidenced by increased task performance across sessions (Figure 2.4A). The acquisition of this learned behavior was consistent with previous findings on motor learning, where reinforcement and task repetition lead to the refinement of motor skills (Wolpert, Diedrichsen, and Flanagan 2011; Krakauer et al. 2019). Importantly, the reward was provided 1 s after a successful trial to 73 study the timing and nature of cortical activation in response to both the task and the reward. Concurrent with behavioral training, widefield cortical activity was recorded observing distinct patterns of neural activation that evolved as the mice learned the task. We implemented and tested a compact, cross-platform system designed for closed-loop feedback experiments. Using this system, head-fixed mice successfully learned to associate either cortical activity or movement-derived signals with auditory feedback and water rewards. Performance increased steadily over sessions: in both one-ROI and two-ROI paradigms, animals showed a significant rise in the number of rewards obtained compared to their baseline (day 0) and control groups without feedback (Animations 1AâF). These results indicate that the system effectively links cortical dynamics or movement signals to behaviorally meaningful outcomes. Notably, both neurofeedback (CLNF) and movement-feedback (CLMF) modes produced reliable and graded closed-loop feedback. In CLNF experiments, auditory tones mapped to ÎF/F0 values from cortical regions of interest accurately reflected ongoing neural activity (Figure 2.1). In two-ROI paradigms, differences between ROI activity were similarly mapped to sound frequency, and the commanded audio outputs were verified to be accurate across the full frequency range (Supplementary Figure 2.2). Improvements to the audio generation pipeline eliminated previous nonlinearities above 10 kHz, confirming that the feedback signal matched the intended output. Importantly, feedback latency was tested and found to be well within the range necessary for effective closed-loop 74 75 Figure 2.2: Schematic of the closed-loop feedback training system (CLoPy) for neurofeedback and specified movement feedback. A) The components of CLoPy CLNF system are presented in a block diagram. Modular components such as the configuration file, camera factory, audio tone generator, and reward delivery system are displayed and are utilized by both the Closed-Loop Neurofeedback (CLNF) and Closed-Loop Movement Feedback (CLMF, in B) systems. The configuration file (config.ini) stored all configurable parameters of the system, including camera settings, feedback parameters, reward thresholds, number of trials, and the duration of trial and rest periods, under an experiment-specific section. The camera factory was an abstract class that provided a unified interface for a programmable camera to the CLNF and CLMF(in B) systems. This abstraction allowed the core system to remain independent of the specific camera libraries required for image streaming. Camera-specific routines were implemented in separate âbrain_camera_streamâ and âbehavior_camera_streamâ classes, which inherited functions from the âcamera_factoryâ superclass and ran in independent thread processes. The Region of Interest (ROI) manager was used by the CLNF core to maintain a list of ROIs, as well as routines to perform rule-specific operations on them, as specified in config.ini. An ROI could be defined as a rectangle (with the upper-left corner coordinates, height, and width) or as a circle (with center coordinates and radius). The audio tone generator mapped the target activity (fluorescence signal in CLNF) to graded audio tone frequencies. It generated audio signals at 44.1 kHz sampling based on the specified frequency and sent the signal to the audio output. Reward delivery was controlled by opening a solenoid valve for a specified duration, which was managed in a separate process 76 thread. The CLNF core was the main program responsible for running the CLNF system. It utilized config.ini, the camera factory, the ROI manager, and integrated the audio tone generator and reward delivery functions. The system also saved the recorded data and configuration parameters with unique identifiers. B) The components of CLoPy CLMF system are presented in a block diagram. The common components of the setup are described in A. The audio tone generator mapped the target activity (control-point speed in CLMF) to graded audio tone frequencies. It generated audio signals at 44.1 kHz sampling based on the specified frequency and sent the signal to the audio output. The CLMF core was the primary program responsible for operating the CLMF system. It utilized config.ini, the camera factory, and DeepLabCut-Live(Kane et al. 2020), integrating the audio tone generator and reward delivery functions. This module also saved the data and configuration parameters with unique identifiers. learning. Using LED-triggering experiments (Supplementary Figure 2.1), we confirmed that the Raspberry Piâbased CLNF system delivered graded auditory feedback with an average latency of ~63 ± 15 ms from event detection to output, using GPIO pins. Please note this latency calculation used GPIO pins for delay measurements, and there could be additional minimal overhead to generate the actual audio feedback signals. These findings demonstrate that our system provides rapid and accurate feedback sufficient to drive volitional control of brain or movement signals in head-fixed mice. 77 For the CLMF experiments, an Omron Sentech STC-MCCM401U3V USB3 Vision camera, connected to the Nvidia Jetson via its Python software developer kit (SDK), was used to calculate the feedback delay. The incoming stream of frames was processed in real-time using a custom deep-neural-network model that was trained using DeepLabCut (A. Mathis et al. 2018) and DeepLabCut-Live (Kane et al. 2020), designed to track previously defined points on the mouse. The model was incrementally improved by fine-tuning and re-training 26 times, using 2080 manually labeled frames spanning 52 videos of 10 mice. The pre-trained model, along with the data, is available at the link shared in the data and code availability statement in methods for anyone to use and fine-tune to adapt for similar platforms. The model was integrated into our CLMF program and deployed on an Nvidia Jetson device for real-time inference of tracked points. A Python-based virtual environment using Conda was created to install all software dependencies. The coordinates of the tracked points for each frame were appended to a list, forming a temporal sequence referred to as "tracks." Upon offline analysis, these real-time tracks were found to be both accurate and stable throughout the duration of the videos. To calculate the feedback delay for movements, a red LED was placed within the behavior camera's field of view. Whenever a threshold-crossing movement was detected in the real-time tracking, the system triggered the LED to turn on. Temporal traces of the tracked left forelimb and the pixel brightness of the red LED were then extracted from the recorded video. By comparing these traces, the average delay between the detected movements and the LED illumination was 78 calculated to be 67±20 ms, which represents the delay in the closed-loop feedback for the CLMF experiments. For CLMF, mice were headfixed in a specially designed head-fixing chamber (Figure 2.1Biii, design guide and 3D model in methods) to achieve multiview behavioral recording from a single camera using mirrors (see methods section). In brief, mice are headfixed in a transparent rectangular tunnel (top view) with a mirror at the front (front view) and at the bottom (bottom view) that allows multiple views of the mouse body. The body parts that we track are: snout-top (snout in the top view), tail-top (base of the tail in the top view), snout-front (snout in the front view), FLL-front (left forelimb in the front view), FLR-front (right forelimb in the front view), snout-bottom (snout in the bottom view), FLL-bottom (left forelimb in the bottom view), FLR-bottom (right forelimb in the bottom view), HLL-bottom (left hindlimb in the bottom view), HLR-bottom (right hindlimb in the bottom view), tail-bottom (base of the tail in the bottom view) (Figure 2.1B). The rationale for selecting these body parts in a particular view was that they needed to be visible at all times to avoid misclassification in real-time tracking. By combining the tracks of a body part in different views, we can form a 3D track of the body part. In a 3D coordinate space having X, Y, and Z axes, tracked points (xb, yb) in the bottom view were treated as being in the 3D X-Y plane, and tracked points (xf, yf) in the front view were treated as being in the 3D Y-Z plane. Thus, X = xb, Y = yb, Z = yf formed tracked points in 3D for a given body part that was tracked in multiple views. 79 Figure 2.3 Experimental protocol and trial structure A) Experimental Protocol (detailed in Methods): In brief, 90-day-old transgenic male and female mice were implanted with a transcranial window and allowed to recover for a minimum of 7 days. One day before the start of the experiment, the mice were placed on a water-restriction protocol (as detailed in Methods). Closed-loop experiment training commenced on day 1, during which mice were required to modulate either their target brain activity (GCaMP signals in regions of interest) or target behavior (tracked paw-speed) during daily sessions of approximately 45 minutes 80 over the course of 10 days. Throughout this period, both cortical and behavioral activities were recorded. After the final experimental session, the mice were removed from the water-restriction protocol. B) Trial Structure of Cortical GCaMP-based Feedback Sessions: Each trial was preceded by a minimum of 10 seconds of rest, which was extended if the tracked body parts of the mouse were not stable (sum of changes across body parts > 1.5 mm i.e. 5 pixel values). Once the mouse remained stable and refrained from moving its limbs, the trial began with a basal audio tone of 1 kHz. The mice then had 30 seconds to increase rule-based activations (in the selected ROI) up to a threshold value to receive a water reward. A trial ended as soon as the activation reached the threshold, triggering a reward delivery for success, or timed out after 30 seconds with an overhead buzzer serving as a negative signal of failure. Both the reward and the negative signal were delivered within 1 second after the audio ceased at the end of each trial. C) Example dorsal cortical ÎF/F0 activity was recorded and overlaid with a subset of Allen CCF coordinates, which could be selected as the center of candidate regions of interest (ROIs) shown as Green and Pink color squares. D) Trial Structure of Behavior Feedback Sessions: The behavioral feedback trials followed a similar structure to the cortical feedback trials, with each trial preceded by at least 10 seconds of 81 rest. The trial began with a basal tone of 1 kHz, which increased in frequency as the mouseâs paw speed increased. E) Example Forelimb Tracking during Feedback Sessions: Forelimb tracking was performed in both the left (blue) and right (green) forelimbs using a camera coordinate system on day 4 of training with mouse FM2, which received feedback based on left forelimb speed. The forelimbs were tracked in 3D, leveraging multiple camera views captured using mirrors positioned at the bottom and front of the setup (Figure 2.1B). For example, FLL-front and FLL-bottom were tracking the left forelimb in front and bottom views, and by combining the tracks of these two points, we obtained a 3D track of the left forelimb (Figure 2.3E). Although these 3D tracks are available in real-time, for our CLMF experiments, we used 2D tracks (xb, yb) for behavioral feedback to keep the task simpler and comparable across mice. Audio output channels and GPIO pins on the Nvidia Jetson were used for audio feedback and reward delivery, respectively. Tracks of each body part were used to calculate the speed of those points in real-time, and a selected body part (also referred to as a control point) was mapped to a function generating proportional audio frequency (same as in CLNF, details in the method section). In the software we have developed, one can also choose to calculate acceleration, radial distance, angular velocity, etc., from these tracks and map it to the function generating varying audio frequency feedback. For our work, a range of spontaneous speeds was calculated from a baseline recording before the start of the training. The threshold speed to receive 82 a reward was also calculated from the baseline recording and set at a value that would have yielded a reward rate of one reward per two-minute period (translates to a basal performance of 25% in our trial task structure). This thresholding step was done to allow the mice to discover task rules and keep them motivated. Both CLNF and CLMF experiments shared a similar experimental protocol (surgery, habituation, then several days of training, Figure 2.3A). A daily session starts with a 30 sec rest period (no rewards or task feedback) followed by 60 trials (maximum 30 sec each) with a 10 sec rest between trials in CLNF, and a minimum of 10 sec rest or until tracked points are stable for 5 sec in CLMF (Figure 2.3B, 2.3D). After the habituation period, a spontaneous session of 30 minutes was recorded where mice were not given any feedback or rewards. The spontaneous session was used to establish baseline levels of GCaMP activity (in target ROI(s) for CLNF experiments) or speed of a target body part for CLMF experiments. This was done to calculate the animal-specific threshold for future training sessions. A success in the trial resulted in a water drop reward that was delivered 1 sec after the end of the trial, and a failed trial ended with a buzzer vibrator 1 sec after the end of the trial (Figure 2.3B, 2.3D). 2.3.1 Mice can explore and learn an arbitrary task, rule, and target conditions. CLNF training (Figure 2.1A) required real-time image processing, feedback, and reward generation. Feedback was a graded auditory tone mapped to the relative changes in selected 83 cortical ROI(s) or movement speed of a tracked body part. Training was conducted using multiple sets of cortical ROI(s) (list of ROI rules and their description can be found in Table 2.4 and visualized in Supplementary Figure 2.7) on both male and female mice (see Table 2.6 for list of mice and their task rules), wherein the task was to increase the activity in the selected ROI(s), according to the rule (also referred to as âthe ruleâ in the future), to exceed a predetermined threshold (Figure 2.6A, 2.6B). Fluorescence activity changes (ÎF/F0) were calculated using a running baseline of 5 seconds, with single or dual ROIs on the dorsal cortical map selected as targets. The distribution of target ROI(s) activity on day 9 of training was higher than on day 1 (Figure 2.5A). A linear regression analysis of whole-session ÎF/F0 activity in the 2-ROI experiment revealed a shift in the regression line slope, favoring the ROI that was required to increase according to the task rule (Figure 2.6C). In general, all ROIs assessed (Table 2.4, Supplementary Figure 2.7) that encompassed sensory, pre-motor, and motor areas were capable of supporting increased reward rates over time based on analysis of group and pooled ROI data (Figure 2.4A, Animation 1). A ÎF/F0 threshold value was calculated from a baseline session on day 0 that would have allowed 25% performance. Starting from this basal performance of around 25% on day 1, mice (CLNF No-rule-change, N=23, n=60 and CLNF Rule-change, N=17, n=60) were able to discover the task rule and perform above 80% over ten days of training (Figure 2.4A, RM ANOVA p=2.83e-5), and Rule-change mice even learned a change in ROIs or rule reversal (Figure 2.4A, RM ANOVA p=8.3e-10, Table 2.6 for different rule changes). There were no significant differences between male and female mice (Supplementary Figure 2.3A). To investigate whether certain ROI(s) were better than others in terms of performance, we performed 84 Figure 2.4: Closed-loop feedback helped mice learn the task and achieve superior performance in CLNF and CLMF in both experiments. A) No-rule-change (N=23, n=60, in Table 2.6) and Rule-change (N=17, n=60) mice were able to learn the CLNF task over several sessions, with performance above 70% by the 10th session (RM ANOVA p=2.83e-5). N represents the total number of animals, n represents total trials on each day (session). The rule change (in pink, day 11) led to a sharp decline in performance (ANOVA, p=8.7e-9), but the mice were able to adapt and learn the task rule change (RM ANOVA p=8.3e-10; see Table 2.6 for different rule changes). The method to determine the ROI(s) used in the changed task rule is described in the methods section. 85 B) Three groups were employed for CLMF experiments. The âRule-changeâ group (N=8, n=60, Table 2.6 received feedback, in pink) was trained with task rule mapping auditory feedback to the speed of the left forelimb and was able to perform above a 70% success rate in four days. N is the total number of animals, n is total trials on each day (session). The task rule mapping was changed from the left to the right forelimb on day 5, so the rewards as well as audio frequencies would now be controlled by the right forelimb. The âNo-rule-changeâ group (N=4, n=60 received audio feedback, no rule change, in green) and the âNo-feedbackâ group (N=4, n=60 no graded audio feedback, no rule change, in blue) were control groups to investigate the role of audio feedback. The performance of the âNo-feedbackâ mice, who did not receive the graded feedback, was never on par (RM-ANOVA p=0.49) with the âNo-rule-changeâ group that received the feedback (RM-ANOVA p=9.6e-7). Additionally, to test the effect of auditory feedback on mice that already had learned the task, we turned off the auditory feedback on day 10 for all mice (indicated by the speaker with a cross). There was no significant change in performance due to feedback removal, indicating that feedback was not necessary once the task was learned. C) Task latencies in each group follow the trend of their performance. Rule change (N=8) and no rule change (N=4) task latencies gradually came down, with an exception on day 5 for rule change when the task rule was changed. No feedback (N=4) task latencies are never on par with the groups that received feedback. 86 D) CLMF Rule-change (N=8) behavior, we looked at the maximum speeds of the left and right forelimbs. The paw with the maximum speed follows the task rule and switches with the change in the task rule. It is worth noting that the task was not restricted to other body parts; i.e., the mice were free to move other body parts along with the control point. 87 Figure 2.5: Change in data distribution with training and before, after the rule change. A) Reward-aligned average (N=4) ÎF/F0 signals associated with the target rule on day1 and day9 (top plot). Kernel density estimate (KDE) of target ÎF/F0 values during the whole session on day1 and day9 of 1-ROI experiments (bottom plot). B) Reward-aligned average (N=4) target paw speed on day1 and day10 (top plot). Kernel density estimate (KDE) of target paw speeds on day1 and day10 (bottom plot). C) In the context of CLNF 2-ROI experiments, bivariate distribution of ROI1 and ROI2 ÎF/F0 values during whole sessions on day9 and day19, with densities projected on the marginal axes. The task rule on day9 was âROI1-ROI2 > thresh.â as opposed to âROI2-ROI1 > thresh.â on day19. The bivariate distribution is significantly different (Multivariate two-sample permutation test, p=2.3e-12) on these days, indicating a robust change in activity within these brain regions. D) Joint (bivariate) distribution of left and right paw speeds during the whole session on day4 and day10 of CLMF. Left and right forelimbs were control-point (CP) on day4 and day10 respectively. There is a visible bias in the bivariate distribution towards the CP on respective days. linear regression of the success rate over the days and, based on the slope of the fitted line, discovered ROI rules that yielded statistically different progression (fast and relatively slower) of success rate from the mean slope of all ROIs (Supplementary Figure 2.3C). We visualized these 88 significantly different ROI-rule-based success rates and segregated them into fast and slow based on mean slope (>=0.095 slope was designated fast, else slow) of the progression (Supplementary Figure 2.3D). Our analysis revealed that certain ROI rules (see description in methods) lead to a greater increase in success rate over time than others (Supplementary Figure 2.3D). As mice learned the CLNF task and their performance improved, task latency progressively decreased (Figure 2.4C). Here, task latency refers to the time required by the mice to complete the task within the 30-s trial window. For this measure, we included all trials, both successful and unsuccessful. In the 2-ROI experiment where the task rule required, for example, âROI1 - ROI2â activity to cross a threshold for reward delivery, mice displayed divergent strategies. Some animals predominantly increased ROI1 activity, whereas others reduced ROI2 activity, both approaches could lead to successful threshold crossing (Figure 2.11; see average reward centered responses). In CLMF training, the real-time speed of a selected (also referred to as control point (CP) in terms of tracked points) point was mapped to the graded audio tone generator function. We trained the mice with the FLL bottom as the CP for auditory feedback and reward generation (example trial in Animation 2). Mice reached 80% performance (Figure 2.4B, CLMF Rule-change, No-rule-change) in the task within four days of training (RM ANOVA, p = 8.03e-7). They were eliciting the target behavior (i.e., moving CP at high speed) more frequently on later days compared to the first day of training (Figure 2.5B), and the correlations of CP speed profiles became more pronounced during the trial periods as compared to the rest period (Figure 2.8A). 89 90 Figure 2.6: CLNF: Cortical activity during the closed-loop-neurofeedback training. A) Target-rule-based ÎF/F0 traces in green on day 1 with rule-1 (top row), on day 10 with rule-1 (second row), on day 11 with new rule-2 (third row), and on day 19 with rule-2 (fourth row). Shared regions are trial periods and regions between grey areas are rest periods. The grey horizontal line depicts the threshold above which mice would receive a reward. Golden stars show the rewards received, and short vertical lines in black show the spout licks. B) Representative reward-centered average cortical responses of the 2ROI experiment on labeled days. ROI1 (green) and ROI2 (pink) are overlaid on the brain maps. The task rule on day 1 and day 4 was âROI1-ROI2 > thresh,â as opposed to âROI2-ROI1 > threshâ on day 11 and day 19. C) Linear regression on ROI1 and ROI2 ÎF/F0 during whole sessions for an example mouse. The regression fit inclines towards ROI1 in sessions where the rule was âROI1-ROI2 > thresh.â (day1 slope=0.44, day6 slope=0.32) while it leans towards ROI2 after the task rule switches to âROI2-ROI1 > thresh.â (day11 slope=0.76, day17 slope=0.80). 2.3.2 Mice can rapidly adapt to changes in the task rule. We have assessed how mice respond to changes in closed-loop feedback rules. CLNF Rule-change mice went through a change in regulated cortical ROI(s) (Figure 2.6A, 2.6B) after being trained on an initial set of ROI(s) (Table 2.6, Rule-change). The new ROI(s) were chosen from a list of candidate ROI(s) for which the cortical activations were still low (see âDetermining ROI(s) for 91 change in CLNF task ruleâ under Methods). Reward threshold values were then recalculated for the ROI(s). A full list of ROI(s) we tried in separate mice is listed in Table 2.6. Mouse performance degraded on the first day of the rule switch to the new ROIs (ANOVA, p=8.7e-9), compared to the previous day (Figure 2.4A), and quickly recovered within five days (RM ANOVA p=8.3e-10) of further training. All new cortical ROI(s) appeared to support recovery to the pre-perturbation success rate (Table 2.6), and data were pooled across mice. This can also be observed in the bivariate distribution of a whole session ÎF/F0 values in ROI1 vs ROI2 on day 9 (before rule change) and day 19 (last day after rule change) in Figure 2.5C. Additionally, the linear regression analysis of whole-session ÎF/F0 activity after rule change in the 2-ROI experiment revealed a shift in the regression line slope, favoring the ROI that was required to increase according to the new task rule (Figure 2.6C). Following the rule change, CLNF task latency increased substantially and persisted at a high level across subsequent sessions, eventually declining as task performance adapted to the new rule (Figure 2.4C). Similarly, in the CLMF experiments, the target body part was changed from FLL to FLR for Rule-change mice on day 5 and was associated with a significant drop in their success rate from 75-80% to ~40% (ANOVA p=0.008, Figure 2.4B). Surprisingly, mice quickly adapted to the rule change and started performing above 70% on day 6 (example trial in Animation 3). Looking closely at their reward rate on day 5 (day of rule change), they had a higher reward rate in the second half of the session as compared to the first half (Supplementary Figure 2.4A), indicating they were adapting to the rule change within one session. This can also be observed in the bivariate 92 distribution of left and right paw speeds on day 4 (before rule change) and day 10 (last day after rule change) in Figure 2.5D. As the mice were learning the CLMF task (increasing performance), task latency decreased (Figure 2.4D). Task latency in this context is the time taken by mice to perform the task within a trial period of 30 s. We included all trials, both successful and unsuccessful, in our calculation. Given that the maximum trial duration is 30 s, the task latency was capped at 30 s. Following the trend in task performance, the task latency started decreasing during the first four days but increased on day 5 (rule change) and started to drop again afterward. We also examined the average paw speeds and distributions during trial periods. It is worthwhile noting that for the rule-change group, left forelimb speeds were higher than right forelimb speeds from day 1 to day 4 (when task rule was to move left forelimb). When the rule was switched from left forelimb to right forelimb on day 5, left forelimb speeds dropped below the right forelimb speeds (Supplementary Figure 2.4E). 2.3.3 Graded feedback helps in task exploration during learning, but not after learning To investigate the role of audio feedback in our task, we also had a group with no task-related graded audio feedback (CLMF No-feedback) and instead received audio with a constant frequency (1 kHz) throughout the trials. CLMF No-rule-change mice who received continuous graded auditory feedback significantly improved their task performance (CLMF No-rule-change RM-ANOVA p = 9.6e-7) and outperformed the CLMF No-feedback mice (Figure 2.4B) very early (No-feedback RM-ANOVA p = 0.49), indicating the positive role of graded feedback for task 93 Figure 2.7: CLMF: Speed of the tracked target body part and cortical activity. A) Left forelimb speed (black), target threshold (grey line), and rewards (golden stars) during a sample period in a session on day 1 of the closed-loop training (top row). Shaded regions are trial periods with interspersed rest periods in white. Left forelimb speed, and rewards on day4 (second row). The target body part was changed from the left forelimb to the right forelimb on day5 (third 94 row). Thus, day5 is the first training day with the new rule. Right forelimb speed, and rewards on day 10 of the training (fourth row). B) Reward-centered average cortical responses on days corresponding to rows in A. The target threshold was crossed at -1 s, and the reward was delivered at 0 s. Notice the task rule change on day 5. exploration and learning the association. When graded audio feedback was removed for CLMF Rule-change mice on day 10 (muted speaker in Figure 2.4B), it did not affect their task performance, indicating the feedback was not essential to keep performing the task that they had already learned. 2.3.4 Cortical responses became focal and more correlated as mice learned the rewarded behavior in CLMF There are reports of cortical plasticity during motor learning tasks, both at cellular and mesoscopic scales (Makino et al. 2017; Huber et al. 2012; W. E. Allen et al. 2017). As mice become proficient in a task, their brain activity becomes more focused and less widespread (Figure 2.9). We noticed the peak activity in different regions of the cortex around the rewarding movement decreased ÎF/F0 in amplitude over days (Figure 2.9A, 2.9B, 2.9C, 2.9E). To quantify this, we measured the peak ÎF/F0 (ÎF/F0peak) value in the time window from -1s to +1s relative to the body part speed threshold crossing event in each cortical region. Consistent with our observations, ÎF/F0peak in 95 several cortical regions gradually decreased over sessions, including the olfactory bulb, sensory forelimb, and primary visual cortex (Figure 2.9A, 2.9B, 2.9C). Notably, when the task rule was changed from FLL to FLR in the CLMF Rule-change mice, we observed a significant increase in ÎF/F0peak in regions including the olfactory bulb (OB), forelimb cortex (FL), hindlimb cortex (HL), and primary visual cortex (V1), as shown in Figure 2.9. We believe the decrease in ÎF/F0peak is unlikely to be driven by changes in movement, as movement amplitudes did not decrease significantly during these periods (Figure 2.9D CLMF Rule-change). However, the decrease in ÎF/F0peak followed the same trend as task latency (Figure 2.4D), suggesting that the decrease in ÎF/F0peak is especially prominent in trials where mice were prepared to make the fast movement. These results suggest that motor learning led to less cortical activation across multiple regions, which may reflect more efficient processing of movement-related activity. In addition to ÎF/F0peak reflecting signs of potentially more efficient cortical signaling, intracortical GCAMP transients measured over days became more correlated (to each other) during the trials as the task performance increased over the sessions (Figure 2.9E). Analysis of pairwise correlations between cortical regions (referred to as seed pixel correlation maps) revealed distinct network activations during rest and trial periods (Figure 2.10). While the general structure of the correlation maps remained consistent between trial and rest periods, certain correlations, such as between V1 and RS, were heightened during task trials, whereas others, such as between M1, M2, FL, and HL, consistently increased over the training sessions (Figure 2.10). 96 Figure 2.8: CLMF: Correlation matrix showing pairwise correlations of left and right forelimb speed profiles. A) Top row: During rewarded trials, over the training sessions of CLMF Rule-change (left), No-rule-change (middle), and No-feedback (right). High correlations (dark cells) between speed profiles of CP indicate a unilateral bias in the movement. It is worth noting the drastic changes in correlations as the control-point was changed from left forelimb to right forelimb in Rule-change mice on day4. Bottom row: During rest periods, over the training sessions of CLMF Rule-change (left), No-rule-change (middle), and No-feedback (right). To statistically examine the differences in seed pixel correlations during trials and rest periods, as well as how these correlations changed over training sessions (Day 1-10), we conducted 97 98 Figure 2.9: Cortical dynamics and network changes during longitudinal CLMF training. A) Reward-centered average responses in the olfactory bulb decrease over the days as performance increases. Data shown is a representative example from sessions of a Rule-change mouse. B) Cortical responses become focal and closely aligned to the paw movement (green line) and reward (cyan line) events on day 10 for group-1 (received feedback) as compared to group-3 (no-feedback). C) ÎF/F0 peak values during successful trials (pink) and during rest (cyan) over the ten-day training period in the olfactory bulb (OB) (left, day 1-day 4 p-value=0.025, day 4-day 5 p-value=0.008), forelimb area (FL) (center, day 1-day 4 p-value=0.008, day 4-day 5 p-value=0.04), and primary visual cortex (right, day 1-day 4 p-value=0.04, day 4-day 5 p-value=0.002). Statistical significance was assessed using the Mann-Whitney test and corrected for multiple comparisons with the Benjamini-Hochberg procedure. D) Average movement (mm) of different tracked body-parts during trials in CLMF Rule-change (left), No-rule-change (center), No-feedback (right). 99 E) Correlations between cortical activation on each training session in barrel-cortex (BC, top left), anterolateral motor cortex (ALM, top right), secondary motor cortex (M2, bottom left), and retrosplenial cortex (RS, bottom right). a two-way repeated measures ANOVA (RM-ANOVA) on the seed pixel correlation maps for each day. The two variables for the RM-ANOVA were experimental condition (trial vs. rest) and session number (Day 1-10). This analysis generated two distinct matrices of Bonferroni-corrected p-values (Figure 2.10), one corresponding to each variable, which segregated the seed pixel correlations that were different between trial and rest periods and those that changed over the training sessions. 2.3.5 Distinct task- and reward-related cortical dynamics During the early sessions (days 1 to 3), cortical activity was observed to be spatially widespread and engaged multiple cortical regions. Temporally, the activity spanned both task-related and reward-related events, with no clear distinction between the two phases (Figure 2.9B, left). This broad activation pattern is consistent with the initial stages of learning, where the brain recruits extensive cortical networks to process novel tasks and integrate sensory feedback (Peters, Chen, and Komiyama 2014). As the mouse performance improved in the later sessions (Days 8 to 10), the cortical activity became more segregated both spatially and temporally (Figure 2.9B, middle). This 100 101 Figure 2.10: CLMF cortex-wide seed pixel correlation maps. Pairwise correlations between activity at cortical locations (also referred to as seed pixel locations). A) Top row: No-rule-change average seed pixel correlation map during trial periods (left), during rest periods (middle), and difference of average correlation map during trial and rest (right). Bottom row: No-feedback average seed pixel correlation map during trial periods (left), during rest periods (middle), and difference of average correlation map during trial and rest (right). B) Significant increase in pairwise seed pixel correlations as RM-ANOVA p-value (Bonferroni corrected) matrix between training sessions over the days (left) and between trial vs rest periods (right) for CLMF No-rule-change mice. C) Significant increase in pairwise seed pixel correlations as RM-ANOVA p-value (Bonferroni corrected) matrix between training sessions over the days (left) and between trial vs rest periods (right) for CLMF No-feedback mice. segregation was particularly notable in mice that received closed-loop feedback (Rule-change), where the spatiotemporal patterns of cortical activation were more closely aligned with the specific task and reward events. This transition from widespread to segregated activation is indicative of the brain's optimization of neural resources as the task becomes more familiar, a phenomenon that has been reported in studies of skill acquisition and motor learning (Makino et al. 2017; Huber et al. 2012). Previous studies have shown that feedback, especially when provided in a temporally 102 precise manner, can accelerate the cortical plasticity associated with learning (Ganguly and Carmena 2009). Overall, these findings highlight the importance of closed-loop feedback in motor learning and suggest that real-time neurofeedback can enhance the specificity of cortical representations, potentially leading to more efficient and robust learning outcomes. Figure 2.11: Average reward centered activity in ROIs for 2-ROI experiment. Examples of reward centered activity in both the ROIs in a 2 ROI experiment reveals different strategies adopted by mice. For a task rule specifying âROI1 - ROI2 > thresholdâ, mouse BZ1 and BZ2 decreased ROI2 activity to meet the reward threshold while mouse BU2 and BU3 increased ROI1 activity. 103 Supplementary Figure 2.1: Method for calculating feedback and reward delay in CLNF and CLMF setups. Two devices (device running closed-loop system, an observer device that was 104 just recording the scene), each connected to a camera with overlapping field of view were employed. A) Setup for calculating feedback delay in CLNF experiments deployed on Raspberry Pi. The difference between the onset of the green LED and red LED ON events is the feedback delay. 1) The Raspberry Pi generates a HIGH signal on the GPIO pin connected to the green LED. 2) The HIGH signal is received at the anode of the green LED, causing it to glow. 3) Light emitted by the green LED is received by the brain camera sensor. 4) An image capturing the green emitted light is captured and sent to the Raspberry Pi. 5) The CLNF program processes the image and detects changes in brightness. 6) The CLNF program maps the brightness change to an audio frequency and generates an audio tone output at that frequency. 7) The CLNF program sends a HIGH signal to the GPIO pin connected to the red LED. 8) The HIGH signal is received at the anode of the red LED, causing it to glow. 9) Light emitted by the red LED is received by the sensor of the brain camera. 10) An image frame capturing the red LED light is captured and sent to the Raspberry Pi. 11) During the previous steps, an observer camera records the green and red LEDs. In offline analysis, detect the brightness change in the green LED. 12) Detect the brightness change in the red LED. 13) Calculate the response delay as the time difference between the green and red LED brightness change events. B) Setup for calculating feedback delay in CLMF experiments deployed on Nvidia Jetson Orin. The difference between the onset of movement and the red LED ON events is the feedback delay. 1) The head-fixed mouse in the CLMF apparatus moved the control point crossing the speed 105 threshold. 2) Behavior is captured by the behavior camera and observer camera sensors. 3) The captured image is sent to Nvidia Jetson running the CLMF program. 4) The image frame is analyzed, and tracked points are detected. Calculate the speed of the control point. 5) Map the control point speed to an audio frequency and generate audio tone output at the frequency. 6) Send a HIGH signal to the GPIO pin connected to the red LED. 7) The HIGH signal is received at the anode of the red LED. 8) Bright light from the red LED reaches the behavior camera and observer camera sensors. 9) The captured image is sent to Nvidia Jetson and the observer device. 10) In offline analysis, detect the control point movement event. 11) Detect the brightness change event in the red LED. 12) Calculate the response delay as the time difference between the control point movement event and the red LED brightness change event. C) Offline analysis to calculate response time using data collected in an experiment. Left: Brightness change events of green LED and red LED in CLNF setup, data represents 100 trials. Right: Control-point movement event and brightness change event of red LED in CLMF setup, data represents 30 trials. 106 Supplementary Figure 2.2: Verification of generated audio tone frequencies. A) Left: Spectrogram of an audio recorded in a session where graded audio tone frequencies were generated sequentially from 1 kHz to 22.627 kHz using the CLNF program. Desired frequency values are shown on the x-axis and expected frequencies are marked in red on the y-axis. The frequency values increase exponentially, and therefore the power bands shrink as frequency 107 increases. Right: Peak powers detected compared to the intended frequency, using the spectrogram on the left. B) The power spectral density of the audio recording used is A. The width of the peaks becomes narrower as the frequency increases since the x-axis is on a log scale. 108 Supplementary Figure 2.3: Learning progression was similar in male and female mice, and even similar between 1ROI and 2ROI experiments. There were some ROI rules that were faster to learn than others. A) The success rates over days in male and female mice are not significantly different. Data from all mice in the No-rule-change and Rule-change groups were separated based on their sex (male, 109 female). For days 1-10,the total number of males was 14 and the total number of females was 9; for days 11-19,the total number of males was 9 and the total number of females was 9. B) Success rate over days based on 1ROI and 2ROI experiments. Data from all mice in the No-rule-change and Rule-change groups were segregated based on the ROI type (1ROI or 2ROI). From Day 1 to Day 10,the total number of mice with 1ROI experiments was 5, and with 2ROI it was 18. From Day 11 to Day 19,the total number of mice with 1ROI was 10, and with 2ROI it was 7. C) Slope values of linear regression line on the success rate over days for different ROI-rules. D) ROI rules with slope values greater than or equal to the mean (0.095) were combined in the red group, and those with slope values lower than the mean were combined in the blue group. At a broad level, we can observe that ROI rules in the red group were faster than those in the blue group. 110 111 Supplementary Figure 2.4: CLMF behavior traces A) Cumulative rewards show performance during the whole session from day 1 to day 10, including a perturbation on day 5 where cumulative rewards drops, in a CLMF rule-change mouse. B) Kullback-Leibler divergence scores of speed distributions of different tracked points (snout, left forelimb, right forelimb, left hind limb, right hind limb, and tail base) on the mouse body. Kernel density estimates (KDE) were derived for these tracked points on each day, and divergence scores compared to day 1 were calculated. C) Reward centered left (in blue) and right (in green) forelimb speeds, top row (day1) and third row (day4). Trial end centered left (in blue) and right (in green) forelimb speeds, second (day1) and fourth row (day4). The target control-point during training was left forelimb. D) Left (in blue) and right (in green) forelimb tracks on day 1 (top) and day 4 (bottom) with the control point being the left forelimb. 112 113 Supplementary Figure 2.5: CLMF Seed pixel correlation maps during rewarded trial, rest periods, and their difference. A) Seed pixel correlation maps of labeled seed pixels on day 1, day 4, day 5 (rule change), and day 10 during rewarded trials (excluding the reward consumption period). Seed pixel locations are indicated by black points on the brain map. B) Seed pixel correlation maps of labeled seed pixels on day 1, day 4, day 5 (rule change), and day 10 during rest periods (excluding the reward consumption period). Seed pixel locations are indicated by black points on the brain map. C) Difference of seed pixel correlation maps of labeled seed pixels during rewarded trials and rest periods (A - B) on day 1, day 4, day 5 (rule change), and day 10. Seed pixel locations are indicated by black points on the brain map. There is a distinct increase in correlation during rewarded trials in cortical regions such as V1 and RS across all seed pixel maps. 114 115 Supplementary Figure 2.6: CLNF, CLMF command line operation and preview steps A) Top: Terminal commands to launch a CLNF experiment. Bottom left: Showing widefield calcium activity (green) and reflectance (blue) signals as a composite RGB image. Overlaid text indicates maximum green and blue intensities in the middle row of the image; bottom curves show intensity in the green channel (faded green) and blue channel (bright green) along the middle row of pixels. Two red squares indicate the ROIs in the 2ROI experiment. White dots are the registered centers of the cortical locations specified in the config.ini file. Bottom right: Showing the corrected ÎF/F0 map of the image on its left in real-time. The overlaid artifacts in the form of text and lines are there since we draw those text and lines on the captured image for preview. These artifacts are not present when a session starts. B) Top: Terminal commands to launch a CLMF experiment. Bottom: The preview window shows a live view with tracked points overlaid on the live view, indicated in red. To start the experiment, press âEscâ on the keyboard, type the mouse ID in the prompt, and then press the Enter button to start the experiment. 116 Supplementary Figure 2.7: Visual representation of 1 ROI and 2 ROI rules in CLNF experiment A) ROIs overlaid on mouse dorsal cortical map during 1 ROI experiments. B) ROIs overlaid on mouse dorsal cortical map during 2 ROI experiments. 117 Supplementary Figure 2.8: Example trials along with audio feedback during CLNF and CLMF training A) Target cortical activity in Green, along with horizontal threshold line, Yellow stars as rewards, Black ticks showing licks, and Orange trace showing the audio frequency. B) Target paw speed in Red, along with horizontal threshold like, Yellow stars as rewards, and Orange trace showing the audio frequency. 118 2.4 Discussion 2.4.1 Flexible, cost-effective, and open-source system for a range of closed-loop experiments We developed a versatile, cost-efficient, and open-source platform designed to support a wide array of closed-loop neuroscience experiments, including closed-loop neural feedback (CLNF) and closed-loop movement feedback (CLMF). This system enhances accessibility for the broader research community, enabling the execution of complex experimental paradigms with minimal resource constraints. Our system is built on readily available hardware components, such as Raspberry Pi and Nvidia Jetson platforms, and leverages Python-based software for real-time data processing, analysis, and feedback implementation. The modular approach ensures that the system can be easily customized to meet the specific requirements of different experimental paradigms. Our study demonstrates the effectiveness of a versatile and cost-effective closed-loop feedback system for modulating brain activity and behavior in head-fixed mice. By integrating real-time feedback based on cortical GCaMP imaging and behavior tracking, we provide strong evidence that such closed-loop systems can be instrumental in exploring the dynamic interplay between brain activity and behavior. The system's ability to provide graded auditory feedback and rewards in response to specific neural and behavioral events showcases its potential for advancing research in neurofeedback and behavior modulation. The hardware backbone of our system is designed around the Raspberry Pi 4B+ and Nvidia Jetson devices, chosen for their compactness, low cost, high computational power, and wide 119 community support. These platforms have been demonstrated to be effective in neuroscience research, for several applications (Michelson et al. 2023; Murphy et al. 2020; Silasi et al. 2018; Dhillon et al. 2021). By utilizing open-source software frameworks such as Python, the system can be modified and extended to incorporate additional functionalities or adapt to new experimental protocols. Our Python-based software stack includes libraries for real-time data acquisition, signal processing, and feedback control. For instance, we utilize OpenCV for video processing and DeepLabCut-Live (A. Mathis et al. 2018; Kane et al. 2020) for pose estimation, which are essential components in experiments requiring precise monitoring and feedback based on animal behavior. Additionally, we have integrated libraries for handling neural data streams, such as NumPy and SciPy, which facilitate the implementation of complex experimental designs (Akam et al. 2022) involving multiple data sources and feedback modalities. By integrating the system with LED drivers and opsin-expressing transgenic mouse lines, it is straightforward to achieve precise temporal control over neural activation, enabling the study of causal relationships between neural circuit activity and behavior (C. Lee et al. 2020). The cost-effectiveness of our system is a significant advantage, making it accessible to a broader range of research labs, including those with limited funding. The use of off-the-shelf components and open-source software drastically reduces the overall cost compared to commercially available systems, which often require expensive proprietary hardware and software 120 licenses (C. Allen and Mehler 2019; White et al. 2019). The open-source nature of our closed-loop platform fosters collaboration and innovation within the research community. By providing unrestricted access, other labs can freely modify, enhance, and share the system, promoting a culture of transparency and shared progress. Importantly, our goal is to increase the number of studies utilizing this platform, enabling a broader exploration of closed-loop methodologies across diverse research contexts. This approach not only accelerates the pace of discovery but also enhances reproducibility and adaptability, ensuring the platform remains a robust tool for advancing neuroscience research. The system's flexibility is demonstrated by its successful application across two closed-loop experimental paradigms (CLNF, CLMF). For example, in our study, we utilized the system to implement real-time feedback based on intracellular calcium-induced fluorescence imaging in awake, behaving mice. The system provided auditory feedback in response to changes in cortical activation, allowing us to explore the role of real-time feedback in modulating both neural activity and behavior. 2.4.2 Importance of closed-loop feedback systems Closed-loop feedback systems have gained recognition for their ability to modulate neural circuits and behavior in real time, an approach that aligns with the principles of motor learning and neuroplasticity. The ability of mice to learn and adapt to tasks based on cortical or behavioral feedback underscores the parallels between closed-loop systems and natural proprioceptive 121 mechanisms, where continuous sensory feedback is crucial for motor coordination and spatial awareness. This study builds upon the foundational work of (Fetz 1969b), who first explored the potential of closed-loop neurofeedback, and expands its application to modern neuroscience by incorporating optical brain-computer interfaces. Our findings are consistent with previous research showing that rodents can achieve volitional control over externally represented variables linked to their behavior (Clancy et al. 2014; Neely, Piech, et al. 2018; Prsa, Galiñanes, and Huber 2017; Clancy and Mrsic-Flogel 2021). Moreover, the rapid adaptation observed in mice when task rules were altered demonstrates the system's capacity to facilitate learning and neuroplasticity, even when the conditions for achieving rewards are modified. The quick recovery of task performance after a rule change, as evidenced by the improved performance within days of training, highlights the robustness of the closed-loop feedback mechanism. We have focused on large regional cortical GCAMP signals that are relatively slow in kinetics. 2.4.3 Neuroplasticity and Cortical Dynamics The observation that cortical responses became more focused as mice learned the rewarded behavior aligns with established theories of motor learning, where neural efficiency improves with practice (Makino et al. 2016; Huber et al. 2012; C. B. Allen, Celikel, and Feldman 2003). As mice became more proficient in the task, the widespread cortical activity observed during the initial training sessions became more regionally localized, indicating more efficient neural processing. 122 The reduction in ÎF/F0peak values across sessions suggests that the brain becomes more efficient at processing task-relevant information, a phenomenon consistent with the optimization of neural circuits observed in skilled motor learning (Wolpert, Diedrichsen, and Flanagan 2011; Krakauer et al. 2019). The distinct spatiotemporal patterns of cortical activation observed in mice receiving closed-loop feedback further support the role of real-time feedback in enhancing cortical plasticity. The pronounced segregation of task-related and reward-related cortical dynamics in the later training sessions indicates that closed-loop feedback facilitates the refinement of neural circuits involved in motor learning. These findings are in line with previous studies that have demonstrated the importance of temporally precise feedback in accelerating cortical reorganization and enhancing learning outcomes (Ganguly and Carmena 2009). 2.4.4 Value of the CLoPy platform in systems neuroscience The CLoPy platform addresses a critical gap in systems neuroscience by providing a flexible and cost-effective closed-loop feedback system tailored to modulate neural activity and behavior in real time. Many current neuroscience studies assess brain activity and behavior separately, with analyses performed post hoc. CLoPy advances this paradigm by enabling researchers to directly investigate the dynamic interplay between these domains through real-time feedback, a fundamental principle of neuroplasticity and motor learning (Fetz 1969b; Wolpert, Diedrichsen, and Flanagan 2011). This integration has broad implications for experimental neuroscience, 123 allowing researchers to probe causal relationships between brain activity, behavior, and environmental contingencies in a controlled and scalable manner. By enabling closed-loop experiments based on neural imaging (e.g., GCaMP fluorescence) and real-time behavioral tracking (e.g., DeepLabCut-Live), CLoPy allows researchers to address a range of experimental questions. For example, the system can be used to study how cortical plasticity facilitates motor learning, how the brain adapts to rule changes in a task, and how feedback mechanisms influence recovery from neurological injuries. These capabilities align with the needs of systems neuroscience researchers who seek to elucidate the mechanisms underlying adaptive brain-behavior interactions across different experimental conditions. Compared to other platforms (see Table 2.1), such as pyControl (Akam et al. 2022), CLoPy uniquely integrates mesoscopic calcium imaging, real-time tracking, and feedback delivery, making it particularly suitable for exploring neural dynamics at a finer resolution. 2.4.5 Positioning within the open-source neuroscience community As part of the broader open-source neuroscience movement, CLoPy exemplifies the principles of accessibility, modularity, and reproducibility. The platform's reliance on widely available hardware, such as Raspberry Pi and Nvidia Jetson, and its use of Python-based libraries ensure that researchers with varying levels of technical expertise can adopt and modify it. This is particularly important in the current landscape, where open-source tools like pyControl (Akam et 124 al. 2022), OpenEphys (Siegle et al. 2017), and Bonsai (Lopes and Monteiro 2021) have transformed experimental neuroscience by reducing costs and fostering collaboration. CLoPy complements these efforts by extending open-source frameworks to the realm of closed-loop neuroscience. It provides detailed documentation, hardware schematics, and adaptable software, empowering researchers to customize the system for diverse experimental needs. For example, CLoPy enables experiments involving optogenetic stimulation, multimodal feedback, and integration with advanced imaging techniques. By lowering barriers to entry, it democratizes access to closed-loop experimental paradigms, particularly for labs with limited resources. 2.4.6 Experimental applications and implications CLoPy's flexibility and modularity make it suitable for a wide range of experimental applications. In this study, we demonstrated its utility in closed-loop neural feedback (CLNF) and closed-loop movement feedback (CLMF) paradigms. These experiments showcase how CLoPy can be used to study fundamental questions about the dynamic interplay between neural activity, feedback, and behavior. For instance, the systemâs ability to deliver graded auditory feedback in response to cortical activation allowed us to explore how real-time neurofeedback modulates neural dynamics. Similarly, its real-time tracking capabilities enabled precise feedback delivery based on specific behavioral events, such as limb movements, facilitating the investigation of motor learning and adaptation. In our system, we measured latencies of ~63 ms for CLNF and ~67 ms for CLMF. While such latencies may limit applications requiring millisecond precision, such as fast whisker 125 movements, saccades, or fine-reaching kinematics, we emphasize that many relevant behaviors, including postural adjustments, limb movements, locomotion, and sustained cortical state changes, occur on timescales that are well within the capture range of our system. It is also important to note that these latencies are not solely dictated by hardware constraints. A significant component arises from the inherent biological dynamics of the calcium indicator GCaMP6s (T.-W. Chen et al. 2013) and calcium signaling itself, which introduce slower temporal kinetics independent of processing delays. Newer variants, such as GCaMP8f, offer faster response times and could further reduce effective biological latency in future implementations. We acknowledge that Raspberry Pi provides a low-cost solution but contributes to modest computational delays, while Nvidia Jetson offers faster inference at higher cost. Our choice reflects a balance between accessibility, cost-effectiveness, and performance, making the system deployable in many laboratories. Importantly, the modular and open-source design means the pipeline can readily be adapted to higher-performance GPUs or integrated with electrophysiological recordings, which provide higher temporal resolution. In the case of CLNF we have focused on large regional cortical GCAMP signals that are relatively slow in kinetics. While such changes are well suited for transcranial mesoscale imaging assessment, it is possible that cellular 2-photon imaging (Yu et al. 2021) or preparations that employ cleared crystal skulls (T. H. Kim et al. 2016) could resolve more localized and higher frequency kinetic signatures. In this case it would be important to potentially tune and enhance closed-loop methodology to more closely follow these events. 126 The platformâs ability to modulate neural and behavioral outputs in real time has far-reaching implications for experimental neuroscience. It enables researchers to study neural mechanisms underlying learning, adaptation, and plasticity with a level of precision and scalability that was previously difficult to achieve. For example, CLoPy can be used to investigate how the brain reorganizes itself after injury or how neural circuits adapt to changing task demands. 2.4.7 Future directions and broad impact To further enhance its utility, future iterations of CLoPy could integrate advanced machine learning algorithms for real-time data analysis and decision-making, enabling more sophisticated feedback paradigms. Additionally, expanding the platform's compatibility with other experimental modalities, such as multi-photon imaging and electrophysiology, could broaden its applications in neuroscience research. CLoPyâs scalability also opens avenues for its use in translational research, such as testing neurorehabilitation interventions or brain-computer interfaces in larger animal models or humans. By providing an open-source, flexible, and cost-effective solution, CLoPy has the potential to significantly advance the field of systems neuroscience. It not only enables researchers to address complex experimental questions but also fosters collaboration and innovation within the neuroscience community. As more labs adopt and refine this platform, we anticipate that it will accelerate the pace of discovery, enhance reproducibility, and contribute to the development of novel therapeutic strategies for neurological disorders. While we aimed to include multiple animals for each experimental condition, certain task rules are represented by only one or a few animals. This limitation primarily arises from logistical challenges, including 127 the extensive time required for training under specific task contingencies and the variability in maintaining high-quality optical windows over prolonged experimental periods. Consequently, while these data provide valuable insights into the feasibility and mechanisms of the task, we acknowledge that broader generalizations should be made cautiously and that further replication will be important in future studies. In conclusion, our study highlights the significant potential of closed-loop feedback systems for advancing neuroscience research. By providing a flexible, cost-effective, and open-source platform, we offer a valuable tool for exploring the complex interactions between brain activity and behavior, with implications for both basic research and clinical applications. 128 Chapter 3: Modelling multi-region cortical interactions using data-constrained recurrent neural networks 3.1 Introduction Advancements in experimental techniques now provide unparalleled access to extensive neural populations across multiple interacting brain regions. However, making sense of these large-scale datasets requires both efficient computational models to uncover key aspects of inter-regional communication to interpret these insights. While much progress has been made in understanding single-region neural coding, it is increasingly clear that cognitive processes often emerge from interactions among distributed cortical networks (S. L. Bressler 1995; Siegel, Donner, and Engel 2012; Varela et al. 2001; Steven L. Bressler and Menon 2010; Steinmetz et al. 2019). Traditional analyses of cortical regions in isolation may therefore provide only partial insights (Machado, Kauvar, and Deisseroth 2022; Pisarchik et al. 2019). Multi-region approaches, enabled by advances in large-scale electrophysiology, optical imaging, and neuroanatomical tracing, are beginning to reveal the integrative nature of cortical processing (Machado, Kauvar, and Deisseroth 2022). The Allen Instituteâs open dataset, particularly the Visual Behavior 2P (VB2P) dataset (M. Garrett et al. 2020; Groblewski et al. 2020; Hu et al. 2021; de Vries et al. 2019) has significantly contributed to the field by providing large volumes of standardized, high-quality neuronal recordings. The VB2P dataset comprises two-photon calcium imaging data capturing the activity of large scale neuronal populations in the mouse visual cortex during visual behavioral tasks. These 129 resources enable modeling efforts that account for the connectivity patterns, stimulus responses, and behavioral correlates of neurons spanning multiple cortical areas. By incorporating physical constraints derived from these datasets, a data-constrained model can potentially capture the underlying circuit architecture and activity patterns more faithfully than unconstrained models. The goal of such modeling is to examine how complex information streams are integrated in the cortex to guide behavior. In this chapter, we describe and discuss a biologically inspired, data-constrained recurrent neural network (RNN) model developed in PyTorch, inspired by the work of (Perich et al. 2020) - specifically constrained by task-specific, neural recordings. Here a RNN (Rumelhart, Hinton, and Williams 1986; Elman 1990) refers to a class of recurrent artificial neural network designed to process temporal or sequential data by maintaining an internal hidden state, or âmemory,â which is updated at each time step based on the current input and the previous hidden state. These recurrent (feedback) connections enable the network to capture temporal dependencies across the sequence, unlike feedforward networks where each input is processed independently. A distinguishing feature of our correlation initialized RNN (thus CorNet) model is that the connection weights are initialized by a normalized correlation matrix, that employs backpropagation to update the unit weights, and can be trained on a GPU, leading to speed up in model training. We employ Allen Instituteâs large-scale dataset of VB2P (M. Garrett et al. 2020; Groblewski et al. 2020; Hu et al. 2021; de Vries et al. 2019), to explore this method. Furthermore, we employ the closed-loop movement feedback (CLMF) dataset (Gupta and Murphy 2025) to 130 investigate the interplay between local cortical mesoscale GCaMP activity during behavioral responses by utilizing this modular RNN approach. Ultimately, this chapter weaves together experimental and computational approaches to illustrate the power of modeling for uncovering the dynamical interactions within the brain's network. 3.2 Methods 3.2.1 Data and code availability The details and source code for the three region toy example RNN simulation can be found in the original paper (Perich et al. 2020) and here- https://github.com/rajanlab/CURBD. The VB2P dataset (M. Garrett et al. 2020) used in this work can be found here- https://portal.brain-map.org/circuits-behavior/visual-behavior-2p The CLMF source data used in this paper is available here- https://doi.org/10.20383/103.01152. Code to implement the model, recreate the figures, are hosted on GitHub and can be found here- https://github.com/pankajkgupta/CorNet. Any additional information required to reanalyze the data reported in this work is available from the lead contact upon request. 3.2.2 Data-constrained RNN modeling of multi-region interactions We constructed Model RNNs that are directly constrained by experimentally-obtained time-series neural data. The network is structured as a vanilla RNN, where number of units ð was matched to the number of recorded neurons in each dataset. The model was implemented in PyTorch and trained on a GPU. Each RNN unit represents a recorded neuron, and the model learns to 131 approximate its temporal dynamics based on its recurrent input. The dynamics are governed by a recurrent equation that evolves neural activity over time: ð¥ð¡+1 = ð(ð â ð¥ð¡ + ð¼ð¡) Where ð¥ð¡ â ð ð is a vector of neural activities at time t, ð â ð ðÃð is recurrent weight matrix, ð¼ð¡ is external input vector at time t, ð nonlinear activation function (ReLU or tanh), and ð is the number of neurons (equal to recorded neurons per session). The model was trained individually for each recorded session, allowing direct correspondence between each RNN unit and a biologically recorded neuron. The recurrent weight matrix ð is initialized using the normalized Pearson correlation coefficients between recorded neurons calculated from preprocessed calcium imaging traces (Figure 3.2B). This biologically constrained initialization embeds observed co-activation structure into the network and ensures that highly correlated neurons have stronger initial interactions. To ensure stable dynamics and prevent exploding activations during the initial phases of learning, the weight matrix is further normalized such that its spectral radius remains less than 1. The spectral radius, defined as the largest absolute value among the eigenvalues of a matrix, governs the long-term behavior of signals propagated through recurrent connections. By constraining this value below 1, we guarantee that iterative applications of the weight matrix cause signal amplitudes to decay over time rather than grow uncontrollably, thereby promoting numerical stability and smoother gradient flow in early training epochs. 132 To incorporate biologically inspired features into the model, we introduced sparsity constraints during the design and training of the recurrent neural network (RNN), enhancing generalization by incorporating dropout during training. Dropout randomly silences a fraction of the network units during each training step, effectively mimicking the sparse and probabilistic nature of neural firing. This regularization technique prevents overfitting and encourages robustness in the learned recurrent dynamics. Together, these biologically motivated constraints enable the CorNet RNN model to more accurately capture the structure and function of real cortical networks while maintaining fidelity to experimental data. The RNN was trained using backpropagation through time (BPTT) implemented in PyTorch. The objective was to minimize the mean squared error (MSE) between predicted and recorded neural activity. We used the Adam optimizer with a learning rate of 0.001, and training was conducted on an NVIDIA GPU for speed and scalability. 3.2.3 Inferring directional inputs from trained CorNet RNN After training the RNN to replicate the temporal dynamics of cortical neural activity, we sought to interpret the learned dynamics by inferring the directional input contributions between neurons and across cortical regions. The trained RNN comprises recurrently connected units, each corresponding to a recorded neuron in the dataset. These units are interconnected through a learned weight matrix ð, initialized with the correlation matrix and optimized during training to reproduce the observed dynamics in the recorded neural activity. 133 Figure 3.1 Training data-constrained RNN model A) Schematic of CorNet training steps. An artificial neural network with the same number of units as in the recorded data. Current output prediction is done based on previous hidden state (weight matrix) and previous output. Training loss is calculated as mean squared error (MSE) between the current output and the recorded activity, and the error is backpropagated to previous steps. B) Schematic of a single unit in the RNN network at time t. C) Training loss (MSE) decreases as the training progresses. D) Schematic of RNN unravelled through time for backpropagation. Let: ð â ð ðÃð be the trained recurrent weight matrix, ð is the number of neurons. 134 ?Ì? â ð ðÃð be the predicted activity of the network at each time point ð after training. This matrix approximates the true recorded activity. ?Ì?(ð¡) â ð ð is the predicted activity vector at time ð¡ Based on the weight matrix ð from the trained CorNet, we aimed to estimate the instantaneous input each neuron receives from all other neurons in the network at every time point. This was accomplished by computing the matrix product between the weight matrix ð and the activity vector ?Ì?(ð¡) at each time step. Mathematically, this operation is equivalent to: ð¼(ð¡) = ð â ?Ì?(ð¡) To compute this over all time points efficiently and obtain a full tensor of size ð Ã ð Ã ð (where each slice represents the input from each unit j to each unit i at each time step), we used the np.einsum operation in Python: ð¼ = ðð. ðððð ð¢ð(â²ðð, ð¡ðâ> ð¡ððâ², ð, ?Ì?, ððð¡ðððð§ð = â²ððð¡ððððâ²), where â²ððâ² refers to the weight from neuron j to neuron i, â²ðâ² refers to the predicted activity of neuron ð at time ð¡, â²ð¡ððâ² denotes the resulting input from ðâ> ð at each time ð¡. This produces a time-varying input tensor ð¼[ð¡, ð, ð], which represents the influence of neuron ð on neuron ð at time ð¡, given the activity of neuron ð and the learned unit weight ððð. Summing along the appropriate axis allows quantification of (1) total input to a neuron across time, 135 and (2) input from one region to another, by grouping neurons by anatomical region labels. This analysis is particularly useful for examining inter-regional interactions. For example, neurons are grouped into cortical areas (e.g., primary visual area: VISp, anterolateral visual area: VISal, anteromedial visual area: VISam, and lateral visual area: VISl) (M. E. Garrett et al. 2014; DâSouza et al. 2022; Harris et al. 2019; Siegle et al. 2021), and by summing the directional input contributions from neurons in one area to another over time, we estimated net directional inputs between brain regions during specific behavioral states or trial epochs (e.g., hit vs. miss trials). This method provides a biologically interpretable way to map the effective connectivity learned by the RNN model and observe how different cortical regions may be influencing one another dynamically over time. It complements traditional correlation-based functional connectivity analyses by providing directional, model-constrained estimates of inter-neuronal and inter-regional inputs, grounded in the trained dynamical model. However, one important limitation is that we are constrained by the spatial extent of the imaging field and the diversity of cell types within it; we do not observe all potentially relevant inputs to each neuron, and thus some inferred interactions may be incomplete or biased due to unobserved neurons and their connections. 3.2.4 Validation of CorNet with simulated data To validate the CorNet RNN model, we employed a simulation framework based on the three-region cortical network toy example introduced in (Perich et al. 2020) for evaluating CorNetâs ability to infer directional interactions across modeled brain regions. The simulated network comprises three functionally distinct cortical regions, each containing interacting populations of neurons with characteristic temporal activity patterns and predefined directional inputs. 136 Importantly, because the simulation provides full access to the ground truth simulated neural dynamics, including the known structure of inter-regional connectivity, it allows us to rigorously test how well a model can recover hidden directional inputs, which are not directly observable in real neural recordings. Since our goal is to apply CorNet to real, partially observed neural data to infer underlying directional influences, it was essential to first benchmark the model using a controlled system where ground truth interactions are known. We therefore used the same simulation framework (illustrated in Figure 3.2) that was employed in the CURBD study (Perich et al. 2020), allowing for a direct comparison between the two approaches. CorNet was implemented in PyTorch with GPU acceleration and trained using backpropagation through time (BPTT) to minimize the mean squared error between its predicted neural activity and the ground truth from the simulation. As mentioned previously, to improve training efficiency and biological plausibility, we initialized the modelâs weights using a normalized pairwise correlation matrix computed from the simulation data. This correlation-based initialization provided a structured starting point, which significantly improved convergence speed and helped the model learn meaningful dynamics more quickly. After 1000 iterations of training, CorNet successfully reproduced the neural activity trajectories of all three regions and accurately recovered the dominant input directions originally defined in the simulation (Figure 3.3). Moreover, due to GPU acceleration and the correlation-based initialization, CorNet achieved these results with substantially reduced training time. 137 Representative results are shown in Figure 3.3, demonstrating a close match between CorNetâs predictions and the ground truth neural dynamics. 3.2.5 Multi-region visual behavior 2P (VB2P) dataset For the modeling of multi-regional cortical interactions, we utilized the Visual Behavior 2-Photon (VB2P) dataset (M. Garrett et al. 2020), a large-scale, publicly available resource from the Allen Institute for Brain Science (AIBS). This dataset consists of in-vivo two-photon calcium imaging recordings from excitatory and inhibitory neurons across various layers and regions of the mouse visual cortex, collected while mice performed a visually guided behavioral task. The dataset includes recordings from multiple cortical areas (primary visual area: VISp, anterolateral visual area: VISal, anteromedial visual area: VISam, and lateral visual area: VISl) at two cortical depths, and consists of recordings from eight cortical planes. Both the cortical depths varied across different animals but were still within the layer 2-3 of the cortex. For ease of pooling the data across animals and interpretation we appended â_1â and â_2â to the labels of top and bottom cortical planes resulting in the region labels as: VISp_1, VISp_2, VISal_1, VISal_2, VISam_1, VISam_2, VISl_1, and VISl_2 (Figure 3.4C). The VB2P data was collected from different genetically defined Cre lines to image from excitatory (Slc17a7-IRES2-Cre;Camk2a-tTA;Ai93, referred as VGLUT1) and inhibitory (VIP-IRES-Cre;Ai148(TIT2L-GC6f-ICL-tTA2), referred as VIP & SST-IRES-Cre;Ai148(TIT2L-GC6f-ICL-tTA2), referred as SST) neurons expressing GCaMP6f in separate animals, yielding 138 Figure 3.2 Multi-region interactions using data-constrained recurrent neural network models 139 A) Multiple regions with representative neurons connected within and across regions in cartoon representation. B) Correlation matrix of simulated data, used to initialize the weights between the units in the CorNet model as a representative example. The weights are from neurons along the x-axis to neurons along the y-axis. C) CorNet trained model weights between neurons in the simulated dataset for training iteration 100 (left) and 1000 (right). D) Simulated activity in regions A, B, and C (top row). Activity of each neuron in a region can be seen as a weighted sum of inputs from all the neurons in each region as shown in the bottom row (A to A, B to A, and C to A). neural data from three different cell types that was collected in separate sessions (all data from AIBS). Mice were trained to perform a go/no-go visual change detection task in which they responded to changes in image identity by licking for a water reward. Imaging was performed during task engagement (behavioral sessions) and passive viewing (passive sessions). We focus on the behavioral sessions in this thesis since these sessions involved an active task. More details about the task as data can be found in the original AIBS publication (M. Garrett et al. 2020). Raw calcium traces were extracted, motion corrected, segmented, and delta F over F0 for each neuron was pre-calculated by the AIBS as part of the dataset release. 140 3.2.6 CLMF dataset We also utilized the movement CLMF dataset previously collected using a custom-built experimental platform (see Chapter 2 for full details) (Gupta and Murphy 2025). The CLMF dataset consists of simultaneously recorded widefield calcium imaging data and behavioral tracking from head-fixed mice trained on a forelimb movement task with real-time auditory feedback. In brief, the imaging setup employed a Pantera TF 1M60 CCD camera (Dalsa) for capturing dorsal cortical GCaMP6s fluorescence, controlled via EPIX software and a frame grabber card. Behavioral imaging was carried out in parallel using an Omron Sentech STC-MCCM401U3V USB3 Vision camera mounted on an Nvidia Jetson Orin device, which also handled real-time pose estimation and trial control. All mice were implanted with a chronic transcranial window to allow for mesoscale cortical imaging across the dorsal surface. Fluorescence images were acquired at 30 Hz with spatial binning and saved as 128x128 pixels 12-bit grayscale frames. To provide real-time feedback, the speed of a tracked forelimb point was mapped to auditory tones via custom Python scripts. Each experiment consisted of 60 trials alternating between task and rest periods. The dataset includes trial-aligned ÎF/F0 calcium signals from dorsal cortical regions, behavioral movement speeds, and associated feedback timing. For modeling, all imaging data were preprocessed by performing ÎF/F0 normalization, z-scoring across trials. Regions of interest (ROIs) were defined anatomically and functionally, and trial-averaged population activity traces were used as input sequences for the RNN training. 141 3.2.7 Phase shift analysis of VB2P cortical activity across neuronal subtypes We analyzed the 2P imaging data collected from multiple cortical regions across experimental sessions involving transgenic mice expressing GCaMP in genetically defined neuronal subtypes. These included the VIP-Cre, SST-Cre, and Emx1-Cre mice, each expressing calcium indicators in distinct neuronal populations. For each mouse and session type (e.g., 'OPHYS_1_images_G', 'OPHYS_3_images_G', refer the original paper describing the dataset), trial-averaged calcium fluorescence activity (ÎF/F0) was extracted for each defined cortical region. We focused on 'hit' trials in which mice correctly responded to a stimulus. The ÎF/F0 time series data for each trial was z-score normalized across time to control for baseline differences and trial-to-trial variability. After normalization, we averaged across all âhitâ trials to obtain a single representative activity trace per region per Cre line. To assess the temporal alignment and potential phase shifts in cortical dynamics between neuronal subtypes (Figure 3.7), we employed cross-correlation analysis, a widely used technique for quantifying the temporal relationship between two time series signals. For each pair of Cre lines within a cortical region (for example within VISp), we computed the cross-correlation between their respective average ÎF/F0 traces. Prior to computing cross-correlation, signals were z-score normalized to ensure zero-mean and unit variance, which standardizes the scale and improves interpretability of the correlation magnitude. Cross-correlation was computed in "full" mode, yielding correlation values across all possible lags between the two signals. The lag corresponding to the maximum cross-correlation was used to estimate the temporal offset (in 142 frames) between the signals. This lag was then converted to a phase shift in degrees by assuming that one full cycle corresponds to the entire signal length (360°). The resulting phase shift provides an interpretable measure of whether one neural population systematically leads or lags another in a given cortical region (Figure 3.7). Additionally, the maximum correlation value was used as a measure of signal similarity. High correlation indicates strong temporal alignment, while the lag indicates directional offset. Cross-correlation is a widely accepted method for assessing temporal alignment and directional dependencies between signals in neuroscience, particularly when signals are oscillatory or exhibit consistent temporal structure (Brody 1999). This technique avoids assumptions about the underlying signal distribution and is well suited for z-scored calcium imaging data. The bootstrapped approach provides robust, distribution-free inference about the significance and variability of detected phase shifts. Compared to other methods such as Fourier-based coherence or phase-locking value (PLV), cross-correlation is more intuitive and interpretable for temporally resolved activity traces, especially when the signals may not be strictly oscillatory but show time-locked evoked dynamics. The detection of phase shifts in activity between genetically defined neuronal populations offers insight into circuit-level differences in processing latency or synchronization. For instance, earlier activation of VIP-expressing interneurons compared to SST-expressing interneurons in the visual cortex may reflect their feedforward disinhibitory roles (Pi et al. 2013; Karnani et al. 2016). To assess the statistical significance of the estimated phase shifts, bootstrapped confidence intervals were used. We resampled the input signals with replacement (n 143 = 1000 iterations) and recalculated phase shifts for each bootstrap iteration. From the distribution of bootstrapped phase shifts, we computed a 95% confidence interval. The p-value was derived as the proportion of bootstrapped phase shifts with opposite sign or centered around zero, adjusted for a two-tailed hypothesis. 3.3 Results 3.3.1 CorNet accurately replicates simulated neural dynamics To validate the ability of the CorNet to accurately capture underlying neural dynamics and infer inter-unit interactions, we first employed a synthetic test dataset adapted from Perich et al. (2020). This simulated system offers ground-truth access to both the temporal activity of individual neurons, and the underlying weights between the units, providing an ideal benchmark to evaluate the performance of our model in a controlled setting. We trained CorNet on the simulated activity to replicate the dynamics of neural populations. Figure 3.3A shows the temporal activity of a representative simulated neuron (black trace) alongside the predicted activity from the RNN trained for 100, 500, and 1000 iterations (increasing shades of green). The model output progressively converged toward the ground-truth recorded neural trace with more training iterations, demonstrating the effectiveness of backpropagation in refining network output. The improving fit illustrates that CorNet can learn the underlying structure of simulated neural trajectories with sufficient training. 144 Figure 3.3 CorNet replicates simulated neural dynamics in a 3-region toy example. A) Activity of an example simulated neuron (black) and dynamics of RNN trained to replicate the simulated neuron after 100 iterations, 500 iterations, and 1000 iterations (increasing shades of green). B) Dynamics of top three principal components in simulation data (black), RNN trained using CorNet (orange), and RNN trained using CURBD (blue). C) Temporal activity of an example neuron in the simulated data (black) and activity of corresponding unit in the CorNet trained RNN (orange). D) Temporal inputs from unit 40 to unit 100 in the simulated data (black) and normalized inferred inputs from unit 40 to unit 100 in the CorNet trained RNN (orange). 145 To assess how well the CorNet captured the overall structure of the neural population dynamics, we compared the top three principal components (PCs) of the simulated population activity with those extracted from the trained networks. As shown in Figure 3.3B, the PCs from CorNet (orange) closely overlapped with those from the original simulation (black), indicating that the model captured the dominant axes of neural variability. In contrast, a RNN trained using a similar method called CURBD (Perich et al. 2020) with uniform random initialization (CURBD; blue) was not as well in recovering these dynamics as accurately for the same number of training iterations (Figure 3.3B), suggesting that CorNet can capture the latent structure of inter-unit coordination. Beyond overall activity reconstruction, one of the critical advantages of using a modular RNN framework is its ability to decompose the overall activity into constituent inferred functional interactions between neurons. Overall temporal activity of a neuron can be split into constituent temporal inputs coming from all the other neurons with non-zero connections, weighted by the learned weight matrix. To depict this, we employed the simulation data where ground truth temporal inputs from each neuron to other neurons are known. We compared the ground-truth temporal input from unit 40 to unit 100 in the simulation with the normalized inferred input from the trained CorNet model (Figure 3.3D). The CorNet-inferred input trace (orange) closely matched the true input (black), suggesting that the model correctly recovered the timing and directionality 146 Figure 3.4 Visual Behavior 2P experiment setup by Allen Institute for Brain Sciences A) Mice underwent a standard training process where they were initially trained to detect orientation changes of grating stimuli and later trained to detect changes in natural scene image stimulus. Natural scene images were presented for 250 ms followed by 500 ms of gray screen subsequently. Consecutive image presentations could be the same or different as shown in the top figure. Trials where image changes are called GO trials, and if images don't change, they are called a CATCH trial. To succeed in a GO trial, mice are supposed to detect the image change and report the change by licking a water spout and receive a water drop as a reward, as depicted in the bottom cartoon. B) The experiment included multi-plane 2-photon calcium imaging recordings from the visual cortex of separate transgenic mice expressing the calcium indicator GCaMP6f in populations of excitatory (Slc17a7-IRES2-Cre;Camk2a-tTA;Ai93(TITL-GCaMP6), referred as VGLUT1) and 147 inhibitory (VIP-IRES-Cre;Ai148(TIT2L-GC6f-ICL-tTA2), referred as VIP & SST-IRES-Cre;Ai148(TIT2L-GC6f-ICL-tTA2), referred as SST) neurons in separate animals. C) Multi-region, multi-plane 2-photon calcium imaging (4 regions, 2 planes; total 8 planes) was recorded from the mouse lines mentioned in B during the experiment sessions. of inter-unit interactions. This result further supports the utility of our model in inferring effective connectivity patterns underlying neural dynamics. Together, these results establish that CorNet is capable of not only replicating synthetic population dynamics but also faithfully recovering both low-dimensional structure and directed interactions from data. The success of CorNet on synthetic data provides a strong foundation for its application to real neural datasets, such as those from the Visual Behavior 2P and closed-loop feedback paradigms explored in subsequent sections. 3.3.2 Cell-type specific neural responses to image changes vary across cortical regions in VB2P dataset To investigate how different neuronal cell types respond to behaviorally relevant visual stimuli, we analyzed two-photon functional calcium imaging (GCaMP) data from the VB2P dataset (Figure 3.4). Specifically, we examined the trial-averaged responses during image change detection tasks across three genetically defined cell populations: excitatory neurons (VGLUT1-Cre), somatostatin-expressing interneurons (SST-Cre), and vasoactive intestinal peptide-148 expressing interneurons (VIP-Cre) (Figure 3.4B; data from separate mice). For each population, we quantified neural activity during hit trials (where the animal correctly detected the image change and licked) and miss trials (where the image change occurred but the animal failed to respond) (Figure 3.6). Panel A of Figure 3.6 presents the group-averaged neural activity traces for each Cre mouse line across the visual cortical regions. In each subplot, the vertical black line marks the onset of the image change. Excitatory (VGLUT1) neurons demonstrated robust, time-locked increases in fluorescence following the image change during hit trials across most regions, suggesting strong sensory and decision-related responses. Notably, the SST population showed more sustained and regionally heterogeneous responses, whereas VIP neurons displayed a broader temporal spread and higher trial-to-trial variability. These qualitative differences suggest distinct roles of cell types in encoding or modulating image change signals during perceptual decision-making. To quantify these differences, Panel B summarizes the average peak fluorescence responses during hit and miss trials for each region and cell type. Across the VGLUT1 group, responses were significantly higher during hit trials compared to miss trials in several key visual regions (e.g., VISp, VISl, VISam), as indicated by *** for p < 0.001 (paired Mann-Whitney U-test) in Figure 3.6B. This reinforces the link between excitatory activity and successful task performance. SST and VIP neurons also exhibited significantly elevated activity during hits in selective regions, though with more variability than excitatory cells. In addition to amplitude comparisons, we conducted a phase shift analysis to investigate the relative timing of neural activation across cell types in each brain region. Using cross-149 correlation of the trial-averaged, normalized activity signals, we quantified phase shifts between pairs of Cre lines (VGLUT1, SST, VIP) for each region. This analysis enabled us to identify consistent temporal leads or lags in population activity dynamics across genotypes during repeated trials. Figure 3.7 summarizes these results, with a bar plot of significant phase shifts and a heatmap showing all regional pairwise phase differences. Notably, in multiple visual areas, the average VIP neuron activity lagged behind that of excitatory neurons (VGLUT1; in separate experiments), suggesting that VIP interneurons may be recruited after excitatory activation. SST neurons, on the other hand, exhibited more heterogeneous timing patterns, with some regions showing a modest lead relative to excitatory neurons and others a lag. These findings are consistent with a model in which excitatory neurons drive initial stimulus responses, while interneurons, especially VIP cells provide delayed feedback or modulatory input, possibly through disinhibition mechanisms (Pfeffer et al. 2013; Karnani et al. 2016). The observed phase differences provide additional support for distinct temporal roles of interneuron subtypes in shaping cortical processing during perceptual decision-making. Interestingly, these observations also align with recent electrophysiological studies that reveal functional modules in the visual cortex with temporally distinct response latencies. For example, (Jia et al. 2022; Siegle et al. 2021) identified driver and driven neuronal modules across visual cortical areas, where the driver population, akin to excitatory VGLUT1 neurons in our dataset, exhibited earlier response latencies compared to downstream driven populations. Moreover, these modules were found to be distributed across visual areas and showed 150 Figure 3.5 Visual Behavior 2P neural and behavior data A) (Stim. row) Natural scene image stimuli followed by grey screen were continuously presented to the mice. Total 8 natural scene images were used in the experiment; different colors represent a unique image identity, dotted lines are where image change occurred, and some of the image presentations were omitted as labeled and shown in light grey color. (Licks row) Mice were trained 151 to detect image change and report it by licking the water spout within 750 ms to release a water reward (Reward row). Rewards are shown by yellow stars below the licks. (Pupil row, Speed row) Pupil diameter was captured using a camera and running speed of the wheel on which mouse was placed was also captured along with the multi-region multi-plane 2P imaging within the indicated visual cortex (shown in colored raster, bottom rows) of the visual cortex during the task. B) Raster map of recorded neural activity (top) and replicated dynamics of trained RNN using CorNet (bottom) unidirectional flow of information from driver to driven units, with the latter often showing delayed, more integrative responses (Jia et al. 2022). These results provide converging evidence from two different modalities, two-photon calcium imaging and high-density electrophysiology, supporting temporally structured signal propagation across cell types and cortical areas. Furthermore, the laminar biases and signal flow directions reported in their study support our interpretation of VIP interneurons as potentially engaged in later-stage modulatory processing (Jia et al. 2022) showed that âdrivenâ neurons, enriched in deeper cortical layers and showing convergent input, may be well-positioned to carry out recurrent computations or feedback integration, consistent with the timing lags observed in VIP activity (Jia et al. 2022; Siegle et al. 2021; Harris et al. 2019). Together, these results underscore the temporal and circuit-level differentiation of excitatory and inhibitory cell types in shaping cortical dynamics during behavior.152 153 Figure 3.6 Cell-type specific neural responses to image change are unique across cortical regions and across the cell-types. A) The group averaged neural activity during hit (blue) and miss (orange) trials in recorded regions (shown in each column) for mouse lines: VGLUT1 (top row), SST (middle row), and VIP (bottom row). The vertical black line represents the image change during the trials. B) Average peak activity during hit (blue) and miss (orange) trials in regions labeled on x-axis for VGLUT1 (left), SST (middle), and VIP (right) groups. Statistical testing between hit and miss trial values for each region is done using paired Mann-Whitney U-test (p-values labeled with stars for significance, *** for p < 0.001). 154 155 Figure 3.7 Phase shift analysis of cortical activity across the Cre lines. A) The group averaged neural activity during hit trials for mouse lines VGLUT1 (blue), SST (purple), and VIP (green) shown in polar coordinates. 180-degree point is where the image change happened and an increase in response can be seen after that. Note the response in the VIP (green) group is out of phase with responses from VGLUT1 (blue) and SST (purple) groups. B) Bar plot showing the estimated phase shifts (in degrees) between pairs of Cre lines for brain regions where significant temporal offsets were observed. Each bar represents the direction and magnitude of the phase shift between the averaged normalized neural activity time series for a specific brain region and Cre line pair. Error bars indicate a ±10° confidence interval around the phase shift estimate (simplified). Only comparisons with high cross-correlation (r > 0.3) and lag > 1 frame were included as significant. Positive or negative values reflect which Cre lineâs activity leads or lags temporally. C) Estimated phase shift (in degrees) between pairs of Cre lines for each brain region. Each cell in the heatmap represents the phase shift between two Cre lines (columns) for a given brain region (rows), as calculated using cross-correlation of their normalized average fluorescence signals during hit trials. Positive values indicate a lead of the first Cre line over the second, while negative values indicate a lag. The color intensity reflects the magnitude and direction of the phase shift, centered at 0°, with warmer colors (red) representing positive shifts and cooler colors (blue) indicating negative shifts.156 3.3.3 Model training performance on simulated and experimental data As mentioned earlier, to evaluate the training dynamics and input inference performance of the data-constrained RNN model, we benchmarked our correlation-initialized recurrent neural network (CorNet) against a previously published input inference framework, CURBD (Perich et al., 2020), using both simulated and real neural population activity datasets. We first assessed model performance using a synthetic dataset generated based on the simulation framework described by Perich et al. (2020). This simulated dataset consists of multiple interconnected neural modules with known input drives, allowing ground-truth comparison of inferred inputs and internal dynamics. Both CorNet and CURBD models were trained to reconstruct the simulated neural activity, and their training loss trajectories were tracked over 1000 iterations (Figure 3.8A). The CorNet model consistently demonstrated superior convergence, exhibiting a significantly lower training loss than the CURBD method across the entire training period. Importantly, the loss curve for CorNet continued to decline steadily, indicating continued learning and refinement of weights throughout the training duration. In contrast, the CURBD model plateaued early in training, suggesting limited capacity to capture the full complexity of the synthetic dynamics. These results provide validation for the CorNet architecture and its utility in reconstructing underlying neural dynamics more faithfully. We next evaluated CorNetâs performance on real neural population data from the Allen Instituteâs Visual Behavior 2-Photon (VB2P) dataset (Figure 3.4, Figure 3.5). Specifically, we trained separate CorNet models on recordings from excitatory neurons (VGLUT1), 157 Figure 3.8 Training loss on simulated and VB2P dataset A) Training loss over 1000 iterations of training steps on simulated data using CorNet (blue) and CURBD (orange) methods. CorNet training loss was much lower than the CURBD method and kept going down during the training iterations. B) CorNet training loss over 5000 iterations using data from VGLUT1 (orange), SST (green), and VIP (blue) mouse lines. The solid line is the group average and the shaded region shows standard deviation. somatostatin-expressing inhibitory neurons (SST), and vasoactive intestinal peptide-expressing inhibitory neurons (VIP). Each model was trained for 5000 iterations, and training loss was tracked throughout (Figure 3.8B). The loss curves revealed distinct training dynamics across cell types. Models trained on SST datasets exhibited the highest training loss, suggesting that the underlying activity patterns in SST neurons may be more complex or contain richer temporal dependencies 158 that are hard to be captured by the recurrent model. In contrast, models trained on VIP data had the lowest training loss on average (Figure 3.8), with VGLUT1 models falling in between. These differences highlight potential cell-type-specific differences in underlying cortical dynamics, which our model tries to capture through its training process. Overall, these results validate the CorNet frameworkâs capacity to model diverse cortical activity patterns and suggest that the training loss trajectory can itself be a useful marker of network complexity and dynamic richness across different cell types. 3.3.4 Inferred directional inputs reveal region-specific functional roles during behavior To investigate how regional cortical interactions differ during successful (hit) versus unsuccessful (miss) perceptual events, we analyzed CorNetâs inferred input dynamics from trained RNNs using the VB2P calcium imaging dataset across three genetically defined cell populations: VGLUT1, SST, and VIP. By comparing inferred inputs during correct (hit) and incorrect (miss) trials, we sought to uncover functional differences in regional connectivity patterns associated with successful task performance (Figure 3.9B, C). We examined the trial-averaged regional neural responses during hit trials, aligning the activity to the time of image change (defined at 180 degrees, Figure 3.9A). Cortical regions were sorted by the latency to rising activity following the stimulus. In VGLUT1 and SST mice, the visual cortex regions showed highly stereotyped, temporally aligned responses, suggesting coordinated dynamics following visual stimulus onset. For example, VGLUT1 mice showed earliest responses in VISam_1 and VISam_2, followed by sequential activation in lateral and posterior visual areas 159 160 Figure 3.9 CorNet inferred directional inputs indicate region specific role during hit vs miss trials A) Average neural activity in different cortical regions during hit trials are sorted by their latency in rising response after image change. Average trial responses are plotted in polar coordinates, so 0 degrees represent the start of the epoch and 180 degrees is the center of epoch where image change occurs. Response latencies of different regions in VGLUT1 (left, order of response VISam_1, VISam_2, VISal_2, VISal_1, VISl_1, VISp_1, VISp_2, VIS1_2) and SST (middle, order of response VISam_1, VISam_2, VISp_1, VISl_1, VISal_1, VISp_2, VISal_2, VIS1_2) are visibly very close to each other and are tightly coupled to the image change event at 180 degrees, as compared to VIP (right, order of response VISl_1, VISal_2, VISp_2, VISl_2, VISal_1, VISam_1, VISp_1, VISam_2). B) CorNet trained RNNs allow us to infer directional temporal inputs from each unit to other units in the network. Average inputs around (1sec. pre and post) hit and miss events were pooled across all animals for each cell-type and t-test was performed to test the significance of difference in inputs during hit versus miss trials for all combinations of directional inputs among the regions as shown in the matrix. In VGLUT1 mice (left), inferred inputs from VISam_1 to VISal_1, VISal_2, VISam_1, VISam_2, and VISl_2 during hit trials were significantly higher than miss trials. In SST mice (middle), inferred inputs from VISam_1 to VISal_2, VISam_1, VISam_2, VISl_1, VISl_2; VISp_1 to VISam_2, VISl_2 during hit trials were significantly higher than miss trials. In VIP mice (right), inferred inputs from VISal_1 to VISal_1, VISl_2; VISal_2 to VISal_2, VISp_1; VISam_1 161 to VISal_2, VISam_1; VISam_2 to VISam_2, VISp_1; VISl_2 to VISl_2 during hit trials were significantly higher than miss trials. C) Average temporal traces of CorNet inferred inputs from VISam_1 to all other regions in VGLUT1 (left), SST (middle), and VIP (right) mice during hit (top) and miss (bottom) trials centered around image change (grey vertical line). (e.g., VISal_1, VISl_1, VISp_1). SST mice exhibited a similar temporal sequence. In contrast, VIP mice displayed a less consistent response ordering, with VISl_1 and VISal_2 leading the activity, and key medial regions (VISam_1, VISam_2) lagging behind. These differences in response timing suggest that the temporal coordination of sensory processing varies substantially across cell types, potentially reflecting their distinct roles in feedforward, recurrent, or inhibitory processing. To assess how inter-regional inputs change during successful versus unsuccessful task outcomes, we analyzed the directional inputs inferred by CorNet RNNs. Specifically, we extracted the temporal inputs from each source region to each target region, averaged around 1 second before and after stimulus presentation, and compared hit versus miss trials using two-sample t-tests. The resulting statistical maps captured task-modulated changes in inferred inputs with spatiotemporal resolution. In VGLUT1 mice, we observed significantly greater inferred input strength during hit trials from VISam_1 to a number of cortical areas, including VISal_1, VISal_2, VISam_2, and VISl_2 (Fig. 3.9B). This suggests that activity in VISam_1 plays a central role in coordinating downstream cortical dynamics during correct perceptual decisions. SST mice showed a similar 162 pattern, with VISam_1 projecting stronger inferred inputs during hit trials to VISal_2, VISl_1, VISl_2, and VISam_2. Additionally, inputs from VISp_1 to VISam_2 and VISl_2 were significantly stronger during hits, suggesting an important modulatory role of the early visual cortex in SST networks. In contrast, VIP mice displayed a more distributed pattern of significant differences. Enhanced inputs were observed during hit trials from VISal_1 to VISl_2, from VISal_2 to VISp_1, and from VISam_2 to VISp_1, among others. These more heterogeneous and recurrent interactions in VIP networks may reflect their unique involvement in modulating gain and excitability rather than directly driving stimulus-evoked responses. We further visualized the temporal dynamics of inferred inputs originating from VISam_1 to all other regions across the three cell types. In VGLUT1 and SST mice, hit trials showed a clear increase in input strength from VISam_1 following the image change event, while miss trials displayed lower and more diffuse patterns. These findings reinforce the notion that VISam_1 serves as a hub for coordinating inter-regional communication during correct task performance. In VIP mice, these patterns were less consistent, again highlighting the potentially different computational roles of VIP populations in visual decision-making. Together, these analyses demonstrate that our CorNet model not only captures dynamic patterns of population activity but also enables the inference of trial-type specific changes in functional connectivity within neuronal subtypes. The observed differences in inferred inputs between hit and miss trials highlight the region-specific roles and cell-type-specific dynamics underlying behavioral outcomes. Particularly, VISam_1 emerges as a key integrator in excitatory and SST networks, while VIP networks show a more distributed modulation across multiple cortical targets. 163 3.3.5 Cell-type-specific connectivity patterns inferred from CorNet model weights Several lines of evidence support the notion that SST interneurons inhibit each other through GABAergic synaptic connections, establishing a form of "self-inhibition" that plays a critical role in regulating local circuit dynamics. In the mouse neocortex, (Pfeffer et al. 2013) showed that SST interneurons form reciprocal inhibitory connections, creating a negative feedback loop that stabilizes their own activity and modulates overall cortical inhibition. This mutual inhibition contributes to gain control mechanisms within cortical microcircuits and prevents excessive suppression of excitatory cells by SST neurons. Extending this observation, (Urban-Ciecko and Barth 2016) emphasized that SST-SST connectivity is essential for maintaining inhibitory tone in the cortex, especially in preventing runaway excitation and exerting fine control over pyramidal neuron output. Similarly, in the hippocampus, (Bloss et al. 2016) demonstrated that SST interneurons engage in local inhibitory interactions that support dendritic-level gain control of CA1 pyramidal neurons, suggesting that SST-mediated mutual inhibition is a conserved circuit motif across cortical and hippocampal regions. Additional studies have confirmed that SST interneurons can receive inhibitory inputs from neighboring SST cells, highlighting their role in circuit homeostasis (Tremblay, Lee, and Rudy 2016; Kepecs and Fishell 2014). These self-inhibitory mechanisms are thought to be vital for tuning network excitability, regulating sensory processing, and enabling flexible control of information flow through inhibitory subnetworks. 164 Figure 3.10 Distribution of synaptic weights in CorNet RNN models trained on the VB2P dataset A) CorNet RNNs were independently trained on each session of the VB2P dataset corresponding to the three Cre mouse lines VGLUT1, SST, and VIP resulting in model synaptic weights between each unit representing the neurons in the dataset. The figure shows example model synaptic 165 weights from a session of VGLUT1 (left), SST (middle), and VIP (right) mouse lines. Neurons are sorted by the region labels they belong to as shown along the x and y axis of the matrices. VGLUT1 expressing excitatory neurons are numerous as compared to SST and VIP neurons in a comparable area of the cortex, resulting in denser looking matrix for VGLUT1 neurons. B) The model synaptic weights were aggregated by cell type to examine the overall distribution of model-inferred connectivity. Each weight matrix represents the learned connection strengths from each unit to all other units; diagonal elements correspond to self-connections, while off-diagonal elements represent connections between distinct units. Left: Distributions of self-connection weights (diagonal elements). VGLUT1 models exhibit a unimodal distribution centered around zero with a shoulder on the positive side, suggesting weak or no self-connections in most units. VIP models show a dominant peak in the positive range, with additional smaller peaks in both positive and negative directions. SST models exhibit a clear bimodal distribution, with symmetric peaks in both positive and negative ranges, indicating divergent self-modulatory dynamics. Right: Distributions of inter-unit connection weights (off-diagonal elements). VGLUT1 models again show a unimodal distribution centered near zero, consistent with sparse or balanced connectivity. VIP models show a similar central peak with broader shoulders, suggesting a more distributed pattern of excitation and inhibition. SST models demonstrate a pronounced bimodal distribution, indicative of strong functional segregation and the presence of both excitatory-like and inhibitory-like weights in the learned connectivity. 166 VIP interneurons are predominantly recognized for their role in disinhibiting cortical circuits through selective inhibition of SST interneurons, rather than through direct inhibition of other VIP interneurons. This disinhibitory motif is crucial for regulating pyramidal neuron excitability and enhancing sensory processing. (Pi et al. 2013) provided foundational evidence that VIP interneurons target SST cells, leading to a release of inhibition (disinhibition) on pyramidal neurons and thereby amplifying their responses during sensory stimulation. Their work also emphasized the absence of VIP-VIP inhibitory connections, suggesting that VIP interneurons rarely inhibit each other and instead function to coordinate disinhibition across the network. Supporting this, (S. Lee et al. 2013) showed that during behaviorally relevant cortical states, VIP interneurons dynamically suppress SST neurons, enabling context-dependent modulation of cortical activity. Additional studies have reinforced this framework of selective disinhibition. (Karnani et al. 2016) demonstrated that behavioral state changes, such as locomotion or arousal, increase the activity of VIP neurons, which in turn suppress SST activity and elevate pyramidal neuron responsiveness. Furthermore, (Pfeffer et al. 2013) quantitatively mapped interneuron connectivity and confirmed that VIP interneurons exhibit strong inhibition onto SST cells but minimal connectivity with other VIP neurons, underscoring their specialized role in circuit-level disinhibition. Collectively, these findings establish distinct and asymmetric connectivity being a core organizational principle of cortical circuits, where SST and VIP neurons play complementary roles in modulating inhibition and excitation to maintain dynamic control over cortical processing. 167 As mentioned earlier, we trained separate RNNs to replicate the activity dynamics of recorded neuronal populations comprising either VGLUT1 expressing excitatory neurons, VIP interneurons, or SST interneurons in the VB2P dataset (Figure 3.5). Each RNN was trained using backpropagation and contained the same number of units as the recorded neurons from each session, resulting in a per session model synaptic weight matrix as shown in Figure 3.10A. Analysis of these resulting recurrent weight matrices across each group revealed distinct distributional signatures associated with each cell type. The weight distribution for networks trained on excitatory neuron activity was unimodal and centered near zero (Figure 3.10B right), indicative of a balanced network dynamic wherein recurrent excitation is counteracted by feedback inhibition, consistent with the tight homeostatic regulation observed in cortical excitatory circuits (Douglas and Martin 2004; Vogels et al. 2011). In contrast, networks trained on VIP neuron activity also showed a unimodal distribution centered at zero but with noticeable shoulders on either side. This pattern may reflect the functional heterogeneity of VIP interneurons, which primarily inhibit other inhibitory neurons such as SST cells, leading to disinhibition of excitatory neurons in a context-dependent manner (Pfeffer et al. 2013; Pi et al. 2013). The shoulders may correspond to subsets of VIP units with stronger or weaker connectivity, consistent with known variability in their projection patterns and modulatory roles during behavioral tasks. Notably, the weight distributions for networks trained on SST neuron activity were distinctly bimodal, with one mode in the negative and one in the positive domain (Figure 3.10B). This suggests a dichotomy in SST network interactions, some units acting as strong inhibitors while others may participate in circuits with excitatory feedback or disinhibitory loops. This finding aligns with reports that SST 168 neurons exert widespread inhibition on pyramidal neurons and other SST interneurons alike, but also receive substantial excitatory input and may themselves engage in inhibitory feedback circuits (Tremblay, Lee, and Rudy 2016; Urban-Ciecko and Barth 2016). The bimodal structure could further hint at distinct subtypes or laminar-specific connectivity differences within SST populations (Muñoz et al. 2017). Overall, these emergent RNN weight structures reflect known biological roles of these cell types, suggesting that recurrent modeling can uncover and reflect biologically meaningful connectivity motifs. 3.3.6 CorNet inferred task relevant inputs from CLMF dataset We also applied the CorNet model on widefield calcium imaging data collected during closed-loop movement feedback (CLMF) experiments (Gupta and Murphy 2025) (see Chapter 2 for behavioral paradigms and imaging details). Our aim was to investigate how inferred inputs between cortical regions varied around key behavioral events such as trial initiation, reward success, and reward failure, and how these dynamics evolved with task rule changes. CorNet models were trained on CLMF data from 8 mice performing a left-forelimb movement task on day 4 of their training. Inferred inputs from the trained model were aligned to trial-aligned behavioral events and averaged over a one-second window before and after the event. The three key event types analyzed were: (1) trial start, (2) successful reward outcome, and (3) fail trials. For each pairwise combination of source and target cortical regions, the directional inferred inputs were computed and compared between conditions. To isolate event-specific input modulations, average inferred inputs centered around trial start were subtracted from those centered around success or 169 failure. Statistical comparison using the Mann-Whitney U test revealed that inferred inputs from multiple regions, particularly OB_L, FL_L, HL_L, OB_R, FL_R, and HL_R to all other cortical targets were significantly higher during success relative to trial initiation (Figure 3.11A, middle panel). This suggests that distributed sensorimotor and limb-associated regions strongly contribute to cortical network drive at the moment of successful task execution. The fact that we observe significant inputs from both the left and right cortical sensorimotor areas during success aligns well with the observation that the mice were moving both their left and right forelimbs to succeed in the trials on that day of training since the task did not punish movements of non-target body parts (refer Chapter 2 methods). Interestingly, during failed trials, a different set of source regions exhibited significant increases in inferred inputs: ALM_L, M1_L, FL_L, M1_R, FL_R, BC_R, and V1_R (Figure 3.11A, right panel). These regions span both motor and sensory cortices, indicating that error-related processing involves distinct cortical communication patterns, potentially reflecting heightened motor planning or sensory expectation around failure. Following a rule-switch paradigm in which mice were required to perform right-forelimb movements instead of left-forelimb starting on Day 4, CorNet models were trained on data from the same cohort of mice on day 8 (after several days of adapting to the new motor contingency). As before, inferred inputs were aligned to trial start, success, and failure events. On day 8, we again observed significant differences in inferred input strengths between success and trial start conditions. However, the specific regions contributing to elevated inputs during successful trials shifted. Inferred inputs from FL_L, HL_L, and HL_R to other regions were significantly increased 170 Figure 3.11 CorNet inferred inputs applied on CLMF widefield calcium imaging dataset CorNet models were trained on sessions from CLMF (refer Chapter 2) widefield GCaMP functional cortical imaging data. Inferred inputs centered around (1 sec. before and after) events such as start of trial, and reward success were averaged for this analysis. A) Average inputs around (1sec. pre and post) success, fail, and start of the trial events were pooled across all animals (N=8) who were trained on a left-forelimb movement task on day 4, for all combinations of directional inputs among the regions as shown in the matrix. Average pooled inputs around the start of the trial were subtracted from those around the success (left). Mann-171 Whitney U test was performed to test the significance of difference in inputs around success versus start of the trials for all combinations of directional inputs among the regions as shown in the matrix (middle). Inputs from regions OB_L, FL_L, HL_L, OB_R, FL_R, and HL_R to all the other regions were significantly higher around the success compared to the start of those trials. A similar test was performed to test the significance of difference in inputs around fails versus start of the corresponding trials for all combinations of directional inputs among the regions as shown in the matrix (right). Inputs from regions ALM_L, M1_L, FL_L, M1_R, FL_R, BC_R, and V1_R to all the other regions were significantly higher around the fails compared to the start of those trials. B) Average inputs around (1sec. pre and post) success, fail, and start of the trial events were pooled across all animals on day 8 (N=8, same animals as in A) for whom the task rule was changed (on day 4) from left-forelimb movement to right-forelimb movement, for all combinations of directional inputs among the regions as shown in the matrix. Average pooled inputs around the start of the trial were subtracted from those around the success (left). Mann-Whitney U test was performed to test the significance of difference in inputs around success versus start of the trials for all combinations of directional inputs among the regions as shown in the matrix (middle). Inputs from regions FL_L, HL_L, and HL_R to all the other regions were significantly higher around the success compared to the start of those trials. A similar test was performed to test the significance of difference in inputs around fails versus start of the corresponding trials for all combinations of directional inputs among the regions as shown in the matrix (right). Inputs from regions OB_L, and OB_R to all the other regions were significantly higher around the fails compared to the start of those trials. 172 during successful task execution (Figure 3.11B, middle panel). This is consistent with the new task demand involving right-forelimb movement, suggesting task-specific reorganization of inter-regional communication. This also aligns with the fact that the animals were trained on the task longer at this point and were mostly moving their right forelimb (instead of both the forelimbs) by day 8 of the training. Conversely, during failed trials, increased inferred inputs were predominantly observed from OB_L and OB_R, which are primary olfactory areas. The engagement of these regions during failure could reflect increased arousal or state-related modulation during unexpected outcomes (Figure 3.11B, right panel). These findings demonstrate that CorNet can successfully extract behaviorally relevant and condition-specific patterns of effective connectivity from widefield imaging data as well. Furthermore, the analysis highlights how cortical dynamics, as reflected in inferred inputs, adapt over time with learning and rule switching. These results emphasize the utility of data-constrained recurrent neural models in decoding distributed brain dynamics in the context of task performance and adaptation. 3.4 Discussion In this study, we developed and validated a biologically constrained recurrent neural network (RNN) model we called CorNet, to simulate and infer the temporal dynamics and effective connectivity of multi-region cortical activity. By integrating large-scale calcium imaging data from 173 both visual behavior (VB2P) (M. Garrett et al. 2020) and closed-loop movement feedback (CLMF) (Gupta and Murphy 2025) paradigms, this work highlights how modern computational models can bridge the gap between high-dimensional neural recordings and interpretable circuit-level dynamics. 3.4.1 Interpretability and biological relevance One of the key strengths of CorNet lies in its biologically inspired design, particularly its initialization from correlation structure, the enforcement of non-negativity, sparsity constraints, and employing backpropagation implemented on a GPU. These design choices allowed the model to more faithfully reflect known neural interactions and enabled direct comparison across datasets featuring different neuronal subtypes (VIP, SST, VGLUT1). The recovered weight distributions aligned with known circuit motifs: SST interneurons exhibited bimodal connectivity suggestive of mutual inhibition and self-regulation (Pfeffer et al. 2013; Urban-Ciecko and Barth 2016), while VIP neurons showed patterns consistent with their disinhibitory roles (Pi et al. 2013). These emergent patterns reinforce the idea that RNN models trained directly on experimental data can recover latent biological structure. 3.4.2 Dynamics of task-dependent connectivity By analyzing trial-type-specific inferred inputs, we demonstrated that cortical inter-regional dynamics are not static but flexibly adapt across different behavioral conditions, including success versus failure and rule switches. The observation that VISam_1 acts as a functional hub during hit 174 trials in both excitatory and SST networks underscores the importance of medial visual areas in perceptual decision-making. In contrast, the broader and more variable inferred connectivity in VIP networks supports their role in modulating gain and maintaining network flexibility (Karnani et al. 2016). Likewise, in the CLMF dataset, inferred directional inputs evolved over time as mice learned and adapted to new motor contingencies. These shifts reflect plasticity in functional connectivity, underscoring the utility of CorNet for studying adaptive cortical communication. 3.4.3 Challenges and limitations Despite the strengths of our modeling approach, there are several important challenges and limitations that must be acknowledged. A major issue is partial observability. The model is trained on experimentally recorded activity from a subset of neurons, often limited to superficial cortical layers. These recordings represent indirect, temporally filtered signals that may not capture the full richness of the underlying synaptic and population-level dynamics. As a result, the model's ability to reconstruct or predict activityâparticularly that arising from deep brain regions or unrecorded populationsâis inherently limited. Important modulatory or feedback influences from such unobserved sources may be missing, thereby constraining the accuracy and interpretability of the inferred dynamics. Another key limitation lies in the distinction between causality and correlation. Although the model learns directed patterns of activity and infers inputs that drive network dynamics, these do not constitute definitive evidence of causal relationships. The model identifies statistical dependencies and functional interactions that reflect the data structure, but without interventional data (such as perturbations using optogenetics or pharmacology), we cannot rule out 175 confounding or shared upstream sources. Thus, the inferred connections should be interpreted as putative or functional influences rather than direct causal links. Finally, generalizability is a concern. In its current form, the model is trained independently for each recording session, meaning it learns session-specific parameters that may not transfer well across animals, brain states, or behavioral contexts. This individualized training strategy limits the model's ability to uncover conserved or population-level motifs of neural dynamics. Future extensions could incorporate shared-weight architectures or transfer learning frameworks, which may enable the model to generalize across different subjects and experimental conditions, thereby broadening its utility and interpretive power. 3.4.4 Future Directions The CorNet framework opens up a rich set of possibilities for future research, particularly in enhancing the biological relevance and computational power of neural network models grounded in real data. One promising direction is multi-modal integration, where CorNet could be extended to incorporate diverse data streams such as electrophysiological recordings, behavioral kinematics, or transcriptomic profiles. Combining these modalities would allow for a more comprehensive characterization of the underlying neural dynamics and may help disambiguate the sources of observed patterns, whether they stem from neural activity, behavioral contingencies, or intrinsic cellular properties. 176 Another avenue lies in incorporating anatomical priors into the modeling process. By embedding known structural connectivity constraints such as those available from the Allen Mouse Brain Atlas or the high-resolution MICrONS connectomics dataset into the networkâs architecture or weight regularization schemes, CorNet models could more closely mimic actual biological networks. This anatomical grounding could improve both the interpretability and generalizability of the model outputs. Additionally, future versions of CorNet could be developed to support adaptive and online learning, allowing the model to update its internal representations in real time as new data are acquired. This would be especially valuable in closed-loop experimental paradigms, where neural and behavioral signals change dynamically in response to feedback. Modeling such time-dependent plasticity would enable a more realistic simulation of learning processes and experience-dependent neural adaptations. Lastly, cell-type-specific modulation remains a key area for refinement. As the diversity of inhibitory and excitatory neuron subtypes plays a critical role in shaping cortical dynamics, future work can focus on modeling these subpopulations more explicitly. This might involve incorporating cell-type-specific modules, gating mechanisms, or connectivity motifs that reflect known functional roles of different interneuron classes. Such refinements would further improve the biological fidelity and functional relevance of the CorNet framework in simulating cortical computation. 177 Chapter 4: Conclusion This thesis presents an integrated experimental and computational framework for studying volitional control and cortical dynamics in mice, focusing on closed-loop feedback systems and data-constrained recurrent neural network models. The research demonstrates that mice can robustly learn to control neural and behavioral variables in real time when provided with continuous, graded feedback, and that their cortical activity patterns adapt systematically with learning. On the experimental side, the closed-loop neurofeedback (CLNF) and movement feedback (CLMF) platforms developed here enabled precise tracking and manipulation of cortical and behavioral activity (Figure 2.2). These systems provided feedback using affordable, open-source hardware platforms like Raspberry Pi and Nvidia Jetson. Through these platforms, mice learned to modulate either mesoscale cortical activity or specific forelimb movements to obtain rewards, and were capable of adapting flexibly to changes in task contingencies (Figure 2.4). From a computational perspective, the CorNet modelâa recurrent neural network trained using data from the Allen Instituteâs Visual Behavior 2-Photon (VB2P) dataset and our own CLMF recordings, allowed the reconstruction of low-dimensional neural dynamics and the inference of directed functional interactions across regions (Figure 3.9, Figure 3.11). By training separate RNNs on VGLUT1, VIP, and SST neuronal populations, CorNet revealed distinct patterns of weight structure and connectivity. For example, SST interneurons exhibited signatures of mutual inhibition and self-regulation, while VIP interneurons showed features consistent with disinhibitory circuit roles. 178 4.1 Contributions to the field This thesis advances the field of systems and computational neuroscience through several major contributions that span experimental tool development, behavioral neuroscience, and computational modeling. A central achievement of this work is the design, implementation, and validation of low-cost, open-source platform capable of delivering real-time closed-loop feedback based on both cortical neural activity and behavioral outputs in head-fixed mice (Gupta and Murphy 2025). These platforms enable researchers to link recorded brain signals or body movements to external sensory feedback or reinforcement in real time, thus facilitating the investigation of volitional control, learning, and neural plasticity. The affordability, scalability, and flexibility of these platforms make them accessible to a broad range of laboratories, including those without access to high-end commercial BCI systems, thereby democratizing closed-loop experimentation in neuroscience. Furthermore, this work demonstrates that mice are capable of learning arbitrary and non-ethological associations between internal neural states or specific movements and external feedback cues (Figure 2.4, Figure 2.5, Figure 2.6). This finding supports the idea that the mammalian brain possesses a high degree of plasticity and can volitionally modulate neural population activity in response to contingent feedback. By leveraging closed-loop paradigms in a more generalized behavioral context, the experiments presented here expand upon prior BCI studies that typically focus on constrained tasks or motor outputs. This shift toward ethologically flexible task designs opens new avenues for investigating the neural basis of decision-making, learning, and cortical reorganization in diverse settings. A particularly novel aspect of this thesis is the demonstration that mice are capable not only of learning such mappings, 179 but also of rapidly adapting to rule changes mid-training. The ability of animals to flexibly adjust their behavior in response to altered task contingencies was accompanied by measurable shifts in both behavioral performance and large-scale cortical activity patterns, suggesting dynamic reconfiguration of underlying circuit dynamics (Figure 2.7). These findings contribute to our understanding of the mechanisms of cognitive flexibility and adaptive motor control, which are fundamental to learning and goal-directed behavior. On the computational side, this work introduces and applies a new framework we named CorNet, for modeling neural dynamics using calcium imaging data at different scales (2-Photon, and mesoscale widefield Calcium imaging). CorNet offers a biologically interpretable, recurrent architecture that infers low-dimensional latent dynamics as well as effective connectivity between brain regions. The model significantly outperforms previously proposed alternatives such as CURBD (Perich et al. 2020) in terms of training speed (on GPU), its ability to capture population-level structure and reproduce observed temporal motifs in neural activity. This framework serves not only as a tool for data-driven hypothesis generation but also as a step toward mechanistic modeling of brain-wide computations. Finally, the thesis explores how different neuronal subtypesâVGLU1-expressing excitatory, SST-expressing inhibitory, and VIP-expressing inhibitory neurons, contribute differentially to cortical dynamics by training RNNs on these cell-type-specific datasets. Analysis of the learned weight matrices revealed distinct connectivity patterns and learning dynamics across cell types. For instance, SST neurons exhibited bimodal weight distributions, potentially reflecting their known role in lateral inhibition and self-inhibition 180 circuits, while excitatory neurons showed more centered, unimodal distributions. These insights highlight the power of combining machine learning models with biological recordings to extract cell-type-specific computational roles in sensory processing and behavior. 4.2 Strengths and Limitations This thesis presents a body of work that integrates experimental paradigms with biologically inspired computational modeling to investigate cortical dynamics and brain-behavior relationships. A key strength of this work lies in the seamless integration of custom-built, low-latency closed-loop experimental systems with modern data analysis frameworks. The ability to deliver real-time feedback based on widefield calcium imaging in awake, behaving mice provided a mesoscale perspective on global cortical activity patterns during behavior and learning. This approach enabled the study of cortical dynamics not only during spontaneous behavior but also in response to precisely timed sensory or motor feedback. The flexibility of the hardware which was implemented using accessible platforms like Raspberry Pi and Nvidia Jetson, and its open-source design contributed to the broader reproducibility and adaptability of the platform across experimental needs. Furthermore, this work benefited from the CorNet modeling framework, which allowed the use of biologically grounded, recurrent neural networks to model and interpret real and synthetic neural activity patterns. This modeling approach offered interpretability and circuit-level insights, bridging the gap between data-driven analysis and neurobiological plausibility. By constraining model architecture and parameters with real neural recordings, the 181 framework enabled hypothesis generation about the underlying structure and function of cortical circuits. Despite these advances, several limitations remain. The use of head-fixed preparations, although essential for stable imaging and controlled feedback delivery, inherently limits the validity of the behavioral findings, as it precludes the expression of full-body, naturalistic behaviors that are fundamental to motor learning in freely moving animals. Additionally, widefield calcium imaging, while offering a panoramic view of dorsal cortex activity, is limited in its spatial and temporal resolutions, it lacks the capacity to resolve individual neurons, neuronal spikes, or distinguish activity across cortical layers and cell types. This constrains the ability to draw conclusions about microcircuit-level computations or cell-type-specific contributions. Moreover, although the RNN models employed here were constrained using empirical data and designed with biological inspiration, they operate at a rate and abstraction level that does not incorporate detailed spiking activity, synaptic dynamics, or biophysical conductance. As such, these models may overlook fine temporal dynamics and mechanistic insights that would be accessible through more detailed spiking neuron models or conductance based simulations. Finally, while the system was tested across multiple Cre-lines and behavioral paradigms, extending these approaches to freely moving animals, higher-resolution imaging modalities, and larger-scale populations will be necessary to fully generalize the conclusions and enhance translational relevance. 182 4.3 Future Research Directions A promising avenue for future work involves adapting the closed-loop neurofeedback (CLNF) and closed-loop motor feedback (CLMF) platforms for use in freely moving animals. Currently constrained to head-fixed paradigms, these systems can be significantly advanced by implementing wireless, untethered versions that operate in real-world environments. Such an extension would increase the ethological validity of closed-loop learning paradigms and allow researchers to investigate how neural representations evolve under more naturalistic and behaviorally relevant conditions (Musall et al. 2019; Meyer et al. 2018). The technical challenges of minimizing feedback latency and maintaining real-time neural analysis in freely moving conditions would also push the boundaries of current closed-loop engineering solutions (Zhou et al. 2018). Recent advances in miniaturized imaging systems and real-time neural decoders offer a promising path forward (Liberti et al. 2017). Another rich direction for future research is to leverage dual-color or multi-color calcium imaging to simultaneously target and record from distinct cell types within the cortexâsuch as excitatory neurons, somatostatin (SST) interneurons, vasoactive intestinal peptide (VIP) interneurons, and parvalbumin (PV) interneurons, as well as neuromodulatory inputs such as cholinergic or dopaminergic axons. This would allow researchers to design closed-loop paradigms where animals are trained to regulate or balance activity across specific cell populations. For instance, it may be possible to investigate whether animals can volitionally control SST vs. VIP activity to regulate inhibition during learning tasks, or whether neuromodulatory tone (e.g., cholinergic signaling) can be behaviorally modulated in a closed-loop framework (Pinto et al. 2013; Fu et al. 2014). Using red and green fluorescent calcium indicators 183 such as jRCaMP1a and GCaMP6s (Dana et al. 2016; T.-W. Chen et al. 2013), these multi-color paradigms (Barbera et al. 2024; Dong et al. 2024; Serikov et al. 2024; Dong et al. 2025) are technically feasible and would open new avenues for dissecting interneuron specific contributions to volitional cortical control. Furthermore, a variation of the current closed-loop system could be integrated into an automated homecage training system, allowing 24/7 behavioral training in a less stressful and more naturalistic environment (Murphy et al. 2020). Such a setup would be invaluable in studying disease models where learning trajectories may be altered, such as in models of autism spectrum disorder, schizophrenia, or neurodegenerative diseases. With continuous data collection and real-time feedback, these systems would help characterize subtle phenotypes or compensatory strategies that are difficult to observe in short, daily sessions. This integration also holds potential for long-term behavioral experiments involving complex learning paradigms or rehabilitation protocols. In terms of translational relevance, closed-loop movement feedback can be extended to therapeutic applications such as post-stroke rehabilitation or in motor disorders like Parkinson's disease. Real-time feedback systems that adapt based on specific movement kinematics can aid in motor relearning and neuroplasticity (Nudo et al. 1996; Guggisberg et al. 2019). For example, reinforcement-based feedback could be delivered contingent on successful or compensatory movements, aiding recovery by engaging the correct motor circuits. Integration with EMG or kinematic sensors would further enable more precise motor feedback paradigms tailored to individual impairment profiles. Such systems could be further enriched by incorporating neuromodulatory stimulation (e.g., vagus nerve or optogenetic stimulation) to enhance plasticity 184 when paired with movement (Ganzer et al. 2018; Zanos 2019). In addition, future closed-loop systems could explore bi-directional feedback involving both motor and cortical signals, helping to disentangle causal relationships between perception, action, and internal neural states. This can be particularly powerful in tasks requiring active inference or predictive coding, where the animal must align internal models with sensory outcomes (Friston 2010). Lastly, a critical future direction lies in closed-loop manipulation of spontaneous cortical dynamics, particularly in understanding how internal brain states (e.g., arousal, attention, motivation) modulate the capacity for feedback-based learning. By designing feedback that is contingent not only on sensory or motor activity but also on internal fluctuations, researchers can explore how spontaneous activity shapes learning and decision-making (Stringer et al. 2019; Jacobs et al. 2020). Together, these future directions greatly expand the utility and versatility of closed-loop paradigms, pushing them beyond simple behavioral tasks into the realm of multi-cell-type, neuromodulatory, disease model, and translational neuroscience research. Such closed-loop platforms, when paired with scalable homecage and real-time computational systems, offer a powerful framework to dissect and manipulate the dynamic interaction between brain and behavior. Another compelling direction for future work is the development of multiscale computational models that integrate calcium imagingâbased architectures like CorNet with more biophysically grounded models such as spiking neural networks (SNNs). Such multiscale 185 frameworks would bridge the gap between macroscopic observations of neural dynamics and microscopic circuit-level computations, enabling simultaneous analysis across spatial and temporal scales. Mesoscale calcium imaging captures slow, population-level dynamics over cortical regions at sub-Hz to low-Hz sampling rates, while SNNs can model millisecond-level precision and capture the effects of individual spikes and synaptic delays (Gerstner and Kistler 2002; âThe Scientific Case for Brain Simulationsâ 2019). By embedding the observed widefield dynamics into a scaffold of biologically plausible spiking units, researchers could simulate how individual neurons and populations jointly contribute to emergent behaviors and long-range coordination. To manage the complexity of inter-areal communication, hierarchical or modular extensions of current RNN-based architectures such as CorNet could be explored. These extensions would reflect the known hierarchical organization of the cortex, where sensory processing involves a progression of transformations from low-level to abstract representations (Felleman and Van Essen 1991). Modular networks have been shown to enhance interpretability and robustness, as well as to align more closely with biological motifs like cortical columns and subnetworks (Yamins and DiCarlo 2016; Barak, Rigotti, and Fusi 2013). Such architectures could also model the context-dependent routing of information across task states or during learning, mirroring dynamic reconfigurations observed in the cortex during behavior (Bassett et al. 2011; âTowards the Neural Population Doctrineâ 2019). Another promising extension involves incorporating reinforcement learning (RL) objectives into CorNet and related recurrent models. Biological learning is driven in large part by 186 feedback from neuromodulatory systems, particularly dopamine, which can encode reward prediction errors used to shape synaptic plasticity (Schultz, Dayan, and Montague 1997; Sutton and Barto 1998). By integrating RL-inspired mechanisms such as policy gradients or temporal difference learning into the CorNet framework, one could simulate how neural populations adapt their activity over time in response to reward contingencies. This would allow models to not only passively fit observed dynamics but to also exhibit goal-directed behavior and learning. Recent work has shown the utility of combining RL with recurrent neural networks to model working memory, foraging, and cognitive flexibility in both rodents and primates (Mante et al. 2013; Francis Song, Yang, and Wang 2016; J. X. Wang et al. 2018). Importantly, the connectivity patterns and dynamic motifs inferred from CorNet can serve as hypotheses for causal circuit-level interventions. By identifying key hubs or directional motifs responsible for encoding task-relevant information, one can use optogenetic or chemogenetic perturbations to test the necessity or sufficiency of these circuits. For example, if CorNet suggests that a particular inter-regional connection is critical for motor planning, targeted suppression of that pathway during behavior could validate the prediction (C. K. Kim et al. 2016; Otchy et al. 2015). This closed-loop cycle of model prediction and causal testing would enhance the explanatory power of computational models and establish functional mappings between model components and real circuits. Another rich avenue for exploration is the generalization of these models across species, including applications in non-human primates and human BCI datasets. Many fundamental principles of cortical dynamicsâsuch as dimensionality reduction, dynamical reconfiguration, and 187 mixed selectivityâare conserved across species (Gallego et al. 2017; Pandarinath et al. 2018). Testing CorNet or related architectures on higher-order species could both validate the translational relevance of these models and adapt them for more applied purposes. For instance, using neural population dynamics to drive brain-computer interface (BCI) feedback in patients with motor impairment could transform neuroprosthetic control strategies (Serruya et al. 2002; Sussillo et al. 2016). Furthermore, mapping model components to resting-state or task-evoked human fMRI patterns could inform clinical biomarkers of neurological disorders and predict treatment outcomes (Drysdale et al. 2016; Finn et al. 2015). Together, these directions will help transform computational neuroscience from descriptive modeling into a predictive and mechanistically grounded discipline, with applications that span basic science and neuroengineering. 4.4 Final remarks This thesis demonstrates that neural activity and behavior can be shaped in a flexible and interpretable manner through closed-loop feedback systems. By combining innovative engineering, rigorous behavioral paradigms, and powerful computational modeling, this work contributes novel insights into the mechanisms of motor learning, volitional control, and cortical computation. The experimental and modeling frameworks developed here lay the groundwork for future investigations into adaptive brain function, neurotechnological interventions, and real-time neural decoding across systems.188 References Abbasi, Aamir, Henri Lassagne, Luc Estebanez, Dorian Goueytes, Daniel E. Shulz, and Valerie Ego-Stengel. 2023. âBrain-Machine Interface Learning Is Facilitated by Specific Patterning of Distributed Cortical Feedback.â Science Advances 9 (38): eadh1328. https://doi.org/10.1126/sciadv.adh1328. Aharoni, Daniel, and Tycho M. Hoogland. 2019. âCircuit Investigations With Open-Source Miniaturized Microscopes: Past, Present and Future.â Frontiers in Cellular Neuroscience 13 (April):141. https://doi.org/10.3389/fncel.2019.00141. Akam, Thomas, Andy Lustig, James M. Rowland, Sampath Kt Kapanaiah, Joan Esteve-Agraz, Mariangela Panniello, Cristina Márquez, et al. 2022. âOpen-Source, Python-Based, Hardware and Software for Controlling Behavioural Neuroscience Experiments.â eLife 11 (January). https://doi.org/10.7554/eLife.67846. Akerboom, Jasper, Tsai-Wen Chen, Trevor J. Wardill, Lin Tian, Jonathan S. Marvin, Sevinç Mutlu, Nicole Carreras Calderón, et al. 2012. âOptimization of a GCaMP Calcium Indicator for Neural Activity Imaging.â The Journal of Neuroscience : The Official Journal of the Society for Neuroscience 32 (40): 13819â40. https://doi.org/10.1523/JNEUROSCI.2601-12.2012. Allegra Mascaro, Anna Letizia, Emilia Conti, Stefano Lai, Antonino Paolo Di Giovanna, Cristina Spalletti, Claudia Alia, Alessandro Panarese, et al. 2019. âCombined Rehabilitation Promotes the Recovery of Structural and Functional Features of Healthy Neuronal Networks after Stroke.â Cell Reports 28 (13): 3474â85.e6. https://doi.org/10.1016/j.celrep.2019.08.062. Allen, Cara B., Tansu Celikel, and Daniel E. Feldman. 2003. âLong-Term Depression Induced by Sensory Deprivation during Cortical Map Plasticity in Vivo.â Nature Neuroscience 6 (3): 291â99. https://doi.org/10.1038/nn1012. Allen, Christopher, and David M. A. Mehler. 2019. âOpen Science Challenges, Benefits and Tips in Early Career and beyond.â PLoS Biology 17 (5): e3000246. https://doi.org/10.1371/journal.pbio.3000246. Allen, William E., Isaac V. Kauvar, Michael Z. Chen, Ethan B. Richman, Samuel J. Yang, Ken Chan, Viviana Gradinaru, Benjamin E. Deverman, Liqun Luo, and Karl Deisseroth. 2017. âGlobal Representations of Goal-Directed Behavior in Distinct Cell Types of Mouse Neocortex.â Neuron 94 (4): 891â907.e6. https://doi.org/10.1016/j.neuron.2017.04.017. Antfolk, Christian, Marco DâAlonzo, Marco Controzzi, Göran Lundborg, Birgitta Rosén, Fredrik Sebelius, and Christian Cipriani. 2013. âArtificial Redirection of Sensation from Prosthetic Fingers to the Phantom Hand Map on Transradial Amputees: Vibrotactile versus Mechanotactile Sensory Feedback.â IEEE Transactions on Neural Systems and Rehabilitation Engineering : A Publication of the IEEE Engineering in Medicine and Biology Society 21 (1): 112â20. https://doi.org/10.1109/TNSRE.2012.2217989. Aravanis, Alexander M., Li-Ping Wang, Feng Zhang, Leslie A. Meltzer, Murtaza Z. Mogri, M. Bret Schneider, and Karl Deisseroth. 2007. âAn Optical Neural Interface: In Vivo Control of Rodent Motor Cortex with Integrated Fiberoptic and Optogenetic Technology.â Journal of Neural Engineering 4 (3): S143â56. https://doi.org/10.1088/1741-2560/4/3/S02. Barak, Omri, Mattia Rigotti, and Stefano Fusi. 2013. âThe Sparseness of Mixed Selectivity Neurons Controls the GeneralizationâDiscrimination Trade-Off.â Journal of Neuroscience 33 (9): 3844â56. https://doi.org/10.1523/JNEUROSCI.2753-12.2013. 189 Barbera, Giovanni, Rashmi Thapa, Navin Adhikari, Yun Li, and Da-Ting Lin. 2024. âImaging Distinct Neuronal Populations with a Dual Channel Miniscope.â Frontiers in Neuroscience 18 (December):1445020. https://doi.org/10.3389/fnins.2024.1445020. Bassett, Danielle S., Nicholas F. Wymbs, Mason A. Porter, Peter J. Mucha, Jean M. Carlson, and Scott T. Grafton. 2011. âDynamic Reconfiguration of Human Brain Networks during Learning.â Proceedings of the National Academy of Sciences 108 (18): 7641â46. https://doi.org/10.1073/pnas.1018985108. Belkacem, Abdelkader Nasreddine, Nuraini Jamil, Sumayya Khalid, and Fady Alnajjar. 2023. âOn Closed-Loop Brain Stimulation Systems for Improving the Quality of Life of Patients with Neurological Disorders.â Frontiers in Human Neuroscience 17 (March):1085173. https://doi.org/10.3389/fnhum.2023.1085173. Bergmann, Til O., Matthias Mölle, Marlit A. Schmidt, Christoph Lindner, Lisa Marshall, Jan Born, and Hartwig R. Siebner. 2012. âEEG-Guided Transcranial Magnetic Stimulation Reveals Rapid Shifts in Motor Cortical Excitability during the Human Sleep Slow Oscillation.â The Journal of Neuroscience : The Official Journal of the Society for Neuroscience 32 (1): 243â53. https://doi.org/10.1523/JNEUROSCI.4792-11.2012. Bloss, Erik B., Mark S. Cembrowski, Bill Karsh, Jennifer Colonell, Richard D. Fetter, and Nelson Spruston. 2016. âStructured Dendritic Inhibition Supports Branch-Selective Integration in CA1 Pyramidal Cells.â Neuron 89 (5): 1016â30. https://doi.org/10.1016/j.neuron.2016.01.029. Bollu, Tejapratap, Brendan S. Ito, Samuel C. Whitehead, Brian Kardon, James Redd, Mei Hong Liu, and Jesse H. Goldberg. 2021. âCortex-Dependent Corrections as the Tongue Reaches for and Misses Targets.â Nature 594 (7861): 82â87. https://doi.org/10.1038/s41586-021-03561-9. Bollu, Tejapratap, Samuel C. Whitehead, Nikil Prasad, Jackson Walker, Nitin Shyamkumar, Raghav Subramaniam, Brian Kardon, Itai Cohen, and Jesse H. Goldberg. 2019. âAutomated Home Cage Training of Mice in a Hold-Still Center-out Reach Task.â Journal of Neurophysiology, January. https://doi.org/10.1152/jn.00667.2018. âââ. 2024. âMotor Cortical Inactivation Impairs Corrective Submovements in Mice Performing a Hold-Still Center-out Reach Task.â Journal of Neurophysiology 132 (3): 829â48. https://doi.org/10.1152/jn.00241.2023. Bouchard, Matthew B., Venkatakaushik Voleti, César S. Mendes, Clay Lacefield, Wesley B. Grueber, Richard S. Mann, Randy M. Bruno, and Elizabeth M. C. Hillman. 2015. âSwept Confocally-Aligned Planar Excitation (SCAPE) Microscopy for High Speed Volumetric Imaging of Behaving Organisms.â Nature Photonics 9 (2): 113â19. https://doi.org/10.1038/nphoton.2014.323. Boyden, Edward S., Feng Zhang, Ernst Bamberg, Georg Nagel, and Karl Deisseroth. 2005. âMillisecond-Timescale, Genetically Targeted Optical Control of Neural Activity.â Nature Neuroscience 8 (9): 1263â68. https://doi.org/10.1038/nn1525. Boyd, Lara A., Barbara M. Quaney, Patricia S. Pohl, and Carolee J. Winstein. 2007. âLearning Implicitly: Effects of Task and Severity after Stroke.â Neurorehabilitation and Neural Repair 21 (5): 444â54. https://doi.org/10.1177/1545968307300438. Boyd, Lara A., Eric D. Vidoni, and Brenda D. Wessel. 2010. âMotor Learning after Stroke: Is Skill Acquisition a Prerequisite for Contralesional Neuroplastic Change?â Neuroscience Letters 482 (1): 21â25. https://doi.org/10.1016/j.neulet.2010.06.082. Boyd, Lara A., and Carolee J. Winstein. 2004. âProviding Explicit Information Disrupts Implicit Motor Learning after Basal Ganglia Stroke.â Learning & Memory (Cold Spring Harbor, N.Y.) 11 (4): 388â96. https://doi.org/10.1101/lm.80104. Bressler, S. L. 1995. âLarge-Scale Cortical Networks and Cognition.â Brain Research. Brain Research 190 Reviews 20 (3). https://doi.org/10.1016/0165-0173(94)00016-i. Bressler, Steven L., and Vinod Menon. 2010. âLarge-Scale Brain Networks in Cognition: Emerging Methods and Principles.â Trends in Cognitive Sciences 14 (6): 277â90. https://doi.org/10.1016/j.tics.2010.04.004. Brody, C. D. 1999. âCorrelations without Synchrony.â Neural Computation 11 (7): 1537â51. https://doi.org/10.1162/089976699300016133. Buonomano, Dean V., and Wolfgang Maass. 2009. âState-Dependent Computations: Spatiotemporal Processing in Cortical Networks.â Nature Reviews. Neuroscience 10 (2): 113â25. https://doi.org/10.1038/nrn2558. Cantillo-Negrete, Jessica, Martín Emiliano Rodríguez-García, Paul Carrillo-Mora, Oscar Arias-Carrión, Emmanuel Ortega-Robles, Marlene A. Galicia-Alvarado, Raquel Valdés-Cristerna, et al. 2025. âThe ReHand-BCI Trial: A Randomized Controlled Trial of a Brain-Computer Interface for Upper Extremity Stroke Neurorehabilitation.â Frontiers in Neuroscience 19 (June):1579988. https://doi.org/10.3389/fnins.2025.1579988. Carmena, Jose M., Mikhail A. Lebedev, Roy E. Crist, Joseph E. OâDoherty, David M. Santucci, Dragan F. Dimitrov, Parag G. Patil, Craig S. Henriquez, and Miguel A. L. Nicolelis. 2003. âLearning to Control a Brain-Machine Interface for Reaching and Grasping by Primates.â PLoS Biology 1 (2): E42. https://doi.org/10.1371/journal.pbio.0000042. Chau, Geeling, Christopher Wang, Sabera Talukder, Vighnesh Subramaniam, Saraswati Soedarmadji, Yisong Yue, Boris Katz, and Andrei Barbu. 2025. âPopulation Transformer: Learning Population-Level Representations of Neural Activity.â ArXiv. https://www.ncbi.nlm.nih.gov/pubmed/38883237. Chen, Tsai-Wen, Trevor J. Wardill, Yi Sun, Stefan R. Pulver, Sabine L. Renninger, Amy Baohan, Eric R. Schreiter, et al. 2013. âUltrasensitive Fluorescent Proteins for Imaging Neuronal Activity.â Nature 499 (7458): 295â300. https://doi.org/10.1038/nature12354. Chen, Zhe Sage, and Bijan Pesaran. 2021. âImproving Scalability in Systems Neuroscience.â Neuron 109 (11): 1776â90. https://doi.org/10.1016/j.neuron.2021.03.025. Ching, Shinung, Max Y. Liberman, Jessica J. Chemali, M. Brandon Westover, Jonathan D. Kenny, Ken Solt, Patrick L. Purdon, and Emery N. Brown. 2013. âReal-Time Closed-Loop Control in a Rodent Model of Medically Induced Coma Using Burst Suppression.â Anesthesiology 119 (4): 848â60. https://doi.org/10.1097/ALN.0b013e31829d4ab4. Chon, Uree, Daniel J. Vanselow, Keith C. Cheng, and Yongsoo Kim. 2019. âEnhanced and Unified Anatomical Labeling for a Common Mouse Brain Atlas.â bioRxiv. https://doi.org/10.1101/636175. Clancy, Kelly B., Aaron C. Koralek, Rui M. Costa, Daniel E. Feldman, and Jose M. Carmena. 2014. âVolitional Modulation of Optically Recorded Calcium Signals during Neuroprosthetic Learning.â Nature Neuroscience 17 (6): 807â9. https://doi.org/10.1038/nn.3712. Clancy, Kelly B., and Thomas D. Mrsic-Flogel. 2021. âThe Sensory Representation of Causally Controlled Objects.â Neuron 109 (4): 677â89.e4. https://doi.org/10.1016/j.neuron.2020.12.001. Clancy, Kelly B., Ivana Orsolic, and Thomas D. Mrsic-Flogel. 2019. âLocomotion-Dependent Remapping of Distributed Cortical Networks.â Nature Neuroscience 22 (5): 778â86. https://doi.org/10.1038/s41593-019-0357-8. Clark, Andy. 1998. Being There: Putting Brain, Body, and World Together Again. MIT Press. https://books.google.com/books/about/Being_There.html?hl=&id=i03NKy0ml1gC. Conti, Emilia, Alessandro Scaglione, Giuseppe de Vito, Francesco Calugi, Maria Pasquini, Tommaso Pizzorusso, Silvestro Micera, Anna Letizia Allegra Mascaro, and Francesco Saverio Pavone. 2022. âCombining Optogenetic Stimulation and Motor Training Improves Functional Recovery and 191 Perilesional Cortical Activity.â Neurorehabilitation and Neural Repair 36 (2): 107â18. https://doi.org/10.1177/15459683211056656. Cowan, Noah J., Mert M. Ankarali, Jonathan P. Dyhr, Manu S. Madhav, Eatai Roth, Shahin Sefati, Simon Sponberg, Sarah A. Stamper, Eric S. Fortune, and Thomas L. Daniel. 2014. âFeedback Control as a Framework for Understanding Tradeoffs in Biology.â Integrative and Comparative Biology 54 (2): 223â37. https://doi.org/10.1093/icb/icu050. Crawley, Jacqueline N. 2007. Whatâs Wrong With My Mouse?: Behavioral Phenotyping of Transgenic and Knockout Mice. John Wiley & Sons. https://play.google.com/store/books/details?id=CTES09IWtm0C. Dana, Hod, Tsai-Wen Chen, Amy Hu, Brenda C. Shields, Caiying Guo, Loren L. Looger, Douglas S. Kim, and Karel Svoboda. 2014. âThy1-GCaMP6 Transgenic Mice for Neuronal Population Imaging in Vivo.â PloS One 9 (9): e108697. https://doi.org/10.1371/journal.pone.0108697. Dana, Hod, Boaz Mohar, Yi Sun, Sujatha Narayan, Andrew Gordus, Jeremy P. Hasseman, Getahun Tsegaye, et al. 2016. âSensitive Red Protein Calcium Indicators for Imaging Neural Activity.â eLife 5 (March). https://doi.org/10.7554/eLife.12727. Dana, Hod, Yi Sun, Boaz Mohar, Brad K. Hulse, Aaron M. Kerlin, Jeremy P. Hasseman, Getahun Tsegaye, et al. 2019. âHigh-Performance Calcium Sensors for Imaging Activity in Neuronal Populations and Microcompartments.â Nature Methods 16 (7): 649â57. https://doi.org/10.1038/s41592-019-0435-6. Datta-Chaudhuri, Timir. 2021. âClosed-Loop Neuromodulation Will Increase the Utility of Mouse Models in Bioelectronic Medicine.â Bioelectronic Medicine 7 (1): 10. https://doi.org/10.1186/s42234-021-00071-x. Dhillon, Navjodh Singh, Agustinus Sutandi, Manoj Vishwanath, Miranda M. Lim, Hung Cao, and Dong Si. 2021. âA Raspberry Pi-Based Traumatic Brain Injury Detection System for Single-Channel Electroencephalogram.â Sensors 21 (8). https://doi.org/10.3390/s21082779. Dombeck, Daniel A., Christopher D. Harvey, Lin Tian, Loren L. Looger, and David W. Tank. 2010. âFunctional Imaging of Hippocampal Place Cells at Cellular Resolution during Virtual Navigation.â Nature Neuroscience 13 (11): 1433â40. https://doi.org/10.1038/nn.2648. Dong, Zhe, Yu Feng, Keziah Diego, Austin M. Baggetta, Brian M. Sweis, Zachary T. Pennington, Sophia I. Lamsifer, et al. 2024. âSimultaneous Dual-Color Calcium Imaging in Freely-Behaving Mice.â bioRxiv. https://doi.org/10.1101/2024.07.03.601770. âââ. 2025. âSimultaneous Two-Color Imaging with a Dual-Channel Miniscope in Freely Behaving Mice.â Science Advances 11 (27): eadr6470. https://doi.org/10.1126/sciadv.adr6470. Dosen, Strahinja, Marko Markovic, Cornelia Hartmann, and Dario Farina. 2015. âSensory Feedback in Prosthetics: A Standardized Test Bench for Closed-Loop Control.â IEEE Transactions on Neural Systems and Rehabilitation Engineering : A Publication of the IEEE Engineering in Medicine and Biology Society 23 (2): 267â76. https://doi.org/10.1109/TNSRE.2014.2371238. Douglas, Rodney J., and Kevan A. C. Martin. 2004. âNeuronal Circuits of the Neocortex.â Annual Review of Neuroscience 27:419â51. https://doi.org/10.1146/annurev.neuro.27.070203.144152. Drysdale, Andrew T., Logan Grosenick, Jonathan Downar, Katharine Dunlop, Farrokh Mansouri, Yue Meng, Robert N. Fetcho, et al. 2016. âResting-State Connectivity Biomarkers Define Neurophysiological Subtypes of Depression.â Nature Medicine 23 (1): 28â38. https://doi.org/10.1038/nm.4246. DâSouza, Rinaldo D., Quanxin Wang, Weiqing Ji, Andrew M. Meier, Henry Kennedy, Kenneth Knoblauch, and Andreas Burkhalter. 2022. âHierarchical and Nonhierarchical Features of the Mouse 192 Visual Cortical Network.â Nature Communications 13 (1): 503. https://doi.org/10.1038/s41467-022-28035-y. El Hady, Ahmed. 2016. Closed Loop Neuroscience. Academic Press. https://play.google.com/store/books/details?id=0ZTBCQAAQBAJ. Elman, Jeffrey L. 1990. âFinding Structure in Time.â Cognitive Science 14 (2): 179â211. https://doi.org/10.1207/s15516709cog1402_1. Erlich, Jeffrey C., Bingni W. Brunton, Chunyu A. Duan, Timothy D. Hanks, and Carlos D. Brody. 2015. âDistinct Effects of Prefrontal and Parietal Cortex Inactivations on an Accumulation of Evidence Task in the Rat,â April. https://doi.org/10.7554/eLife.05457. Ethier, C., E. R. Oby, M. J. Bauman, and L. E. Miller. 2012. âRestoration of Grasp Following Paralysis through Brain-Controlled Stimulation of Muscles.â Nature 485 (7398): 368â71. https://doi.org/10.1038/nature10987. Farkhondeh Tale Navi, Farhad, Soomaayeh Heysieattalab, Dhakshin S. Ramanathan, Mohammad Reza Raoufy, and Mohammad Ali Nazari. 2022. âClosed-Loop Modulation of the Self-Regulating Brain: A Review on Approaches, Emerging Paradigms, and Experimental Designs.â Neuroscience 483 (February):104â26. https://doi.org/10.1016/j.neuroscience.2021.12.004. Felleman, D. J., and D. C. Van Essen. 1991. âDistributed Hierarchical Processing in the Primate Cerebral Cortex.â Cerebral Cortex (New York, N.Y. : 1991) 1 (1): 1â47. https://doi.org/10.1093/cercor/1.1.1-a. Ferster, C. B., and B. F. Skinner. 1957. Schedules of Reinforcement. East Norwalk: Appleton-Century-Crofts. https://doi.org/10.1037/10627-000. Fetz, E. E. 1969a. âOperant Conditioning of Cortical Unit Activity.â Science. https://doi.org/10.1126/science.163.3870.955. âââ. 1969b. âOperant Conditioning of Cortical Unit Activity.â Science 163 (3870): 955â58. https://doi.org/10.1126/science.163.3870.955. Finn, Emily S., Xilin Shen, Dustin Scheinost, Monica D. Rosenberg, Jessica Huang, Marvin M. Chun, Xenophon Papademetris, and R. Todd Constable. 2015. âFunctional Connectome Fingerprinting: Identifying Individuals Using Patterns of Brain Connectivity.â Nature Neuroscience 18 (11): 1664â71. https://doi.org/10.1038/nn.4135. Fiser, Aris, David Mahringer, Hassana K. Oyibo, Anders V. Petersen, Marcus Leinweber, and Georg B. Keller. 2016. âExperience-Dependent Spatial Expectations in Mouse Visual Cortex.â Nature Neuroscience 19 (12): 1658â64. https://doi.org/10.1038/nn.4385. Forys, Brandon J., Dongsheng Xiao, Pankaj Gupta, and Timothy H. Murphy. 2020. âReal-Time Selective Markerless Tracking of Forepaws of Head Fixed Mice Using Deep Neural Networks.â eNeuro 7 (3): ENEURO.0096â20.2020. https://doi.org/10.1523/ENEURO.0096-20.2020. Francis Song, H., Guangyu R. Yang, and Xiao-Jing Wang. 2016. âTraining Excitatory-Inhibitory Recurrent Neural Networks for Cognitive Tasks: A Simple and Flexible Framework.â PLOS Computational Biology 12 (2): e1004792. https://doi.org/10.1371/journal.pcbi.1004792. Friston, Karl. 2010. âThe Free-Energy Principle: A Unified Brain Theory?â Nature Reviews Neuroscience 11 (2): 127â38. https://doi.org/10.1038/nrn2787. Fu, Yu, Jason M. Tucciarone, J. Sebastian Espinosa, Nengyin Sheng, Daniel P. Darcy, Roger A. Nicoll, Z. Josh Huang, and Michael P. Stryker. 2014. âA Cortical Circuit for Gain Control by Behavioral State.â Cell 156 (6): 1139â52. https://doi.org/10.1016/j.cell.2014.01.050. Gallego, Juan A., Matthew G. Perich, Lee E. Miller, and Sara A. Solla. 2017. âNeural Manifolds for the Control of Movement.â Neuron 94 (5): 978â84. https://doi.org/10.1016/j.neuron.2017.05.025. 193 Ganguly, Karunesh, and Jose M. Carmena. 2009. âEmergence of a Stable Cortical Map for Neuroprosthetic Control.â PLoS Biology 7 (7): e1000153. https://doi.org/10.1371/journal.pbio.1000153. Ganzer, Patrick D., Michael J. Darrow, Eric C. Meyers, Bleyda R. Solorzano, Andrea D. Ruiz, Nicole M. Robertson, Katherine S. Adcock, et al. 2018. âClosed-Loop Neuromodulation Restores Network Connectivity and Motor Control after Spinal Cord Injury,â March. https://doi.org/10.7554/eLife.32058. Garrett, Marina E., Ian Nauhaus, James H. Marshel, and Edward M. Callaway. 2014. âTopography and Areal Organization of Mouse Visual Cortex.â The Journal of Neuroscience : The Official Journal of the Society for Neuroscience 34 (37): 12587â600. https://doi.org/10.1523/JNEUROSCI.1124-14.2014. Garrett, Marina, Sahar Manavi, Kate Roll, Douglas R. Ollerenshaw, Peter A. Groblewski, Nicholas D. Ponvert, Justin T. Kiggins, et al. 2020. âExperience Shapes Activity Dynamics and Stimulus Coding of VIP Inhibitory Cells.â eLife 9 (February). https://doi.org/10.7554/eLife.50340. Gerstner, Wulfram, and Werner M. Kistler. 2002. Spiking Neuron Models: Single Neurons, Populations, Plasticity. Cambridge University Press. https://doi.org/10.1017/CBO9780511815706. Gilad, Ariel, and Fritjof Helmchen. 2020. âSpatiotemporal Refinement of Signal Flow through Association Cortex during Learning.â Nature Communications 11 (1): 1744. https://doi.org/10.1038/s41467-020-15534-z. Girardeau, Gabrielle, Karim Benchenane, Sidney I. Wiener, György Buzsáki, and Michaël B. Zugaro. 2009. âSelective Suppression of Hippocampal Ripples Impairs Spatial Memory.â Nature Neuroscience 12 (10): 1222â23. https://doi.org/10.1038/nn.2384. Giszter, Simon F. 2015. âMotor Primitives--New Data and Future Questions.â Current Opinion in Neurobiology 33 (August):156â65. https://doi.org/10.1016/j.conb.2015.04.004. Gonzalez, Melissa, Mark A. Gradwell, Joshua K. Thackray, Komal R. Patel, Kanaksha K. Temkar, and Victoria E. Abraira. 2024. âUsing DeepLabCut-Live to Probe State Dependent Neural Circuits of Behavior with Closed-Loop Optogenetic Stimulation.â bioRxiv. https://doi.org/10.1101/2024.07.28.605489. Grani, Fabrizio, Cristina Soto-Sánchez, Antonio Fimia, and Eduardo Fernández. 2022. âToward a Personalized Closed-Loop Stimulation of the Visual Cortex: Advances and Challenges.â Frontiers in Cellular Neuroscience 16 (December):1034270. https://doi.org/10.3389/fncel.2022.1034270. Groblewski, Peter A., Douglas R. Ollerenshaw, Justin T. Kiggins, Marina E. Garrett, Chris Mochizuki, Linzy Casal, Sissy Cross, et al. 2020. âCharacterization of Learning, Motivation, and Visual Perception in Five Transgenic Mouse Lines Expressing GCaMP in Distinct Cell Populations.â Frontiers in Behavioral Neuroscience 14 (June):104. https://doi.org/10.3389/fnbeh.2020.00104. Grosenick, Logan, James H. Marshel, and Karl Deisseroth. 2015. âClosed-Loop and Activity-Guided Optogenetic Control.â Neuron 86 (1): 106â39. https://doi.org/10.1016/j.neuron.2015.03.034. Grynkiewicz, G., M. Poenie, and R. Y. Tsien. 1985. âA New Generation of Ca2+ Indicators with Greatly Improved Fluorescence Properties.â The Journal of Biological Chemistry 260 (6): 3440â50. https://www.ncbi.nlm.nih.gov/pubmed/3838314. Guggenmos, David J., Meysam Azin, Scott Barbay, Jonathan D. Mahnken, Caleb Dunham, Pedram Mohseni, and Randolph J. Nudo. 2013. âRestoration of Function after Brain Damage Using a Neural Prosthesis.â Proceedings of the National Academy of Sciences of the United States of America 110 (52): 21177â82. https://doi.org/10.1073/pnas.1316885110. Guggisberg, Adrian G., Philipp J. Koch, Friedhelm C. Hummel, and Cathrin M. Buetefisch. 2019. âBrain 194 Networks and Their Relevance for Stroke Rehabilitation.â Clinical Neurophysiology : Official Journal of the International Federation of Clinical Neurophysiology 130 (7): 1098â1124. https://doi.org/10.1016/j.clinph.2019.04.004. Gupta, Pankaj K., and Timothy H. Murphy. 2025. âReal-Time Closed-Loop Feedback System For Mouse Mesoscale Cortical Signal And Movement Control: CLoPy.â eLife 14 (January). https://doi.org/10.7554/eLife.105070.1. Han, Yoon K., Hania Köver, Michele N. Insanally, John H. Semerdjian, and Shaowen Bao. 2007. âEarly Experience Impairs Perceptual Discrimination.â Nature Neuroscience 10 (9): 1191â97. https://doi.org/10.1038/nn1941. Harris, Julie A., Stefan Mihalas, Karla E. Hirokawa, Jennifer D. Whitesell, Hannah Choi, Amy Bernard, Phillip Bohn, et al. 2019. âHierarchical Organization of Cortical and Thalamic Connectivity.â Nature 575 (7781): 195â202. https://doi.org/10.1038/s41586-019-1716-z. Harvey, Christopher D., Forrest Collman, Daniel A. Dombeck, and David W. Tank. 2009. âIntracellular Dynamics of Hippocampal Place Cells during Virtual Navigation.â Nature 461 (7266): 941â46. https://doi.org/10.1038/nature08499. He, Shenghong, Jean Debarros, Saed Khawaldeh, Alek Pogosyan, Abteen Mostofi, Fahd Baig, Erlick Pereira, Peter Brown, and Huiling Tan. 2020. âClosed-Loop DBS Triggered by Real-Time Movement and Tremor Decoding Based on Thalamic LFPs for Essential Tremor.â Annual International Conference of the IEEE Engineering in Medicine and Biology Society. IEEE Engineering in Medicine and Biology Society. Annual International Conference 2020 (July):3602â5. https://doi.org/10.1109/EMBC44109.2020.9175433. Hillman, Elizabeth M. C. 2007. âOptical Brain Imaging in Vivo: Techniques and Applications from Animal to Man.â Journal of Biomedical Optics 12 (5): 051402. https://doi.org/10.1117/1.2789693. Hochberg, Leigh R., Daniel Bacher, Beata Jarosiewicz, Nicolas Y. Masse, John D. Simeral, Joern Vogel, Sami Haddadin, et al. 2012. âReach and Grasp by People with Tetraplegia Using a Neurally Controlled Robotic Arm.â Nature 485 (7398): 372â75. https://doi.org/10.1038/nature11076. Hochberg, Leigh R., Mijail D. Serruya, Gerhard M. Friehs, Jon A. Mukand, Maryam Saleh, Abraham H. Caplan, Almut Branner, David Chen, Richard D. Penn, and John P. Donoghue. 2006. âNeuronal Ensemble Control of Prosthetic Devices by a Human with Tetraplegia.â Nature 442 (7099): 164â71. https://doi.org/10.1038/nature04970. Hontani, Yusaku, Fei Xia, and Chris Xu. 2021. âMulticolor Three-Photon Fluorescence Imaging with Single-Wavelength Excitation Deep in Mouse Brain.â Science Advances 7 (12). https://doi.org/10.1126/sciadv.abf3531. Huber, D., D. A. Gutnisky, S. Peron, D. H. OâConnor, J. S. Wiegert, L. Tian, T. G. Oertner, L. L. Looger, and K. Svoboda. 2012. âMultiple Dynamic Representations in the Motor Cortex during Sensorimotor Learning.â Nature 484 (7395): 473â78. https://doi.org/10.1038/nature11039. Hu, Brian, Marina E. Garrett, Peter A. Groblewski, Douglas R. Ollerenshaw, Jiaqi Shang, Kate Roll, Sahar Manavi, Christof Koch, Shawn R. Olsen, and Stefan Mihalas. 2021. âAdaptation Supports Short-Term Memory in a Visual Change Detection Task.â PLOS Computational Biology 17 (9): e1009246. https://doi.org/10.1371/journal.pcbi.1009246. Izquierdo, Alicia, and Annabelle M. Belcher. 2012. âRodent Models of Adaptive Decision Making.â Methods in Molecular Biology (Clifton, N.J.) 829:85â101. https://doi.org/10.1007/978-1-61779-458-2_5. Jacobs, Elina A. K., Nicholas A. Steinmetz, Andrew J. Peters, Matteo Carandini, and Kenneth D. Harris. 2020. âCortical State Fluctuations during Sensory Decision Making.â Current Biology : CB 30 (24): 195 4944â55.e7. https://doi.org/10.1016/j.cub.2020.09.067. Jia, Xiaoxuan, Joshua H. Siegle, Séverine Durand, Greggory Heller, Tamina K. Ramirez, Christof Koch, and Shawn R. Olsen. 2022. âMulti-Regional Module-Based Signal Transmission in Mouse Visual Cortex.â Neuron 110 (9): 1585â98.e9. https://doi.org/10.1016/j.neuron.2022.01.027. Jun, James J., Nicholas A. Steinmetz, Joshua H. Siegle, Daniel J. Denman, Marius Bauza, Brian Barbarits, Albert K. Lee, et al. 2017. âFully Integrated Silicon Probes for High-Density Recording of Neural Activity.â Nature 551 (7679): 232â36. https://doi.org/10.1038/nature24636. Kane, Gary A., Gonçalo Lopes, Jonny L. Saunders, Alexander Mathis, and Mackenzie W. Mathis. 2020. âReal-Time, Low-Latency Closed-Loop Feedback Using Markerless Posture Tracking.â eLife 9 (December). https://doi.org/10.7554/eLife.61909. Karnani, Mahesh M., Jesse Jackson, Inbal Ayzenshtat, Jason Tucciarone, Kasra Manoocheri, William G. Snider, and Rafael Yuste. 2016. âCooperative Subnetworks of Molecularly Similar Interneurons in Mouse Neocortex.â Neuron 90 (1): 86â100. https://doi.org/10.1016/j.neuron.2016.02.037. Karvat, Golan, Artur Schneider, Mansour Alyahyay, Florian Steenbergen, Michael Tangermann, and Ilka Diester. 2020. âReal-Time Detection of Neural Oscillation Bursts Allows Behaviourally Relevant Neurofeedback.â Communications Biology 3 (1): 1â10. https://doi.org/10.1038/s42003-020-0801-z. Kepecs, Adam, and Gordon Fishell. 2014. âInterneuron Cell Types Are Fit to Function.â Nature 505 (7483): 318â26. https://doi.org/10.1038/nature12983. Kim, Christina K., Samuel J. Yang, Nandini Pichamoorthy, Noah P. Young, Isaac Kauvar, Joshua H. Jennings, Talia N. Lerner, et al. 2016. âSimultaneous Fast Measurement of Circuit Dynamics at Multiple Sites across the Mammalian Brain.â Nature Methods 13 (4): 325â28. https://doi.org/10.1038/nmeth.3770. Kim, Sung-Yon, Avishek Adhikari, Soo Yeun Lee, James H. Marshel, Christina K. Kim, Caitlin S. Mallory, Maisie Lo, et al. 2013. âDiverging Neural Pathways Assemble a Behavioural State from Separable Features in Anxiety.â Nature 496 (7444): 219â23. https://doi.org/10.1038/nature12018. Kim, Tony Hyun, Yanping Zhang, Jérôme Lecoq, Juergen C. Jung, Jane Li, Hongkui Zeng, Cristopher M. Niell, and Mark J. Schnitzer. 2016. âLong-Term Optical Access to an Estimated One Million Neurons in the Live Mouse Cortex.â Cell Reports 17 (12): 3385â94. https://doi.org/10.1016/j.celrep.2016.12.004. Knudsen, Eric B., and Joni D. Wallis. 2020. âClosed-Loop Theta Stimulation in the Orbitofrontal Cortex Prevents Reward-Based Learning.â Neuron 106 (3): 537â47.e4. https://doi.org/10.1016/j.neuron.2020.02.003. Koralek, Aaron C., Xin Jin, John D. Long 2nd, Rui M. Costa, and Jose M. Carmena. 2012. âCorticostriatal Plasticity Is Necessary for Learning Intentional Neuroprosthetic Skills.â Nature 483 (7389): 331â35. https://doi.org/10.1038/nature10845. Krakauer, John W., Asif A. Ghazanfar, Alex Gomez-Marin, Malcolm A. MacIver, and David Poeppel. 2017. âNeuroscience Needs Behavior: Correcting a Reductionist Bias.â Neuron 93 (3): 480â90. https://doi.org/10.1016/j.neuron.2016.12.041. Krakauer, John W., Alkis M. Hadjiosif, Jing Xu, Aaron L. Wong, and Adrian M. Haith. 2019. âMotor Learning.â Comprehensive Physiology 9 (2): 613â63. https://doi.org/10.1002/cphy.c170043. Krook-Magnuson, Esther, Jennifer N. Gelinas, Ivan Soltesz, and György Buzsáki. 2015. âNeuroelectronics and Biooptics: Closed-Loop Technologies in Neurological Disorders.â JAMA Neurology 72 (7): 823â29. https://doi.org/10.1001/jamaneurol.2015.0608. Lee, Candice, Andreanne Lavoie, Jiashu Liu, Simon X. Chen, and Bao-Hua Liu. 2020. âLight Up the Brain: The Application of Optogenetics in Cell-Type Specific Dissection of Mouse Brain Circuits.â 196 Frontiers in Neural Circuits 14 (April):18. https://doi.org/10.3389/fncir.2020.00018. Lee, Soohyun, Illya Kruglikov, Z. Josh Huang, Gord Fishell, and Bernardo Rudy. 2013. âA Disinhibitory Circuit Mediates Motor Integration in the Somatosensory Cortex.â Nature Neuroscience 16 (11): 1662â70. https://doi.org/10.1038/nn.3544. Levi, Timothée, Paolo Bonifazi, Paolo Massobrio, and Michela Chiappalone. 2018. âEditorial: Closed-Loop Systems for Next-Generation Neuroprostheses.â Frontiers in Neuroscience 12 (February):26. https://doi.org/10.3389/fnins.2018.00026. Liberti, William A., L. Nathan Perkins, Daniel P. Leman, and Timothy J. Gardner. 2017. âAn Open Source, Wireless Capable Miniature Microscope System.â Journal of Neural Engineering 14 (4): 045001. https://doi.org/10.1088/1741-2552/aa6806. Lim, Diana H., Majid H. Mohajerani, Jeffrey Ledue, Jamie Boyd, Shangbin Chen, and Timothy H. Murphy. 2012. âIn Vivo Large-Scale Cortical Mapping Using Channelrhodopsin-2 Stimulation in Transgenic Mice Reveals Asymmetric and Reciprocal Relationships between Cortical Areas.â Frontiers in Neural Circuits 6 (March):11. https://doi.org/10.3389/fncir.2012.00011. Lo, Meng-Chen, and Alik S. Widge. 2017. âClosed-Loop Neuromodulation Systems: Next-Generation Treatments for Psychiatric Illness.â International Review of Psychiatry (Abingdon, England) 29 (2): 191â204. https://doi.org/10.1080/09540261.2017.1282438. Lopes, Gonçalo, Niccolò Bonacchi, João Frazão, Joana P. Neto, Bassam V. Atallah, Sofia Soares, Luís Moreira, et al. 2015. âBonsai: An Event-Based Framework for Processing and Controlling Data Streams.â Frontiers in Neuroinformatics 9 (April):7. https://doi.org/10.3389/fninf.2015.00007. Lopes, Gonçalo, and Patricia Monteiro. 2021. âNew Open-Source Tools: Using Bonsai for Behavioral Tracking and Closed-Loop Experiments.â Frontiers in Behavioral Neuroscience 15 (March):647640. https://doi.org/10.3389/fnbeh.2021.647640. Luo, Shengtao, Xiaopeng Zhou, Hui Zhou, Tao Li, Yutong He, Jiang-Fan Chen, and Liping Zhang. 2024. âVolitional Modulation of Neuronal Activity in the External Globus Pallidus by Engagement of the Cortical-Basal Ganglia Circuit.â The Journal of Physiology, July. https://doi.org/10.1113/JP286046. Machado, Timothy A., Isaac V. Kauvar, and Karl Deisseroth. 2022. âMultiregion Neuronal Activity: The Forest and the Trees.â Nature Reviews. Neuroscience 23 (11): 683â704. https://doi.org/10.1038/s41583-022-00634-0. Madisen, Linda, Aleena R. Garner, Daisuke Shimaoka, Amy S. Chuong, Nathan C. Klapoetke, Lu Li, Alexander van der Bourg, et al. 2015. âTransgenic Mice for Intersectional Targeting of Neural Sensors and Effectors with High Specificity and Performance.â Neuron 85 (5): 942â58. https://doi.org/10.1016/j.neuron.2015.02.022. Makino, Hiroshi, Eun Jung Hwang, Nathan G. Hedrick, and Takaki Komiyama. 2016. âCircuit Mechanisms of Sensorimotor Learning.â Neuron 92 (4): 705â21. https://doi.org/10.1016/j.neuron.2016.10.029. Makino, Hiroshi, Chi Ren, Haixin Liu, An Na Kim, Neehar Kondapaneni, Xin Liu, Duygu Kuzum, and Takaki Komiyama. 2017. âTransformation of Cortex-Wide Emergent Properties during Motor Learning.â Neuron 94 (4): 880â90.e8. https://doi.org/10.1016/j.neuron.2017.04.015. Mante, Valerio, David Sussillo, Krishna V. Shenoy, and William T. Newsome. 2013. âContext-Dependent Computation by Recurrent Dynamics in Prefrontal Cortex.â Nature 503 (7474): 78â84. https://doi.org/10.1038/nature12742. Marquez-Chin, Cesar, Naaz Kapadia-Desai, and Sukhvinder Kalsi-Ryan. 2021. BrainâComputer Interfaces: Neurorehabilitation of Voluntary Movement after Stroke and Spinal Cord Injury. Morgan & Claypool Publishers. 197 https://books.google.com/books/about/Brain_Computer_Interfaces.html?hl=&id=IWo-EAAAQBAJ. Mathis, Alexander, Pranav Mamidanna, Kevin M. Cury, Taiga Abe, Venkatesh N. Murthy, Mackenzie Weygandt Mathis, and Matthias Bethge. 2018. âDeepLabCut: Markerless Pose Estimation of User-Defined Body Parts with Deep Learning.â Nature Neuroscience 21 (9): 1281â89. https://doi.org/10.1038/s41593-018-0209-y. Mathis, Mackenzie Weygandt, Alexander Mathis, and Naoshige Uchida. 2017. âSomatosensory Cortex Plays an Essential Role in Forelimb Motor Adaptation in Mice.â Neuron 93 (6): 1493â1503.e6. https://doi.org/10.1016/j.neuron.2017.02.049. Ma, Ying, Mohammed A. Shaik, Sharon H. Kim, Mariel G. Kozberg, David N. Thibodeaux, Hanzhi T. Zhao, Hang Yu, and Elizabeth M. C. Hillman. 2016. âWide-Field Optical Mapping of Neural Activity and Brain Haemodynamics: Considerations and Novel Approaches.â Philosophical Transactions of the Royal Society of London. Series B, Biological Sciences 371 (1705). https://doi.org/10.1098/rstb.2015.0360. McGreevy, Paul, and Robert Boakes. 2011. Carrots and Sticks: Principles of Animal Training. DARLINGTON PRESS. https://books.google.com/books/about/Carrots_and_Sticks.html?hl=&id=AG_fdrmUKroC. Merel, Josh, Matthew Botvinick, and Greg Wayne. 2019. âHierarchical Motor Control in Mammals and Machines.â Nature Communications 10 (1): 5489. https://doi.org/10.1038/s41467-019-13239-6. Meyer, Arne F., Jasper Poort, John OâKeefe, Maneesh Sahani, and Jennifer F. Linden. 2018. âA Head-Mounted Camera System Integrates Detailed Behavioral Monitoring with Multichannel Electrophysiology in Freely Moving Mice.â Neuron 100 (1): 46â60.e7. https://doi.org/10.1016/j.neuron.2018.09.020. Michelson, Nicholas J., Federico Bolaños, Luis A. Bolaños, Matilde Balbi, Jeffrey M. LeDue, and Timothy H. Murphy. 2023. âMeso-Py: Dual Brain Cortical Calcium Imaging in Mice during Head-Fixed Social Stimulus Presentation.â eNeuro 10 (12). https://doi.org/10.1523/ENEURO.0096-23.2023. Miltenberger, Raymond G. 2001. Behavior Modification: Principles and Procedures. Wadsworth Publishing Company. https://books.google.com/books/about/Behavior_Modification.html?hl=&id=-BZHAAAAMAAJ. Miranda, Jose Garcia Vivas, Jean-François Daneault, Gloria Vergara-Diaz, Ãngelo Frederico Souza de Oliveira E. Torres, Ana Paula Quixadá, Marcus de Lemos Fonseca, João Paulo Bomfim Cruz Vieira, et al. 2018. âComplex Upper-Limb Movements Are Generated by Combining Motor Primitives That Scale with the Movement Size.â Scientific Reports 8 (1): 12918. https://doi.org/10.1038/s41598-018-29470-y. Miyawaki, Atsushi, Juan Llopis, Roger Heim, J. Michael McCaffery, Joseph A. Adams, Mitsuhiko Ikura, and Roger Y. Tsien. 1997. âFluorescent Indicators for Ca2+based on Green Fluorescent Proteins and Calmodulin.â Nature 388 (6645): 882â87. https://doi.org/10.1038/42264. Moritz, Chet T., Steve I. Perlmutter, and Eberhard E. Fetz. 2008. âDirect Control of Paralysed Muscles by Cortical Neurons.â Nature 456 (7222): 639â42. https://doi.org/10.1038/nature07418. Muñoz, William, Robin Tremblay, Daniel Levenstein, and Bernardo Rudy. 2017. âLayer-Specific Modulation of Neocortical Dendritic Inhibition during Active Wakefulness.â Science (New York, N.Y.) 355 (6328): 954â59. https://doi.org/10.1126/science.aag2599. Murphy, Timothy H., Nicholas J. Michelson, Jamie D. Boyd, Tony Fong, Luis A. Bolanos, David Bierbrauer, Teri Siu, et al. 2020. âAutomated Task Training and Longitudinal Monitoring of Mouse Mesoscale Cortical Circuits Using Home Cages.â eLife 9 (May). 198 https://doi.org/10.7554/eLife.55964. Musall, Simon, Matthew T. Kaufman, Ashley L. Juavinett, Steven Gluf, and Anne K. Churchland. 2019. âSingle-Trial Neural Dynamics Are Dominated by Richly Varied Movements.â Nature Neuroscience 22 (10): 1677â86. https://doi.org/10.1038/s41593-019-0502-4. Nakai, Junichi, Masamichi Ohkura, and Keiji Imoto. 2001. âA High Signal-to-Noise Ca2+ Probe Composed of a Single Green Fluorescent Protein.â Nature Biotechnology 19 (2): 137â41. https://doi.org/10.1038/84397. Nakai, Nobuhiro, Masaaki Sato, Okito Yamashita, Yukiko Sekine, Xiaochen Fu, Junichi Nakai, Andrew Zalesky, and Toru Takumi. 2023. âVirtual Reality-Based Real-Time Imaging Reveals Abnormal Cortical Dynamics during Behavioral Transitions in a Mouse Model of Autism.â Cell Reports 42 (4): 112258. https://doi.org/10.1016/j.celrep.2023.112258. National Research Council, Division on Earth and Life Studies, Institute for Laboratory Animal Research, and Committee for the Update of the Guide for the Care and Use of Laboratory Animals. 2011. Guide for the Care and Use of Laboratory Animals: Eighth Edition. National Academies Press. https://books.google.com/books/about/Guide_for_the_Care_and_Use_of_Laboratory.html?hl=&id=GyxkAgAAQBAJ. Neely, Ryan M., Aaron C. Koralek, Vivek R. Athalye, Rui M. Costa, and Jose M. Carmena. 2018. âVolitional Modulation of Primary Visual Cortex Activity Requires the Basal Ganglia.â Neuron 97 (6): 1356â68.e4. https://doi.org/10.1016/j.neuron.2018.01.051. Neely, Ryan M., David K. Piech, Samantha R. Santacruz, Michel M. Maharbiz, and Jose M. Carmena. 2018. âRecent Advances in Neural Dust: Towards a Neural Interface Platform.â Current Opinion in Neurobiology 50 (June):64â71. https://doi.org/10.1016/j.conb.2017.12.010. Newman, Jonathan P., Ming-Fai Fong, Daniel C. Millard, Clarissa J. Whitmire, Garrett B. Stanley, and Steve M. Potter. 2015. âOptogenetic Feedback Control of Neural Activity,â July. https://doi.org/10.7554/eLife.07192. Newman, Jonathan P., Riley Zeller-Townson, Ming-Fai Fong, Sharanya Arcot Desai, Robert E. Gross, and Steve M. Potter. 2012. âClosed-Loop, Multichannel Experimentation Using the Open-Source NeuroRighter Electrophysiology Platform.â Frontiers in Neural Circuits 6:98. https://doi.org/10.3389/fncir.2012.00098. Nicolelis, Miguel A. L. 2001. âActions from Thoughts.â Nature 409 (6818): 403â7. https://doi.org/10.1038/35053191. Nudo, R. J., G. W. Milliken, W. M. Jenkins, and M. M. Merzenich. 1996. âUse-Dependent Alterations of Movement Representations in Primary Motor Cortex of Adult Squirrel Monkeys.â The Journal of Neuroscience : The Official Journal of the Society for Neuroscience 16 (2): 785â807. https://doi.org/10.1523/JNEUROSCI.16-02-00785.1996. OâConnor, Daniel H., S. Andrew Hires, Zengcai V. Guo, Nuo Li, Jianing Yu, Qian-Quan Sun, Daniel Huber, and Karel Svoboda. 2013. âNeural Coding during Active Somatosensation Revealed Using Illusory Touch.â Nature Neuroscience 16 (7): 958â65. https://doi.org/10.1038/nn.3419. OâDoherty, Joseph E., Mikhail A. Lebedev, Peter J. Ifft, Katie Z. Zhuang, Solaiman Shokur, Hannes Bleuler, and Miguel A. L. Nicolelis. 2011. âActive Tactile Exploration Using a Brain-Machine-Brain Interface.â Nature 479 (7372): 228â31. https://doi.org/10.1038/nature10489. OâRegan, J. K., and A. Noë. 2001. âA Sensorimotor Account of Vision and Visual Consciousness.â The Behavioral and Brain Sciences 24 (5): 939â73; discussion 973â1031. https://doi.org/10.1017/s0140525x01000115. Orsborn, Amy L., and Jose M. Carmena. 2013. âCreating New Functional Circuits for Action via Brain-199 Machine Interfaces.â Frontiers in Computational Neuroscience 7 (November):157. https://doi.org/10.3389/fncom.2013.00157. Otchy, Timothy M., Steffen B. E. Wolff, Juliana Y. Rhee, Cengiz Pehlevan, Risa Kawai, Alexandre Kempf, Sharon M. H. Gobes, and Bence P. Ãlveczky. 2015. âAcute off-Target Effects of Neural Circuit Manipulations.â Nature 528 (7582): 358â63. https://doi.org/10.1038/nature16442. Overduin, Simon A., Andrea dâAvella, Jinsook Roh, Jose M. Carmena, and Emilio Bizzi. 2015. âRepresentation of Muscle Synergies in the Primate Brain.â Journal of Neuroscience 35 (37): 12615â24. https://doi.org/10.1523/JNEUROSCI.4302-14.2015. Packer, Adam M., Botond Roska, and Michael Häusser. 2013. âTargeting Neurons and Photons for Optogenetics.â Nature Neuroscience 16 (7): 805â15. https://doi.org/10.1038/nn.3427. Pandarinath, Chethan, Paul Nuyujukian, Christine H. Blabe, Brittany L. Sorice, Jad Saab, Francis R. Willett, Leigh R. Hochberg, Krishna V. Shenoy, and Jaimie M. Henderson. 2017. âHigh Performance Communication by People with Paralysis Using an Intracortical Brain-Computer Interface.â eLife 6 (February). https://doi.org/10.7554/eLife.18554. Pandarinath, Chethan, Daniel J. OâShea, Jasmine Collins, Rafal Jozefowicz, Sergey D. Stavisky, Jonathan C. Kao, Eric M. Trautmann, et al. 2018. âInferring Single-Trial Neural Population Dynamics Using Sequential Auto-Encoders.â Nature Methods 15 (10): 805â15. https://doi.org/10.1038/s41592-018-0109-9. Paz, Jeanne T., Thomas J. Davidson, Eric S. Frechette, Bruno Delord, Isabel Parada, Kathy Peng, Karl Deisseroth, and John R. Huguenard. 2013. âClosed-Loop Optogenetic Control of Thalamus as a Tool for Interrupting Seizures after Cortical Injury.â Nature Neuroscience 16 (1): 64â70. https://doi.org/10.1038/nn.3269. Perich, Matthew G., Charlotte Arlt, Sofia Soares, Megan E. Young, Clayton P. Mosher, Juri Minxha, Eugene Carter, et al. 2020. âInferring Brain-Wide Interactions Using Data-Constrained Recurrent Neural Network Models.â bioRxiv. https://doi.org/10.1101/2020.12.18.423348. Peters, Andrew J., Simon X. Chen, and Takaki Komiyama. 2014. âEmergence of Reproducible Spatiotemporal Activity during Motor Learning.â Nature 510 (7504): 263â67. https://doi.org/10.1038/nature13235. Pfeffer, Carsten K., Mingshan Xue, Miao He, Z. Josh Huang, and Massimo Scanziani. 2013. âInhibition of Inhibition in Visual Cortex: The Logic of Connections between Molecularly Distinct Interneurons.â Nature Neuroscience 16 (8): 1068â76. https://doi.org/10.1038/nn.3446. Pi, Hyun-Jae, Balázs Hangya, Duda Kvitsiani, Joshua I. Sanders, Z. Josh Huang, and Adam Kepecs. 2013. âCortical Interneurons That Specialize in Disinhibitory Control.â Nature 503 (7477): 521â24. https://doi.org/10.1038/nature12676. Pinto, Lucas, Michael J. Goard, Daniel Estandian, Min Xu, Alex C. Kwan, Seung-Hee Lee, Thomas C. Harrison, Guoping Feng, and Yang Dan. 2013. âFast Modulation of Visual Perception by Basal Forebrain Cholinergic Neurons.â Nature Neuroscience 16 (12): 1857â63. https://doi.org/10.1038/nn.3552. Pinto, Lucas, Kanaka Rajan, Brian DePasquale, Stephan Y. Thiberge, David W. Tank, and Carlos D. Brody. 2019. âTask-Dependent Changes in the Large-Scale Dynamics and Necessity of Cortical Regions.â Neuron 104 (4): 810â24.e9. https://doi.org/10.1016/j.neuron.2019.08.025. Pisarchik, Alexander N., Vladimir A. Maksimenko, Andrey V. Andreev, Nikita S. Frolov, Vladimir V. Makarov, Maxim O. Zhuravlev, Anastasija E. Runnova, and Alexander E. Hramov. 2019. âCoherent Resonance in the Distributed Cortical Network during Sensory Information Processing.â Scientific Reports 9 (1): 18325. https://doi.org/10.1038/s41598-019-54577-1. 200 Prsa, Mario, Gregorio L. Galiñanes, and Daniel Huber. 2017. âRapid Integration of Artificial Sensory Feedback during Operant Conditioning of Motor Cortex Neurons.â Neuron 93 (4): 929â39.e6. https://doi.org/10.1016/j.neuron.2017.01.023. Rosin, Boris, Maya Slovik, Rea Mitelman, Michal Rivlin-Etzion, Suzanne N. Haber, Zvi Israel, Eilon Vaadia, and Hagai Bergman. 2011. âClosed-Loop Deep Brain Stimulation Is Superior in Ameliorating Parkinsonism.â Neuron 72 (2): 370â84. https://doi.org/10.1016/j.neuron.2011.08.023. Rumelhart, David E., Geoffrey E. Hinton, and Ronald J. Williams. 1986. âLearning Representations by Back-Propagating Errors.â Nature 323 (6088): 533â36. https://doi.org/10.1038/323533a0. Salkoff, David B., Edward Zagha, Erin McCarthy, and David A. McCormick. 2020. âMovement and Performance Explain Widespread Cortical Activity in a Visual Detection Task.â Cerebral Cortex (New York, N.Y. : 1991) 30 (1): 421â37. https://doi.org/10.1093/cercor/bhz206. Schalk, Gerwin, Dennis J. McFarland, Thilo Hinterberger, Niels Birbaumer, and Jonathan R. Wolpaw. 2004. âBCI2000: A General-Purpose Brain-Computer Interface (BCI) System.â IEEE Transactions on Bio-Medical Engineering 51 (6): 1034â43. https://doi.org/10.1109/TBME.2004.827072. Schultz, W., P. Dayan, and P. R. Montague. 1997. âA Neural Substrate of Prediction and Reward.â Science (New York, N.Y.) 275 (5306): 1593â99. https://doi.org/10.1126/science.275.5306.1593. Sehara, Keisuke, Paul Zimmer-Harwood, Matthew E. Larkum, and Robert N. S. Sachdev. 2021. âReal-Time Closed-Loop Feedback in Behavioral Time Scales Using DeepLabCut.â eNeuro 8 (2). https://doi.org/10.1523/ENEURO.0415-20.2021. Serikov, Almas, Iryna Martsishevska, Wooyeon Shin, and Jeongjin Kim. 2024. âProtocol for in Vivo Dual-Color Fiber Photometry in the Mouse Thalamus.â STAR Protocols 5 (2): 102931. https://doi.org/10.1016/j.xpro.2024.102931. Serruya, Mijail D., Nicholas G. Hatsopoulos, Liam Paninski, Matthew R. Fellows, and John P. Donoghue. 2002. âInstant Neural Control of a Movement Signal.â Nature 416 (6877): 141â42. https://doi.org/10.1038/416141a. Shadmehr, Reza. 2017. âDistinct Neural Circuits for Control of Movement vs. Holding Still.â Journal of Neurophysiology 117 (4): 1431â60. https://doi.org/10.1152/jn.00840.2016. Shadmehr, Reza, Maurice A. Smith, and John W. Krakauer. 2010. âError Correction, Sensory Prediction, and Adaptation in Motor Control.â Annual Review of Neuroscience 33:89â108. https://doi.org/10.1146/annurev-neuro-060909-153135. Siegel, Markus, Tobias H. Donner, and Andreas K. Engel. 2012. âSpectral Fingerprints of Large-Scale Neuronal Interactions.â Nature Reviews Neuroscience 13 (2): 121â34. https://doi.org/10.1038/nrn3137. Siegle, Joshua H., Xiaoxuan Jia, Séverine Durand, Sam Gale, Corbett Bennett, Nile Graddis, Greggory Heller, et al. 2021. âSurvey of Spiking in the Mouse Visual System Reveals Functional Hierarchy.â Nature 592 (7852): 86â92. https://doi.org/10.1038/s41586-020-03171-x. Siegle, Joshua H., Aarón Cuevas López, Yogi A. Patel, Kirill Abramov, Shay Ohayon, and Jakob Voigts. 2017. âOpen Ephys: An Open-Source, Plugin-Based Platform for Multichannel Electrophysiology.â Journal of Neural Engineering 14 (4): 045003. https://doi.org/10.1088/1741-2552/aa5eea. Siegle, Joshua H., and Matthew A. Wilson. 2014. âEnhancement of Encoding and Retrieval Functions through Theta Phase-Specific Manipulation of Hippocampus.â eLife 3 (July):e03061. https://doi.org/10.7554/eLife.03061. Silasi, Gergely, Jamie D. Boyd, Federico Bolanos, Jeff M. LeDue, Stephen H. Scott, and Timothy H. Murphy. 2018. âIndividualized Tracking of Self-Directed Motor Learning in Group-Housed Mice Performing a Skilled Lever Positioning Task in the Home Cage.â Journal of Neurophysiology 119 201 (1): 337â46. https://doi.org/10.1152/jn.00115.2017. Silasi, Gergely, Dongsheng Xiao, Matthieu P. Vanni, Andrew C. N. Chen, and Timothy H. Murphy. 2016. âIntact Skull Chronic Windows for Mesoscopic Wide-Field Imaging in Awake Mice.â Journal of Neuroscience Methods 267 (July):141â49. https://doi.org/10.1016/j.jneumeth.2016.04.012. Skinner, B. F. 1990. The Behavior of Organisms: An Experimental Analysis. B. F. Skinner Foundation. https://play.google.com/store/books/details?id=S9WNCwAAQBAJ. Skocek, Oliver, Tobias Nöbauer, Lukas Weilguny, Francisca Martínez Traub, Chuying Naomi Xia, Maxim I. Molodtsov, Abhinav Grama, et al. 2018. âHigh-Speed Volumetric Imaging of Neuronal Activity in Freely Moving Rodents.â Nature Methods 15 (6): 429â32. https://doi.org/10.1038/s41592-018-0008-0. Soleimani, Ghazaleh, Michael A. Nitsche, Til Ole Bergmann, Farzad Towhidkhah, Ines R. Violante, Romy Lorenz, Rayus Kuplicki, et al. 2023. âClosing the Loop between Brain and Electrical Stimulation: Towards Precision Neuromodulation Treatments.â Translational Psychiatry 13 (1): 279. https://doi.org/10.1038/s41398-023-02565-5. Sorge, Robert E., Loren J. Martin, Kelsey A. Isbester, Susana G. Sotocinal, Sarah Rosen, Alexander H. Tuttle, Jeffrey S. Wieskopf, et al. 2014. âOlfactory Exposure to Males, Including Men, Causes Stress and Related Analgesia in Rodents.â Nature Methods 11 (6): 629â32. https://doi.org/10.1038/nmeth.2935. Srinivasan, Shriya S., Benjamin E. Maimon, Maurizio Diaz, Hyungeun Song, and Hugh M. Herr. 2018. âClosed-Loop Functional Optogenetic Stimulation.â Nature Communications 9 (1): 5303. https://doi.org/10.1038/s41467-018-07721-w. Staddon, J. E. R. 2016. Adaptive Behavior and Learning. Cambridge University Press. https://play.google.com/store/books/details?id=UPWTCwAAQBAJ. Steinmetz, Nicholas A., Cagatay Aydin, Anna Lebedeva, Michael Okun, Marius Pachitariu, Marius Bauza, Maxime Beau, et al. 2021. âNeuropixels 2.0: A Miniaturized High-Density Probe for Stable, Long-Term Brain Recordings.â Science (New York, N.Y.) 372 (6539). https://doi.org/10.1126/science.abf4588. Steinmetz, Nicholas A., Peter Zatka-Haas, Matteo Carandini, and Kenneth D. Harris. 2019. âDistributed Coding of Choice, Action and Engagement across the Mouse Brain.â Nature 576 (7786): 266â73. https://doi.org/10.1038/s41586-019-1787-x. Stringer, Carsen, Marius Pachitariu, Nicholas Steinmetz, Charu Bai Reddy, Matteo Carandini, and Kenneth D. Harris. 2019. âSpontaneous Behaviors Drive Multidimensional, Brainwide Activity.â Science (New York, N.Y.) 364 (6437): 255. https://doi.org/10.1126/science.aav7893. Stroud, Jake P., Mason A. Porter, Guillaume Hennequin, and Tim P. Vogels. 2018. âMotor Primitives in Space and Time via Targeted Gain Modulation in Cortical Networks.â Nature Neuroscience 21 (12): 1774â83. https://doi.org/10.1038/s41593-018-0276-0. Sun, Guanghao, Fei Zeng, Michael McCartin, Qiaosheng Zhang, Helen Xu, Yaling Liu, Zhe Sage Chen, and Jing Wang. 2022. âClosed-Loop Stimulation Using a Multiregion Brain-Machine Interface Has Analgesic Effects in Rodents.â Science Translational Medicine 14 (651): eabm5868. https://doi.org/10.1126/scitranslmed.abm5868. Sussillo, David, Sergey D. Stavisky, Jonathan C. Kao, Stephen I. Ryu, and Krishna V. Shenoy. 2016. âMaking Brainâmachine Interfaces Robust to Future Neural Variability.â Nature Communications 7 (1): 1â13. https://doi.org/10.1038/ncomms13749. Sutton, Richard S., and Andrew G. Barto. 1998. Reinforcement Learning: An Introduction. MIT Press. https://books.google.com/books/about/Reinforcement_Learning.html?hl=&id=U57uDwAAQBAJ. 202 âThe Scientific Case for Brain Simulations.â 2019. Neuron 102 (4): 735â44. https://doi.org/10.1016/j.neuron.2019.03.027. Thut, Gregor, Til Ole Bergmann, Flavio Fröhlich, Surjo R. Soekadar, John-Stuart Brittain, Antoni Valero-Cabré, Alexander T. Sack, et al. 2017. âGuiding Transcranial Brain Stimulation by EEG/MEG to Interact with Ongoing Brain Activity and Associated Functions: A Position Paper.â Clinical Neurophysiology : Official Journal of the International Federation of Clinical Neurophysiology 128 (5): 843â57. https://doi.org/10.1016/j.clinph.2017.01.003. Tian, Lin, S. Andrew Hires, Tianyi Mao, Daniel Huber, M. Eugenia Chiappe, Sreekanth H. Chalasani, Leopoldo Petreanu, et al. 2009. âImaging Neural Activity in Worms, Flies and Mice with Improved GCaMP Calcium Indicators.â Nature Methods 6 (12): 875â81. https://doi.org/10.1038/nmeth.1398. Tonin, Luca, Emanuele Menegatti, and Damien Coyle. 2021. Advances in the Integration of Brain-Machine Interfaces and Robotic Devices. Frontiers Media SA. https://books.google.com/books/about/Advances_in_the_Integration_of_Brain_Mac.html?hl=&id=G80nEAAAQBAJ. Toth, L. A., and T. W. Gardiner. 2000. âFood and Water Restriction Protocols: Physiological and Behavioral Considerations.â Contemporary Topics in Laboratory Animal Science 39 (6): 9â17. https://www.ncbi.nlm.nih.gov/pubmed/11487246. âTowards the Neural Population Doctrine.â 2019. Current Opinion in Neurobiology 55 (April):103â11. https://doi.org/10.1016/j.conb.2019.02.002. Tremblay, Robin, Soohyun Lee, and Bernardo Rudy. 2016. âGABAergic Interneurons in the Neocortex: From Cellular Properties to Circuits.â Neuron 91 (2): 260â92. https://doi.org/10.1016/j.neuron.2016.06.033. Tsien, R. Y. 1981. âA Non-Disruptive Technique for Loading Calcium Buffers and Indicators into Cells.â Nature 290 (5806): 527â28. https://doi.org/10.1038/290527a0. Tucker-Davis Technologies. n.d. âRZ and RX Processors.â Accessed October 12, 2025. https://www.tdt.com/docs/synapse/hardware/rz-and-rx-processors/. Urban-Ciecko, Joanna, and Alison L. Barth. 2016. âSomatostatin-Expressing Neurons in Cortical Networks.â Nature Reviews Neuroscience 17 (7): 401â9. https://doi.org/10.1038/nrn.2016.53. Valley, M. T., M. G. Moore, J. Zhuang, N. Mesa, D. Castelli, D. Sullivan, M. Reimers, and J. Waters. 2020. âSeparation of Hemodynamic Signals from GCaMP Fluorescence Measured with Wide-Field Imaging.â Journal of Neurophysiology 123 (1): 356â66. https://doi.org/10.1152/jn.00304.2019. Vanni, Matthieu P., and Timothy H. Murphy. 2014. âMesoscale Transcranial Spontaneous Activity Mapping in GCaMP3 Transgenic Mice Reveals Extensive Reciprocal Connections between Areas of Somatomotor Cortex.â The Journal of Neuroscience: The Official Journal of the Society for Neuroscience 34 (48): 15931â46. https://doi.org/10.1523/JNEUROSCI.1818-14.2014. Varela, Francisco, Jean-Philippe Lachaux, Eugenio Rodriguez, and Jacques Martinerie. 2001. âThe Brainweb: Phase Synchronization and Large-Scale Integration.â Nature Reviews Neuroscience 2 (4): 229â39. https://doi.org/10.1038/35067550. Vogels, T. P., H. Sprekeler, F. Zenke, C. Clopath, and W. Gerstner. 2011. âInhibitory Plasticity Balances Excitation and Inhibition in Sensory Pathways and Memory Networks.â Science (New York, N.Y.) 334 (6062): 1569â73. https://doi.org/10.1126/science.1211095. Vries, Saskia E. J. de, Jerome A. Lecoq, Michael A. Buice, Peter A. Groblewski, Gabriel K. Ocker, Michael Oliver, David Feng, et al. 2019. âA Large-Scale Standardized Physiological Survey Reveals Functional Organization of the Mouse Visual Cortex.â Nature Neuroscience 23 (1): 138â51. https://doi.org/10.1038/s41593-019-0550-9. 203 Wahlsten, Douglas, Pamela Metten, Tamara J. Phillips, Stephen L. Boehm 2nd, Sue Burkhart-Kasch, Janet Dorow, Sharon Doerksen, et al. 2003. âDifferent Data from Different Labs: Lessons from Studies of Gene-Environment Interaction.â Journal of Neurobiology 54 (1): 283â311. https://doi.org/10.1002/neu.10173. Wang, Jane X., Zeb Kurth-Nelson, Dharshan Kumaran, Dhruva Tirumala, Hubert Soyer, Joel Z. Leibo, Demis Hassabis, and Matthew Botvinick. 2018. âPrefrontal Cortex as a Meta-Reinforcement Learning System.â Nature Neuroscience 21 (6): 860â68. https://doi.org/10.1038/s41593-018-0147-8. Wang, Quanxin, Song-Lin Ding, Yang Li, Josh Royall, David Feng, Phil Lesnar, Nile Graddis, et al. 2020. âThe Allen Mouse Brain Common Coordinate Framework: A 3D Reference Atlas.â Cell 181 (4): 936â53.e20. https://doi.org/10.1016/j.cell.2020.04.007. Wekselblatt, Joseph B., Erik D. Flister, Denise M. Piscopo, and Cristopher M. Niell. 2016. âLarge-Scale Imaging of Cortical Dynamics during Sensory Perception and Behavior.â Journal of Neurophysiology 115 (6): 2852â66. https://doi.org/10.1152/jn.01056.2015. White, Samantha R., Linda M. Amarante, Alexxai V. Kravitz, and Mark Laubach. 2019. âThe Future Is Open: Open-Source Tools for Behavioral Neuroscience Research.â eNeuro 6 (4). https://doi.org/10.1523/ENEURO.0223-19.2019. Widge, Alik S., and Chet T. Moritz. 2014. âPre-Frontal Control of Closed-Loop Limbic Neurostimulation by Rodents Using a Brain-Computer Interface.â Journal of Neural Engineering 11 (2): 024001. https://doi.org/10.1088/1741-2560/11/2/024001. Willett, Francis R., Donald T. Avansino, Leigh R. Hochberg, Jaimie M. Henderson, and Krishna V. Shenoy. 2021. âHigh-Performance Brain-to-Text Communication via Handwriting.â Nature 593 (7858): 249â54. https://doi.org/10.1038/s41586-021-03506-2. Witten, Ilana B., Shih-Chun Lin, Matthew Brodsky, Rohit Prakash, Ilka Diester, Polina Anikeeva, Viviana Gradinaru, Charu Ramakrishnan, and Karl Deisseroth. 2010. âCholinergic Interneurons Control Local Circuit Activity and Cocaine Conditioning.â Science (New York, N.Y.) 330 (6011): 1677â81. https://doi.org/10.1126/science.1193771. Wolpaw, Jonathan R., Niels Birbaumer, Dennis J. McFarland, Gert Pfurtscheller, and Theresa M. Vaughan. 2002. âBrain-Computer Interfaces for Communication and Control.â Clinical Neurophysiology : Official Journal of the International Federation of Clinical Neurophysiology 113 (6): 767â91. https://doi.org/10.1016/s1388-2457(02)00057-3. Wolpert, Daniel M., Jörn Diedrichsen, and J. Randall Flanagan. 2011. âPrinciples of Sensorimotor Learning.â Nature Reviews. Neuroscience 12 (12): 739â51. https://doi.org/10.1038/nrn3112. Xiao, Dongsheng, Matthieu P. Vanni, Catalin C. Mitelut, Allen W. Chan, Jeffrey M. LeDue, Yicheng Xie, Andrew C. N. Chen, Nicholas V. Swindale, and Timothy H. Murphy. 2017. âMapping Cortical Mesoscopic Networks of Single Spiking Cortical or Sub-Cortical Neurons.â eLife 6 (February). https://doi.org/10.7554/elife.19976. Yamins, Daniel L. K., and James J. DiCarlo. 2016. âUsing Goal-Driven Deep Learning Models to Understand Sensory Cortex.â Nature Neuroscience 19 (3): 356â65. https://doi.org/10.1038/nn.4244. Yang, Guangyu Robert, and Xiao-Jing Wang. 2020. âArtificial Neural Networks for Neuroscientists: A Primer.â Neuron 107 (6): 1048â70. https://doi.org/10.1016/j.neuron.2020.09.005. Ye, Joel, Jennifer L. Collinger, Leila Wehbe, and Robert Gaunt. 2023. âNeural Data Transformer 2: Multi-Context Pretraining for Neural Spiking Activity.â bioRxiv. https://doi.org/10.1101/2023.09.18.558113. Yu, Che-Hang, Jeffrey N. Stirman, Yiyi Yu, Riichiro Hira, and Spencer L. Smith. 2021. âDiesel2p Mesoscope with Dual Independent Scan Engines for Flexible Capture of Dynamics in Distributed 204 Neural Circuitry.â Nature Communications 12 (1): 6639. https://doi.org/10.1038/s41467-021-26736-4. Zanos, Stavros. 2019. âClosed-Loop Neuromodulation in Physiological and Translational Research.â Cold Spring Harbor Perspectives in Medicine 9 (11). https://doi.org/10.1101/cshperspect.a034314. Zeiler, Steven R., and John W. Krakauer. 2013. âThe Interaction between Training and Plasticity in the Poststroke Brain.â Current Opinion in Neurology 26 (6): 609. https://doi.org/10.1097/WCO.0000000000000025. Zhou, Pengcheng, Shanna L. Resendez, Jose Rodriguez-Romaguera, Jessica C. Jimenez, Shay Q. Neufeld, Andrea Giovannucci, Johannes Friedrich, et al. 2018. âEfficient and Accurate Extraction of in Vivo Calcium Signals from Microendoscopic Video Data,â February. https://doi.org/10.7554/eLife.28728. Zong, Weijian, Horst A. Obenhaus, Emilie R. Skytøen, Hanna Eneqvist, Nienke L. de Jong, Ruben Vale, Marina R. Jorge, May-Britt Moser, and Edvard I. Moser. 2022. âLarge-Scale Two-Photon Calcium Imaging in Freely Moving Mice.â Cell 185 (7): 1240â56.e30. https://doi.org/10.1016/j.cell.2022.02.017. Zrenner, Christoph, Paolo Belardinelli, Florian Müller-Dahlhaus, and Ulf Ziemann. 2016. âClosed-Loop Neuroscience and Non-Invasive Brain Stimulation: A Tale of Two Loops.â Frontiers in Cellular Neuroscience 10 (April):92. https://doi.org/10.3389/fncel.2016.00092.
Thesis/Dissertation
eng
Neuroscience
Vancouver : University of British Columbia Library
Attribution-NonCommercial-NoDerivatives 4.0 International
Graduate
Murphy, Timothy H.
Open-source real-time feedback system for shaping cortical and behavioral motor dynamics in mice reveal altered cortical networks and behavior with closed-loop training
Text