Strategy dependent recruitment of distributed cortical circuits during spatial navigation

Spatial navigation is a complex cognitive process that involves neural computations in distributed regions of the brain. Little is known about how cortical regions are coordinated when animals navigate novel spatial environments or how that coordination changes as environments become familiar. We recorded mesoscale calcium (Ca2+) dynamics across large swathes of the dorsal cortex in mice solving the Barnes maze, a 2D spatial navigation task where mice used random, serial, and spatial search strategies to navigate to the goal. Cortical dynamics exhibited patterns of repeated calcium activity with rapid and abrupt shifts between cortical activation patterns at sub-second time scales. We used a clustering algorithm to decompose the spatial patterns of cortical calcium activity in a low dimensional state space, identifying 7 states, each corresponding to a distinct spatial pattern of cortical activation, sufficient to describe the cortical dynamics across all the mice. When mice used serial or spatial search strategies to navigate to the goal, the frontal regions of the cortex were reliably activated for prolonged durations of time (> 1s) shortly after trial initiation. These frontal cortex activation events coincided with mice approaching the edge of the maze from the center and were preceded by temporal sequences of cortical activation patterns that were distinct for serial and spatial search strategies. In serial search trials, frontal cortex activation events were preceded by activation of the posterior regions of the cortex followed by lateral activation of one hemisphere. In spatial search trials, frontal cortical events were preceded by activation of posterior regions of the cortex followed by broad activation of the lateral regions of the cortex. Our results delineated cortical components that differentiate goal- and non-goal oriented spatial navigation strategies.


