Abstract
Recently acquired memories are reactivated in the hippocampus during sleep, an initial step for their consolidation1-3. This process is concomitant with the hippocampal reactivation of prior memories4-8, posing the problem of how to prevent interference between older and recent, initially labile, memory traces. Theoretical work has suggested that consolidating multiple memories while minimizing interference can be achieved by randomly interleaving their reactivation9-14. An alternative is that a temporal micro-structure of sleep can promote the reactivation of different types of memories during specific substates. To test these two hypotheses, we developed a method to simultaneously record large hippocampal ensembles and monitor sleep dynamics through pupillometry in naturally sleeping mice. Oscillatory pupil fluctuations revealed a previously unknown micro-structure of non-REM sleep associated memory processes. We found that memory replay of recent experiences dominated in sharp-wave ripples (SWRs) during contracted pupil substates of non-REM sleep, while replay of prior memories preferentially occurred during dilated pupil substates. Selective closed-loop disruption of SWRs during contracted pupil non-REM sleep impaired the recall of recent memories, while the same manipulation during dilated pupil substates had no behavioral effect. Stronger extrinsic excitatory inputs characterized the contracted pupil substate, whereas higher recruitment of local inhibition was prominent during dilated pupil substates. Thus, the micro-structure of non-REM sleep organizes memory replay, with prior versus new memories being temporally segregated in different substates and supported by local and input-driven mechanisms respectively. Our results suggest that the brain can multiplex distinct cognitive processes during sleep to facilitate continuous learning without interference.
One prominent problem that both biological and artificial neural networks face is the interference between previously stored and newly acquired memories, as it can lead to catastrophic forgetting9-11. An influential proposal to answer this problem is that initial memory consolidation is restricted to the hippocampus and gradually transferred to the neocortex where memories are then integrated with pre-existing knowledge1,15. However, it has been shown that the hippocampus continues reactivating memories for multiple days after their initial acquisition (i.e., learning)4-8,16, therefore risking interference with newly incorporated information that is especially fragile before relocation to the cortex1,9,11,15.
A candidate mechanism for hippocampal memory consolidation is the reactivation (or replay) of experience-related neuronal patterns within SWRs during non-Rapid Eye Movement (NREM) sleep2,3,17-19. Previous research has consistently shown that only a fraction of SWRs interspersed within NREM sleep contains replay events of recent experiences4,16,18-22. These observations, together with theoretical work on both biological and artificial neural networks9-14, lead to the proposal that randomly interleaving the reactivation of new and prior memories in the hippocampus could facilitate consolidation without interference. So far, most mechanistic evidence of memory reactivation comes from rodent studies, where SWRs are evaluated evenly throughout NREM sleep2,23,24, despite evidence suggesting NREM as a non-homogeneous state25,26. On the other hand, NREM sleep in humans is characterized by different stages that are specifically associated with distinct memory processes23,27, although the underlying cellular mechanisms are not well understood. Therefore, an alternative hypothesis is that NREM sleep, which is conserved across species, including rodents, has a previously unrecognized micro-structure. Such temporal organization could involve specific substates with dedicated mechanisms to support the initial consolidation of recent memories, leaving other substates for reactivation of previous memories. This process may support not only memory maintenance but also other generative functions such as linking, composition and inference28-33. In both humans and animals, pupil fluctuations have been proven as a sensitive marker of brain state changes34,35, and thus can be a useful readout of sleep dynamics; yet data about pupil dynamics in rodents during NREM sleep is scarce. Here, we developed an approach for simultaneous electrophysiology, closed-loop optogenetics, and pupillometry to monitor brain-state dynamics in freely behaving and sleeping mice to uncover the temporal organization of sleep and memory replay.
Pupil dynamics reveal a micro-structure within NREM sleep in mice
To investigate the role of sleep micro-structure in hippocampal memory replay, we combined pupillometry with high-density electrophysiology and real-time pupil-dependent optogenetic intervention. We deployed a custom miniaturized head-stage featuring optical fibers, high-density silicon probes with active electronics, camera, infrared LED and a mirror (Extended Data Fig. 1)36. This head-stage allowed the simultaneous recording of hundreds of single neurons as well as local-field potentials (LFPs) and pupil dynamics during freely moving behavior and natural sleep in mice (Fig. 1a, left; Extended Data Fig. 1). For pupil-dependent manipulation of memory, we developed a method for real-time pupil tracking (Fig. 1a, right; Extended Data Fig. 1), by taking advantage of the fact that mice sleep with their eyes open37,38 (Extended Data Fig. 1i). Our online algorithm showed high tracking accuracy when compared with manually scored frames (Extended Data Fig. 1e-g) and standard offline methods (DeepLabCut -DLC-; Extended Data Fig. 1h)39. To classify brain states into waking (WAKE), NREM and REM sleep, we applied previously validated methods based on hippocampal and cortical LFP features24,40. Pupil diameter shrank during sleep, becoming smallest during REM periods (Fig. 1b; Extended Data Fig. 2a). During NREM periods, pupil diameter oscillated between constriction and dilation on a minute-scale, with a peak frequency of ~0.015 Hz (Fig. 1c; Extended Data Fig. 2b). To verify brain state separation using spectral LFP features, we employed uniform manifold approximation and projection (UMAP) for visualization. Episodes of WAKE, NREM and REM were largely segregated in a low-dimensional UMAP space (Fig. 1d, bottom left). Interestingly, projecting pupil size over the spectral feature space revealed a structured distribution (Fig. 1d, upper left). This structure was then quantified using a graph-based structure index (SI)41 in the original high-dimensional space. The distribution of pupil size showed a high SI, and significantly differed from a randomly distributed pattern (Fig. 1e), indicating that pupil size is a good estimate of global brain state. This result was further supported by the close relationship between pupil size and sleep LFP features, such as electromyogram proxy (EMG proxy), theta power and power spectrum slope of the LFP signals (Extended Data Fig. 2c). Importantly, restricting the same analysis to NREM epochs, during which SWRs are prominent, also showed a structured distribution of pupil sizes (Fig. 1d, right; Fig. 1e), suggesting that NREM sleep in mice is not a homogenous brain state.
Fig. 1|. Oscillatory pupil dilation revealed micro-architecture in natural sleep.

a, Left, experimental scheme for pupillometry and electrophysiology in free moving mice. Right, pupil tracking with DLC, and our real-time online algorithm across behavioral states. Two pupil snapshots at its peak and valley during NREM are shown at the bottom. b, Representative pupil trace with LFP-scored sleep stages. Gray area highlights the infra-slow oscillatory pattern of pupil dilation during a NREM episode. c, Left, representative auto-correlogram of pupil size during NREM sleep shown in b. Right, peak frequency in pupil power spectral profiles during NREM bouts (mean ± sem = 0.016 ± 0.004 Hz; n = 9 sessions with NREM bouts longer than 10 mins from 5 mice). d, Visualization of network states constructed from CA1 LFPs using unsupervised UMAP. Data from the session shown in b. Left, states occupied during WAKE, NREM and REM sleep. Middle, distribution of pupil size across WAKE, NREM and REM. Right, distribution of pupil size during NREM only (z-scored within NREM; unvisited states in gray). e, Structure index (SI; see Methods), characterizing the pupil distribution across the original high-dimensional state space, tested against pupil-label shuffled distributions (n = 14 days from 5 mice; 95th percentiles of shuffle distributions are shown; ***both p’s = 1.22e-4, paired signed-rank test). Left dot pairs reflect SI across all states and right pairs within NREM. f, Method schematic. Ripple waveform from time samples in a 50 ms window defined the high-dimensional space and reduced to a low-dimensional space for visualization. g, Individual SWRs formed a continuous distribution of their peak amplitudes (left), and pupil size (right). h, SI of pupil size distribution across the high-dimensional ripple waveform space is significantly higher than shuffles (**p = 0.0098, paired signed-rank test).
Next, we sought to characterize the relationship between pupil dynamics and SWRs. We found that although pupil diameter could have any size during a given SWR, the rate of SWRs was largely anticorrelated with pupil size during both NREM and WAKE states (Extended Data Figs. 4a-c), in line with previous studies in awake head-fixed mice42-44. To further determine whether pupil-dependent sleep substates characterized by different pupil sizes correlated with SWR features, we represented SWRs as points in a high-dimensional space constructed from their ripple-band LFP waveforms and applied UMAP for visualization (Fig. 1f)45. As expected, labeling SWRs by their waveform features, such as amplitude, revealed a structured distribution along the low-dimensional UMAP space (Fig. 1g, left; Extended Data Figs. 3 and 4)45. Interestingly, labeling SWRs by their associated pupil size also revealed a significant non-random structure (Fig. 1g, right; Fig. 1h and Extended Data Figs. 3 and 4). This relationship with waveform features was not observed for delta waves and spindles (Extended Data Figs. 3 and 4), and such gradient could not be fully explained by pupil-size correlation with the EMG proxy, microarousals (MA), small-irregular activity (SIA) states (Extended Data Figs. 3 and4), REM sleep transitions or different phases of sleep (Extended Data Fig. 3)37,46-49. Taken together, these results suggest that pupil size fluctuations can be used as a read-out of the micro-structure of NREM sleep, a state traditionally considered to be homogenous in rodents, and that such micro-structure modulates SWR properties.
Replay of recent experience occurs during small pupil NREM substates
We next asked whether the micro-structure of NREM sleep revealed by pupil dynamics is related to memory replay content. To do that, we trained mice in a T-maze delayed-alternation memory task, preceded (PRE) and followed (POST) by 2-hour sleep sessions (Extended Data Fig. 5a). We employed a Bayesian decoder trained on the spatial rate maps of hippocampal cells in the maze (Extended Data Fig. 5a-c) to classify replay events during sleep SWRs (Fig. 2a, top). Similar to previous reports, we found that only ~10% of SWRs had significant replay (mean ± SD = 9.71 ± 0.14%)50,51, and SWRs with and without associated replay occurred interspersed throughout the 2 hours of POST sleep (Fig. 2a, bottom). However, we observed that replay events preferentially occurred during small pupil substates of NREM sleep (Fig. 2a,b). Indeed, replay probability co-fluctuated with pupil size (Extended Data Fig. 2d-f), and both replay probability and percentage of significant replay events (compared to shuffled events; see Methods) were anticorrelated with pupil size during NREM sleep (Fig. 2b,c). Specifically, only SWRs that occurred during small pupil substates had a higher probability than chance of expressing replay, while replay probability was below chance for SWRs occurring during large pupil substates (Fig. 2c). Because the probability of replay depends on the neuronal firing rate during SWRs, we tested whether this relationship was maintained when subsampling SWRs to match their population firing rate and number of SWRs across pupil size sextiles, which showed similar results (Extended Data Fig. 5d). To further account for the change in cell participation during NREM episodes52 (Extended Data Fig. 5f), we examined the correlation between pupil size and replay probability at different NREM phases and found similar results across different phases (Extended Data Fig. 5g). Importantly, replays occurring during small pupil substates better represented task sequential activity patterns than those during large pupil (r = −0.07, p = 3.25e-18, n = 15,844 SWRs, Spearman correlation between replay scores and pupil sizes). We further confirmed these results with an alternative metric by calculating memory reactivation strength using co-active cell assemblies during behavior and quantifying their activity patterns during sleep SWRs (see Methods)18,19,51. Similar to sequence replay, assembly reactivation strength was also significantly anti-correlated with pupil size (Extended Data Fig. 5e). Such anti-correlation was also present during SWRs in quiet WAKE (Extended Data Fig. 5e).
Fig. 2|. Small pupil substates promote replay of recent memories.

