Fig. 6: Grid cell modules reanchor to the lever location.

a, Examples of six grid cells with firing fields near the lever location in light and dark trials. First row, Firing rate maps during random foraging. Second row, Spikes (red) on the running path (gray) during three trials. Only spikes emitted within 18 cm of the lever are shown. Third row, Firing rate as a function of the direction of the animal relative to the lever center. Fourth row, Firing rate as a function of direction around the lever on different trials. Each row represents a trial in which the mouse pressed the lever. b, Directional selectivity (MVL) of neurons in the lever-centered reference frame in light and dark trials in the AutoPI task against a null condition generated with random foraging in the same session. The null condition is generated by using the lever positions from light or dark trials of the AutoPI task and applying them to the random foraging data. We ensured that the occupancy at each lever position (18 cm around the lever) during random foraging matches the actual occupancy observed during the task. From this, we generated lever reference frame firing rate maps separately for light and dark trials. The directional selectivity of these lever-centered maps was then calculated and used as the null condition (N = 17 mice with grid cells with lever-anchored fields, two-sided Wilcoxon sign-rank test, Light: P = 1.526 × 10−5, Dark: P = 7.629 × 10−5). Box plots show the median (center line), first and third quartiles (box bounds) and 1.5 times the interquartile range (whiskers). c, Intertrial stability of grid cells with lever-anchored firing fields. Intertrial stability was defined as the Pearson correlation coefficient between the firing rate maps generated from two stacks of randomly assigned trials of the specified light condition. Maps were calculated in the room reference frame or the lever reference frame (N = 17 mice with grid cells with lever-anchored fields, two-sided Wilcoxon sign-rank test, light: P = 6.777 × 10−1, dark: P = 2.090 × 10−3). Box plots show the median (center line), first and third quartiles (box bounds) and 1.5 times the interquartile range (whiskers). d, Anchoring of grid cell modules to the lever position during dark trials. Top, Examples of the running paths of the mouse around the lever during recording sessions from four different mice (mouse running speed > 10 cm s−1). The mouse’s path is color coded to reflect the direction of the mouse around the lever. Middle, Decoded position of the mouse in toroidal space when the mouse is around the lever. The color code represents the direction of the mouse relative to the lever. Bottom, Kernel density estimate of the decoded lever position in toroidal space when the mouse is near the lever. e, Distribution of decoded directional error for all dark trials or during three separate phases (search, at lever and homing) of the dark trials. f, Distribution of the difference between grid orientation drift at the lever and distance-matched orientation drift for each trial, averaged across the 24 sessions (N = 24 sessions, one-sample Wilcoxon signed-rank test, P = 0.375). For further details, see Supplementary Fig. 6c. g, Anchoring strength to the lever or the room reference frame during dark trials. Data during the search behavior and when the mouse was at the lever are shown separately and split evenly into the beginning, middle and end (N = 24 sessions, two-sided Wilcoxon sign-rank test, Search, Beg.: P = 1.192 × 10−7, Middle: P = 2.384 × 10−7, End: P = 9.084 × 10−5; At lever, Beg.: P = 8.905 × 10−3, Middle: P = 2.384 × 10−7, End: P = 3.576 × 10−7). Box plots show the median (center line), first and third quartiles (box bounds) and 1.5 times the interquartile range (whiskers). ****P < 0.0001, ***P < 0.001, *0.01 < P < 0.05; NS, 0.05 < P.