INTRODUCTION
We imaged calcium activity across 8x10mm 2 of the dorsal cortex, encompasses parts of 92 the primary and secondary motor cortices, the somatosensory and barrel cortices, the 93 retrospenial cortex and part of the visual cortex in both hemispheres using a 94 miniaturized head mounted camera (mini-mScope, (Rynes & Surinach et al. 2021)) in 95 eight freely behaving Thy1-GCaMP6f mice 33 , as they solved the Barnes maze (Fig. 1a-96 c). As mice learned the location of the goal, they exhibited expected results in the 97 strategies used to search for the goal, which could be categorized as random, serial, or 98 spatial search strategies 5 ( Fig. 1d. As trials progressed, mice demonstrated a reduction 99 in primary errors, or the number of incorrect holes checked prior to reaching the correct 100 location of goal, and primary latency, or the initial trial time until the goal location is 101 found (Fig. 1 e-f). of the goal was altered. Similarly, the number of primary errors decreased from 11.7 ± 109 9.2(11 IQR) on day 1, to 6.3 ± 6.1(7 IQR) on day 2 and 5.7 ± 5.7(7.5 IQR) on day 3 110 across all mice, and the number of primary errors increased to 10.9 ± 9.2(16 IQR) when 111 the goal location was changed in the probe trial (Fig. 1e, Day 1 vs Day 2 p = 0.012, Day 112 1 vs Day 3 p = 0,0001, Wilcoxon ranked sum test). These results are consistent with 113 previous results obtained in this task 21 , indicating mounting the mini-mScope did not 114 interfere with behavior.

116
Across trials, mice utilized increasingly non-random search methods as they learned to 117 navigate the maze. On day 1, 54.5% of trials were nonrandom, whereas 45.5% were 118 random. On day 3, 93.7% of trials were non-random and 6.3% of trials were random. As 119 trials progressed 13.6% of trials were spatial on day 1, 36.36% of trials were spatial on 120 day 2, and 46.8% of trials were spatial on day 3 (Fig 1f).

122
While the white noise and bright lights were presented as mildly noxious stimuli and 123 motivated the mice to navigate to the goal progressively faster, mice rarely entered the 124 goal immediately after first poke (21% of trials, n=13/63 trials), preferring to explore the 125 arena. In a subset of trials, mice explored the two nearest holes and the edge around 126 the goal hole in 32% of trials (n=20/63), entering the goal hole 5-30 s after nearby 127 exploration. A large subset of mice (46%, n=29/63) chose to repeat one or more 128 searches around the maze after first goal poke before entering at some later trial time. 129 Thus, while the animals were motivated to go to the goal, the environment was not 130 excessively stress-inducing such that mice were not prevented from exploring the maze 131 further. 132 133 134 Mesoscale cortical dynamics exhibited discrete shifts in cortical activation 135 patterns 136 137 The mini-mScope imaged a field of view (FOV) of 8 mm x 11 mm, with a craniotomy 138 encompassing 6 brain regions: primary motor cortex (M1), somatosensory cortex 139 (SSC), premotor/frontal cortex (M2), retrosplenial cortex (RSC), primary visual cortex 140 (V1), and barrel cortex (BC) on each hemisphere at a resolution of ~39-56 µm per pixel 141 from the center to lateral edges of the FOV. As the mice navigated the maze, prolonged 142 patterns of calcium activation across the FOV occurred sporadically, with shifts between 143 these calcium activity patterns occurring at ~0.2-1 s time scales (Fig. 1g).

145
We used an image correlation and clustering methodology to cluster spatial pattens of 146 calcium activity observed in individual frames into groups of highly correlated images 147 with similar patterns of cortical activation. We refer to these groups of highly correlated 148 images as cortical activation 'states' (Fig 2a-b, Supplementary Fig 1a). Briefly, the z-149 scored calcium DF/F activity recorded at each time frame was correlated with every 150 frame recorded for a mouse across all trials, forming an image correlation matrix. The 151 data in this matrix was then iteratively clustered into increasing numbers of states. The 152 number of states needed to optimally cluster the cortical activity patterns is not known a 153 priori. We used a t-distance optimization algorithm to determine the optimal number of 154 states that could segregate the image correlation matrix into groups to maximize the 155 correlations between images within a group while simultaneously minimizing the 156 correlations between images across groups 34 (See Methods and Supplementary Fig.  157 1 for more details). We found that 5-10 states optimally described calcium activity 158 clusters across each mouse (Supplementary Fig 1b, Supplementary Fig 2). An 159 example of this clustering methodology for one mouse is shown in Figure 2a To identify a common state space to describe activity in all mice, similar clustering 162 methodology was employed. Briefly, the average DF/F activity for each state identified 163 per mouse was calculated by averaging activity across all frames within each state. The 164 average frames for each state for all mice were then correlated to form a second image 165 correlation matrix across all mice (51 x 51 matrix, Supp. Fig. 1a). The image correlation 166 matrix was then sorted into 7 states via k-means clustering to construct the intra-mouse 167 state space model.

169
The spatial distribution of the mean calcium activity of all seven states for one mouse is 170 shown in Figure 2c top. Additionally, a bar graph of the mean DF/F activity patterns for 171 each ROI in the Allen brain atlas across all 7 states in each mouse (Fig 2c, bottom).

172
States 1 and 2 were characterized by high calcium activity in the frontal regions of the 173 FOV. State 3 was characterized by high activity in several cortical areas of each 174 hemisphere, with peak activation in bilateral somatosensory, primary motors, and 175 antero-lateral retrospenial cortex. States 4 and 5 were characterized by high calcium 176 activity in the posterior regions of the FOV. State 6 was characterized by high calcium 177 activity in the vicinity of the midline. Lastly, state 7 was marked by activity distributed 178 broadly across the left hemisphere. Observed mean activation patterns for states 1-6 179 were lateralized in most mice (Supplementary Fig. 2), perhaps indicating functional 180 specialization between the cortical hemispheres during navigation.

182
Every mouse had one of state 1 or 2 present where frontal regions of the cortex were 183 active, with n = 4 mice expressing both states. Additionally, every mouse had one of 184 state 4 or 5 present, where the posterior regions of the cortex were active, with n = 2 185 mice exhibiting both states. State 3 and 6 where the lateral regions of the cortex and the 186 medial regions of the cortex were respectively active were present in all mice (n = 8), 187 and state 7, where the activity was higher in predominantly in the left hemisphere was 188 present in n = 5 mice (Supplementary Fig. 2). Example montages of DF/F z-score We evaluated the probability of a particular cortical activation state being active. For all 199 states, mean state activation probability varied between 14.2% -22.7% ( Fig. 2f-g).

200
States 3 and 6 which are present in all the mice had slightly higher activation 201 probabilities of 22.5 ± 9.2 % and 18.8 ± 6.9% respectively. Thus, there was no one state 202 having a dominant activation probability. Grouping trials by search strategy 203 ( Supplementary Fig. 9a), we observed no significant differences in state activation 204 probabilities for any of the states. The mean state activation probabilities did not change 205 substantially as mice performed successive trials ( Supplementary Fig. 9a right).

207
We further examined how cortical activation changed from one state to the other by 208 constructing state transition probabilities matrices for serial search trials and spatial 209 search trials (Supplementary Fig. 9b). Notably, state 3 had a high probability of 18.7% 210 and 15.3% to transition to state 1 in random and serial trials, respectively. Transition 211 probability from state 3 to state 1 in corresponding spatial trials decreased to 6.3% 212 during spatial trials. State transition probabilities from state 5 were low (<6%) when 213 transitioning to other states in trials on which mice used a random search strategy. In 214 trials on which mice used a serial search strategy, state 5 transitioned to state 6 with a 215 probability of 6.1%. In contrast, state 5 transitioned to state 3 and 7 with probabilities of 216 6.3% and 8.7% respectively during trials which mice used a spatial search method.

217
These results highlight how cortical dynamics were different for the trials with different 218 behavioral strategies. 219 220 Frontal regions of the cortex are activated for prolonged durations shortly after 221 trial initiation 222 223 Representing the patterns of cortical activation in a low-dimensional state space allowed 224 us to examine trial-by-trial variation in cortical dynamics during the spatial navigation 225 task. We observed repeated temporal sequences of state activation that occurred 226 shortly after trial initiation. Trials typically started with a variegated sequence of states, 227 but then transitioned to a clear and prolonged period of activation of the one or both 228 frontal cortex active states (states 1 or 2) near the start of the trial (Fig. 2d). These 229 prolonged durations of frontal cortex states (henceforth referred to as frontal state 230 activation event or FSA event) could be algorithmically identified as conditions where 231 state 1 or 2 was active for more than 1 second near the start of the trial (Fig. 3a). The 232 FSA events occurred in 57.1% of trials where mice used random search method, 91.7% 233 of trials which the mouse used a serial search method, and 85.0% of trials where the 234 mouse used a spatial search method (Fig. 3b). These FSA periods were primarily 235 associated with non-random search strategy trials. Overall, mean onset to the FSA 236 event was 2.3 ± 1.9 s. In trials in which mice performed a random search strategy, the 237 mean onset to the FSA event was 1.4 ± 1.2 s, whereas in serial search trials it was 2.3 238 ± 2.0 s, and 2.5 ± 2.0 s in spatial search strategy trials (Fig. 3c, p = 0.46 random vs 239 serial, p = 0.30 random vs spatial, p = 0.45 serial vs spatial). The mean duration of the 240 FSA event was 2.0 ± 0.7 s. The duration of the FSA event at the beginning of trials were 241 also longer in serial search and spatial than in random strategy trials. In trials on which 242 the mice performed a random strategy, the mean duration of the FSA event was 1.5 ± 243 0.4 s, whereas it was 2.0 ± 0.6 s in serial trials, and 2.2 ± 1.0 s in spatial trials (Fig. 3d, 244 p = 0.082 random vs serial, p = 0.18 random vs spatial, p = 0.98 serial vs spatial).

246
Frontal state activation events coincided with approach to edge of the maze 247 248 We next evaluated the behavior of the mice around the FSA events in serial and spatial 249 search trials by examining the position, velocity, and head direction of the mice ( Fig. 3e-250 l). Plots of the location of the mice during the FSA event indicated that the FSA event 251 occurred when mice approached the edge of the maze from the initial starting location 252 at the center of the maze (Fig. 3f). In 84.4% of trials with a FSA event, the event 253 initiated before or during the mouse's approach to the edge of the arena. The starting 50 ms prior to the end of the event as mice approached the vicinity of the goal 264 ( Fig. 3f right and Fig. 3g right). Correspondingly, the probability of activation of either 265 one of the frontal states was significantly higher in the approach zone of the maze, as 266 compared to state activation probabilities across the whole maze in serial and spatial 267 trials (p = 0.0022 serials trials, p = 0.003 spatial trials, Wilcoxon rank sum test).

269
Frontal activation state events in spatial trials followed initial orientation towards 270 the goal 271 272 The period before the FSA event is likely a self-localization event in which mice survey 273 the space before deciding on direction of approach to the edge of the mice. We 274 examined the changes in both the allocentric heading direction angle (ω), and the 275 egocentric heading direction angle (φ) of the mice at the start of the FSA event ( Fig. 3i-276 m). When mice employed spatial search strategies, mice oriented towards the goal 277 quadrant (½ω½< 45°) in 59% of trials (10/17 trials) at the onset of the FSA event, with an 278 increased fraction (76.4%, 13/17 trials) 500 ms after event onset. In contrast, mice were 279 oriented towards the goal quadrant in the allocentric reference frame in only 27% of 280 serial trials (9/33) at the event onset ( Fig. 3j top left). Mean ω was 64 ± 62° in spatial 281 trails as compared to 92 ± 50° in serial trials at FSA event onset (p = 0.103, Wilcoxon 282 rank sum test). Mean ω was 46 ± 43° in spatial trails, significantly lower as compared to 283 97 ± 45° in serial trials 1s after FSA event onset (p = 0.017, Wilcoxon rank sum test). 284 285 Similar differences in egocentric heading direction angles between serial and spatial 286 trials at the start of the FSA event ( Fig. 3l and m). When mice employed spatial search 287 strategies, mice oriented in the direction of goal quadrant (½φ ½< 45°) in 65% of trials 288 (11/17 trials), with an increased fraction (82%, 14/17 trials) 500 ms after event onset. In 289 contrast, mice were oriented towards the goal quadrant in the egocentric reference 290 frame in 24% of serial trials (8/33) at the event onset, with no decline in egocentric 291 heading direction angle observed after event onset ( Fig. 3l top left). Mean φ at event 292 onset was 63 ± 59°, significantly lower than the mean φ of 98 ± 46° in serial trials (p = 293 0.020, Wilcoxon rank sum test). Significant differences in mean φ were maintained 1s 294 after event onset (Fig. 3m left, p = 0.020, Wilcoxon Rank-sum test).

296
Sequences of state transitions before activation of the frontal cortex were search 297 strategy dependent 298 299 We next evaluated if there were differences in sequences of state activation during 300 specific periods around the FSA events. Examining state activation probabilities in the 301 duration of time prior to the FSA event period revealed differences between serial and 302 spatial search methods (Fig. 4a). In trials where mice utilized serial searches, state 7 303 had an activation probability of 29.3 ± 29.2% prior to FSA event. In spatial trials, the 304 activation probability reduced to 14.1 ± 5.4%. State 3 had an activation probability of 305 28.7 ± 26.9% prior to the FSA event in spatial search trials, significantly higher than the 306 activation probability in serial search trials (12.4 ± 19.6%, p = 0.007, Wilcoxon ranked 307 sum test, Fig. 4a). State 6 activation probability did not change notably between the two 308 search strategies (16.5 ± 17.4% serial search trials, 11.9 ± 13.6% spatial search trials). 309 Examining state transition probabilities in the period before the FSA event revealed 310 differences in dynamics of cortical activity between spatial and serial trials (Fig. 4b).

311
Most prominently, state 3 had a high probability of transitioning to many states in spatial 312 trials, but not in serial trials.

314
To quantify the patterns of state transitions leading up to the FSA, we constructed peri-315 event state probability histograms (Fig. 4g). As a control, we generated randomized 316 data by performing 100 bootstraps of the time series of states for each trial. We 317 determined if a state's activation probability was statistically significant from the 318 bootstrapped trials by using an Anova test with a Bonferroni correction of the mean 319 state activation probability aligned to the FSA period to the bootstrapped data. In serial 320 trails, the 1 s period leading up to the FSA event was marked by significantly higher 321 activation of state 4, followed state 5 and then by state 7 when compared bootstrapped 322 mean. In contrast, in spatial trials, the same 1 s period was marked by activation of 323 state 5 that was followed by activation of state 3 before entering the FSA period (Fig.  324  4d). These results indicate that the sequences of state transitions occurring before the 325 FSA events were search strategy dependent (Fig. 4e).

327
State 3 was preferentially active before FSA during goal-heading direction in 328 spatial but not serial trials 329 330 When considering the entire duration before the FSA event, heading direction in the 331 allocentric reference frame was significantly more aligned towards the goal in spatial 332 search was an overall change in tuning of heading direction for most states that differed 337 between serial and spatial trials. We next asked if the animals head orientation affected 338 the activation of states. We examined the times when head direction of the mice was 339 aligned to the goal quadrant in the allocentric reference frame (½ω½< 45°, Fig. 4f) and 340 egocentric reference frame (½φ½< 45°, Fig. 4g). Within these events we asked what the 341 likelihood of a certain state being active was prior to the FSA event. State 3, which was 342 significantly more likely to be active immediately prior to FSA event onset in spatial trials 343 (Fig. 4a,c), was much more likely to be active when animals were oriented towards the 344 goal quadrant in the allocentric frame of reference during spatial trials), as compared to 345 serial trials (mean P(s3) spatial = 0.33, mean P(s3) serial = 0.13, p = 0.046, Wilcoxon 346 Rank-sum test). For egocentric goal orientation, state 3 also had a higher probability of 347 being active while mice were oriented to the goal as well (mean P(s3) spatial = 0.31, 348 mean P(s3) serial = 0.07, p = 0.021, Wilcoxon Rank-sum test). No significant 349 differences were found for any of the other states. These results indicate that state 3 350 was preferentially activated when the animals head direction was oriented towards the 351 goal in spatial trials, but not in serial trials. Thus, activation of state 3 in spatial trials may 352 indicate a recognition of the goal direction in spatial trials when mice make direct 353 approaches to the goal. We discovered coordinated sequences of brain-wide activity patterns reflected in 359 mesoscale cortical activity on a spatial navigation task that differentiated goal-oriented 360 and non-goal-oriented strategies. The clustering algorithm we developed in this study 361 identified 7 cortical activation states that were generalizable across mice and trials, and 362 15 state transitions that occurred frequently during this spatial navigation task. Similar 363 numbers of dynamic motifs have been independently described in studies looking at 364 mesoscale calcium dynamics during head-fixed spontaneous behaviors 35 , with distinct 365 dynamics observed during memory guided and sensory guided tasks 36 , and 366 uninstructed movements during sensory decision making 37 and locomotion 38 . These 367 findings suggest that such generalizable repeated sequences of cortical activity may 368 underlie a diverse set of behaviors. Our data show that these sequences differentiate 369 decision strategies, most likely due to changes in the computations underlying these 370 decision strategies.

