Data from: Cortex-wide characterization of decision-making neural dynamics during spatial navigation
Data files
Apr 15, 2026 version files 513.23 GB
-
Alt_no_tone_data.zip
21.30 GB
-
GFP_control_data.zip
25.52 GB
-
Lick_data.zip
34.27 GB
-
Main_data.zip
326.09 GB
-
Naive_data.zip
106.05 GB
-
README.md
9.05 KB
Abstract
To assess the spatial and temporal cortical dynamics during freely-moving decision making, we recorded widefield Ca2+ neuronal activity in mice navigating an 8-maze task with two paradigms in the Main cohort. The first required an alternating figure-8 pattern to receive a reward. The second involved a rule change that only rewarded left turns. For each mouse in this Main cohort, the dataset includes the brain imaging and behavioral data as the mice performed the tasks. A cortical state analysis that identified common global patterns of cortex-wide activity was used, and the cortical state data, and now cortical states relate to the behavior, are included. Also included is an analysis of sequences of cortical states during the behavior. There are similar sets of data for a second Naive cohort of mice that were not trained in the tasks. A third cohort of animals, Alt No Tone, provides the cortical imaging and behavioral data in a version of the experiment in which mice were not given a tone cue. A fourth cohort, Lick, includes data on cortical imaging and behavior data as the mice reached for a reward. Finally, the GFP control provides brain imaging and behavior data for a set of mice that were studied but injected with a control florescence probe to control for hemodynamic effects. The datasets are structured based on the five different cohorts of mice investigated and are titled: Main data, Naive data, Lick data, GFP control data, and Alt No Tone data. In each of these these datasets is first divided into the data from the individual mice in each cohort. For the Main data, Naive data, Lick data, and Alt No Tone cohorts, the data on each individual mouse includes the brain imaging and associated behavioral video data for each specific type of experiment. There are brain state files. For the GFP Control data, this includes the brain imaging and behavioral data. We have uploaded the main parts of the Methods section that details how each data was collected, preprocessed, and all analyses used. Finally, all codes used for data analysis are available in a Code Ocean capsule.
Cortex-wide characterization of decision-making neural dynamics during spatial navigation
Dataset DOI: 10.5061/dryad.mkkwh71f8
Description of the data and file structure
This dataset involves wide-field calcium imaging of neuronal activity in the dorsal cerebral cortex of mice as they freely navigate an 8-maze. The cortical neuronal imaging used GCaMP7f. The main experiment is based on two paradigms in the 8-maze task, the first paradigm required the mice to make alternating left and right turns, and the second paradigm required the mice to make left-only turns. The data associated with the alternating paradigm are labeled with 'Alt', and Left-only paradigm with 'LO'. Supplementary control datasets are also provided. These data can be used to identify and characterize features of cortical neuronal activity and processing in relation to mouse behavior in the 8-maze. Across all data sets, 25 mice are included, and various additional forms of scored behavior to assist in linking cortical activity and behavior in time and place. For the main experiment and supplementary control datasets, there are two basic types of raw data as the mice move in the 8-maze that are provided as temporal sequences of frames: 1) cortical calcium fluorescence (Delta/F/F) and 2) simultaneous videos of the mouse (.avi files). Significant correlations between cortical activity and behavior were identified.
Analysis codes and software used in the manuscript for these datasets are provided on Code Ocean in a capsule linked to the title of this manuscript: https://codeocean.com/capsule/cd462a14-cfb3-4445-b8e2-5a8238f760bf/
Files and variables
File: Main_data.zip
Description: This is the main dataset for the manuscript and is based on 11 mice studied in the 2 main experimental paradigms in the 8-maze: Alternating (Alt) and Left-only (LO). The Database is organized by mouse and is structured as follows (example for subject m20 data):
- m20 - folder containing all data recorded from subject m20
- alt_4 - subfolder containing single day recording of the mouse m20 in day 4 of performing Alternating paradigm
- alt4_dff_stack.mat - Matlab data file
- calcium_data_structure - variable (Matlab structure) containing:
- dff_data - 2D matrix variable storing the sequence of z-scored DeltaF/F frames recorded in that session. Columns record individual pixel standard deviations from mean fluorescence in time.
- imrow and imcol - field of view size in pixels
- calcium_data_structure - variable (Matlab structure) containing:
- meso20_combined.avi - video recording of the behavior during recording session.
- meso-20_combinedDLC*.csv - The corresponding DLC pose estimation output including x and y coordinates in pixels as well as the likelihood score for nose, head, body and tail. (DLC refers to Deep LabCut, a commonly used program to extract behavioral data from videos).
- alt4_dff_stack.mat - Matlab data file
- alt_4 - subfolder containing single day recording of the mouse m20 in day 4 of performing Alternating paradigm
These are the files and variables containing the raw data measured during the experiments. All other files and variables are either derived from these data during analysis by the code in the repository, or free variables used and explained in the code.
File: Naive_data.zip
Description: Dataset of naive control mice. These mice were placed in the 8-maze and allowed to freely move in the maze but had no previous training in the 8-maze and did not receive a reward. The cortical imaging and behavior was recorded as in the Main dataset. This Naive dataset is important for understanding which aspects of the cortical activity are unique to the experimental paradigms in the 8-maze. Five mice were recorded for 4 days in two different trials each day. This database is organized by recording Day and the example provided is for Day 1.
- Day 1 - folder containing all data recorded during day 1 for all naive mice
- m38_t1 - folder containing the cortical recording for subject m38 during trial 1
- dff_stack.mat - Matlab structure including the "calcium_data_structure" variable
- dff_data - 2D matrix variable storing the sequence of z-scored DeltaF/F frames recorded in that session. Columns are individual pixel standard deviations from mean fluorescence in time.
- imrow and imcol - field of view size in pixels
- dff_stack.mat - Matlab structure including the "calcium_data_structure" variable
- m38_t2 - similar to m38_t1 except this is for trial 2
- m38_t1 - folder containing the cortical recording for subject m38 during trial 1
- beh_videos - folder containing the video recordings and the DLC pose estimation for days 1 and 2
- m38d1t1.avi - video recording of subject m38 behavior during day 1 trial 1
- m38d1t1DLC_*.csv - file including the corresponding DLC pose estimation output including x and y coordinates in pixels as well as the likelihood score for nose, head, body, and tail.
File: Alt_no_tone_data.zip
Description: In this control dataset, we removed the cue tones used in the main experiment to signal the mice to make either a left or right turn in the Alternating paradigm. Six mice were recorded for 3 days each. This database is organized by mouse as detailed below for the example subject m20 data:
- m20 - folder containing all data recorded from subject m20
- d1_dff_stack.mat - Matlab data file including the data recorded in day 1 of Alt_no_tone
- calcium_data_structure - variable (Matlab structure) containing:
- dff_data - 2D matrix variable storing the sequence of z-scored DeltaF/F frames recorded in that session. Columns are individual pixel standard deviations from mean fluorescence in time.
- imrow and imcol - field of view size in pixels
- calcium_data_structure - variable (Matlab structure) containing:
- d1_dff_stack.mat - Matlab data file including the data recorded in day 1 of Alt_no_tone
- d1 alt no tone manually scored behavior.xlsx - file recording the left/right choice at the T during day 1 for all mice. The columns are:
- ID - subject id
- Decision - Success (1) or Error (0). For success the reward was dispensed at the appropriate spout.
- L(1)/R(2) - Turn direction at the T. 1 - turn left, 2 - turn right.
- D1meso-20_combined - file recording subject m20 behavior during day 1.
File: Lick_data.zip
Description: This dataset involves mice trained to lick a reward spout in response to an auditory cue. In this data a capacitive sensor was added to explicitly record the individual licks. Data from 4 mice are included and the dataset is organized by mouse as shown for mouse R2645.
- R2645 - folder including data recorded from subject R2645
- 011325 - folder including data recorded on the 01/13/25 sessions in the "stacks" folder
- R2645_001 - folder including data recorded in session 1
- dff_stack.mat - Matlab data file containing the cortical dff recording
- calcium_data_structure - variable Matlab structure containing dff_data - 2D matrix variable storing the sequence of z-scored DeltaF/F frames recorded in that session. Columns are individual pixel standard deviations from mean fluorescence in time.
- dff_stack.mat - Matlab data file containing the cortical dff recording
- imrow and imcol - field of view size in pixels
- lick_frames.mat - Matalab data file containing the indexes of the frames in which the mouse licked the spout - lick_frames - vector variable. Value 1 indicates the frames when the mouse licked the spout, as detected by a capacitive sensor.
- R2645_001 - folder including data recorded in session 1
- 011325 - folder including data recorded on the 01/13/25 sessions in the "stacks" folder
File: GFP_control_data.zip
Description: Dataset of mice training in the 8-maze task but they express eGFP, which is not dependent on cortical activity, instead of GCaMP7f used in the other datasets. This control experiment was used to evaluate the impact of hemodynamics on the widefield calcium recordings. Five mice were recorded for two days. This database is organized by recording Day and the example provided is for Day 1.
- Day 1 - folder containing all data recorded during day 1 for all GFP mice
- m33 - folder containing data for subject m33
- no_zscore_dff.mat - Matlab data file containing the cortical dff recording
- calcium_data_structure - variable Matlab structure containing
- dff_data - 2D matrix variable storing the sequence of DeltaF/F frames recorded in that session. Columns are individual pixel standard deviations from mean fluorescence in time.
- imrow and imcol - field of view size in pixels
- calcium_data_structure - variable Matlab structure containing
- manually_scored_behavior.xlsx - file recording the left/right choice at the T during day 1 for mouse m33. The columns are:
- ID - subject id
- Decision - Success (1) or Error (0). For success the reward was dispensed at the appropriate spout.
- Spout 30Hz - Frame index when the mouse approached the spout at 30Hz acquisition frequency.
- Spout 15Hz - Frame index when the mouse approached the spout at 15Hz acquisition frequency.
- L(1)/R(2) - Turn direction at the T. 1 - turn left, 2 - turn right.
- Decision 30Hz - Frame index when the mouse approached the T crossing at 30Hz acquisition frequency.
- Spout 15Hz - Frame index when the mouse approached the T crossing at 15Hz acquisition frequency.
- no_zscore_dff.mat - Matlab data file containing the cortical dff recording
- meso-33_combined.avi - file recording subject m33 behavior during day 1.
- Day1_beh.xlsx - file combining the manually scored behavior for all mice, same column structure as the individual files.
- m33 - folder containing data for subject m33
Methods
All experiments were approved by the Institutional Animal Care and Use Committee (IACUC) at the University of Minnesota. Mice were housed in a 12hr light-dark cycle, with times of darkness (the period of mouse wakefulness) occurring during the day when experiments were performed. Animal rooms were kept at an ambient temperature of 68-74 °F and 30-70 % humidity.
Based on these previous modified T-maze designs, we constructed an automated 8-maze that was able to detect mouse position and deliver a drop of 5 % sucrose solution on either side of the maze after a desired rule was followed. The 8-maze was an 80 x 54 cm rectangular arena constructed using clear acrylic and custom 3D-printed connection pieces (see Figure 1e). The walls of the arena were 12 cm tall, and corridors were 8 cm wide. The internal walls and floor of the maze were covered with a white, textured vinyl sticker to create traction for the mouse and promote higher visual contrast for overhead cameras. Intersections at the entrance and exit of the central corridor had motorized swing doors to shape the mouse’s path in a figure-8 path during behavior training sessions. Using an Arduino script (version 1.8.19), servo motors and infrared break beam sensors controlled the position of 3D printed swing doors relative to the mouse’s position in the maze. To reduce potential IR penetrating light artifacts, break beam sensors were covered with a vinyl sticker that had a pinhole to allow just enough light through for the sensor to function.
Two variants of the 8-maze task were implemented to target different aspects of cognitive processing and examine different patterns of cortical activation. The first paradigm required the mice to execute an alternating figure-8 pattern to receive a reward (Figure 1e in the corresponding manuscript, middle). A solenoid valve (The Lee Company, #LHDA0533315H) was used to deliver a 27 µL reward of 5 % sucrose through a rubber-tipped needle spout on either side of the maze when the correct decision was made. The second paradigm implemented a rule change where the animal was only rewarded on the left side of the maze (Figure 1e, bottom). During this left-only paradigm, the right side of the maze remained open to exploration but did not deliver a reward. The distance the animals were required to travel was equal for both paradigms, and each side of the maze was identical. All mice were tested in both paradigms, starting with alternating, and followed directly by the change to left-only. This way, any mouse-specific changes in behavior could be isolated, and the differences in cortical activity associated with the rule change could be determined.
Speakers were mounted on the maze walls on either side of the T-intersection (see Figure 1d) and played one of 3 innocuous tones at specific times during testing. During the alternating paradigm, a brief 3520 Hz tone was played on the right speaker when the mouse was in the central corridor to signify that a right-hand turn was necessary for a reward, and a 1047 Hz tone was played on the left speaker when a left-hand turn was necessary for a reward. 15 cm after the T-intersection on either side of the maze, a 2637 Hz reinforcement tone was played only when the correct decision was made. Tones remained consistent for the left-only task, with the only difference being that only the 1047 Hz tone was played in the central corridor to signal only for left-hand turns. Two behavior cameras were mounted 1.5 m above the maze (30 fps, FLIR blackfly) and used Spinnaker recording software SDK 2.0.0.147 (FLIR Systems, version 1.2). Prior to each trial, the maze was thoroughly cleaned with 70 % ethanol to eliminate inter-trial olfactory cues. The entire maze was enclosed in an arena with black curtains hanging on each of the walls to reduce the amount of light in the maze. Only ambient room light from underneath the maze was present during testing trials.
Mouse training in the 8-maze lasted for 3 weeks, broken into separate 1-week phases. The first phase simply involved handling the mouse for a 5-minute session per day. The second phase consisted of placing the mouse in the 8-maze with a weighted dummy head-mounted microscope and providing a sucrose reward whenever the mouse reached the spout (one ~10 min session per day). During the third phase, a functional mini-mScope was attached, including the data and power wires. Mice were then trained to follow a figure-8 pattern to receive a sucrose reward using both automatic swinging doors (one 5.5-minute session per day). To verify that the behavior was learned, the door at the top of the maze was removed to give the mouse free choice, and decision accuracy was measured. After shaping was completed and the mice achieved a decision accuracy > 80 %, cortical Ca2+ imaging was initiated during the alternating task for 7 days, followed by the left-only task for 7-8 days. Only a single recording session per day per mouse was run to ensure the animals were consistently water-deprived and not satiated by the water delivered from the reward spouts.
Behavior analysis
Mouse behavior in the 8-maze task was analyzed using a combination of manual scoring and automatic pose estimation software (DeepLabCut). Manual scoring consisted of finding the exact frame where the animal's nose entered the T-intersection defined in Figure 1d, and the frame when the nose reached the reward spout. If the mouse did not stop at the spout, this frame was defined as the point where the nose is closest to the spout for the particular lap. Using DeepLabCut, the position of the mouse’s nose, head, body, and base of the tail was tracked and quantified. For speed and position analysis, head position was used as it had the most accurate measure of tracking.
For the analyses of speed and state activations with respect to mouse position, the 8-maze was divided into 22 regions, with region 1 being the entrance into the central corridor, 7 at the T-intersection, 16 at the spout, and 22 at a region just before returning to the central corridor. The regions were mirrored on either arm of the symmetrical maze. These maze regions were 7 cm in length, which is approximately the length of a mouse’s body.
Animals, cranial windows, and viral vector injections
In this study, 25 C57BL/6 mice (13 male, 12 female, average age of 126 ± 41 days) were used (Jackson Laboratory, Strain #:000664, RRID: IMSR_JAX:000664). Animals were housed in a 12-hour reverse light/dark cycle, and all behavioral testing was done during the dark phase. Mice were water-restricted to 1 mL per day and maintained at a weight of at least 80 % of their pre-restriction weight. The mice were implanted with a version of our cranial polymer window. Under aseptic conditions, mice were anesthetized with isoflurane (5 % induction; 1-2 % maintenance), followed by a large craniotomy and implanted with polymer windows and titanium headplates. The craniotomy and polymer skull provided optical access to a large region of the dorsal neocortex. Following a 1-week recovery from implantation, the 11 experimental mice (5 male, 6 female) trained in the two 8-maze paradigms and 5 naïve control mice (3 male, 2 female) were retro-orbitally injected with 4.4 x 1011 genocopies of a GCaMP7f viral vector in 100 µl of sterile saline (AAV-PHP.eb-Syn-jGCaMP7f-WPRE; Addgene #104488). An additional cohort of 5 animals (2 male, 3 female) was retro-orbitally injected with a Ca2+ independent eGFP indicator to serve as a control for hemodynamic modulation (pAAV.hSyn.eGFP.WPRE.bGH, Addgene #105539). For licking confound analysis, an additional 4 animals (3 male,1 female) were injected with the GCaMP7f viral vector and trained in a rectangular arena (15 cm by 48 cm) to lick one of two reward spouts in response to one of two randomly presented tones (1259 Hz for 1 sec, 1587 Hz for 0.3 sec) that distinguished between the two spouts. Behavioral imaging was combined with custom capacitive sensors to quantify licking. The viral vectors were incubated for at least 3 weeks prior to Ca2+ imaging. Approximately 80 % of injections were successful, with unsuccessful expression defined as when the brain surface was not visible with the same illumination settings. Animals with unsuccessful expression of the GCaMP were not used. The eGFP cohort was trained and studied in the alternating paradigm over ten 5.5-minute recording sessions. The naïve cohort served as untrained controls and were imaged as they freely explored the 8-mice but did not receive water rewards.
Immunohistochemistry
To harvest the brains for tissue processing, the animals were deeply anesthetized using 5 % isoflurane and transcardially perfused first with ice-cold phosphate-buffered saline (PBS) followed by 4 % paraformaldehyde (PFA). Extracted brains were fixed in PFA for 2 days before sectioning at 50 µm thickness using a vibratome. Brain slices were then gently shaken in a blocking solution (10 % Donkey serum in 0.1M TBS) for 1 hour. The slices were next incubated in a 1:1000 dilution of the primary antibody for GFP staining (rabbit anti-GFP, Invitrogen #A6455, Lot 24115918) overnight at 4 °C, followed by three 10-minute washes in tris-buffered saline (TBS). The slices were then incubated in a 1:1000 dilution of the secondary antibody overnight at 4 °C (Donkey anti-rabbit Alexa Fluor Plus 488, Invitrogen #A32790, Lot WF320931). Using a confocal microscope (Leica Stellaris 8), images of the sections were taken at 20X magnification (488 nm excitation). The images were then tiled together to get a single high-resolution image for each section (see Figure 1c-d and Supplementary Figure 1).
Widefield imaging with the mini-mScope
A miniaturized head-mounted microscope (mini-mScope) was used to record Ca2+ activity during 5.5-minute recording sessions during both paradigms (n=81 alternating, n=77 left-only, from 11 subjects), naïve controls (n=37 from 5 subjects), and eGFP controls (n=10 from 5 subjects). The mini-mScope body was adapted from our original design and was machined from polyoxymethylene (Delrin). Underneath the mini-mScope body, 3 magnets were inserted for attachment to the magnets in the cortical window implant. The body housed a single blue LED (470 nm, Digikey) and a dichroic mirror (Chroma) to reflect light onto the dorsal cortex and pass the emitted fluorescence signal. To eliminate wavelengths of light outside of the range that excites GCaMP7f, a bandpass excitation filter was added to the LED (450-490 nm, Chroma). For Ca2+ imaging, a miniaturized imaging sensor, the miniFAST, was used. The focal plane was adjusted by sliding the CMOS housing along the mini-mScope shaft until a clear brain image was displayed, and a screw was used to anchor the CMOS in place. The emitted light from GCaMP7f was directed to a collecting lens in the central shaft of the mini-mScope body and was passed through a bandpass emission filter (500-550 nm, Chroma) before reaching the CMOS sensor.
Widefield Ca2+ recordings
The CMOS sensor was set to record at 15 frames per second (fps) with the gain set to ~25 for a trial duration of 330 s. The data acquisition unit (DAQ) for the miniFAST CMOS sensor synchronized the behavior cameras with the CMOS sensor using TTL pulses. Prior to each recording trial, the PET window on the animal's implant was gently cleaned with saline to remove any dust or debris from the imaging field. The mini-mScope was attached to the mouse, and the animal was placed in the center corridor of the 8-maze facing the T-intersection. During the recordings, a manually controlled motorized commutator was used to relieve torsion in the coaxial and LED power cables.
All data processing was completed using custom MATLAB scripts (MathWorks version 9.13.0.2126072 R2022b). The video was first rotated 180 degrees to have the rostral cortex at the top of the image. Each frame was converted to grayscale and resized using an 80 % bilinear compression. A mask was drawn to exclude pixels in the background and central sinus. The ΔF/F calculation normalizes the data to changes in global illumination fluctuations to account for differences in LED power during each trial. This involved dividing each pixel of the image stack by its mean over the entire recording. From this, the mean fluorescence of each frame divided by the mean of the entire stack was subtracted, yielding a normalized image stack. The data were spatially filtered by averaging a 7 pixel-radius and temporally filtered with a 0.1-5 Hz bandpass filter. The filtered ΔF/F data were then z-scored for each recording trial. See Supplementary Video 3 for a side-by-side comparison of raw fluorescence with processed ΔF/F videos.
To align the Allen Common Coordinate Framework (CCFv3) to the ΔF/F data, we adapted an algorithm that uses manual estimation of the right, left, and center points of the line that separates the cortex from the olfactory bulbs. Medial points at the posterior end of the retrosplenial cortex and bregma were also estimated. Using these landmarks, the CCF was warped and overlaid on the brain image. The alignment was validated through comparison with our previous studies using the same cortical window and alignment to the CCF.
ΔF/F bootstrapping
The fluorescence data were bootstrapped by randomly sampling 90-frame segments of the average ΔF/F traces to generate a confidence interval representing the null distribution of fluorescence activity. The number of 90-frame segments selected matched the number of total laps each animal made in a particular paradigm (alternating: 760, left-only: 808). The method of calculating variance of the randomly sampled data matched that for the behaviorally aligned data, where ΔF/F traces were averaged within each animal, and the standard deviation was determined by comparing the traces from each animal. This was repeated separately for each of the 14 CCF regions. The resulting 95 % confidence intervals for each region show the mean fluorescence ± 2 SDs.
Identifying cortical activation patterns using K-means clustering
Using a clustering method adapted from our original study, the Ca2+ data were reduced into distinct cortical activation patterns. A k-means clustering step was implemented at three levels: 1) session level; 2) mouse level; and 3) global level. For session-level clustering (Figure 7a), the correlation coefficients between each ΔF/F frame were calculated (MATLAB corrcoef function), and the resulting correlation values were clustered using a k-means algorithm (5000 iterations; 5 replicates).
To determine the optimal number of clusters for a particular trial, a data reconstruction algorithm was utilized to guarantee that the resulting data reduction described the majority of the variability in the real ΔF/F data. By sequentially testing increasing numbers of clusters (starting with 2 clusters), the average of all frames within each cluster was calculated. This resulted in a 2-dimensional rectangular matrix of j pixels and n states. The pseudoinverse of this matrix represented the spatial weighting matrix [S] (see Figure 7). The temporal weighting matrix [T] was calculated by multiplying the 2-dimensional ΔF/F stack of i frames and j pixels with the spatial weighting matrix [S]. This resulted in an i x n rectangular matrix representing to what degree each state contributes to each ΔF/F frame. Data reconstruction was completed by multiplying the temporal component [T] by the spatial component [S]. A correlation between each real ΔF/F frame and the reconstructed frame was calculated, and the average across all frames was used to determine if the clusters sufficiently described the real ΔF/F data. When the average correlation between real and reconstructed frames reached a threshold of 0.85, successive testing of cluster numbers was aborted, and that number of clusters was used for the within-trial k-means analysis. In 30 of the 158 recordings, the reconstruction correlation plateaued before reaching the 85 % threshold. This primarily happened in 2 animals (m20 and m22) with the lowest expression of GCaMP7f, although every recording showed a clustering reconstruction of at least 75 %. In cases where the correlation did not change more the 3 % after the addition of 5 clusters, the optimal cluster number was determined at this plateau, and the algorithm did not force additional clusters to be added.
Using the output from the session-level clustering, a second k-means clustering step was completed to classify a set of clusters for all sessions within individual animals. This second step followed the analysis outlined for the session-based clustering described in Figure 7a, except that the optimal number of clusters was determined by the average number of clusters for the particular animal. In this clustering step, the k-means parameters were set to 106 iterations and 100 replicates.
The final k-means clustering step combined all the outputs from the within-mouse clustering to define a universal catalog of clusters that we refer to as cortical states (Figure 7b). Due to varying FOVs for each animal, each mouse-level average cluster image was aligned to a representative brain FOV by performing minor image rotations and translations. Once the pixel space was consistent across all state images, the correlation of each image was calculated and clustered using k-means with 106 iterations and 500 replicates as parameters. The optimal number of states was determined by a t-distance calculation that maximizes the within-cluster correlation and minimizes the across-cluster correlation.
Cortical states for naïve animals were identified in two ways. The first method followed the same clustering algorithm as trained states, where clusters were identified first at the session-level, followed by the mouse level, and the global level from the naïve ΔF/F data. An alternative method was implemented to achieve a one-for-one comparison between naïve and trained cortical states. In this analysis, each ΔF/F frame of the naïve mouse recordings was correlated with the average images of each of the 9 global cortical states determined for the trained mice. Naïve ΔF/F frames were assigned to whichever state yielded the highest correlation, resulting in a consistent state space between the two groups.
View angle analysis
For each frame, we calculated the allocentric four-quadrant view angle in a fixed orthogonal coordinate system oriented such that 0° is the vertical direction towards the T-intersection. The angles were first calculated using the tail-head direction vector (atan2, Matlab), followed by a translation into a 0° to 360° interval using modulo 360 (mod function, Matlab). View angle values were smoothed using a sliding 5-frame average. Egocentric view angle was determined as the difference between consecutive allocentric view angles.
The linear regressions between the view angle and state probability were calculated for each state individually. Average state probability and average view angle within maze bins were calculated for each of the 11 mice during all correct alternating trials. The model was constructed using the following cosine regression, where 𝜃 is the view angle for either the allocentric or egocentric coordinate systems.
Cortical state and motif bootstrapping
Null distributions of state activation with respect to maze bin were generated by concatenating the brain state vectors from all trials of the trained mice (~690,000 frames) and shuffling them to uncouple the state activation with linear position in the maze. This was repeated 100 times, and a null state distribution was calculated for each of the 22 bins. The > 99.99 % confidence interval plots, as shown in Figures 4, 6, and Supplementary Figure 8, are the shuffled mean state probability ± 4 SDs to account for multiple comparisons. Using the same approach, a null distribution of state activation was generated for all trials in the naïve cohort.
Characterizing 2-state and 3-state motifs
To identify significant cortical state motifs, the continuous cortical state vector for each lap in the maze was first isolated and smoothed using a custom script that found the most common state within a 5-frame sliding window (MATLAB 2022b). This smoothing was done to isolate only the most prominent sequences of states and eliminate transient motifs that represented a small fraction of the data. Prolonged activations of the smoothed cortical state segment were then reduced to a single frame, resulting in a sequence of each state activation throughout the lap. Next, the frequency of each of the 72 possible 2-state permutations and 504 3-state permutations was calculated over all correct and incorrect laps in the maze. To avoid redundancy, the 3-state motifs only included sequences of 3 different states and excluded any that only included two states (e.g., 2→3→2) since the frequencies of those sequences were captured with the 2-state motifs. The frequencies of each permutation were then normalized to the total number of 2-state or 3-state sequences to generate a probability distribution for each. The probabilities for 2-state and 3-state motifs were first calculated using all data, then from the data of each paradigm separately, to determine if there are motifs that are specific to the alternating or left-only variants of the task.
These observed probabilities were then compared with randomized, bootstrapped probabilities to identify which permutations occurred significantly more often than chance. These bootstrapped probabilities were generated by shuffling each lap segment of cortical states and following the same smoothing algorithm, frequency calculation and the non-shuffled data. This was repeated over 1000 iterations for all trials for both the 2- and 3-state motifs to generate a distribution of probabilities for each permutation. Each observed probability was then compared with its respective bootstrapped probability distribution using a one-tailed t-test, resulting in a p-value. Multiple comparisons corrections were implemented using a custom script of the Benjamini-Hochberg false discovery rate method, with corrected p-values < 0.05 characterized as significant. To isolate only the most probable 3-state motifs that were common across both paradigms, a minimum probability of 0.005 was applied. The 3-state motifs unique to either paradigm and all 2-state motifs yielded a more manageable number of significant permutations, so no minimum probability was set for those. Motif propagation direction was defined by estimating the activation center of mass and manually assigning the pattern as either anterior propagating or posterior propagating. If there was a combination of anterior/posterior or the main propagation was lateral/medial, the motifs were placed in the ‘other’ category.
Once the significant motifs were identified, all imaging frames were assigned as either 1 (on) or 0 (off) for each significant permutation. Similar to state probabilities, combined motif probabilities could be analyzed by calculating the proportion of frames where a group of motifs is activated with the total number of frames.
Statistical analysis
With the exception of the k-means clustering, bootstrapping to obtain null distributions, and determination of false discovery rate as described above, other statistical analyses were performed using Graphpad PRISM 10.2.3. State probability curves in the various conditions shown in Figure 5 were compared using a repeated measures 2-way ANOVA with Bonferroni post-hoc correction to strictly control for multiple comparisons. Each condition was represented by a probability curve for each of the 11 subjects. If a state was not present for a particular animal, it was excluded from analysis for that state. A complete description of which states are present in which mice is shown in Figure 3c. Samples were matched between the two conditions since the probabilities were calculated using the same animals, in the same maze bins. Significance was determined when the interaction effects (Bin x Outcome, Bin x Choice, Bin x Paradigm) were < 0.05. The same procedure was used to determine main-effect differences when comparing motif directional propagation (Figure 6). Also, statistics for changes in ΔF/F and states for different conditions are fully reported in Supplementary Tables 1-4. Comparisons between trained and naïve animals used an ordinary 2-way ANOVA without repeated measures (Figure 4).