a, Top: two representative SWR events during small (left) and large (right) pupil substates, respectively. For each event, multi-unit (MUA) spike density (top), CA1 LFP (middle), and decoded position (cyan line, best linear fit) for the event are shown. Bottom: curves showing replay probability and inverted pupil size during a NREM bout. Note the significant sequential representation of a spatial trajectory for the contracted pupil event, but not for the dilated pupil event. b, Replay probability over pupil size sextiles (****p = 6.99e-12, one-way ANOVA with post hoc test for linear trend; 15 sessions from 3 animals; mean ± sem). c, Percent of significant replay events out of all SWRs over pupil sextiles (****p< 1e-16, one-way ANOVA with post hoc test). Bootstrapped distributions are shown (n = 100 times). Note significantly higher replay percentage in the lowest sextile, and lower percentage in the highest sextile (****both p’s < 1e-16, rank-sum tests compared to random shuffles of replay probabilities across SWR events). d, Illustration of the GLM for quantifying the contribution of replay probability versus other SWR properties. GLMs were fitted with all variables (full models), and the coefficients for a target variable (e.g., reactivation strength, RS) were set to zero to make cross-validated predictions on held-out data of pupil sizes (ablated models)53. The contribution was quantified as the decrease of GLM prediction gain compared to the full model54,55. e, GLM gain for the full, pupil-size label shuffled, and ablated models. Note the strongest reduction of GLM prediction gain for the replay probability (****p < 0.0001, one-way ANOVA with Sidak’s post hoc test).
To investigate how well pupil dynamics accounted for memory replay beyond simple SWR properties (e.g., ripple amplitude), we employed a generalized linear model (GLM) to predict pupil size considering ripple amplitude, reactivation strength and replay probability. We estimated the contribution of each variable by measuring the ‘prediction gain’ reduced from ablating the variable53-55 (see Methods). We found that while all variables significantly contributed to prediction of pupil size, ablation of replay had the most severe reduction in prediction gain (Fig. 2e), suggesting a tight relationship between replay and pupil dynamics. Furthermore, using pupil size to predict replay probability and examining the time course of this relationship, we found that pupil size could significantly predict replay probability at the time of SWR onset (Extended Data Fig. 5h,i). This finding persisted after excluding all periods around SIA states, suggesting that the correlation between pupil size and replay was not simply due to the occurrence of SIA states (Extended Data Fig. 5j). Overall, these results indicate that transient substates during NREM sleep, characterized by a contracted pupil size, provide a privileged temporal window for the replay of recent memories.
Disruption of SWRs during small but not large pupil NREM substates impairs consolidation of recent memory
To assess the causal role of replay of recent experiences during small pupil substates in memory performance, we sought to disrupt SWRs in a pupil-dependent manner. Previous work showed that disrupting SWRs during post-learning sleep impaired memory consolidation3,19,56,57. However, such manipulations did not allow for a specific link between SWR-associated replay of a recent memory and its consolidation. Therefore, whether the synchronous population bursts or the fine temporal structure (replay) of neuronal firing underlies memory consolidation is still an open question. To answer this question, we aimed at disrupting SWRs that selectively occur during small pupil substates, based on our observation that memory replay was largely restricted to these periods. We hypothesized that exclusively disrupting these SWRs would be enough to impair memory consolidation, while disrupting a similar fraction of SWRs during large pupil substates would leave memory intact. To test this hypothesis, we leveraged our method for real-time tracking of pupil dynamics and detecting SWRs (Fig. 1a; Extended Data Figs. 1 and 6). We trained mice in a spatial learning task consisting in finding a hidden water reward location in a cheeseboard maze that changed every day56,58,59 and tested their memory recall after 2 hours of rest. Mice learnt the optimal route to collect rewards in less than 5 trials and remembered it 2 hours later (Extended Data Fig. 7). We performed optogenetic closed-loop SWR disruption19,60 during post-learning sleep during small or large pupil size substates specifically (Fig. 3a, Extended Data Fig. 6 and Extended Data Fig. 7a,b). We then compared the effect on memory recall of these two types of manipulations (in different sessions of the same animals) (Fig. 3b, Extended Data Fig. 7). In each experiment, we first determined the size threshold for classifying small and large pupil substates (Extended Data Fig. 6; see Methods) and verified that the fraction of SWRs disrupted did not significantly differ between the two conditions (Fig. 3c). Strikingly, disruption of only small pupil-associated SWRs (SWRpupilS) was sufficient to impair memory consolidation, while disruption of large pupil-associated SWRs (SWRpupilL) had no impact on behavior (Fig. 3b,d). In SWRpupilS disruption sessions, mice took more time and a longer path to find the reward location in the post-learning probe session (without reward present), as well as in the first testing trial, compared to its own training trial or SWRpupilL disruption sessions (Fig. 3d,e; Extended Data Fig. 7c,d). Animals’ running speed did not significantly differ across the two conditions (Extended Data Fig. 7e). The memory effects of SWRpupilS and SWRpupilL disruption were not correlated with the fraction of SWRs disrupted (Extended Data Fig. 7g), suggesting that the memory impairment cannot be explained by the amount of SWRs disrupted. We obtained similar results with a complementary SWR disruption method, closed-loop optogenetic activation of CA1 parvalbumin positive (PV+) interneurons triggered by either SWRpupilS or SWRpupilL (Extended Data Fig. 7h-n). In addition, disrupting all SWRs during pos-task sleep had a similar effect to SWRpupilS disruption (Extended Data Fig. 7f), in line with previous studies3,19,56,57. To investigate if mice still retained some inaccurate memory after SWR disruption, we looked at animals’ goal-direction-heading angle during the task task61. Goal-direction angles were widely distributed in the first training trial but aligned with the trajectory towards the goal during the last training trial, and this goal-directing effect was lost after SWRpupilS disruption but not in SWRpupilL disruption (Extended Data Fig. 8), further supporting an impairment effect of recent goal memory after SWRpupilS disruption. These results provide experimental evidence supporting the hypothesis that the key mechanism for memory consolidation is not SWRs and associated population bursts per se, but the coordinated replay of task-related activity patterns specifically.
Fig. 3|. Optogenetic disruption of SWRs in small but not large pupil substates selectively disrupts recent memory.

a, Example of optogenetic disruption of SWRs in small (top) and large (bottom) pupil substates during sleep. Yellow line: ripple-band filtered LFP. Green line: pupil size. Triangles: time of optogenetic stimulation. Red circle: time of remaining SWRs detected offline after optogenetic disruption. b, Examples of mouse paths during SWRpupilS (top) and SWRpupilL (bottom) disruption sessions. Arrowhead: home box location. Yellow circle: reward location. c, Fractions of SWRs disrupted were similar in the small and large pupil condition. (p = 0.96, rank-sum test; n = 8 sessions from 5 mice for each condition). d, Latency to reward location during training, probe, and test trials for SWR disruption in small (left) and large (right) pupil substates. Thin line for a single session, thick line as mean ± sem across sessions. e, Latency of probe and the 1st testing trial versus the last training trial. Each dot pair for one session (**p = 0.0078, *p = 0.016, n.s., p = 0.69, paired signed-rank test). f, Experimental paradigm for learning multiple goals (see Methods). g, Example mouse path during the last training trial (left) and the 1st testing trial (right). Black rhombus and black line: familiar goal and path to the familiar goal. Blue circle and blue line: novel goal and path to the novel goal. h, Latency of probe and the 1st testing trial versus the last training trial to the novel (blue) and the familiar (black) goal. Each dot pair for one session (*p = 0.016 and 0.031, n.s., p = 0.69 and 0.30, paired signed-rank test; n = 7 sessions from 4 mice for each condition).
We next asked whether the memory deficit observed after SWRpupilS disruption represented a general disruption of hippocampal-dependent memory performance or a specific deficit in consolidating a newly acquired memory. To answer this question, we modified the cheeseboard task to include two reward locations (Fig. 3f). Mice learnt one reward location for 3 days (“familiar goal”). On the 4th learning day, after testing memory of the familiar goal for 5 trials, a new reward location was introduced (“novel goal”) for 5 additional trials. Probe and test trials were conducted after a 2-hour sleep period. In non-manipulation days, mice remembered both the new and the prior goals in test trials (Extended Data Fig. 9a). We found that SWRpupilS disruption during post-training sleep resulted in an impaired recall of the novel goal (Fig. 4b, Extended Data Fig. 9b). Interestingly, mice still remembered the familiar goal after this disruption (Fig. 4b, Extended Data Fig. 9b), indicating that disrupting SWRpupilS only impaired the consolidation of the novel goal learned that day.
Fig. 4|. Reactivation of novel and prior memories are temporally segregated by small and large pupil substates.

a, Overview of experimental design. b, Example cell assemblies detected in familiar (left) and novel (right) environments. Weight vectors of all 91 simultaneously recorded putative pyramidal neurons are shown. Neurons with the highest weights (cells 1-4) are highlighted. c, Firing rate maps for the 4 neurons highlighted in b. Note the place-field remapping across environments and similar place fields for the neuronal pairs from the same assembly (Extended Data Fig. 9). d, Reactivation strength (RS) of cell assemblies detected in familiar (black) and novel (blue) environments shown in b and c, along with pupil size (green), during NREM sleep. Note the segregation of reactivation of novel and familiar assemblies with pupil sizes. e, Preferential reactivation of familiar environment during large pupil substates (**p = 0.0076, one-way ANOVA with post hoc test for linear trend; n = 10 novel-familiar session pairs from 5 animals). f, peri-SWR reactivation strength for a representative rigid (top) and plastic (bottom) cell assembly during PRE (gray) versus POST (red) SWRs, and during POST SWRpupilL (yellow) versus SWRpupilS (blue) are shown (mean ± sem). Note the increase of RS from PRE to POST for the plastic assembly, and the higher RS during SWRpupilL compared to SWRpupilS for the rigid assembly. g,h, Large pupil substates biased to reactivation of rigid cell assemblies. g, RS difference for plastic versus rigid assemblies (*p = 0.014 for small, n.s., p = 0.90 for middle, *p = 0.023 for large, rank-sum test compared to 0; **p = 0.0011, one-way ANOVA with post hoc test for linear trend). h, Rank-order correlation of POST reactivation at different pupil sizes with PRE reactivation. Note the stronger correlation for SWRpupilL (*p = 0.031, one-way ANOVA with post hoc test for linear trend; n = 10 PRE-POST session pairs).
Sleep micro-structure segregates the reactivation of novel and prior memories
Given that mice still remembered the familiar goal after SWRpupilS disruption, we sought to test whether SWRpupilL reactivated previously formed memory traces. To examine this, we detected cell assemblies when mice navigated in a familiar versus novel environment respectively (Fig. 4a-c, Extended Data Fig. 9c-e; see Methods) and examined their SWR reactivation during POST sleep (Fig. 4d). Context- and location-specific cell assemblies were detected in each environment (Extended Data Fig. 9f-g)7. Consistent with our hypothesis, cell assemblies encoding the familiar environments were preferentially reactivated in large pupil substates, while reactivation of the novel environment dominated in small pupil substates (Fig. 4d,e). To investigate if the preferred reactivation of familiar environments during large pupil substates can generalize to other prior experiences, we classified cell assemblies detected during the spatial memory task into ‘plastic’ (i.e., cell assemblies showing a learning-related enhancement of memory reactivation from PRE to POST sleep) or ‘rigid’ (i.e., cell assemblies lacking a learning-related enhancement) (Fig. 4f; see also Methods). Such ‘rigid’ assembly patterns may correspond to other prior memories and are thus not modified by the new learning51,52,62. As expected, a higher fraction of plastic assemblies was observed in novel environments compared to the familiar ones (Extended Data Fig. 9h). Interestingly, while plastic assemblies showed a higher reactivation during SWRpupilS, rigid assemblies were preferentially reactivated during SWRpupilL (Fig. 4f,g). To further validate this result, we computed the rank-order correlation of neuronal sequences during PRE versus POST sleep SWRs. Neuronal sequences during POST SWRpupilL were more similar to the PRE SWR sequences than those during POST SWRpupilS (Fig. 4h). These results suggest that SWRpupilL preferentially reactivate neural patterns representing previously acquired memories, contrary to SWRpupilS which instead represent newly encoded experiences.
Circuit mechanisms of memory replay during different NREM substates
Finally, we aimed to determine the underlying circuit mechanisms of SWRpupilS- and SWRpupilL -associated activity respectively. Previous work suggests that CA1 replay is controlled by CA3 inputs18,63,64. Therefore, we examined the strength of CA3 as well as the two other main excitatory inputs to CA1, CA2 and entorhinal layer 3 (EC3), during SWRpupilS and SWRpupilL. We implanted mice with linear probes spanning all CA1 dendritic layers, which allowed us to estimate the strength of the inputs using current source density (CSD) analysis (Fig. 5a)65. We found that CA3 input was stronger during SWRpupilS compared to SWRpupilL, while CA2 input did not show significant differences (Fig. 5a). Furthermore, sharp-waves, generated by postsynaptic excitatory currents elicited by CA3 inputs63,66, had a higher amplitude during SWRpupilS than during SWRpupilL (Extended Data Fig. 10a), consistent with the CSD input analysis. Surprisingly, EC3 input was also stronger during SWRpupilS compared to SWRpupilL. Previous studies related EC3 input to the generation of SWR bursts67,68. We found that the incidence and the duration of SWR bursts had a negative correlation with pupil size (Extended Data Fig. 10d,e), in line with the CSD analysis. This further supports an enhanced contribution of EC3 inputs during SWRpupilS.
Fig. 5|. Distinct input and local circuit properties in small and large pupil substates.