372
Trial initiation was marked by an initial duration lasting 1-2 seconds of variegated 373 sequences of states while animals were in the center of the maze near the starting summarized in Figure 3i. This points to different brain wide circuits being recruited at 391 different time points during the task. Further, these data suggest a frontal role in moving 392 towards the edge and suggests differences in information processing between spatial 393 and serial strategies, both of which successfully get the mouse to the goal.

395
Goal-oriented spatial navigation depends on cognitive maps 39 , dependent on structures 396 such as the hippocampus (HPC) and connected cortical circuits 1,3,40-42 . Recent work 397 looking simultaneously at mesoscale cortical activity and HPC electrophysiology has 398 established a temporal link between mesoscale cortical activity and hippocampal 399 oscillatory such as slow gamma activity and sharp wave ripples in the HPC 25,43-45 . Such 400 studies confirm previously elucidated systems across hippocampus and cortical brain 401 regions that mediate spatial navigation 46,47 . 402 We posit that the distinct spatio-temporal sequences of cortical activation we observed 403 in this study may be part of a larger cortico-hippocampal network computation wherein 404 incoming sensory information seeds retrieval of encoded memory in the HPC followed 405 by reactivation of trace memory in the cortex, followed by execution of motor sequences 406 in which frontal regions of the cortex are active (Fig. 5). These sequences are different 407 depending on whether the navigation strategy involves orienting towards a known 408 spatial goal before making an approach or part of a simpler serial search process. 409 410

413
Surgery: Eight Thy-GCaMP6f mice were used in this study 33 . All animal procedures 414 were performed in accordance with the University of Minnesota's Institutional Animal 415 Care and Use committee (IACUC). Mice were pre-emptively administered 1 mg/kg slow-416 release Buprenorphine (Bupenorphine-SR, ZooPharm) and 1 mg/kg Meloxicam prior to 417 surgery. They were then anesthetized using 1-4% isoflurane in pure oxygen prepared 418 for surgery following standard aseptic procedures -the scalp was shaved and sterilized 419 with repeated, alternate scrubbing with Betadine and 70% ethanol. cylinder in the center of the maze and a dummy mini-mScope was fitted to their 443 implants. Non-goal holes were covered, revealing only the goal hole, and the mouse 444 was allowed to explore the maze for 4 minutes. The maze was then rotated by 90º 445 degrees for acquisition trials. During acquisition trial days, the mini-mscope was fitted 446 onto mice for recording. Mice were placed in the start cylinder in low red-light 447 conditions. Immediately when the trial began, white noise was played at 60 dB and a 448 yellow overhead light was turned on. Non-goal holes were 1 cm deep with black silicone 449 floors. Trials were terminated when the mouse entered the goal hole or after a 3-minute 450 experiment time. For the probe trials, the maze was rotated so that the goal was in a 451 different location with respect to the visual cues. Following all trials, the mouse was 452 placed in the goal box for 1 minute, then returned to their home cage outside of the 453 behavioral enclosure. In between trials, the maze was cleaned with 70% ethanol to 454 reduce odor trails.