a, Left, averaged CSD and LFP depth profile for SWRs in a representative session. Right, CSD magnitude revealed stronger CA3 and entorhinal inputs during SWRpupilS (n.s., p = 0.80, ***p = 0.0002 and 0.0007 for rad and l-m, respectively, rank-sum tests compared to 0). Box plots show median, 75th (box), and 90th (whiskers) percentile. b, Firing rate difference between CA1 INTs and PYRs during SWRs in different pupil substates (**p = 0.0068, one-way ANOVA with post hoc test for linear trend; n = 17 sessions from 4 animals). c, CCGs for a representative pre-/post-synaptic PYR-INT pair during small, middle and large pupil substates. Dashed line shows 0 ms lag from the reference spike. d, CA1 PYR-INT spike transmission probability was stronger in large pupil substates (*p = 0.028, paired t-test). e,f, Optogenetic induction of ripples at different pupil sizes. e, Examples of optogenetically induced ripples in CA1 at the corresponding pupil sizes shown on the left. A spontaneous ripple is shown for comparison (indicated by the triangle). Note the smaller ripple amplitude induced at the larger pupil size (trace b), with the same stimulation intensity. Cyan vertical line: light stimulation pulse onset. f, Amplitude of optogenetically induced (opto; dark red) and spontaneous (spont; light red) ripples from the same sleep sessions over pupil size sextiles (**p = 0.014, ****p = 4e-15, one-way ANOVA with post hoc test for linear trend. n = 9 sessions from 6 animals). Data are shown as mean ± sem in b, d and f.
Beyond the input-driven mechanisms, previous studies have shown that feedback inhibition from local interneurons contributes to SWR generation and the coordination of associated spiking content69-72. We examined the firing rates of both CA1 pyramidal cells (PYRs) and interneurons (INTs) and found that the overall firing rates of both cell types were anti-correlated with pupil size during NREM (Extended Data Fig. 10f,g), but their ratio indicated an increased inhibition specifically during SWRpupilL (Fig. 5b). To directly characterize the strength of feedback inhibition during SWRs, we identified putative monosynaptic pairs (PYR – INT) using their spike train cross-correlograms (CCGs), as previously described (Fig. 5c, Extended Data Fig. 10b)73. We then estimated their synaptic strength using the spike transmission probability. PYR-INT spike transmission probability was stronger during SWRpupilL than SWRpupilS (Fig. 5d), indicating an enhanced feedback inhibition in CA1. Altogether, our results showing stronger excitatory inputs and reduced feedback inhibition during SWRpupilS compared to SWRpupilL suggest that CA1 is in a more excitable state during small pupil substates, which may facilitate the replay of recently active assemblies. To better probe the excitability of the network during these different pupil states, we optogenetically generated SWRs19,60,69 during sleep (Fig. 5e). We found an anticorrelation between the amplitude of artificially generated SWRs and pupil size (Fig. 5f), similar to that of spontaneous SWRs, supporting the idea that CA1 has enhanced excitability during small pupil substates.
Discussion
Using pupillometry in combination with large hippocampal ensemble recordings in mice, we found that NREM sleep has a stereotypic micro-structure that regulates memory replay. Pupil size oscillated between contracted and dilated substates in a minute-timescale, signaling an alternation between different hippocampal network states. While SWRs occurred throughout the whole NREM sleep, replay of recent experiences occurred in SWRs during small pupil substates as compared to large pupil substates. This suggests that rather than a homogeneous state, NREM sleep is composed of different substates that favor replay of recent or remote memories respectively. This is also in line with previous studies showing that only a subset of sleep SWRs (~10-15%)4,22,50-52 contain significant replay events. The fundamental contribution of SWRs to memory consolidation is supported by previous work showing that disruption of all SWRs following learning results in memory deficits3,19,56,57. However, these manipulations lacked the resolution to test which aspects of neural activity associated with SWRs are necessary for consolidation. Importantly, we found that selectively disrupting only the subset of SWRs during small, but not large, pupil substates, impaired the recall of recent memories. This result suggests that it is the precise temporal structure of sequential activity during SWRs, beyond simple population firing rate increase, that is necessary for memory consolidation.
In contrast to SWRs during small pupil substates, SWRs during large pupil substates preferentially reactivated assemblies representing prior memories. Therefore, the micro-structure of NREM sleep temporally segregated two important memory functions: the initial consolidation of recent experiences during contracted pupil substates and the maintenance of prior memories during the dilated pupil substates. This subdivision can have important advantages. By isolating the replay of recent memories, small pupil substates can protect labile memory traces from interference and facilitate their segregation from other partially overlapping memories. By enabling the replay of multiple prior memories, dilated pupil substates could support memory integration, linking, the construction of relational representations, as well as generalization and inference; functions in which the hippocampus has also been implicated29,30,32,33,74. In support of this functional segregation, we found that different circuit mechanisms preferentially contribute to SWRpupilS and SWRpupilL. Excitatory inputs from CA3 and entorhinal cortex layer 3 were stronger during SWRpupilS. This result supports the canonical view of CA3 as the main contributor to the generation of replay of recent experiences64,75,76, as well as recent observations of the potential involvement of direct entorhinal inputs18,67,68,77,78. However, despite the importance of CA2 for SWR generation and temporal coordination of replay79,80, CA2 input was not particularly enhanced during SWRpupilS. Complementary to the input-driven SWR generation, recent work has suggested that CA1 can also generate SWR-associated neuronal sequences locally, supported by its pyramidal cell-interneuron interactions60,69-72. In agreement with this idea, we found an enhanced recruitment of local feedback inhibition during SWRpupilL.
Pupil fluctuations are strongly coupled to changes in neuromodulatory tone, particularly acetylcholine (ACh) and norepinephrine (NE)35,81-83. These neuromodulators also influence hippocampal oscillatory patterns (e.g., theta and gamma oscillations, SWRs), synchrony and excitation/inhibition balance84-87. Both ACh and NE tone are generally higher during theta compared to SWR states84-87. ACh attenuates recurrent CA2/3 excitatory activity necessary for SWRs generation86, and stimulation of medial septum cholinergic neurons suppresses SWRs in the hippocampus88. NE release paired with perforant path stimulation induces long-term plasticity of excitatory postsynaptic potentials in hippocampal slices, and electrical stimulation of locus coeruleus (main source of NE) induces a lasting decreased in the probability of SWR occurrence89. It is therefore likely that cholinergic and noradrenergic inputs contribute to SWR generation, memory replay and associated mechanisms during distinct pupil states.
Similar to previous work, we also found that pupil size during sleep was negatively correlated with the occurrence of cortical oscillatory patterns such as delta waves and spindles37. On the other hand, sleep microarousals and elevated EMG proxy correlated with pupil dilation37,46,90, supporting the idea that pupil size is a good proxy to assess global brain state35,91. However, we observed frequent fluctuations in pupil diameter beyond those coupled to states transitions (e.g., between NREM, REM and MAs). Because the replay of a recent experience is strongest during the subset of SWRs that are coupled to cortical spindles92,93, it is therefore plausible that hippocampal-cortical coupling is associated with enhanced replay during SWRpupilS, whereas synchronous coordination of hippocampus and cortex may not be required for the replay of remote experiences1,9,15 occurring during SWRpupilL.
In summary, our study reveals the existence of distinct substates and mechanisms within NREM sleep that segregate the replay of recent and prior memories. This finding provides a potential solution for the long-standing problem in both biological and artificial neural networks of preventing catastrophic interference while also enabling memory integration9-11. Given that pupillometry is widely used as a non-invasive technique to study human cognition, our results could help refine non-invasive intervention experiments for improving human memory, such as targeted memory reactivation, which often lack the temporal resolution of specific brain processes and has variable effects on memory94-99.
Materials and Methods
Animals
All experiments conformed to guidelines established by the National Institutes of Health and have been approved by the Cornell University Institutional Animal Care and Use Committee. All mice were kept in the vivarium on a 12-hour light / dark cycle with ad libitum access to food and water except during training in T-maze or cheeseboard (see behavioral tasks). They were housed with a maximum of 5 per cage before surgery and individually afterward. B6FVBF1/J mice (~27-32 g, 3-6 months old, The Jackson Laboratory) were used in electrophysiological recordings. CaMKIIα-Cre/+; Ai32/+ mice (~25-30 g, 3-6 months old) and Pvalb-IRES-Cre/+; Ai32/+ mice (~26-30 g, 3 months old) were used for optogenetics experiments. The former line was generated by crossing B6.Cg-Tg(Camk2a-cre)T29-1Stl/J line and Ai32(RCL-ChR2(H134R)/EYFP (The Jackson Laboratory), and the latter line was generated by crossing B6.129P2- Pvalbtm1(cre)Arbr/J and Ai32(RCL-ChR2(H134R)/EYFP (The Jackson Laboratory).
Surgical procedures
Silicon probes were implanted as previously described19. Briefly, mice were anesthetized with isoflurane, coordinates were taken following stereotaxic guidance after which craniotomies were performed. Silicon probes (NeuroNexus or Diagnostic Biochips) were mounted on a micro-drive (Cambridge Neurotech) to allow accurate adjustment of the vertical position of the electrodes after implantation. A variety of electrodes were used for these experiments, including A5x12/16-buz/lin-5mm-100-200-160(64ch), ASSY-156-P1 (64ch) A4x32- Poly2-5mm-23s-200-177(128ch). A stainless-steel wire connected to a thin wire (California wires) was inserted over the cerebellum as the ground (GND) and cemented in place using C&B Metabond (Parkell). A layer of Metabond was applied to the full of the skull and a customized plastic head-stage with a camera holder (Extended Data Fig. 1) was attached to the skull using Metabond and dental acrylic, over which four flaps of copper mesh were attached to cover the implant. The probe was then inserted right above the right hemisphere in dorsal CA1 (AP = −1.9 mm, ML = 1.6 mm from Bregma and 0.9 mm from the surface of the brain); aided by the micromanipulators. Once the probe had been inserted and drives cemented to the skull, craniotomies were sealed with artificial dura-gel. For animals used for optogenetics (see optogenetics manipulations), an optic fiber (200 μm) was attached under microscope guidance to one of the shanks of the silicon probe and implanted in one hemisphere; in the contralateral hemisphere, a second optic fiber was implanted over the CA1 and cemented to the skull. Finally, the four flaps of copper mesh were bent upwards and soldered between them to provide stability to the implant. The ground wire from the cerebellum was connected to the ground wires of the probe and all together to the copper mesh. Post-operative care included administration of ketoprofen subcutaneously for 3 days. The mouse was allowed to fully recover in its home-cage over a heating pad. After recovery (~1 week), the probe was lowered gradually in 75–150-μm steps per day until the desired position was reached. We used physiological landmarks and characteristic LFP patterns19 as well as responses to optogenetic stimulation to identify the layers corresponding to the different hippocampal subregions.
Behavioral tasks
Before surgery, animals were accustomed to the different mazes (cheeseboard and T-maze) for 2-3 days. Mice were handled daily and accommodated to the experimenter, recording room, and cables for at least a week before the start of the experiments. One day before the beginning of tasks, animals were placed under water restriction. 0.5-1 mL water was provided daily after tasks to maintain their body weight above 80% ad libitum.
In the T-maze delayed alternation task (Extended Data Fig. 5a), mice (n = 5) were trained to run in a figure-8 maze (60.96-cm diameter), starting at the beginning of the center stem and having to alternate between left and right arms of the maze in each trial. A ~8-s delay was introduced at the beginning of each trial, during which the animal was confined at the center stem by automatic doors. Upon completion of a correct trial, a reward (30% sugar water) was provided at the end of the side arms. Animals ran two T-maze sessions per day (~20-40 trials for ~30 mins per session), interleaved with 2-h pre-task (PRE) and post-task (POST) sleep sessions.
In the cheeseboard task (79-cm diameter; Fig. 3)56, where the animals (n = 9) learned to find a goal well with hidden water reward. A trial started when animals left the start box, and was completed once the animal had retrieved the reward at the goal location (Fig. 3b). After each trial, the animals had to return to the start box to collect a small amount of food reward before the next trial began. The location of the goal well changed daily. Each training session was composed of 6 trials and followed by a 2-h POST sleep session. After the POST session, animal’s memory performance for the learned goal was assessed in a test session. Each test session contained a 3-min probe trial, where the reward was omitted, and subsequently 5 test trials with reward at the learned goal.
In a two-goal version of the cheeseboard task (Fig. 3f,g), animals (n = 4) learned a fixed goal location with hidden water reward (familiar goal) for 10 trials during the first 2 days. On the 3rd day, the same goal location was baited during the first 5 trials; the reward location was switched (without any cue) to a new location for the subsequent 4-5 trials (novel goal). Similar to the one-goal cheeseboard task (Fig. 3), animal’s memory performance was then assessed with a probe trial and 5 test trials with reward at the novel goal after a 2-h POST sleep session.
We also collected behavioral and electrophysiological data from 5 mice in the novel versus familiar environments (Fig. 4a; n = 2 mice from T-mazes, and 3 from cheeseboard mazes). For the T-maze sessions, animals performed a delayed alternation task, and were rewarded upon a completion of a correct trial at the reward well. For the cheeseboard open fields, animals performed random exploration without reward. The animals explored one maze in one room (i.e., familiar environment) for several days before the experiment. During the experimental days, the animals were first exposed to the familiar environment for one session (~30 mins), and then moved to a different room to explore a novel maze with a similar shape but a different layout to the familiar maze (Fig. 4a). 2-h rest sessions were recorded before (PRE) and after (POST) the novel-familiar experiences.
Optogenetics manipulations
In the main set of experiments, closed-loop SWR disruption was based on strong activation of the pyramidal cell population via optogenetics, following previously described methods19,100. For pupil-gated SWR disruption, a binary thresholding signal based on the real-time pupil size was used to enable a disruption window. Within this window, the closed-loop system triggered a stimulation pulse (5-10 mW, 10 ms) once a SWR was detected, resulting in a strong population spike and subsequent recruitment of inhibition that abolished ongoing SWR activity. In an additional cohort of mice (PV::ChR2 animals), strong and long-lasting (5-10 mW blue light, 50-100 ms) activation of parvalbumin positive (PV+) interneurons was delivered once a SWR was detected, resulting in a strong attenuation of neuronal firing and ongoing SWR activity (Extended Data Fig. 7h-m). The stimulation intensity was adjusted to an optimal regime before the experimental day, as previously described19. In the small-pupil SWR disruption condition, SWRs were disrupted when the pupil size detected by an online tracking algorithm was lower than a threshold (see online pupil detection; Fig. 3, Extended Data Fig. 6). In large-pupil SWR disruption condition, SWRs were disrupted when the pupil size was above the threshold. The threshold was derived from pupil dynamics during the PRE sleep session on the experimental day, and was adjusted to ensure a balanced number of SWRs disrupted in both conditions (Fig. 3c). All the optogenetic disruption was conducted during the 2-h POST sleep session after the cheeseboard training session (Fig. 3b,f).
To quantify the performance of our closed-loop detection, a manual scoring of SWR detection was employed during randomly selected 10-min segments in three sessions from three different animals (Extended Data Fig. 6b,c). The same scoring was performed during both SWRpupilS and SWRpupilL disruption conditions. Briefly, LFP traces from the channels used for ripple and sharp-wave detection, respectively, were visualized using Neuroscope2, with pupil states marked by a pupil size-triggered digital input signal extracted from the online pupil video tracking. The LFP traces around each stimulation pulse were visually inspected and scored as true positive or false positive. Each event of actual optogenetic stimulations was visualized and examined individually. In addition, SWRs occurring within the small or large pupil states, as defined by the digital input signal, were also examined and counted for the quantification. A false positive was defined as an online detected SWR that, upon post hoc evaluation, was not a true event. A false negative was defined as a SWR that, upon post hoc evaluation, was a true event but it was not disrupted during the experiment.
SWR generation (Fig. 5e,f) was conducted as previously described19. Briefly, ~60-ms, low-intensity (1-2 mW) trapezoid-shaped, blue light pulses were delivered at a rate of 0.3 Hz to activate ChR2, while animals rested in their home cage. Before the experimental day, the intensity was manually adjusted during a test session in the home cage by gradually increasing light power until a SWR was produced.
Behavior and pupil tracking
During the tasks, the position of the mouse was tracked with an overhead camera (Basler acA720-520uc USB 3.0) at 30 Hz, and later extracted using DeepLabCut (DLC)39. For pupil tracking, a pupil recording system for freely moving mice was built and customized based on previously described methods36. The pupil was illuminated by an LED mounted in the head implant, positioned just above the mouse eye and passed through a near infrared (NIR) dichroic filter (FM01, Thorlab; Fig, 1a, Extended Data Fig. 1). The video was captured using a NIR Raspberry Pi camera module (OV5647, Arducam) at a frame rate of 30 Hz with a resolution of 640 x 480 pixels. To accommodate both the pupil recording modules and electrophysiological implants, a customized plastic head-stage was developed (Extended Data Fig. 1). The system was synchronized with Intan electrophysiological recordings (see Recording system and preprocessing of data; Extended Data Figs. 1 and 6) through TTL pulses. DLC was later used for offline tracking of the pupil. In order to maximize the amount of time that mice had their eyes open during sleep, the sleep sessions were recorded in the homecage, with the cage lid open under complete dark conditions during a relatively short time (~2 hrs). For each animal, the signal to noise ratio for pupil detection during sleep was optimized by adjusting software and environmental conditions to facilitate pupil detection even with minimum open of their eyes.
Recording system and preprocessing of data
An Intan RHD2000 interface board or Intan Recording Controller was used for electrophysiological recordings. The sampling rate was set at 20 kHz. Both amplification and digitization were done in the head stage (Intan Technologies). Data were visualized online during recording using the Intan software and Neuroscope (Neurosuite). LFP signals were down-sampled at 1250 Hz for subsequent analysis.
Tissue processing and immunohistochemistry
After experiments were terminated, mice were deeply anesthetized and kept under high-flow (4-5%) isoflurane anesthesia. They were then perfused transcardially with 0.9% phosphate buffer saline (PBS) solution followed by 4% paraformaldehyde (PFA) solution. Brains were kept in PFA for 24 hours and if necessary, in PBS afterwards until further processing. Brains were then sectioned into 70-μm thick slices (Leica Vibratome, 2000). Finally, sections were washed and mounted on glass slides with fluorescence medium (Fluoroshield with DAPI – F6057, Sigma, USA). Immunostained slices were examined and histological images were acquired with a Zeiss confocal microscope.
Quantification and statistical analyses
Online pupil detection
For online tracking, pupil video captured by the camera was streamed in real time from a Raspberry Pi 4 to a host PC via an ethernet cable (Extended Data Fig. 6). Online tracking was conducted using the Open Computer Vision Library101. Briefly, each frame captured by the camera was first converted into a black-white binary image based on the intensity of individual pixels. Following this, the edge of the pupil was identified using a contour detection method, which involves fitting a circle to the detected edge. The size of the pupil was then determined by calculating the area of this circle. To enhance tracking accuracy and reliability, a Python API was developed to enable online monitoring of tracking quality and real-time manual adjustments and optimization. The online tracking system was interfaced with the electrophysiological recording and optogenetic closed-loop systems through digital pulses to gate SWR disruption (see optogenetics manipulations).
Quantifications of pupil tracking quality
The raw pupil diameter from DLC and online detection ( and ) was first interpolated using piecewise cubic interpolation to pad missing values (periods with missing values longer than 1s were not padded for an accurate estimation of eye closed time; see below). The outliers were further detected and removed using a moving window method (MATLAB function isoutlier with movmean = 5000 at 30 Hz sampling rate). Same procedures were used for eye tracking to normalize the pupil diameter. The quality of online pupil tracking was measured as r-squared score (i.e., coefficient of determination) compared to DLC as follows:
where mean squared error (MSE) was calculated as , and residual sum of squares (RSS) was computed as (Extended Data Fig. 1g). Eye-closed time was determined as the periods during which DLC lost pupil tracking points (with likelihood < 0.9) for more than 5 seconds (Extended Data Fig. 1h).
To further quantify the performance of the offline DLC and online tracking algorithms, we obtained ground truth data by asking three different researchers to manually and independently define pupil boundary for each image frame (Extended Data Fig. 1e,f). To ensure that the selected frames covered a wide range of visual features and avoid sampling redundancy, we used k-means clustering to select 25 random frames (each with approximately distinct visual appearance) of each randomly selected sleep session in n = 4 animals. These three researchers were only presented with the raw image without any markers. We then compared their manual scorings by computing the correlation between the assessments of the three independent researchers and further compared these to the original DLC tracking and the online tracking results using r-squared score (i.e., coefficient of determination).
Spike sorting and single unit classification
Spike sorting was performed semi-automatically using KiloSort102 (https://github.com/cortex-lab/KiloSort), followed by manual curation using the software Phy (https://github.com/kwikteam/phy)and custom designed plugins (https://github.com/petersenpeter/phy-plugins) to obtain well-isolated single units. Cluster quality was assessed by manual inspection of waveforms and auto-correlograms, and by the isolation distance metrics. Multi-units, noise clusters, or poorly isolated units were discarded from further analysis. Well isolated units were classified into putative cell types using the MATLAB package, Cell Explorer (https://github.com/petersenpeter/CellExplorer)103. Spiking features such as auto-correlogram (ACG; Extended Data Fig. 10c), spike waveform, and putative monosynaptic connections derived from short-term cross-correlograms (CCGs; Fig. 5c, Extended Data Fig. 10b; see also monosynaptic connection analyses), were used to characterize and classify well-isolated units. Three cell types were assigned: putative pyramidal cells, narrow waveform interneurons, and wide waveform interneurons. The two key metrics used for this separation were burst index and trough-to-peak latency. Burst index was determined by calculating the average number of spikes in the 3-5 ms bins of the spike ACG divided by the average number of spikes in the 200-300 ms bins. To calculate the trough-to-peak latency, the average waveforms were taken from the recording site with the maximum amplitude for the averaged waveforms of a given unit. For further quantifications, well-isolated cells with at least 100 spikes in a given session were included in the analyses. Only putative pyramidal cells were used for further analysis, unless otherwise specified.
SWR, delta-wave, and spindle detection
For SWR detection, the wide-band signal from a CA1 pyramidal layer channel was filtered (difference-of-Gaussians; zero-lag, linear phase FIR), and instantaneous power was calculated by clipping at 4 SDs, rectified, and lowpass filtered19,60,69. The low-pass filter cut-off was at a frequency corresponding to π cycles of the mean band-pass (for 80-250 Hz band-pass, the low-pass was 55 Hz). Subsequently, the power of the non-clipped signal was computed, and all events exceeding 4 SDs from the mean were detected. The events were then expanded until the non-clipped power fell below 1 SD. Sharp waves were detected separately using LFP from a CA1 str. radiatum channel, filtered with band-pass filter boundaries (5-40 Hz). LFP events of a minimum duration of 20 ms and a maximum of 400 ms exceeding 2.5 SD of the background signal were included as SWRs. For each SWR, the maximum of the envelope from the Hilbert transform of the filtered LFP signal in the ripple band was defined as “ripple amplitude”. Ripple duration was calculated as the difference between stop and start times, and the instantaneous ripple frequency was calculated by computing the analytical signal of the ripple-band filtered LFP using the Hilbert transform, unwrapping the phase angles, applying median filtering and taking the difference between samples nearest the peak power bin of the ripple and dividing by 2 π104.
Delta waves were detected based on a previously described method55 (Extended Data Fig. 4m-o, Extended Data Fig. 3d,e). Briefly, the LFP signal from a cortical recording channel above the hippocampus was filtered (< 6 Hz) and z-scored. Sessions without a cortical channel were excluded from this analysis. Delta waves were further identified based on detection of both large positive deflections in the cortical LFP, and concurrent decreases in MUA activity. LFP events of a minimum duration of 150 ms and a maximum of 500 ms were included as delta waves. For each delta wave, the difference between its peak and trough power was defined as “delta amplitude”.
To detect spindles (Extended Data Fig. 4c,m-o; Extended Data Fig. 3d,e), the cortical LFP was band-pass filtered (9-17 Hz) and z-scored (sessions without a cortical channel were excluded from this analysis). The envelope of the Hilbert transform was then smoothed using a 100-ms Gaussian window. Spindles were detected as epochs where the envelope remained above 2.5 SDs for more than 0.5 s, with a peak > 5 SDs. Events separated by less than 0.4 s were merged, and combined events lasting more than 3.5 s were discarded105. For each spindle, the z-scored envelope maximum was defined as “spindle amplitude”.
Ripple burst detection
After detecting SWRs, we detected ripple bursts as previously described67. The time lags between the onsets of ripple events were computed. Singlets (Extended Data Fig. 10d) were defined as SWR events that are temporally separated by ≥ 200 ms to adjacent SWR events, while the number of adjacent SWRs (< 200 ms) was determined and these adjacent events were combined as a single ripple-burst event. The interval between the onset of the first ripple event and the offset of the last event within a ripple burst was defined as the duration of the ripple-burst event (Extended Data Fig. 10e). The proportions of ripple bursts versus singlets were compared across different pupil-size terciles (Extended Data Fig. 10e).
Sleep and brain state classification
Broadband LFP (i.e., slope of power spectral density), narrow-band theta frequency LFP, and estimated electromyogram (EMG) were used as input into the algorithm for estimating brain states as previously described24,40 (Extended Data Figs. 2c and 3a). Briefly, spectrograms were computed from broadband LFPs using a fast Fourier transform with 10 s and sliding windows of 1 s. PCA were then computed after a -transform. The first component reflected power in the low (< 20Hz) frequency range, with oppositely weighted power at higher (> 32 Hz) frequencies. Theta dominance was quantified as the ratio of powers in the 5-10 Hz and 2-16 Hz frequency bands. EMG was estimated as the zero-lag correlation between 300-600 Hz filtered signals between recording sites. Soft sticky thresholds on these metrics were used to identify sleep states. High LFP principal component and the low EMG were considered non-rapid eye movement (NREM) sleep, the high theta and low EMG were considered REM sleep, and the remaining times were taken as WAKE. Accelerometer fluctuations (i.e., a signal that does not depend on LFPs) extracted from the preamplifier (Analog Devices ADXL335 3-axis accelerometer) were used as an alternative estimate of movement to validate analyses of neural and pupil dynamics correlation with EMG.
From a rest session in which a clear bimodality of EMG distributions was observed (n = 9 sessions from 4 mice), microarousals (MAs) were further detected during NREM sleep based on the estimated EMG signal as epochs where the normalized EMG (range from 0-1) remained above 0.45 for more than 0.5 s, with a peak > 0.6. EMG events of a minimum duration of 0.5 s and a maximum of 12 s were included as MAs90,106 (Extended Data Fig. 3). Small-irregular activity (SIA) sleep states, during which hippocampal neural activity becomes highly desynchronized with low-amplitude LFP48, was also estimated using a previously established method49 (Extended Data Figs. 3 and 5j). To detect SIA (i.e., periods of low LFP power activity < 50 Hz), CA1 LFP was squared and smoothed using a 300-ms Gaussian window. The square root of the smoothed signal was then z-scored. The SIA threshold was defined as the bimodal dip of in the LFP distribution, and SIA periods were defined as NREM periods in which the LFP signal was below the threshold.
Structure Index
Our method for analyzing structural relationships of pupil sizes with brain states or SWRs starts by extracting sleep LFP and SWR features (Fig. 1). We used broadband LFP (i.e., slope of power spectral density), narrow-band theta (5-10 Hz), delta (1-4 Hz), ripple (80-250 Hz), sharp-wave (2-50 Hz) frequency LFPs, and estimated EMG from LFPs (see sleep states classification) as high-dimensional features for brain state characterization. For SWR features, raw LFP signals from the CA1 pyramidal layer was down-sampled at 1250 Hz, filtered at the ripple (> 80 Hz) band, and cut ±25-ms windows around the peak of detected SWRs (rounded to 63 points) to build the high-dimensional space, as previously described45. We then used the structure index (SI; https://github.com/PridaLab/structure_index)41 to quantify the amount of structure of pupil sizes presents over the high-dimensional data cloud. Given the response profile of the pupil size relative to SWR onset (Extended Data Fig. 4a), the averaged pupil size in the 30-s window after SWR onset were used as the pupil-size label for that SWR. To visualize the high-dimensional point cloud for sleep LFP features and SWR waveform features, we reduced the dimensions using unsupervised (pupil-size labels not used) Uniform Manifold Approximation and Projection (UMAP; https://www.mathworks.com/matlabcentral/fileexchange/71902)45,107,108. However, note that the SIs were calculated in the original high-dimensional space.
Spatial fields and linearization
Spatial fields (Extended Data Fig. 5a-c) were calculated only during locomotor periods (> 2 cm/s) at positions with sufficient occupancy (> 20 ms). 2D occupancy-normalized rate map (Extended Data Fig. 5a) were constructed using spike counts and occupancies with 150 x 150 spatial bins, smoothed with a 2D Gaussian kernel (SD = 2). To construct the 1D linearized rate maps on the 2 trajectory types in a T-maze (left vs. right; Extended Data Fig. 5a-c), animals’ linear positions were first estimated by projecting the actual 2D positions onto pre-defined idealized paths along the track, and further classified as belonging to 1 of the 2 trajectory types16,18. The linearized rate maps were then calculated with 100 equally spaced bins of the linear positions and smoothed with a 1D Gaussian (SD = 1).
Reactivation strength and cell assembly analyses
For cell assembly detection (Extended Data Fig. 9f-h, Fig. 4; 1 out of 5 T-maze animals without single-unit recording is excluded from this analysis), we used an unsupervised statistical method based on a principal component analysis (PCA) followed by independent component analysis (ICA), as previously described7,18,19,55,109. First, spike trains for each neuron were binned (50-ms bin) for the whole session. During the locomotor periods of the task (> 2 cm/s), the matrix of firing correlation coefficients for all pairs of neurons was constructed, and assemblies were determined based on their principal components with the eigenvalues exceed the threshold for random firing correlations (using the Marčenko-Pastur law). Next, ICA (fast-ICA algorithm) was applied to determine the vector of weights with which neuron’s firing contributes to each assembly (Fig. 4b). A given cell was considered a member of an assembly if its weight exceeded the mean weight of the assembly by 3 SDs (Extended Data Fig. 9f-h)7,19. The strength of the -th assembly’s re/activation for a given time bin was computed as:
where is the activity matrix of the z-scored firing rate of each unit, and is the outer product of the component ’s weights with the diagonal set to zero. Reactivation strength (RS) for a given SWR was calculated as the mean of during that event (Extended Data Fig. 5e, Fig. 4). Cell assemblies in novel and familiar environments were detected separately based on the spike trains during locomotion periods in the familiar and novel behavioral session, respectively (Fig. 4b-e). To further quantify the specific contribution of novel and familiar experiences to post-experience sleep reactivation (Fig. 4e), we normalized RS during POST sleep by the mean RS in PRE sleep.
To classify cell assemblies into “rigid” and “plastic” (Fig. 4f,g), we considered only cell assemblies with a significant increase in RS during POST SWRs (0 to 100 ms after SWR onset) compared to baseline (−500 to −100 ms relative to SWR onset; with p < 0.05, rank-sum paired test). For these assemblies, SWR-associated RS of each assembly was calculated as the mean RS within a 100-ms window after SWR onset across all SWRs in PRE and POST sleep. Rigid assemblies were further defined as those that did not increase their SWR-associated reactivation strength after learning (POST sleep) compared to PRE sleep, while plastic assemblies were defined as those that increased after learning compared to PRE sleep.
Replay sequence detection
Detection of replay sequences during SWRs was based on previously described methods50,110 (2 out 5 T-maze animals without high-density probes are excluded from this analysis). In brief, the high synchrony events (HSEs) during immobility period (< 1 cm/s) were first detected as previously reported111. To detect HSEs, the combined activity of all pyramidal spikes was binned into 1-ms bins and smoothed with a Gaussian kernel (SD = 15 ms), to produce population firing rate curve over time. HSEs were initially detected as contiguous periods when the population firing rate stayed above 3 SDs of the mean, and further refined as times around the initially detected events during which the firing rate exceeded the mean. Only HSEs with a duration ≥ 50 ms were included for further replay analysis. Candidate replay events were defined as the HSEs during which ≥ 5 place cells fired and overlapped with at least one SWR18. Each candidate event was then divided into 10-ms non-overlapping bins. For each time bin, a memoryless Bayesian decoder was built for the 2 trajectory types in a T-maze (left vs. right; Extended Data Fig. 5a-c) to estimate the probability of animals’ position given the observed spikes (Bayesian reconstruction; or posterior probability matrix):
where is the set of all linear positions on the track for the 2 trajectory types (i.e., , left or right), and we assumed a uniform prior probability over and . Assuming that all cells active in a sequence fired independently and followed a Poisson process:
vwhere is the duration of the time window (), and is a normalization constant such that ( is the -th position bin, is the total length of the track, and is the -th trajectory type; or 2, representing left or right trajectory, respectively). To identify sequential structure of a decoded HSE, a weighted correlation52 was calculated for the posterior probability matrix of each trajectory, and the significance was assessed by circularly shifting the time-bins of the posterior probability matrix (n = 1000 times). A sequence was considered significant if its weighted correlation exceeded the 97.5th percentile or was below the 2.5th percentile (for reverse sequences) of the shuffled distributions (i.e., p < 0.025). If more than one trajectory type were significant, the trajectory with the lowest p-value was considered as the replayed trajectory, and the replay probability was computed as (1- p).
To further visualize dynamics of the slow-oscillatory pupil signal and fast-timescale sporadic replay events (Fig. 2a), the averaged replay probability over time was adaptively estimated by treating each SWR as a pulse function and smoothed using a Gaussian kernel (SD = 2.5 sec; psth function from the Chronux toolbox), while the continuous pupil diameter was smoothed using local linear regression with a 2.5-s moving window (locsmooth function from the Chronux toolbox).
Rank-order correlation
To determine the similarity of neuronal sequences during POST sleep and PRE sleep, we calculated their rank-order correlation as previously described60,112 (Fig. 4h). Rank order in a given SWR was defined as the normalized temporal position (from 0 to 1) of a neuron in the sequence of all cells that participated in that SWR. The ranks were averaged for all events, in which a cell participated, to obtain a mean rank order. The correlation between the PRE and POST rank orders was then calculated.
Generalized Linear Models
To determine the contribution of individual SWR variables (Fig. 2d; ripple amplitude, RS, replay probability) for predicting pupil sizes, we calculated the prediction gain for the targeted variable in the generalized linear models (GLMs). We constructed GLMs with an identity link function to predict pupil size using ripple amplitude, RS, and replay probability. To measure the prediction accuracy, we performed five-fold cross-validation by randomly partitioning SWRs into five equally sized sets. For each fold, we used four of five folds to train the GLM and the remaining fold to test. The prediction error was defined as the mean absolute difference between the predicted and the real pupil size in the test set. For the same test fold, we performed 100 random shuffles of the pupil-size label for each SWR, and measured the prediction error of the shuffled dataset. The prediction gain was defined as the shuffled prediction error divided by the real prediction error, and then z-scored as follows54,55:
where is the prediction gain of the real data, and and is the mean and SD of the shuffled distribution respectively. To further evaluate the contribution of individual variables for the prediction, we constructed an “ablated model” with the coefficient zeroed for the target variable53. The prediction gain () was then computed for the ablated model and compared to the “full model” (Fig. 2d).
Event-pupil correlation
The cross-correlation of SWR rates and pupil sizes (Extended Data Fig. 4b) were calculated after smoothing the pupil-diameter trace using local linear regression (locsmooth function from the Chronux toolbox), and the SWR rate with a Gaussian kernel (SD = 1; psth function from the Chronux toolbox; http://chronux.org/). The smoothed curves were then z-scored by subtracting the mean from each trace and dividing by the product of the SDs separately in each brain state (WAKE or NREM)81. For event-pupil correlation (e.g., ripple amplitude and pupil size in Extended Data Fig. 4l,n,o), the feature (e.g., ripple amplitude) and pupil size were first z-scored across NREM (or WAKE) periods within a rest session. Spearman correlation coefficient was then calculated for a given feature and the corresponding pupil-size label (see structure index) across all SWR events.
Cheeseboard task performance
Animals’ performance of the cheeseboard task (Fig. 3, Extended Data Figs. 7-9) was measured as latency and path length of each trial56,113. Latency and path length for each trial was defined as the interval and the distance traveled between the departure from the home box and the retrieval of the water reward at the goal location, respectively. For the two-goal version (Fig. 3f-h), the latency and path length for the novel goal was defined as the interval and the distance traveled between the departure from the familiar goal location and the retrieval of the water reward at the novel goal location. Given that different animals had different performance asymptotes (Fig. 3d), a performance index was also calculated as (Extended Data Figs. 7g):
where is the latency of the 1st testing trial, and is for the last training trial.
To measure head direction of the mice in the cheeseboard task (Fig. 3, Extended Data Fig. 8), we computed the azimuth heading-direction () of the mice during trajectory running as follows:
where and are changes in the animal’s head position in the azimuthal plane, and is the imaginary unit. The goal-direction () was further defined as the angle between the heading-direction () and the direction of the vector () connecting the position of the animal’s head (,) with the position of the goal (,)61:
The degree of the concentration of goal-direction distributions was used as an estimate of how well the mice remembered “where to look”, with a sharp distribution associating with a straight path to the goal. This is measured by a circular concentration coefficient κ (κ = 0 indicates uniform circular distribution; Extended Data Fig. 8b).
Current source density analysis
To address the contribution of the different upstream inputs into the LFP recorded in the CA1 subregion, we employed current source density (CSD) analysis65,114 (Fig. 5a). First, event-triggered LFP signals were isolated for the small- and large-pupil substates separately. For each of them, CSD analyses were applied to the profile of the CA1 LFPs. The different layers (i.e., stratum oriens – SO-, radiatum – SR- and lacunosum-moleculare -SLM-) associated with the main inputs into CA1 (i.e., CA2, CA3 and entorhinal inputs respectively) were identified by the voltage reversal of LFP signals and depth profile of currents sources and sinks (from CSD analysis), assuming current sources as positive CSD values and current sinks as negative CSD values as described previously115. The strength of each input was estimated as the power of the CSD in their corresponding layers. Specifically, the CSD value for each input (SO, SR or SLM) was calculated as the absolute magnitude of the corresponding sinks in each layer. Then, a ratio was calculated as the CSD magnitude during SWRs as:
Monosynaptic connection analyses
Cross-correlograms (CCGs) between pairs of PYR and INT neurons were constructed (Fig. 5c, Extended Data Figs. 10b; 0.8-ms bins), and only connections from PYR to INT were considered. For visualization, CCGs were rate normalized (i.e., counts/number of reference spikes/Δt) in units of spikes per sec (Fig. 5c, Extended Data Fig. 10b). Further, we identified putative monosynaptic connections of PYR-INT cell pairs by short-lag (2-3 ms) peaks in their CCGs as previously described73. The peak in the CCG needed to exceed that from the slowly co-modulated baseline, and the peak in the causal direction (positive lags) needed to be significantly larger than the largest peak in the anti-causal direction (negative lags) for further analysis73. To assess the effective strength of PYR-INT synaptic coupling, we calculated spike transmission probability of the PYR-INT cell pairs that exhibited monosynaptic connectivity. To calculate spike transmission probability, the lower frequency baseline was estimated as previously described73, and the spike transmission probability after presynaptic spikes using raw CCG normalized by the number of reference spikes was defined as:
Only monosynaptically connected cell pairs with a transmission probability > 0.1 were considered116, and their spike transmission probabilities were further calculated and compared using the CCGs constructed from spikes occurring at different pupil-size terciles (Fig. 5c,d).
Statistical Analyses
Data analysis was performed using custom routines in Python, MATLAB (MathWorks) and GraphPad Prism 9 (GraphPad Software). No specific analysis was used to estimate minimal population sample or group size, but the number of animals, sessions and recorded cells were larger or similar to those employed in previous related works19,30,42,77. Unless otherwise noted, non-parametric two-tailed Wilcoxon rank-sum or Wilcoxon signed-rank test was used for unpaired and paired data comparisons respectively, and ANOVA was used for multiple comparisons. P < 0.05 was considered the cutoff for statistical significance, which is indicated by asterisks (*p<0.05, **p<0.01, ***p<0.001, and ****p<0.0001). Error bars show SEMs, and boxplots show median, 75th (box), and 90th (whiskers) percentile, unless indicated otherwise. For boxplots, points below the 10th percentile and above the 90th percentile are defined as outliers; outliers are not displayed in the plots but included in statistical analysis. Due to experimental constraints of optogenetic experiments (e.g., animal removing fiber attachment that can damage the implant, light remaining on for too long due to failure or artifacts, and etc.), experimenters were not blind to these manipulations.
Extended Data
Extended Data Fig. 1|. Online pupil tracking in combination with closed-loop optogenetics and high-density electrophysiology.

a, Experimental scheme for high-density electrophysiology recordings in combination with closed-loop optogenetics and pupillometry. Pupil images are captured by a pupil-tracking camera connected to a Raspberry Pi microcontroller, which then sends digital pulses to the Intan USB Interface Board for synchronization. Meanwhile, electrophysiological signals from high-density silicon probes are recorded by the Intan Board, and then transmitted to the Spike2 system for closed-loop optogenetic SWR disruption. b-c, Components for pupil-electrophysiology dual recording headstage. b, Top view of the design. c, Customized headstage for accommodating both silicon probes and pupil camera. d, Hot mirror (left) has a dichroic filter with transmission rates greater than 85% from 450 to 645 nm and reflection rates above 90% from 750 to 1200 nm, enabling reflection of pupil illuminated by the NIR LED (940 nm; right). e-h, Online pupil tracking performance. e, High consistency of manual pupil scoring among the 3 researchers (r = 0.996 for Researcher 1 vs. 2, r = 0.979 for Researcher 1 vs. 3, and r = 0.978 for Researcher 2 vs 3, respectively; see Methods). Each dot is for one image frame (25 random frames per session, 1 session per animal, n = 4 mice). g, Performance of offline DLC and online algorithms using manual tracking as the “ground truth”. Performance was quantified as r-squared score (i.e., coefficient of determination; see Methods; r-squared = 0.953 and 0.950 for manual vs. online and DLC tracking, respectively; n.s., p = 0.15, rank-sum test; each paired line for one animal). h, Direct comparison between DLC and online tracking performance (**p = 0.002, rank-sum test compared to 0). Each circle for one session. i, Percentage of eye-closed periods during 2-h rest sessions (left column for sessions with electrophysiological recordings only, right column for sessions with electrophysiological recording and optogenetic SWR disruption). horizontal bars: median values. Note that only a few sessions (n = 3 out of 33) have a percentage larger than 5%.
Extended Data Fig. 2|. Pupil dynamics in different brain states and their coherence with replay dynamics.

a, Distributions of pupil sizes in different sleep states (vertical line, median; ****p < 1e-16, Kolmogorov-Smirnov tests)37. b, Power spectral profiles for pupil dilation during undisturbed NREM episodes shown in Fig. 1b. c, 3D scatter plot showing the relationship of pupil sizes with theta (5-10 Hz) power, slope of power spectral density (PSD), and estimated EMG amplitude from LFP (EMG proxy; see Methods). d,e, Auto-correlogram (d) and power spectral profiles (e) of replay probability during NREM sleep. f, Coherence between the spectrum profiles of replay probability and pupil size. Note the peak at ~0.016 Hz (yellow arrowheads) shown in both pupil and replay signals. Same session as in Fig. 1b-d.
Extended Data Fig. 3|. Pupil-ripple dynamics over different phases of sleep periods.

a, Representative recordings showing the relationship between EMG proxy and head motion signal from the head-mounted accelerometer (i.e., acceleration) during a 2-hr sleep session. b, Representative recordings showing REM sleep transitions. LFP spectrogram (top), pupil size (middle), and EMG proxy (bottom) traces are shown. c, Pupil size around REM sleep transitions (vertical dash lines for onset and offset of REM sleep; n = 23 sessions from 5 animals). NREM to REM transitions were associated with pupil contraction, with prolonged reduction of pupil size preceding the transitions from NREM to REM and dilation from REM to NREM, in line with previous results37,46,90. However, the significant correlation between ripple amplitude and pupil size was observed during NREM both before (60s before REM onset; Pearson’s r = −0.065, ****p = 2.83e-14) and after (60s after REM offset; Pearson’s r = −0.096, ****p = 4.61e-22) REM episodes. d, Pupil size (left) and its correlation (right) with ripple delta and spindle amplitude across a sleep session (whole NREM time during a sleep session was equally divided into 3 parts; n = 21 sessions from 5 animals). Average pupil size (n.s., p = 0.37, Friedman test) and its correlation with ripple/ delta/ spindle amplitudes (all p’s > 0.05, z-test for correlation) did not change significantly. e, Within individual NREM episodes (a NREM episode was equally divided into 3 parts; n = 21 sessions from 5 animals), pupil size was significantly larger at the early phase, presumably owing, at least in part, to the transition from WAKE to sleep (left; ****p = 4.28e-8, **p = 0.0061, Friedman test with Dunn’s post hoc). Delta and spindle correlation with pupil size showed a small, but not significant, increase (z = −0.79 and p = 0.43 for delta waves, z = −1.13 and p = 0.26 for spindles, z-test for correlation). Error bars: sem.
Extended Data Fig. 4|. Relationship between pupil-ripple dynamics and different sleep patterns.

a, Averaged pupil size around SWRs during WAKE (yellow) and NREM sleep (pink; t = 0 for SWR onset; ****p’s < 1e-16 compared to the baseline, rank-sum tests). Black line, time-bin shuffled distribution. b, Cross-correlation between pupil sizes and SWR rates during WAKE (yellow) and NREM sleep (pink; ****p’s < 1e-16 compared to the baseline). c, Example recording showing pupil and ripple dynamics in relation to different sleep patterns. Orange shadings: microarousals (MAs); Blue shadings: SIA periods. Note that only some pupil size transitions coincided with a MA, in line with previous reports42,90,106. Right panels show SWR rate during 2-hr sleep sessions (top; median = 0.50 Hz) and enlarged view of two 30-s segments denoted on the left (green bars). d, Distribution of amplitude of EMG proxy in different sleep states (vertical line, median; ****p’s < 1e-16, Kolmogorov-Smirnov tests). WAKE was associated with the highest EMG power, whereas REM has the lowest EMG power (n = 9 sessions from 4 animals), in agreement with previous sleep studies24,46,90. e, Pupil was often dilated when EMG power was high (n = 9 sessions from 4 animals). f, Averaged pupil size around MAs during NREM sleep (****p < 1e-16 compared to the baseline; n = 9 sessions from 4 animals). g, Preserved pupil-ripple relationship during NREM after excluding MA periods (± 20 s around MAs; ****p < 1e-16, rank-sum test; n = 9 sessions from 4 animals). h, Averaged pupil size around SIA periods during NREM sleep (****p < 1e-16 compared to the baseline; n = 23 sessions from 5 animals). i, Cross-correlation between SIA states and SWR rates, in agreement with previous findings that SWRs rarely occurred during SIA48,49 (n = 23 sessions from 5 animals). j, Preserved pupil-ripple relationship during NREM after excluding SIA periods (****p < 1e-16 compared to the baseline; n = 23 sessions from 5 animals). k, Amplitude of ripples over pupil size sextiles (yellow and pink for WAKE and NREM sleep, respectively). Note the significant decreasing trend (****p < 1e-16 and = 1.23e-9 for NREM and WAKE, respectively, one-way ANOVA with post hoc test for linear trend; n = 23 sessions from 5 animals). l, Correlation of pupil size with ripple amplitude, ripple frequency and SWR-associated HSE duration (p = 9.06e-6****, 0.33e-5****, and 0.0084**, respectively, rank-sum test compared to 0; horizontal bars, median; each circle for one session; n = 23 sessions from 5 animals). m, Averaged pupil size around spindles during NREM sleep (****p < 1e-16 compared to the baseline, rank-sum test). n, Amplitude of spindles and delta waves over pupil size sextiles during NREM sleep (n.s., p = 0.94 and 0.15 for delta waves and spindles, respectively, one-way ANOVA with post hoc test for linear trend; n = 21 sessions from 5 animals). o, Correlation of delta-wave and spindle amplitude with pupil size (n.s., p = 0.76, 0.45, 0.47 and 0.053, from left to right, rank-sum test compared to 0; n = 21 sessions from 5 animals). Error bars: sem.
Extended Data Fig. 5|. Place-field properties and reactivation strength for the T-maze spatial memory task.

a, Left, schematic of the T-maze alternation task (see Methods). Right, two example place fields on the T-maze. b, Linearized place fields on the left (red) and right (blue) trajectory of the two example cells shown in a. c, Normalized rate maps on the linearized trajectories of all spatially-tuned cells used for replay decoding in Fig. 2a, sorted by peak location on the left (top) and right (bottom) trajectory. d, Replay probability over pupil size sextiles after matching MUA firing rates of replay events across sextiles (mean ± sem; 15 sessions from 3 animals; ****p = 1.92e-8, one-way ANOVA with post hoc test for linear trend). e, Reactivation strength over pupil size sextiles during NREM sleep (pink; ****p = 3.09e-13) and WAKE (yellow; ***p = 2.85e-4, one-way ANOVA with post hoc test for linear trend; 17 sessions from 4 animals; mean ± sem). f, Pyramidal cell (PYR) participation ratio during ripples showed a decrease within NREM (*p = 0.036, Kruskal-Wallis test with Dunn’s post hoc), consistent with previous findings47. g, Preserved correlation between pupil size and replay probability within NREM (p < 1e-3****, = 0.007**, = 0.001***, from left to right, permutation tests compared to 0), despite the change in PYR participation (f). h, Pupil size did not predict spindle (black) or delta amplitude (brown). i, Ripple amplitude (green) and replay probability (teal) could be significantly predicted by pupil size at the time of SWR onset (green and teal horizontal bars indicate significant time periods with p < 0.05, compared to label shuffled distributions). j, Pupil size remained predictive for replay probability after excluding the periods around SIA states (−10 s before SIA onset to 10 s after SIA offset). Data are shown as mean ± sem, and gray shading for the 95th percentile of shuffles in h-j.
Extended Data Fig. 6|. Closed-loop optogenetic disruption of SWRs contingent upon pupil substates.

a, Left, pupil video frame captured by the camera was streamed in real-time from a Raspberry Pi microcontroller (bottom, schematic illustrations of a mouse carrying head-mounted eye camera, high-density silicon probes and optical fibers). Middle, pupil image was then analyzed by a customized online tracking algorithm with binarization /thresholding and contour detection. A Python API was developed with online monitoring interfaces to enable real-time curation for optimization of tracking accuracy. The pupil size estimated by the algorithm was used to update the thresholds for NREM and WAKE states respectively. If the pupil size crossed the threshold (above or below for large versus small pupil conditions respectively), closed-loop optogenetic disruption of SWRs was triggered19,60. Right, physiological SWRs are identified by the co-occurrence of both sharp wave and ripple. SWRs that occurred while pupil size was below threshold were left intact. b, Percentages of true positive (TP), false negative (FN), false positive (FP) events during SWRpupils (blue bars) versus SWRpupilL (black bars) disruption from 3 mice (one example session per mice; see Methods). Numbers (N denoted on top) correspond to total event counts. c, False discovery rate and false negative rate are comparable for SWRpupilS (blue bars) versus SWRpupilL (black bars) disruption (n.s., p = 0.75 and 0.50, respectively, paired signed-rank test).
Extended Data Fig. 7|. Additional quantifications and control experiments of optogenetic SWR disruption for consolidation of a recent memory.

a, Example of a SWR disruption event. Top, a spontaneous SWR event (triangle, ripple onset). Bottom, disruption of a detected SWR event (blue shading, light stimulation pulse). b, A prolonged suppression of neuronal firing (mean ± sem) induced by the short stimulation pulse (blue shading)19,60 for SWRpupilS (left) and SWRpupilL (right) disruption (****both p’s < 1e-16, rank-sum tests, compared normal vs. disrupted MUA firing rate within the 0-100 ms window). Note that different cells recorded in different sessions contributed to mean firing rate difference for these two plots. c,d, Learning performance quantified as path length (i.e., distance traveled to the goal location) for SWRpupilS (left) and SWRpupilL (right) disruption. Data are shown as in Fig. 3d,e (*p = 0.031 and 0.047, n.s., p = 0.30 and 0.47, from left to right in d, paired signed-rank test). e, Animals’ running speed was not significantly different for SWRpupilS and SWRpupilL disruption (n.s., p = 0.93, one-way ANOVA compared SWRpupilS and SWRpupil disruption; n.s., p > 0.99, = 0.22, 0.71 and 0.20, from left to right, paired signed-rank test). f, Latency of probe and the 1st testing trial versus the last training trial for all SWR disruption during 2h rest versus no optogenetic disruption sessions (*p = 0.036 and 0.013, n.s., p = 0.47 and 0.063, one-tailed paired t-test). g, Memory impairment for SWRpupilS disruption cannot be explained by the percentage of SWRs disrupted (n.s., p(SWRpupilS) = 0.53, p(SWRpupilL) = 0.79, linear regression; ***p = 0.0002, compared performance index of SWRpupilS vs. SWRpupilL, rank-sum test). Each circle for one session (n = 8 for each condition; blue, SWRpupilS; black, SWRpupilL). h-m, Additional experiment using closed-loop CA1 PV interneuron stimulation (in PV::ChR2 mice) to suppress SWRs (n = 6 sessions for SWRpupilS (left) and SWRpupilL (right) disruption, respectively, 12 sessions from 2 animals in total). h, Fractions of SWRs disrupted were similar in the small and large pupil condition (p = 0.065, rank-sum test). i, Example of a SWR disruption event for PV activation experiments. j, Suppression of neuronal firing (mean ± sem) induced by PV activation using blue light pulses during SWRpupilS (top) and SWRpupil disruption (bottom; ****both p’s < 1e-16, rank-sum tests, compared normal vs. disrupted MUA firing rate within the 0-100 ms window). Two different pulse lengths (50 and 100 ms) were used, but results were consistent for the two pulse lengths. k,l, Learning performance quantified as latency (j) and path length (k) across trials. m,n, Memory performance was impaired for SWRpupilS, but not SWRpupilL, disruption (p = 0.031*, 0.031*, 0.31 and 0.56, from left to right, in l; p = 0.063, 0.031*, 0.22 and > 0.99, from left to right, in m). Error bars: sem.
Extended Data Fig. 8|. Quantification of goal-direction angle on the one-goal cheeseboard maze task with SWR disruption.

a, Examples of goal-direction distributions during SWRpupilS (top) and SWRpupilL (bottom) disruption sessions (same sessions shown in Fig. 3b). Goal-direction angle was defined as the azimuthal angle between the heading direction and the mouse-to-goal direction, as previously described61 (see Methods). During the first training trial of each day, when the animal did not know where the goal was, the goal-direction angle was widely distributed (i.e., low circular concentration; left column). In the last trial, after the animal had learned, the goal-direction angle showed a sharp distribution around 0 (second left column). Such wide distributions were shown after SWRpupilS, but not SWRpupilL, disruption (two right columns). b, For SWRpupilS disruption (top), goal-direction concentration of the probe and the first testing trial was significantly lower than that during the last training trial (*p = 0.016 and 0.023 for probe and 1st testing trial, respectively), and was similar to the first training trial (n.s., p = 0.20, paired signed-rank test). However, the distributions of goal-direction angles remained concentrated after SWRpupilL disruption (n.s., p = 0.81 and 0.81 for probe and 1st testing trial compared to the last training trial, respectively, paired signed-rank test).
Extended Data Fig. 9|. Additional controls for novel and familiar memory reactivation.

a,b, Additional controls for optogenetic SWR disruption in the familiar-novel goal cheeseboard task. a, Latency of the 1st testing trial versus the last training trial for the cohort without optogenetic disruption (n.s., p = 0.13 and 0.14, one-tailed paired t-test; probe trial was not presented to this cohort). b, Learning performance quantified as path length for the optogenetic disruption experiments shown in Fig. 3h (*p = 0.016 and 0.047, n.s., p = 0.69 and 0.47, from left to right, paired signed-rank test). c-e, Behavioral parameters during novel and familiar explorations shown in Fig. 4. Meaning running speed (c), proportion of running periods (d), and number of trials (T-maze only; e) are shown. Note that the proportions of running periods over the whole session were lower for T-maze sessions than Cheeseboard maze sessions, which could be due to animals taking more time at the reward wells and the inter-trial delay periods. In addition, although there was a small tendency for exploring more in the novel contexts, the differences across animals were not significant (p = 0.19, 0.19, and 0.13 for c-e, respectively, paired signed-rank test). f, Place-field similarity, measured as Pearson correlation coefficient of rate maps (r), for the pairs of neurons with high weights within the same assembly (assembly members; see Methods)7,19 versus other neuronal pairs (**p = 0.002, paired signed-rank test). g, Assembly member pairs have higher theta covariance in the same environment, in which they were detected, than that in the different environment (****p = 1.53e-5, rank-sum test compared to 0) and were significantly different from other neuronal pairs (****p = 1.53e-5, paired signed-rank test). h, Fraction of plastic assemblies was significantly larger in the novel environments than in the familiar ones (**p = 0.0039, paired signed-rank test; n = 50 rigid and 108 plastic, 38 rigid and 127 plastic cell assemblies in the familiar and novel environments, respectively).
Extended Data Fig. 10|. Additional quantifications of input and local circuit properties in small and large pupil substates.

a, Larger sharp-wave in the small pupil substates (****p < 1e-16, one-way ANOVA with post hoc test for linear trend). b, CCGs for an additional example pre-/post-synaptic PYR-INT pair during small, middle and large pupil substates. Data are shown as in Fig. 5b. c, Autocorrelations of the INT and PYR pairs shown in b (top two rows) and Fig. 5b (bottom two rows). d, Representative LFP traces from CA1 pyramidal layer (red) and stratum radiatum (rad; black), showing identified ripple bursts (yellow shading) and singlets (gray shadings)67. e, Ripple bursts had longer duration (left; ****p = 3.76e-7, one-way ANOVA with post hoc test for linear trend) and occurred more frequent (right; ****p < 1e-16, one-way ANOVA with Dunnett’s post hoc test, bootstrapped distributions are shown, n = 100 times) in the small pupil substates. f, INT firing rate during NREM episodes was higher in the small pupil substates (****p < 1e-16, one-way ANOVA with post hoc test for linear trend). g, From left to right, correlation of pupil size with firing rate difference between INTs and PYRs during NREM SWRs, ripple amplitude, INT firing rate, and PYR firing rate during NREM episodes (****p < 1e-16, rank-sum test compared to 0; bootstrapped distributions are shown, n = 100 times). Error bars: sem.
Acknowledgments
The authors thank members of the Oliva and Fernandez-Ruiz labs, Yuta Senzai and Jesse Goldberg for providing useful feedback on the manuscript.
Funding
This work was supported by NIH grant R00MH122582 and R01MH130367 (AO), NIH grant R00MH120343, 1DP2MH136496, Sloan Fellowship, Whitehall Research Grant and Klingenstein-Simons Fellowship (AFR), and Klarman Fellowship (WT).
Footnotes
Competing interests
The authors declare no competing interests.
Data availability
All data are available from the corresponding authors upon request. Source data are provided with this paper.
Code availability
Custom scripts used in this study can be downloaded from Github (https://github.com/ayalab1/neurocode) and (https://github.com/ayalab1/pupil_project).
References
- 1.Buzsáki G. Two-stage model of memory trace formation: a role for "noisy" brain states. Neuroscience 31, 551–570, doi: 10.1016/0306-4522(89)90423-5 (1989). [DOI] [PubMed] [Google Scholar]
- 2.Diekelmann S & Born J The memory function of sleep. Nat. Rev. Neurosci 11, 114–126, doi: 10.1038/nrn2762 (2010). [DOI] [PubMed] [Google Scholar]
- 3.Girardeau G, Benchenane K, Wiener SI, Buzsáki G & Zugaro MB Selective suppression of hippocampal ripples impairs spatial memory. Nat. Neurosci 12, 1222–1223, doi: 10.1038/nn.2384 (2009). [DOI] [PubMed] [Google Scholar]
- 4.Karlsson MP & Frank LM Awake replay of remote experiences in the hippocampus. Nat. Neurosci 12, 913–918, doi: 10.1038/nn.2344 (2009). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 5.Tayler KK, Tanaka KZ, Reijmers LG & Wiltgen BJ Reactivation of neural ensembles during the retrieval of recent and remote memory. Curr Biol 23, 99–106, doi: 10.1016/j.cub.2012.11.019 (2013). [DOI] [PubMed] [Google Scholar]
- 6.O'Neill J, Senior TJ, Allen K, Huxter JR & Csicsvari J Reactivation of experience-dependent cell assembly patterns in the hippocampus. Nat Neurosci 11, 209–215, doi: 10.1038/nn2037 (2008). [DOI] [PubMed] [Google Scholar]
- 7.van de Ven GM, Trouche S, McNamara CG, Allen K & Dupret D Hippocampal offline reactivation consolidates recently formed cell assembly patterns during sharp wave-ripples. Neuron 92, 968–974, doi: 10.1016/j.neuron.2016.10.020 (2016). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 8.Huelin Gorriz M, Takigawa M & Bendor D The role of experience in prioritizing hippocampal replay. Nat Commun 14, 8157, doi: 10.1038/s41467-023-43939-z (2023). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 9.McClelland JL, McNaughton BL & O'Reilly RC Why there are complementary learning systems in the hippocampus and neocortex: insights from the successes and failures of connectionist models of learning and memory. Psychological review 102, 419–457, doi: 10.1037/0033-295X.102.3.419 (1995). [DOI] [PubMed] [Google Scholar]
- 10.McCloskey M & Cohen NJ in The psychology of learning and motivation Vol. 24 (ed Bower GH) 109–165 (Academic Press, 1989). [Google Scholar]
- 11.McNaughton BL Cortical hierarchies, sleep, and the extraction of knowledge from memory. Artificial Intelligence 174, 205–214, doi: 10.1016/j.artint.2009.11.013 (2010). [DOI] [Google Scholar]
- 12.Saxena R, Shobe JL & McNaughton BL Learning in deep neural networks and brains with similarity-weighted interleaved learning. Proc Natl Acad Sci U S A 119, e2115229119, doi: 10.1073/pnas.2115229119 (2022). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 13.van de Ven GM, Siegelmann HT & Tolias AS Brain-inspired replay for continual learning with artificial neural networks. Nat Commun 11, 4069, doi: 10.1038/s41467-020-17866-2 (2020). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 14.Gonzalez OC, Sokolov Y, Krishnan GP, Delanois JE & Bazhenov M Can sleep protect memories from catastrophic forgetting? eLife 9, doi: 10.7554/eLife.51005 (2020). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 15.Frankland PW & Bontempi B The organization of recent and remote memories. Nat. Rev. Neurosci 6, 119–130, doi: 10.1038/nrn1607 (2005). [DOI] [PubMed] [Google Scholar]
- 16.Tang W, Shin JD, Frank LM & Jadhav SP Hippocampal-prefrontal reactivation during learning is stronger in awake compared with sleep states. J Neurosci 37, 11789–11805, doi: 10.1523/JNEUROSCI.2291-17.2017 (2017). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 17.Tang W & Jadhav SP Sharp-wave ripples as a signature of hippocampal-prefrontal reactivation for memory during sleep and waking states. Neurobiol Learn Mem 160, 11–20, doi: 10.1016/j.nlm.2018.01.002 (2019). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 18.Liu C, Todorova R, Tang W, Oliva A & Fernandez-Ruiz A Associative and predictive hippocampal codes support memory-guided behaviors. Science 382, eadi8237, doi: 10.1126/science.adi8237 (2023). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 19.Oliva A, Fernández-Ruiz A, Leroy F & Siegelbaum SA Hippocampal CA2 sharp-wave ripples reactivate and promote social memory. Nature 587, 264–269, doi: 10.1038/s41586-020-2758-y (2020). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 20.Wilson MA & McNaughton BL Reactivation of hippocampal ensemble memories during sleep. Science 265, 676–679, doi: 10.1126/science.8036517 (1994). [DOI] [PubMed] [Google Scholar]
- 21.Silva D, Feng T & Foster DJ Trajectory events across hippocampal place cells require previous experience. Nat Neurosci 18, 1772–1779, doi: 10.1038/nn.4151 (2015). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 22.Farooq U & Dragoi G Emergence of preconfigured and plastic time-compressed sequences in early postnatal development. Science 363, 168–173, doi: 10.1126/science.aav0502 (2019). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 23.Inostroza M & Born J Sleep for preserving and transforming episodic memory. Annu. Rev. Neurosci 36, 79–102, doi: 10.1146/annurev-neuro-062012-170429 (2013). [DOI] [PubMed] [Google Scholar]
- 24.Watson BO, Levenstein D, Greene JP, Gelinas JN & Buzsáki G Network homeostasis and state dynamics of neocortical sleep. Neuron 90, 839–852 (2016). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 25.Lacroix MM et al. Improved sleep scoring in mice reveals human-like stages. bioRxiv, doi: 10.1101/489005 (2018). [DOI] [Google Scholar]
- 26.Claverie D. et al. Sleep biomarkers for stress-induced vulnerability to depression. Sleep 46, doi: 10.1093/sleep/zsad068 (2023). [DOI] [PubMed] [Google Scholar]
- 27.Staresina BP et al. Hierarchical nesting of slow oscillations, spindles and ripples in the human hippocampus during sleep. Nat Neurosci 18, 1679–1686, doi: 10.1038/nn.4119 (2015). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 28.Lewis PA & Durrant SJ Overlapping memory replay during sleep builds cognitive schemata. Trends Cogn Sci 15, 343–351, doi: 10.1016/j.tics.2011.06.004 (2011). [DOI] [PubMed] [Google Scholar]
- 29.Schlichting ML & Preston AR Memory integration: neural mechanisms and implications for behavior. Current opinion in behavioral sciences 1, 1–8, doi: 10.1016/j.cobeha.2014.07.005 (2015). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 30.Barron HC et al. Neuronal Computation Underlying Inferential Reasoning in Humans and Mice. Cell 183, 228–243.e221, doi: 10.1016/j.cell.2020.08.035 (2020). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 31.Liu Y, Mattar MG, Behrens TEJ, Daw ND & Dolan RJ Experience replay is associated with efficient nonlocal learning. Science 372, doi: 10.1126/science.abf1357 (2021). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 32.Whittington JCR, McCaffary D, Bakermans JJW & Behrens TEJ How to build a cognitive map. Nat Neurosci 25, 1257–1272, doi: 10.1038/s41593-022-01153-y (2022). [DOI] [PubMed] [Google Scholar]
- 33.Cai DJ et al. A shared neural ensemble links distinct contextual memories encoded close in time. Nature 534, 115–118, doi: 10.1038/nature17955 (2016). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 34.McGinley MJ et al. Waking State: Rapid Variations Modulate Neural and Behavioral Responses. Neuron 87, 1143–1161, doi: 10.1016/j.neuron.2015.09.012 (2015). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 35.McCormick DA, Nestvogel DB & He BJ Neuromodulation of Brain State and Behavior. Annu Rev Neurosci 43, 391–415, doi: 10.1146/annurev-neuro-100219-105424 (2020). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 36.Meyer AF, Poort J, O'Keefe J, Sahani M & Linden JF A Head-Mounted Camera System Integrates Detailed Behavioral Monitoring with Multichannel Electrophysiology in Freely Moving Mice. Neuron 100, 46–60 e47, doi: 10.1016/j.neuron.2018.09.020 (2018). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 37.Yuzgec O, Prsa M, Zimmermann R & Huber D Pupil Size Coupling to Cortical States Protects the Stability of Deep Sleep via Parasympathetic Modulation. Curr Biol 28, 392–400 e393, doi: 10.1016/j.cub.2017.12.049 (2018). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 38.Senzai Y & Scanziani M A cognitive process occurring during sleep is revealed by rapid eye movements. Science 377, 999–1004, doi: 10.1126/science.abp8852 (2022). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 39.Nath T. et al. Using DeepLabCut for 3D markerless pose estimation across species and behaviors. Nature protocols 14, 2152–2176, doi: 10.1038/s41596-019-0176-0 (2019). [DOI] [PubMed] [Google Scholar]
- 40.Levenstein D, Buzsaki G & Rinzel J NREM sleep in the rodent neocortex and hippocampus reflects excitable dynamics. Nat Commun 10, 2478, doi: 10.1038/s41467-019-10327-5 (2019). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 41.Sebastian ER, Esparza J & L M. d. l. P. Quantifying the distribution of feature values over data represented in arbitrary dimensional spaces. PLoS Comput Biol 20, e1011768, doi: 10.1371/journal.pcbi.1011768 (2024). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 42.McGinley MJ, David SV & McCormick DA Cortical Membrane Potential Signature of Optimal States for Sensory Signal Detection. Neuron 87, 179–192, doi: 10.1016/j.neuron.2015.05.038 (2015). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 43.Nguyen ND et al. Cortical reactivations predict future sensory responses. Nature 625, 110–118, doi: 10.1038/s41586-023-06810-1 (2024). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 44.Farrell JS, Hwaun E, Dudok B & Soltesz I Neural and behavioural state switching during hippocampal dentate spikes. Nature, doi: 10.1038/s41586-024-07192-8 (2024). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 45.Sebastian ER et al. Topological analysis of sharp-wave ripple waveforms reveals input mechanisms behind feature variations. Nat Neurosci 26, 2171–2181, doi: 10.1038/s41593-023-01471-9 (2023). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 46.Kjaerby C. et al. Memory-enhancing properties of sleep depend on the oscillatory amplitude of norepinephrine. Nat Neurosci 25, 1059–1070, doi: 10.1038/s41593-022-01102-9 (2022). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 47.Grosmark AD, Mizuseki K, Pastalkova E, Diba K & Buzsáki G REM sleep reorganizes hippocampal excitability. Neuron 75, 1001–1007, doi: 10.1016/j.neuron.2012.08.015 (2012). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 48.Jarosiewicz B & Skaggs WE Level of arousal during the small irregular activity state in the rat hippocampal EEG. J Neurophysiol 91, 2649–2657, doi: 10.1152/jn.01082.2003 (2004). [DOI] [PubMed] [Google Scholar]
- 49.Kay K. et al. A hippocampal network for spatial coding during immobility and sleep. Nature 531, 185–190, doi: 10.1038/nature17144 (2016). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 50.Tang W, Shin JD & Jadhav SP Multiple time-scales of decision-making in the hippocampus and prefrontal cortex. eLife 10, doi: 10.7554/eLife.66227 (2021). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 51.Harvey RE, Robinson HL, Liu C, Oliva A & Fernandez-Ruiz A Hippocampo-cortical circuits for selective memory encoding, routing, and replay. Neuron 111, 2076–2090 e2079, doi: 10.1016/j.neuron.2023.04.015 (2023). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 52.Grosmark AD & Buzsáki G Diversity in neural firing dynamics supports both rigid and learned hippocampal sequences. Science 351, 1440–1443, doi: 10.1126/science.aad1935 (2016). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 53.Tseng SY, Chettih SN, Arlt C, Barroso-Luque R & Harvey CD Shared and specialized coding across posterior cortical areas for dynamic navigation decisions. Neuron 110, 2484–2502 e2416, doi: 10.1016/j.neuron.2022.05.012 (2022). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 54.Rothschild G, Eban E & Frank LM A cortical–hippocampal–cortical loop of information processing during memory consolidation. Nat. Neurosci 20, 251–259, doi: 10.1038/nn.4457 (2016). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 55.Todorova R & Zugaro M Isolated cortical computations during delta waves support memory consolidation. Science 366, 377–381, doi: 10.1126/science.aay0616 (2019). [DOI] [PubMed] [Google Scholar]
- 56.Gridchyn I, Schoenenberger P, O'Neill J & Csicsvari J Assembly-Specific Disruption of Hippocampal Replay Leads to Selective Memory Deficit. Neuron 106, 291–300 e296, doi: 10.1016/j.neuron.2020.01.021 (2020). [DOI] [PubMed] [Google Scholar]
- 57.Ego-Stengel V & Wilson MA Disruption of ripple-associated hippocampal activity during rest impairs spatial learning in the rat. Hippocampus 20, 1–10, doi: 10.1002/hipo.20707 (2010). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 58.Roux L, Hu B, Eichler R, Stark E & Buzsáki G Sharp wave ripples during learning stabilize the hippocampal spatial map. Nat. Neurosci 261, 1055, doi: 10.1038/nn.4543 (2017). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 59.Fernandez-Ruiz A. et al. Gamma rhythm communication between entorhinal cortex and dentate gyrus neuronal assemblies. Science 372, doi: 10.1126/science.abf3119 (2021). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 60.Fernandez-Ruiz A. et al. Long-duration hippocampal sharp wave ripples improve memory. Science 364, 1082–1086, doi: 10.1126/science.aax0758 (2019). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 61.Sarel A, Finkelstein A, Las L & Ulanovsky N Vectorial representation of spatial goals in the hippocampus of bats. Science 355, 176–180, doi: 10.1126/science.aak9589 (2017). [DOI] [PubMed] [Google Scholar]
- 62.Mocle AJ et al. Excitability mediates allocation of pre-configured ensembles to a hippocampal engram supporting contextual conditioned threat in mice. Neuron, doi: 10.1016/j.neuron.2024.02.007 (2024). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 63.Csicsvari J, Hirase H, Mamiya A & Buzsaki G Ensemble patterns of hippocampal CA3-CA1 neurons during sharp wave-associated population events. Neuron 28, 585–594 (2000). [DOI] [PubMed] [Google Scholar]
- 64.Davoudi H & Foster DJ Acute silencing of hippocampal CA3 reveals a dominant role in place field responses. Nat Neurosci 22, 337–342, doi: 10.1038/s41593-018-0321-z (2019). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 65.Fernandez-Ruiz A, Makarov VA, Benito N & Herreras O Schaffer-specific local field potentials reflect discrete excitatory events at gamma frequency that may fire postsynaptic hippocampal CA1 units. J Neurosci 32, 5165–5176, doi: 10.1523/JNEUROSCI.4499-11.2012 (2012). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 66.Ylinen A. et al. Sharp wave-associated high-frequency oscillation (200 Hz) in the intact hippocampus: network and intracellular mechanisms. Journal of Neuroscience 15, 30–46 (1995). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 67.Yamamoto J & Tonegawa S Direct medial entorhinal cortex input to hippocampal CA1 is crucial for extended quiet awake replay. Neuron 96, 217–227 e214, doi: 10.1016/j.neuron.2017.09.017 (2017). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 68.Oliva A, Fernandez-Ruiz A, Fermino de Oliveira E & Buzsaki G Origin of Gamma Frequency Power during Hippocampal Sharp-Wave Ripples. Cell reports 25, 1693–1700 e1694, doi: 10.1016/j.celrep.2018.10.066 (2018). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 69.Stark E. et al. Pyramidal cell-interneuron interactions underlie hippocampal ripple oscillations. Neuron 83, 467–480, doi: 10.1016/j.neuron.2014.06.023 (2014). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 70.Noguchi A, Huszar R, Morikawa S, Buzsaki G & Ikegaya Y Inhibition allocates spikes during hippocampal ripples. Nat Commun 13, 1280, doi: 10.1038/s41467-022-28890-9 (2022). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 71.Gan J, Weng SM, Pernia-Andrade AJ, Csicsvari J & Jonas P Phase-Locked Inhibition, but Not Excitation, Underlies Hippocampal Ripple Oscillations in Awake Mice In Vivo. Neuron 93, 308–314, doi: 10.1016/j.neuron.2016.12.018 (2017). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 72.Hulse BK, Moreaux LC, Lubenov EV & Siapas AG Membrane Potential Dynamics of CA1 Pyramidal Neurons during Hippocampal Ripples in Awake Mice. Neuron 89, 800–813, doi: 10.1016/j.neuron.2016.01.014 (2016). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 73.English DF et al. Pyramidal Cell-Interneuron Circuit Architecture and Dynamics in Hippocampal Networks. Neuron 96, 505–520 e507, doi: 10.1016/j.neuron.2017.09.033 (2017). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 74.Tang W & Jadhav SP Multiple-Timescale Representations of Space: Linking Memory to Navigation. Annu Rev Neurosci 45, 1–21, doi: 10.1146/annurev-neuro-111020-084824 (2022). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 75.Buzsaki G. Hippocampal sharp wave-ripple: A cognitive biomarker for episodic memory and planning. Hippocampus 25, 1073–1188, doi: 10.1002/hipo.22488 (2015). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 76.Nakashiba T, Buhl DL, McHugh TJ & Tonegawa S Hippocampal CA3 output is crucial for ripple-associated reactivation and consolidation of memory. Neuron. 62, 781–787 (2009). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 77.Zutshi I & Buzsaki G Hippocampal sharp-wave ripples and their spike assembly content are regulated by the medial entorhinal cortex. Curr Biol 33, 3648–3659 e3644, doi: 10.1016/j.cub.2023.07.039 (2023). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 78.Chenani A. et al. Hippocampal CA1 replay becomes less prominent but more rigid without inputs from medial entorhinal cortex. Nat Commun 10, 1341, doi: 10.1038/s41467-019-09280-0 (2019). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 79.Oliva A, Fernandez-Ruiz A, Buzsáki G & Berenyi A Role of hippocampal CA2 region in triggering sharp-wave ripples. Neuron 91, 1342–1355, doi: 10.1016/j.neuron.2016.08.008 (2016). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 80.He H, Wang Y & McHugh TJ Behavioral status modulates CA2 influence on hippocampal network dynamics. Hippocampus 33, 252–265, doi: 10.1002/hipo.23498 (2023). [DOI] [PubMed] [Google Scholar]
- 81.Reimer J. et al. Pupil fluctuations track rapid changes in adrenergic and cholinergic activity in cortex. Nat Commun 7, 13289, doi: 10.1038/ncomms13289 (2016). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 82.Pinto L. et al. Fast modulation of visual perception by basal forebrain cholinergic neurons. Nat Neurosci 16, 1857–1863, doi: 10.1038/nn.3552 (2013). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 83.Cazettes F, Reato D, Morais JP, Renart A & Mainen ZF Phasic Activation of Dorsal Raphe Serotonergic Neurons Increases Pupil Size. Curr Biol 31, 192–197 e194, doi: 10.1016/j.cub.2020.09.090 (2021). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 84.Duncan KD & Schlichting ML Hippocampal representations as a function of time, subregion, and brain state. Neurobiol Learn Mem 153, 40–56, doi: 10.1016/j.nlm.2018.03.006 (2018). [DOI] [PubMed] [Google Scholar]
- 85.Hasselmo ME The role of acetylcholine in learning and memory. Curr.Opin. Neurobiol 16, 710–715 (2006). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 86.Zhang Y. et al. Cholinergic suppression of hippocampal sharp-wave ripples impairs working memory. Proc Natl Acad Sci U S A 118, doi: 10.1073/pnas.2016432118 (2021). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 87.Zhang Y. et al. Interaction of acetylcholine and oxytocin neuromodulation in the hippocampus. Neuron 112, 1862–1875 e1865, doi: 10.1016/j.neuron.2024.02.021 (2024). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 88.Vandecasteele M. et al. Optogenetic activation of septal cholinergic neurons suppresses sharp wave ripples and enhances theta oscillations in the hippocampus. Proc Natl Acad Sci U S A 111, 13535–13540, doi: 10.1073/pnas.1411233111 (2014). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 89.Novitskaya Y, Sara SJ, Logothetis NK & Eschenko O Ripple-triggered stimulation of the locus coeruleus during post-learning sleep disrupts ripple/spindle coupling and impairs memory consolidation. Learn Mem 23, 238–248, doi: 10.1101/lm.040923.115 (2016). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 90.Osorio-Forero A. et al. Noradrenergic circuit control of non-REM sleep substates. Curr Biol 31, 5009–5023 e5007, doi: 10.1016/j.cub.2021.09.041 (2021). [DOI] [PubMed] [Google Scholar]
- 91.Grujic N, Polania R & Burdakov D Neurobehavioral meaning of pupil size. Neuron, doi: 10.1016/j.neuron.2024.05.029 (2024). [DOI] [PubMed] [Google Scholar]
- 92.Peyrache A, Battaglia FP & Destexhe A Inhibition recruitment in prefrontal cortex during sleep spindles and gating of hippocampal inputs. Proc Natl Acad Sci U S A 108, 17207–17212, doi: 10.1073/pnas.1103612108 (2011). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 93.Varela C & Wilson MA mPFC spindle cycles organize sparse thalamic activation and recently active CA1 cells during non-REM sleep. eLife 9, doi: 10.7554/eLife.48881 (2020). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 94.Rasch B, Buchel C, Gais S & Born J Odor cues during slow-wave sleep prompt declarative memory consolidation. Science 315, 1426–1429, doi: 10.1126/science.1138581 (2007). [DOI] [PubMed] [Google Scholar]
- 95.Turker B. et al. Behavioral and brain responses to verbal stimuli reveal transient periods of cognitive integration of the external world during sleep. Nat Neurosci 26, 1981–1993, doi: 10.1038/s41593-023-01449-7 (2023). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 96.Rudoy JD, Voss JL, Westerberg CE & Paller KA Strengthening individual memories by reactivating them during sleep. Science 326, 1079, doi: 10.1126/science.1179013 (2009). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 97.Arzi A. et al. Humans can learn new information during sleep. Nat Neurosci 15, 1460–1465, doi: 10.1038/nn.3193 (2012). [DOI] [PubMed] [Google Scholar]
- 98.Lewis PA & Bendor D How Targeted Memory Reactivation Promotes the Selective Strengthening of Memories in Sleep. Curr Biol 29, R906–R912, doi: 10.1016/j.cub.2019.08.019 (2019). [DOI] [PubMed] [Google Scholar]
- 99.Cellini N & Capuozzo A Shaping memory consolidation via targeted memory reactivation during sleep. Ann N Y Acad Sci, doi: 10.1111/nyas.13855 (2018). [DOI] [PubMed] [Google Scholar]
- 100.Fernandez-Ruiz A, Oliva A & Chang H High-resolution optogenetics in space and time. Trends Neurosci 45, 854–864, doi: 10.1016/j.tins.2022.09.002 (2022). [DOI] [PubMed] [Google Scholar]
- 101.Bradski G. The opencv library. Dr. Dobb's Journal: Software Tools for the Professional Programmer 25, 120–123 (2000). [Google Scholar]
- 102.Pachitariu M, Steinmetz N, Kadir S, Carandini M & Kenneth DH Kilosort: realtime spike-sorting for extracellular electrophysiology with hundreds of channels. bioRxiv, doi: 10.1101/061481 (2016). [DOI] [Google Scholar]
- 103.Petersen PC, Siegle JH, Steinmetz NA, Mahallati S & Buzsaki G CellExplorer: A framework for visualizing and characterizing single neurons. Neuron 109, 3594–3608 e3592, doi: 10.1016/j.neuron.2021.09.002 (2021). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 104.Nitzan N. et al. Propagation of hippocampal ripples to the neocortex by way of a subiculum-retrosplenial pathway. Nat Commun 11, 1947, doi: 10.1038/s41467-020-15787-8 (2020). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 105.Maingret N, Girardeau G, Todorova R, Goutierre M & Zugaro M Hippocampo-cortical coupling mediates memory consolidation during sleep. Nat Neurosci 19, 959–964, doi: 10.1038/nn.4304 (2016). [DOI] [PubMed] [Google Scholar]
- 106.Osorio-Forero A. et al. Noradrenergic locus coeruleus activity functionally partitions NREM sleep to gatekeep the NREM-REM sleep cycle. bioRxiv, 2023.2005.2020.541586, doi: 10.1101/2023.05.20.541586 (2024). [DOI] [Google Scholar]
- 107.McInnes L, Healy J & Melville J Umap: Uniform manifold approximation and projection for dimension reduction. arXiv preprint arXiv:1802.03426 (2018). [Google Scholar]
- 108.Tang W, Shin JD & Jadhav SP Geometric transformation of cognitive maps for generalization across hippocampal-prefrontal circuits. Cell reports 42, 112246, doi: 10.1016/j.celrep.2023.112246 (2023). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 109.Lopes-dos-Santos V, Ribeiro S & Tort AB Detecting cell assemblies in large neuronal populations. J Neurosci Methods 220, 149–166, doi: 10.1016/j.jneumeth.2013.04.010 (2013). [DOI] [PubMed] [Google Scholar]
- 110.Shin JD, Tang W & Jadhav SP Dynamics of Awake Hippocampal-Prefrontal Replay for Spatial Learning and Memory-Guided Decision Making. Neuron 104, 1110–1125 e1117, doi: 10.1016/j.neuron.2019.09.012 (2019). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 111.Davidson TJ, Kloosterman F & Wilson MA Hippocampal replay of extended experience. Neuron 63, 497–507, doi: 10.1016/j.neuron.2009.07.027 (2009). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 112.Stark E, Roux L, Eichler R & Buzsaki G Local generation of multineuronal spike sequences in the hippocampal CA1 region. Proc Natl Acad Sci U S A 112, 10521–10526, doi: 10.1073/pnas.1508785112 (2015). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 113.Pfeiffer BE & Foster DJ Hippocampal place-cell sequences depict future paths to remembered goals. Nature 497, 74–79, doi: 10.1038/nature12112 (2013). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 114.Fernandez-Ruiz A & Herreras O Identifying the synaptic origin of ongoing neuronal oscillations through spatial discrimination of electric fields. Frontiers in computational neuroscience 7, 5, doi: 10.3389/fncom.2013.00005 (2013). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 115.Schomburg EW et al. Theta phase segregation of input-specific gamma patterns in entorhinal-hippocampal networks. Neuron 84, 470–485, doi: 10.1016/j.neuron.2014.08.051 (2014). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 116.Mizuseki K & Buzsaki G Preconfigured, skewed distribution of firing rates in the hippocampus and entorhinal cortex. Cell reports 4, 1010–1021, doi: 10.1016/j.celrep.2013.07.039 (2013). [DOI] [PMC free article] [PubMed] [Google Scholar]
Associated Data
This section collects any data citations, data availability statements, or supplementary materials included in this article.
Data Availability Statement
All data are available from the corresponding authors upon request. Source data are provided with this paper.
Custom scripts used in this study can be downloaded from Github (https://github.com/ayalab1/neurocode) and (https://github.com/ayalab1/pupil_project).