456
The Barnes maze was constructed from a 2.5. cm thick white, high-density polyethylene 457 (HDPE) sheet. A 1-meter diameter circle was cut out of the HDPE sheet. Twenty 10 cm 458 diameter holes were cut into the perimeter 5 cm from the edge of the sheet. A custom-459 made stair-case goal box was 3D printed using 1.75 mm diameter black PLA filament 460 on a fused deposition modeling 3D printer (M2 3D printer, MakerGear). The maze was 461 mounted onto an aluminum extrusion frame and anchored to a behavioral enclosure. 462 The maze was 0.6 meters from the ground and at least 1.5 meters from any wall. The 463 walls of the behavioral enclosure were made from 1/8-inch-thick single plywood sheets 464 (Eucatile white tile board, Home Depot) and were coated with acoustic damping foam 465 on the inner walls (JBER Acoustic Sound Foam Panels, Amazon) that covered the 1.8 466 m x 1.8 m x 2.4 m enclosure. A single behavior camera was mounted 1.2 m above the 467 center of the arena to record behavior during the experiments (Blackfly S USB-3, FLIR). 468 The mini-mScope electronics were routed through a low torque commutator (Carousel 469 Commutator 1x DHST 2x LED, Plexon Inc).

471
Cortex-wide imaging using mini-mscope 472 473 Behavior imaging: One overhead camera was used to capture the entirety of the 474 Barnes maze. The behavior camera was set to external trigger mode, line 3 trigger, any 475 edge, (Spinview) and was synchronized to capture frames with the TTL pulses sent by 476 the mini-mScope at each frame capture. The behavior camera exposure was set to 477 1000 µs and the resulting frames were compressed by 25% and saved to random 478 access memory (128 GB RAM) as a .avi video file. and green LEDs on the mini-mScope were pulsed for 120 seconds, prior to the 488 experiment to allow them to warm up and reach a stable intensity. The mice were 489 brought into the Barnes maze under red light and placed into the opaque cylinder at the 490 center of the maze ~90 s after the LEDs were turned on. The mini-mScope was 491 attached to the mice via 3 interlocking magnets. At ~120 seconds, the white noise and 492 yellow LEDs in the Barnes maze were switched on and the opaque cylinder was 493 removed, marking the start of the trial. Trials typically lasted until mice went into the goal 494 hole or at the end of 180 seconds.

496
Data pre-processing: 497 Behavior data pre-processing: For each trial, the location of each hole in the Barnes 498 maze and the outer shape of the maze was automatically detected using computer 499 vision scripts to define regions of interests (ROIs) within the Barnes maze. The location 500 of the goal hole was marked to track where it was located, as the Barnes maze was 501 rotated across cohorts and probe days. The behavior camera data was aligned with the 502 calcium imaging data via timestamps generated by the CMOS data acquisition board. 503 Any frame drops or motion artifacts detected in the calcium imaging data were dropped 504 in both the calcium imaging data and the behavior imaging data. The behavior camera 505 data was also down sampled to match the calcium channel from the mini-mScope. 506 507 Calcium data pre-processing: To assist with data saving, the MiniFAST software saves 508 calcium imaging data in separate 1000 frame videos. The individual 1000 frame videos 509 were combined into a single video using custom MATLAB scripts (2022b, MathWorks). 510 The mean pixel intensity of each frame was calculated, and K-means clustering was 511 used to classify each mean pixel intensity of the video into the blue and green channels. 512 Frames that were not classifiable into either the blue nor green channels due to large 513 motion artifacts or irregularities in LED intensity (~0.04% of all frames) were marked for 514 removal in future analysis. The videos corresponding to both illumination wavelengths 515 were then passed through a motion correction algorithm 53 . 516 517 The calcium data videos were compressed to 80% of their original size with a bilinear 518 binning algorithm (2022b, MathWorks). One frame randomly selected in each trial was 519 used to draw a mask around the imaged brain surface and exclude the background and 520 superior sagittal sinus artery to reduce noise in the overall DF/F signal. For each 521 mouse, the masks across all trials were averaged to generate a mouse-specific average 522 cortex mask. The average mask was imposed across images acquired in all trials for a 523 mouse so that the number of pixels used in each analysis remained consistent.

525
Each pixel within the mask was corrected for global illumination fluctuations using a 526 correction algorithm that produces DF/F data 54 . The DF/F data was filtered using a zero-527 order phase Chebyshev band-pass filter with cutoff frequencies of 0.1 Hz and 5 Hz 528 (2022b, MathWorks). The resulting data was then spatially filtered with a 7-pixel 529 nearest-neighbor average using a custom MATLAB (2022b, MathWorks) script. The 530 resulting DF/F time series for each pixel was then z-scored. 531 532 Data Analysis 533 534 Behavior: Data from the overhead behavior camera was analyzed using an 535 unsupervised, marker-less tracking algorithm (DeepLabCut 55 ). The program was trained 536 to track the nose, the top of the head/mini-mScope, between the ears, the right and left 537 forepaws, the shoulder blades, right and left hind paws, the lower back, the base of the 538 tail, and the tip of the tail. This tracking data was used to determine where the mice 539 were in the Barnes maze throughout the trial. To classify search strategy, the Barnes 540 maze was split into 4 equal quadrants and each hole was automatically detected and 541 labeled. Random trials were classified if the mouse's tracking trajectory crossed over 3 542 quadrants of the maze non-sequentially before reaching the goal. Serial trials were 543 classified if the mice traveled less than 3 sequential quadrants and covered at least 3 544 sequential holes on either end of the goal hole. Spatial trials were defined if the mice 545 traversed less than 2 sequential quadrants and no more than 1 sequential hole on either 546 side of the goal hole. Radially, the maze was divided into the central circle, the 547 approach zone and the serial exploration zone, with the diameter of the central circle 548 corresponding to the length of the mice (60 pixels), and the inner radius of the serial 549 exploration zone being one length of the mouse lesser than the outer diameter of the 550 maze.

552
State identification using image correlation clustering: All calcium data was 553 analyzed using custom scripts in MATLAB (2022b, MathWorks). At each time point, the 554 DF/F z-score for the current frame was correlated with all frames across trials per 555 mouse using a Pearson's correlation coefficient to construct a correlation matrix across 556 trials (Figure 2b). The correlation matrix was then sorted using k-means clustering with 557 RNG defaults for reproducibility and with 5000 maximum iterations and 500 replicates to 558 search for common, reoccurring activity patterns across time. A t-distance optimization 559 algorithm was used to determine the optimal number of clusters to sort the correlation 560 matrix, so that the correlations within each cluster were maximized and correlations 561 across clusters were minimized 34 . The number of clusters for which the largest 562 cumulative t-distance value obtained was selected as the number of clusters or states 563 for each mouse (Supplementary Figures 1-2). All the frames within an identified 564 cluster were averaged to generate a mean activity spatial map for each state. Image 565 correlations between these mean activity maps for each state identified for all mice were 566 computed to construct a second correlation matrix, which was then sorted into 7 567 clusters via k-means clustering (Figure 2c, Supplementary Figure 1a, 568 Supplementary Figure 2). 569 570 Frontal state activation: The time series of state activations for all trials were filtered 571 using a sliding window to extract periods of high activation of state 1 and 2 (the frontal 572 states) for all trials. The frontal state activation event was determined to be present if it 573 persisted for a period greater than 1 second, with up to 4 frames of jitter into other 574 states before returning to state 1 or state 2. After the events were labeled, all state 575 activation time series were aligned to the start and end of the frontal state activation 576 event period for statistics and further analysis. 577 578 Head orientation angle: Two angles were defined for head orientation of the mouse 579 during the start of the trial until the frontal state activation period. The allocentric angle, 580 denoted as ω, was the angle between the instantaneous mouse body-head vector 581 relative to fixed vector drawn from the center of the maze to the goal. The egocentric 582 angle, denoted as φ, was the angle difference between the instantaneous mouse body-583 head vector and vector drawn from the instantaneous position of the mouse's body to 584 the goal location. 585 586 Statistics: Wilcoxon rank sum non-parametric tests were used to determine the 587 statistical significance between serial and spatial search strategies' state activation 588 (Figure 3e, Figure 4 h,l). A Kruskal-Wallis test was used to determine statistical 589 significance between head direction angles in the pre-FSA period. Non-parametric tests 590 allow for unequal sample sizes between the search strategies. ANOVA tests were run 591 with a Bonferroni correction to determine the significance of state activation in the peri-592 event state probability histograms (Figure 2g). All error bars denote standard deviation. 593 594 cortex. c) Traces obtained from tracking data of one mouse which utilized random, 605 serial, and spatial search methods as it learned to navigate the Barnes maze. d) Bar 606 plot showing the mean primary latency, or time to first goal hole discovery, across days 607 as mice learned to navigate the Barnes maze. * indicates p < 0.05, Wilcoxon rank sum 608 test. e) A bar plot showing the mean number of primary errors, or the number of times 609 the mouse checked an incorrect hole before reaching the goal. * indicates p < 0.05. f) A 610 bar plot showing the percentage of search strategies utilized across all trial days. g) 611 Left: Tracking data from a spatial trial in which the mouse makes a single error on the 612 way to the goal. The trace is annotated with periods that correspond to state-like shifts 613 in calcium data across the cortex shown in the graph on the right. Right: a map of the 614 calcium data across the entire FOV acquired during the trial shown in the left panel.

615
Numbered lines correspond to state-like global calcium activity transitions observed 616 during the behavioral periods marked in the left panel. Pseudo color maps of the 617 calcium DF/F z-score from frames during each behavioral period are shown below. All 618 error bars indicate sample standard deviation. 619 620 621 622 Figure 2: Identifying brain states from mesoscale calcium activity. a) Example of 623 the method used to identify cortex-wide brain states from widefield calcium imaging 624 during spatial navigation from one mouse. Data from all trials for one mouse is shown. 625 All pixels across the FOV are plotted vs time. Trials are indicated by T1-T8 labels, 626 separated by the white lines. b) Left: A correlation matrix is constructed by computing 627 the image correlation between all frames. K-means clustering is used to organize the 628 correlation matrix into highly correlated groups, denoted as states. Center: The number 629 of states is determined by using an optimization algorithm which maximizes intra-cluster 630 correlation while minimizing inter-cluster correlations. The maximum t-distance value 631 indicates the optimal number of states for this mouse (k=10 states here). Right: the 632 result of re-sorting the correlation map on the left into an optimized number of clusters 633 determined with k-means clustering and t-distance optimization, resulting in 10 states 634 for this mouse. c) Common state space model across n = 8 mice and 63 trials. Optimum 635 number of states varied from 5-10 states across all mice, with an average of 6.4 ± 2 636 states (Supplementary Figs. 1 and 2). 7 states were selected as sufficient to describe 637 the state space across mice. States were identified by cortical areas across the FOV 638 with high DF/F z-score calcium signal. The top row illustrates simplified activity maps 639 with high DF/F z-score activity. Below the top row are average DF/F z-score heat maps 640 for the mouse in a-b which fit into the common state space. Bottom: bar graphs 641 depicting the average DF/F z-score of cortical regions across mice using the Allen atlas. indicates state number. f) State transition probability matrix across all trials. g) Bar 647 graph of the total state activation probabilities across all trials. 648 649