Sparse-to-dense coding transformation between hippocampal areas CA3 and CA1 Authors: Shir R. Maimon, Tamir Eliav, Johnatan Aljadeff, Aviya Shalev, Yishai Gronich, Nikita M. Finger, Keegan E. Eveland, Cynthia F. Moss, Liora Las, Nachum Ulanovsky Published: 2026 ABSTRACT The hippocampus is crucial for spatial memory and navigation. It contains place cells1–7: spatially selective neurons found in areas CA1 and CA3—two distinct hippocampal subregions with substantially different anatomical connectivity8. Previous studies have found highly similar spatial coding between CA1 and CA3 place cells3,9–11. This raises the question of why two subregions that form consecutive processing stages would exhibit identical neural coding. Here we hypothesized that the lack of differences between CA1 and CA3 spatial coding is due to the experimental paradigm: using small arenas. We tested this hypothesis by simultaneously recording from CA1 and CA3 neurons in bats flying in flight tunnels up to 200 m in length. We identified highly distinct neural coding in CA1 and CA3: whereas CA1 neurons exhibited dense spatial coding, consisting of multiple place fields12, CA3 neurons exhibited ultrasparse spatial coding, consisting predominantly of single place fields. Despite this marked difference, the sizes of place fields were very similar between the two subregions, across 5 different environment sizes ranging from 6 m to 200 m. Using a neural-network model, we show that such a sparse-to-dense transformation can facilitate fast learning of new spatial maps. We also found that in a large multicompartment environment, place cells were strongly modulated by trajectory history—a contextual effect (retrospective coding) that could last for over 100 m. Together, by using large naturalistic environments, we identified a CA3-to-CA1 coding transformation that serves to reformat spatial information into a more efficient, compressed neural code. Main Navigation and spatial memory are vital abilities for the survival of animals in natural environments. The hippocampal formation has a key role in these spatial functions, and it contains several types of spatial cells—neurons whose activity is correlated with the animal’s position in space, which together form an elaborate cognitive map of the environment13–16. One of these spatial cell types is place cells, which are found in the hippocampus. In small environments, these cells are typically characterized by a high firing rate when the animal passes through a single confined location in space—termed the place field—and a much lower activity outside this field1–7. The hippocampus comprises several distinct subregions that contain place cells, including areas CA1 and CA3. Area CA3 lies upstream of CA1 and projects heavily to CA1 (refs. 8,17). These two subregions differ markedly in their anatomical connectivity: area CA1 contains little intrinsic excitatory connections, while area CA3 has strong recurrent connectivity, and CA1 also functions as a major output from the hippocampus to the subiculum and cortex, while CA3 does not8,17–19. Despite these fundamental differences in anatomical connectivity, the basic spatial coding properties of place cells in CA1 and CA3 in small experimental setups are very similar, consisting mainly of single place fields with similar field sizes and spatial information3,9–11. Major differences between CA1 and CA3 were reported regarding their remapping properties when the environment is changed3,4,20,21, as well as differences in long-term stability of place fields22–25, but in small stable environments, the basic neural coding of space seems to be rather similar between these two areas. Some studies have reported small differences in place-fields sizes, firing rates or fraction of place cells between CA1 and CA3 (refs. 3,10,11,26–28); however, overall, these differences were rather small, especially considering the substantially different anatomy of these two areas. While both CA1 and CA3 place cells exhibit single place fields in small environments11, one study—which investigated the spatial representations of CA1 and CA3 place cells in rats exploring a larger environment (1.8 m × 1.4 m box)—showed a slightly larger number of place fields per neuron in both regions, but did not find a difference between the two subregions in terms of the number of place fields or their field sizes26. Another study29 recorded CA3 place cells in rats running on a larger linear track (18 m) and found mostly single place fields, but this study did not record in CA1, and therefore no direct comparison was available between the two subregions. Collectively, on the basis of rodent experiments that directly compared place cells in CA1 and CA3, no substantial differences have been found thus far in the basic neural-coding properties between the two brain areas. This presents the question of why the hippocampus contains two consecutive processing stages, CA3 and CA1, with a highly different anatomy but very similar neural coding of space. We posited that this conundrum arises because thus far, CA1 and CA3 place cells were directly compared only in relatively small environments—and we hypothesized that in more naturalistic spatial scales of hundreds of metres or kilometres, fundamental differences may be revealed between spatial coding in CA1 and CA3. In our previous work12, we recorded CA1 neurons in flying mammals (Egyptian fruit bats) as they were flying in a 200-m-long tunnel and found that CA1 place cells exhibited multiple place fields with varying sizes for different fields of the same neuron (multiple fields in CA1 were also shown in rodents navigating a large environment30). This multifield multiscale spatial code is fundamentally different from the single-field code observed in CA1 of bats and rodents in small laboratory environments. However, thus far, no recordings have been conducted in CA3 in such large environments with ecological spatial scales. Here we recorded simultaneously from both CA1 and CA3 place cells in bats flying in long flight tunnels (130, 180 and 200 m) and in shorter tunnels (6 and 15 m). Similar to rodent studies, in the smaller environments, we found no difference in spatial coding between CA1 and CA3: place cells in both regions exhibited single place fields with similar field sizes. By contrast, we found a major difference between CA1 and CA3 place cells in the large-scale environments. In contrast to CA1 place cells, CA3 place cells predominantly exhibited only single place fields in the long tunnel. Overall, our results demonstrate a sparse-to-dense coding transformation between hippocampal subregions CA3 and CA1. Moreover, in a large multicompartment environment, we found a memory effect in the neural coding, which was more robust in CA1 than in CA3. These fundamental neural-coding differences between these two hippocampal subregions—revealed here by using very large environments—suggest distinct functional roles for CA1 and CA3 in real-world, large-scale ecological settings. Sparse CA3 coding versus dense CA1 coding We trained bats to fly back and forth in a long flight tunnel: 130, 180 or 200 m in length (Fig. 1a and Extended Data Fig. 1a,b; each bat was tested in one tunnel length). The bats flew between two spherical landing-platforms (balls) positioned at the two ends of the tunnel, where the bats could land to receive food and rest. After training, we used a wireless neural logger to record neurons from dorsal CA1 and dorsal CA3 in five bats flying in the long tunnel, and an additional nine bats with only dorsal CA1 recordings (Fig. 1b,c, Methods and Extended Data Table 1). Overall, we recorded 810 putative pyramidal neurons from dorsal CA1 of 14 bats, and 457 putative pyramidal neurons from dorsal CA3 of five bats. Place cells comprised 76.3% and 58.6% of the pyramidal neurons in CA1 and CA3, respectively, exhibiting significant spatial tuning and distinct place fields (nCA1 = 618 out of 810 and nCA3 = 268 out of 457 were place cells; numbers were pooled across the three large environments; significant place cells were defined on the basis of spatial information compared to spike shuffles; Methods). We analysed the neuronal data separately for each flight direction, because the firing-rate maps of place cells are independent between two movement directions in linear environments12,31.Fig. 1Simultaneous electrophysiological recording in areas CA1 and CA3 of bats flying in long flight tunnels.a, Experimental setup. Bats flew in a very long linear tunnel with a length of 130, 180 or 200 m. We also recorded from bats flying in smaller tunnel segments: 6 or 15 m. Illustration: G. Brodsky. b, Coronal section through the dorsal hippocampus of bat 2, in which we recorded in both CA1 (the grey arrowhead indicates tetrode tracks) and CA3 (the purple arrowhead indicates an electrolytic lesion). Scale bar, 1 mm. The lines indicate the approximate anatomical borders of CA1 (grey) and CA3 (purple). Overall, five bats had simultaneous recordings in both CA1 and CA3, and an additional nine bats had recordings in CA1 only. c, Spike sorting of two tetrodes, one in CA3 (left) and one in CA1 (right) (data from full recording sessions: 63 and 67 min). Shown are spike clusters of different well-isolated neurons (colours), with spike amplitudes plotted for three of the tetrodes’ four channels (Ch1–4). d, Examples of six cells: three in CA3 (top, purple) and three in CA1 (bottom, grey). For each cell, shown are firing-rate maps (top; bin size, 20 cm) and spike-raster plots (bottom); the flight direction is indicated by an arrow. Detected place fields are denoted by thick horizontal lines above the raster plots. The light grey vertical bars indicate zones with low flight speed (take-off or landing). Additional examples are shown in Extended Data Fig. 2. Simultaneous electrophysiological recording in areas CA1 and CA3 of bats flying in long flight tunnels. a, Experimental setup. Bats flew in a very long linear tunnel with a length of 130, 180 or 200 m. We also recorded from bats flying in smaller tunnel segments: 6 or 15 m. Illustration: G. Brodsky. b, Coronal section through the dorsal hippocampus of bat 2, in which we recorded in both CA1 (the grey arrowhead indicates tetrode tracks) and CA3 (the purple arrowhead indicates an electrolytic lesion). Scale bar, 1 mm. The lines indicate the approximate anatomical borders of CA1 (grey) and CA3 (purple). Overall, five bats had simultaneous recordings in both CA1 and CA3, and an additional nine bats had recordings in CA1 only. c, Spike sorting of two tetrodes, one in CA3 (left) and one in CA1 (right) (data from full recording sessions: 63 and 67 min). Shown are spike clusters of different well-isolated neurons (colours), with spike amplitudes plotted for three of the tetrodes’ four channels (Ch1–4). d, Examples of six cells: three in CA3 (top, purple) and three in CA1 (bottom, grey). For each cell, shown are firing-rate maps (top; bin size, 20 cm) and spike-raster plots (bottom); the flight direction is indicated by an arrow. Detected place fields are denoted by thick horizontal lines above the raster plots. The light grey vertical bars indicate zones with low flight speed (take-off or landing). Additional examples are shown in Extended Data Fig. 2. Consistent with our previous report12, CA1 place cells in the long tunnel exhibited multiple place fields per direction, with varying field sizes (examples are shown in Fig. 1d, bottom row, and Extended Data Fig. 2b; population: Fig. 2a,b, grey). In contrast to CA1 place cells, the large majority of CA3 place cells exhibited spatial firing-rate maps with a single field (examples are shown in Fig. 1d,top, and Extended Data Fig. 2a; population: Fig. 2a; compare the number of fields in CA3 (purple) versus CA1 (grey); the distributions for individual bats are shown in Extended Data Fig. 3). Specifically, 73.7% (250 out of 339) of the significant place cells × directions in CA3 had a single field, compared with only 29.6% (292 out of 986) in CA1. Moreover, many CA1 place cells had 5 or even ≥10 fields (31.9% (197 out of 618) had ≥5 fields in at least one direction)—indicating multifield firing, which almost never occurred in CA3 (Fig. 2a; only 0.7% (2 out of 268) of CA3 place cells had ≥5 fields). This difference in the number of place fields was highly significant across the recorded population of CA1 and CA3 neurons (Fig. 2a, bottom; Wilcoxon rank-sum test, P = 4 × 10–56)—in each of the three different large-scale tunnels (see the individual bats and tunnels in Fig. 2a, top, and Extended Data Fig. 3a). These findings could not be explained by differences in spike-sorting quality between CA1 and CA3 (Extended Data Fig. 4j–l). Despite this marked difference in the number of place fields, the sizes of place fields were almost identical between CA1 and CA3: both areas exhibited a similar log-normal distribution of field sizes (entire population: Fig. 2b, bottom; Wilcoxon rank-sum test, P = 0.66; see Fig. 2b, top, and Extended Data Fig. 3b for individual bats). Peak firing rates per map were also similar between CA1 and CA3 (Extended Data Fig. 4a). Firing-rate maps in bothCA1 and CA3 were highly stable (Fig. 2c; median correlations, r = 0.78 in CA1 and r = 0.86 in CA3; assessed via Pearson correlation between firing-rate maps in first versus second half of the session; see Extended Data Fig. 4c, top, for stability for odd versus even flights, which yielded similar results; note that the difference in stability between CA1 and CA3 (Wilcoxon rank-sum test, P = 8 × 10–9) was not a by-product of the denser CA1 coding (Extended Data Fig. 4d)). CA3 place cells exhibited much higher spatial information than CA1 place cells (Fig. 2d; P = 10–72), as well as lower spatial coverage (Fig. 2e; P = 9 × 10–31) and sparser firing-rate maps (P = 7 × 10–59; Fig. 2f and Extended Data Fig. 3c–e). Past studies in rodents have reported higher spatial information, higher stability and lower spatial coverage in CA3 than in CA1 (refs. 10,11); however, these previously reported differences were very small compared with the large difference between CA3 and CA1 that we found here in their number of place fields (Fig. 2a)—a difference that was revealed by using very large environments. The sparse coding in CA3 and dense coding in CA1 were found throughout the proximodistal anatomical extent of both areas (Extended Data Fig. 5). Thus, our results suggest that place cells in large environments exhibit ultrasparse coding in CA3 but dense coding in CA1.Fig. 2Sparse-to-dense coding transformation between hippocampal subregions CA3 and CA1 in very large environments.a–f, The distributions of firing-rate map properties for place cells in CA1 (grey) and CA3 (purple) for bat 1 (130 m) with simultaneous recordings in CA1 and CA3 (top), and for all recorded bats (bottom; 14 bats in CA1 and 5 bats in CA3). a, The number of place fields per neuron per flight direction (top, n = 164 (CA1) and n = 157 (CA3) for bat 1; bottom, n = 986 (CA1) and n = 339 (CA3) cells × directions for all bats). b, Place-field size (top, n = 472 (CA1) and n = 211 (CA3) fields for bat 1; bottom, n = 3,837 (CA1) and n = 462 (CA3) fields for all bats). c, Map stability, assessed through Pearson correlation of the firing-rate maps for first versus second half of the session. d, Spatial information. e, Coverage of the environment by place fields as the percentage of the environment size. f, Sparsity (lower sparsity score indicates sparser map). In c–f, numbers of cells × directions are as in a. In a–f, the dots and horizontal lines above each histogram indicate the median and interquartile range. P values were calculated using two-sided Wilcoxon rank-sum tests between CA1 and CA3. Note that all comparisons between CA1 and CA3 yielded highly significant differences, except for place-field sizes. g–k, Comparison of place-cell properties between CA1 (grey) and CA3 (purple) as a function of environment size, for tunnels of lengths 6, 15, 130, 180 and 200 m. Shown are the number of fields per direction (g), place-field size (h), coverage of the environment by place fields (i), percentage of significant place cells (j) and the percentage of single-field maps out of all the significant firing-rate maps (k). The box plots show the median (black horizontal line), 25–75% percentiles (grey and purple box limits) and 10–90% percentiles (whiskers). The solid lines connect the mean values. Numbers in g and i: n = 40, 27, 200, 294 and 492 cells × directions (CA1) and n = 6, 12, 157, 139 and 43 cells × directions (CA3) for tunnels of length 6, 15, 130, 180 and 200 m, respectively. Numbers in h: n = 45, 34, 594, 965 and 2,278 fields (CA1) and n = 7, 14, 211, 185 and 66 fields (CA3) in each tunnel length. Numbers in j and k: n = 3, 1, 2, 4 and 8 bats (CA1) and n = 1, 1, 1, 3 and 1 bats (CA3) in each tunnel length. Sparse-to-dense coding transformation between hippocampal subregions CA3 and CA1 in very large environments. a–f, The distributions of firing-rate map properties for place cells in CA1 (grey) and CA3 (purple) for bat 1 (130 m) with simultaneous recordings in CA1 and CA3 (top), and for all recorded bats (bottom; 14 bats in CA1 and 5 bats in CA3). a, The number of place fields per neuron per flight direction (top, n = 164 (CA1) and n = 157 (CA3) for bat 1; bottom, n = 986 (CA1) and n = 339 (CA3) cells × directions for all bats). b, Place-field size (top, n = 472 (CA1) and n = 211 (CA3) fields for bat 1; bottom, n = 3,837 (CA1) and n = 462 (CA3) fields for all bats). c, Map stability, assessed through Pearson correlation of the firing-rate maps for first versus second half of the session. d, Spatial information. e, Coverage of the environment by place fields as the percentage of the environment size. f, Sparsity (lower sparsity score indicates sparser map). In c–f, numbers of cells × directions are as in a. In a–f, the dots and horizontal lines above each histogram indicate the median and interquartile range. P values were calculated using two-sided Wilcoxon rank-sum tests between CA1 and CA3. Note that all comparisons between CA1 and CA3 yielded highly significant differences, except for place-field sizes. g–k, Comparison of place-cell properties between CA1 (grey) and CA3 (purple) as a function of environment size, for tunnels of lengths 6, 15, 130, 180 and 200 m. Shown are the number of fields per direction (g), place-field size (h), coverage of the environment by place fields (i), percentage of significant place cells (j) and the percentage of single-field maps out of all the significant firing-rate maps (k). The box plots show the median (black horizontal line), 25–75% percentiles (grey and purple box limits) and 10–90% percentiles (whiskers). The solid lines connect the mean values. Numbers in g and i: n = 40, 27, 200, 294 and 492 cells × directions (CA1) and n = 6, 12, 157, 139 and 43 cells × directions (CA3) for tunnels of length 6, 15, 130, 180 and 200 m, respectively. Numbers in h: n = 45, 34, 594, 965 and 2,278 fields (CA1) and n = 7, 14, 211, 185 and 66 fields (CA3) in each tunnel length. Numbers in j and k: n = 3, 1, 2, 4 and 8 bats (CA1) and n = 1, 1, 1, 3 and 1 bats (CA3) in each tunnel length. We next compared CA1 and CA3 firing properties across environments of different sizes. To this end, we recorded in bats flying in shorter segments of the long tunnel (6 m and 15 m; examples are shown in Extended Data Fig. 6a,b; CA1, n = 51 place cells in 4 bats; CA3, n = 15 place cells in 2 bats; a list of cell numbers per bat is shown in Extended Data Table 1). We found no difference in the number of place fields in CA1 and CA3 in these smaller environments. In both hippocampal subregions, firing-rate maps typically exhibited one field (Fig. 2g (left box plots) and Extended Data Figs. 3g and 6c), similar to place cells recorded in small environments in rodents3,9–11. Next, we analysed systematically the spatial properties of place cells as a function of environment size. The number of fields in CA1 place cells increased with the increase in environment size (Fig. 2g, grey, and Extended Data Fig. 3g, grey), but the number of fields in CA3 place cells remained consistently low (Fig. 2g (purple) and Extended Data Fig. 3g, purple). Notably, place-field sizes were highly similar between areas CA1 and CA3 across all the five tested environments, with both areas showing a matching increase in field size with environment size (Fig. 2h and Extended Data Fig. 3h). Consequently, the spatial coverage of the firing-rate maps was similar between CA1 and CA3 in smaller environments, but diverged in larger environments (Fig. 2i and Extended Data Fig. 3i). Furthermore, across all environment sizes, CA3 had a lower proportion of significant place cells than CA1 (Fig. 2j and Extended Data Fig. 3j); that is, fewer CA3 neurons were recruited to represent a given environment regardless of the environment size. Notably, in both CA1 and CA3, in the largest environment of 200 m, more than 80% of the pyramidal neurons were significant place cells (Fig. 2j and Extended Data Fig. 3j, right box plots). We speculate that in even larger environments such as the multikilometre spaces in which these bats naturally navigate in the wild32,33, nearly all CA1 and CA3 neurons would become significant place cells. Finally, in both subregions, we observed a decrease in the percentage of single-field maps with the increase in environment size (Fig. 2k)—indicating the recruitment of additional place fields. The substantial differences in spatial firing patterns that we report here suggest a fundamental functional difference in neural coding between these two hippocampal subregions: sparse coding in CA3 versus dense coding in CA1—a difference that becomes more prominent with increases in the environment size. CA3 sparse coding enables fast learning We next examined the potential functional implications of the sparse single-field code observed in CA3 versus the dense multifield code in CA1. Using simulations, we compared the spatial-coding performance of two coding schemes—sparse and dense—with parameters matched to our experimental data from CA3 and CA1, respectively (as done previously for CA1 only12; Methods). A maximum-likelihood decoder was used to compare the decoding error for simulated data for these two schemes. In smaller environments, both coding schemes performed equally well but, as the environment became larger, the CA1 dense code substantially outperformed the CA3 sparse code (Fig. 3a–c, compare the grey with purple lines). Specifically, in large environments, both the mean decoding error and the probability of catastrophic errors (decoding errors larger than 5% of the environment size) were more than tenfold larger for CA3 than for CA1 (Fig. 3a,b). Moreover, the minimal number of neurons required to accurately encode large environments was substantially lower for the CA1 dense code than for the CA3 sparse code (Fig. 3c). Specifically, we found that in large environments, four times more neurons were needed in CA3 than in CA1 to achieve a given decoding error: a compression factor of around four in the number of required neurons in CA3/CA1 (Extended Data Fig. 7b). The advantage of the dense multifield CA1 code over the sparse single-field CA3 code could not be attributed to differences in mean firing rate between CA1 and CA3 (Extended Data Fig. 7c–f), and was also evident when decoding was performed using the empirical firing-rate maps recorded in the large tunnels (Extended Data Fig. 7g). Together, these results suggest that for accurate coding of position in large environments, the dense CA1 code is much more effective than the sparse CA3 code. This raises the question of what the possible advantage is of having a very sparse code in CA3.Fig. 3Simulations show that dense code in CA1 yields better spatial precision, whereas sparse code in CA3 enables faster learning.a,b, Positional decoding accuracy for simulations of CA1 (grey) and CA3 (purple) coding schemes, as a function of environment size (from 20 to 1,000 m; n = 50 simulated place cells). The simulated place fields were drawn from field size and coverage distributions fitted to our CA1 and CA3 experimental data (Methods). Shown are the mean decoding error (a), and the probability of catastrophic errors (b), namely decoding errors larger than 5% of the environment size. Note that the CA3 sparse code has larger decoding errors and a tenfold higher probability of catastrophic errors than the CA1 dense code. c, The minimal number of neurons required for a reaching mean decoding error of <2 m. d, Feedforward connectivity model between CA3 neurons (purple) and CA1 neurons (grey). Illustration: G. Brodsky. e,f, Learning time of the simulation in the network model shown in d for learning new 200 m spatial maps (e), or learning after a small local perturbation to an already learned spatial map (f), plotted as a function of the number of place fields in every neuron of the CA3 input layer. We used here the node-perturbation learning rule (see Extended Data Fig. 8b for an alternative learning rule; Methods). Data are the median and interquartile range over n = 200 simulations (Methods; note the error bars are very small and are clearly visible only for six fields). Note that in both e and f, the learning time was over tenfold faster when the input CA3 neurons had one field as compared with six fields. The learning-steps plotted here are normalized by the spatial bin size (Methods) and are therefore not equivalent to behavioural trials during an actual experiment. Simulations show that dense code in CA1 yields better spatial precision, whereas sparse code in CA3 enables faster learning. a,b, Positional decoding accuracy for simulations of CA1 (grey) and CA3 (purple) coding schemes, as a function of environment size (from 20 to 1,000 m; n = 50 simulated place cells). The simulated place fields were drawn from field size and coverage distributions fitted to our CA1 and CA3 experimental data (Methods). Shown are the mean decoding error (a), and the probability of catastrophic errors (b), namely decoding errors larger than 5% of the environment size. Note that the CA3 sparse code has larger decoding errors and a tenfold higher probability of catastrophic errors than the CA1 dense code. c, The minimal number of neurons required for a reaching mean decoding error of <2 m. d, Feedforward connectivity model between CA3 neurons (purple) and CA1 neurons (grey). Illustration: G. Brodsky. e,f, Learning time of the simulation in the network model shown in d for learning new 200 m spatial maps (e), or learning after a small local perturbation to an already learned spatial map (f), plotted as a function of the number of place fields in every neuron of the CA3 input layer. We used here the node-perturbation learning rule (see Extended Data Fig. 8b for an alternative learning rule; Methods). Data are the median and interquartile range over n = 200 simulations (Methods; note the error bars are very small and are clearly visible only for six fields). Note that in both e and f, the learning time was over tenfold faster when the input CA3 neurons had one field as compared with six fields. The learning-steps plotted here are normalized by the spatial bin size (Methods) and are therefore not equivalent to behavioural trials during an actual experiment. To examine the potential use of a sparse code in CA3, we drew inspiration from a different brain system that also shows a sparse-coding to dense-coding network architecture—the bird song system in zebra finches. Specifically, in the zebra finch brain, area HVC contains neurons that exhibit very sparse firing, whereby each neuron typically fires a single burst of spikes during song production34,35, similar to place cells in CA3, which exhibit single fields in the long tunnel. These ultrasparse coding neurons in area HVC then project to area RA, in which neurons have dense firing patterns, firing multiple times along the duration of the song35, similar to place cells in CA1. It has been suggested that the sparse-to-dense architecture in birdsong (HVC → RA) is required for fast motor learning of songs36,37. We therefore hypothesized that the sparse-to-dense architecture that we found here in CA3 → CA1 is required for fast learning of spatial maps; for example, acquiring representations of novel environments or learning spatial changes in landmark arrangement in a familiar environment. To examine this, we were inspired by theoretical work on the birdsong system36 and constructed a simplified model that relies on the direct connections between CA3 and CA1 to perform spatial learning. We used two different synaptic learning rules: a node-perturbation rule (Fig. 3d–f and Extended Data Fig. 8a) and a weight-perturbation rule (Extended Data Fig. 8b and Methods). For this, we generated a set of target CA1 maps to be learned in the simulations; these maps had spatial-coverage and place-field statistics that were drawn from the experimental CA1 data in the long 200-m tunnel. We found that the learning of new CA1 output maps was substantially faster if the input maps from CA3 had sparse representations, namely, single fields (or double fields), as compared to multiple fields (Fig. 3e). In particular, the learning was more than tenfold faster when input maps in CA3 had only one field as compared to six fields (Fig. 3e). Note that our theoretical model is deliberately simplified and does not account for contributions from other regions, such as inputs from CA2 or the entorhinal cortex into CA1 (Methods). Another advantage of the sparse-to-dense architecture was revealed in our simulations through the distribution of synaptic weights. Specifically, we found that for sparser CA3 maps (single fields), the distribution of learned synaptic weights from CA3 to CA1 became substantially sparser, as reflected by a heavier tail of the distribution (Extended Data Fig. 8a–c, right). Our recent theoretical work38 suggests that such heavy-tailed synaptic weight distributions, which emerged here only when maps in CA3 had a single field, help to stabilize CA1 spatial representations in the face of ongoing synaptic plasticity, such as the plasticity occurring during spatial learning. Notably, the sparse CA3 → dense CA1 architecture exhibited an advantage in learning time also when we performed simulations of perturbing an already learned map: when CA3 neurons had sparse coding with one or two fields, the learning was much faster (Fig. 3f and Extended Data Fig. 8d) and the changes in synaptic input to CA1 neurons were more localized to the perturbation area (Extended Data Fig. 9g), compared with the case of dense CA3 inputs. This result demonstrates an intuitive explanation for why spatially sparse input leads to faster learning36 (Fig. 3e–f)—sparse maps in the input layer help decouple positions, therefore reducing interference between distant locations in the environment during the learning process. In other words, each synaptic adjustment between CA3 and CA1 during learning causes local changes in the output maps, with minimal interference between different areas of the environment—therefore enabling quicker and more efficient learning. We next sought to validate the model assumptions experimentally, specifically, the assumption that the learning should take place at the synapses between CA3 and CA1 (note that plasticity in CA3 → CA1 synapses was shown previously by many experimental studies39–42). This entails that during learning of local spatial changes in a familiar environment, the neuronal changes within the hippocampus will be reflected mostly in the output layer, CA1, and not in the input layer, CA3. To test this experimentally, we introduced a small local perturbation in the long 180-m tunnel environment, and we expected to see over-representation of neuronal changes around the perturbed location in CA1 neurons but not in CA3 neurons. Specifically, we changed the location of a prominent landmark by 7.5 m between two consecutive sessions (Extended Data Fig. 1b, orange triangles, and 1d), while keeping in place all of the other landmarks. We recorded from 2 bats a total of 233 place cells × directions in CA1 and 73 place cells × directions in CA3 (we limited the analysis to 140 m at the western-most portion of the tunnel, around the perturbed landmark; Methods). We found that 31% of the place cells × directions in CA1 and 30% in CA3 significantly changed their firing-rate maps between the two sessions in at least one spatial bin (see the three example cells in Fig. 4a; the orange dots above the first two cells show significant changes; Bonferroni corrected for the number of bins; and see Fig. 4b). In both CA1 and CA3, changes were distributed throughout the tunnel (Fig. 4c, top; see background changes). These uniform changes were possibly due to noise or representational drift12,25,43,44. In addition to these spatially uniform changes, CA1 neurons—but not CA3 neurons—showed also a local over-representation of firing-rate changes around the perturbed landmark (Fig. 4c, top left, see the peak). This local over-representation was seen also when matching the number of cells in CA1 and CA3 (Extended Data Fig. 9b). Notably, this difference between CA1 and CA3 could not be attributed to differences in place-field distributions relative to landmarks, as both CA1 and CA3 place fields did not exhibit over-representation of landmarks (Extended Data Fig. 9c,d). This suggests that there is a genuine difference in the responses of place cells in CA1 versus CA3 to local spatial perturbations, supporting the assumptions of our model that learning occurs in the synaptic weights between CA3 and CA1, and that CA3 representations remain stable despite local perturbations in the environment. This result is consistent with the slightly higher map stability that we found in CA3 (Fig. 2c and Extended Data Fig. 4c–e), and also consistent with reports from rodents that CA3 place cells are less sensitive to small changes in the environment4,20, and show higher map stability10,11.Fig. 4Testing the model assumption that CA3 is more stable to local perturbations than CA1.a, Example place cells recorded in CA1 (cells 7 and 8) and in CA3 (cell 9) during the landmark-perturbation experiment (‘zoomed in’ around the perturbed landmark; see Extended Data Fig. 9a for the ‘zoomed out’ figure). The landmark was moved 7.5 m between two positions, indicated by the dashed orange line (session 1) and solid orange line (session 2), and by the pair of orange triangles. For each cell shown are firing-rate maps (top) and spike-raster plots (middle and bottom) for the two behavioural sessions, for one flight direction (arrow); olive colour, session 1; light blue, session 2. The orange dots above the firing-rate maps show the spatial bins that significantly changed their firing rate between the sessions (t-test, Bonferroni-corrected for the number of spatial bins (1 m bins); Methods). Note the two CA1 cells showed clear differences in their firing-rate maps between the sessions, while the CA3 cell remained stable (compare olive versus light blue). b, The percentages of firing-rate maps with at least one significantly changed spatial bin, out of all the firing-rate maps of place cells in CA1 (grey; n = 72 out of 233 cells × direction exhibited significantly changed bins) and in CA3 (purple; n = 22 out of 73). Data from n = 2 bats (Extended Data Table 1). c, Localized changes in CA1 place cells (grey, left), but not in CA3 place cells (purple, right), around the perturbed-landmark location (solid and dashed orange lines). Shown are the position of significantly changed spatial bins for each cell × direction (bottom, sorted by median position of changed bins (1 m bins)) and the overall number of changed-bins (top; 5 m non-overlapping windows), plotted as a function of position (n = 72 (CA1), n = 22 (CA3) cells × directions). The asterisks indicate spatial bins with significant (P < 0.05) firing-rate changes based on binomial test. P values of binomial and shuffle tests are indicated for the peak of the CA1 place cells (top left). Note the over-representation of changes in neuronal firing near the perturbed landmark in CA1 place cells (top left)—but not in CA3 place cells (top right). Testing the model assumption that CA3 is more stable to local perturbations than CA1. a, Example place cells recorded in CA1 (cells 7 and 8) and in CA3 (cell 9) during the landmark-perturbation experiment (‘zoomed in’ around the perturbed landmark; see Extended Data Fig. 9a for the ‘zoomed out’ figure). The landmark was moved 7.5 m between two positions, indicated by the dashed orange line (session 1) and solid orange line (session 2), and by the pair of orange triangles. For each cell shown are firing-rate maps (top) and spike-raster plots (middle and bottom) for the two behavioural sessions, for one flight direction (arrow); olive colour, session 1; light blue, session 2. The orange dots above the firing-rate maps show the spatial bins that significantly changed their firing rate between the sessions (t-test, Bonferroni-corrected for the number of spatial bins (1 m bins); Methods). Note the two CA1 cells showed clear differences in their firing-rate maps between the sessions, while the CA3 cell remained stable (compare olive versus light blue). b, The percentages of firing-rate maps with at least one significantly changed spatial bin, out of all the firing-rate maps of place cells in CA1 (grey; n = 72 out of 233 cells × direction exhibited significantly changed bins) and in CA3 (purple; n = 22 out of 73). Data from n = 2 bats (Extended Data Table 1). c, Localized changes in CA1 place cells (grey, left), but not in CA3 place cells (purple, right), around the perturbed-landmark location (solid and dashed orange lines). Shown are the position of significantly changed spatial bins for each cell × direction (bottom, sorted by median position of changed bins (1 m bins)) and the overall number of changed-bins (top; 5 m non-overlapping windows), plotted as a function of position (n = 72 (CA1), n = 22 (CA3) cells × directions). The asterisks indicate spatial bins with significant (P < 0.05) firing-rate changes based on binomial test. P values of binomial and shuffle tests are indicated for the peak of the CA1 place cells (top left). Note the over-representation of changes in neuronal firing near the perturbed landmark in CA1 place cells (top left)—but not in CA3 place cells (top right). A second assumption of our model is that CA1 map formation depends on inputs from CA3, implying that in a novel environment, stabilization of CA3 maps should precede that of CA1. Indeed, during a bat’s first exposure to the long tunnel, CA3 firing-rate maps stabilized faster than those in CA1 (Extended Data Fig. 9f, left). Overall, these findings (Fig. 4 and Extended Data Fig. 9f) support our model assumptions, and therefore further corroborate the conclusion that the sparse-to-dense architecture of the hippocampal CA3 → CA1 network may have a key role in facilitating fast learning of spatial maps. Strong and long-range retrospective coding Natural navigation in the real world requires high cognitive functions, such as path planning, memory and decision-making. To investigate the sparse and dense codes in CA3 and CA1 under more complex settings, we constructed a very large asymmetric T-maze that required choosing where to go. Specifically, the 180-m tunnel was connected at one end to two additional 10-m compartments: (1) a straight compartment that was a direct continuation of the long 180-m tunnel; and (2) a turn compartment that was perpendicular to the 180-m tunnel (Extended Data Fig. 1b, top). The bats freely explored all of the compartments and volitionally landed on three landing balls positioned at the three ends of the environment (n = 4 bats). We also conducted a second behavioural session in which the junction leading to the short compartments was blocked (Extended Data Fig. 1b, bottom). We compared the spatial coding in both behavioural sessions (with choice versus no choice), and in different compartments of the environment, but did not find an effect of choice availability or neuronal compartmentalization of the tunnel (Extended Data Fig. 10). Importantly, this unique setup enabled us to examine the effects of future and past behaviours on the spatial coding of CA1 and CA3 neurons in very large environments. Previous research in rodents running in small mazes has shown that some place cells in CA1 (and, to a lesser extent, in CA3) not only represent the animal’s current location, but also encode future trajectories—these neurons are often called splitter cells (as they ‘split’ their responses depending on future paths), and this future coding is known as prospective coding45–50. Moreover, some place cells in the rodent CA1 were also shown to represent the animal’s past trajectory—known as retrospective coding45–48. Here we studied how the sparse-coding neurons in CA3 and dense-coding neurons in CA1 represent future spatial choices and past trajectories over very long distances—tens or hundreds of metres away from the animal’s current location. To investigate hippocampal prospective and retrospective coding, we focused on firing-rate maps in the common 180-m tunnel segment (Fig. 5a; session 1: black rectangle for prospective, green rectangle for retrospective). For analysing prospective coding, we compared the firing-rate spatial maps in this common area between two types of forward flights (eastward) depending on where they ended: (1) in the straight compartment (to-straight), or (2) in the turn compartment (to-turn) (example cell: Fig. 5b, left, dark blue and red). For retrospective coding, we compared returning flights (westward) depending on where they started: (1) in the straight compartment (from-straight) or (2) in the turn compartment (from-turn) (Fig. 5b, right, dark blue and red). We first focused our analysis on CA1, where we recorded more neurons than in CA3.Fig. 5Prominent and long-range retrospective coding in hippocampal neurons in a large multicompartment environment.a, Top, session 1 (multicompartment, with choice): schematic of forward flights (left) to-straight (dark-blue) or to-turn (red), and returning flights (right) from-straight (dark-blue) or from-turn (red). Bottom, session 2 (single compartment, no-choice; light blue). b, An example cell (cell 10), showing forward flight direction (left, prospective) and returning flight direction (right, retrospective). Top, firing-rate maps for each flight type (colours are as in a); the three bottom panels show the spike rasters for each flight-type. The green solid circles show significant retrospective place fields. The grey empty circles represent place fields for which the firing-rate change cannot be solely attributed to prospective/retrospective coding, due to significant behavioural differences (Methods). The vertical arrows on the right dark blue raster show a single flight that resembled the red raster, suggesting ‘confusion’ of maps. c,d, Two additional example cells (cell 11 (CA1; c) and cell 12 (CA1; d)): only returning flights (retrospective) are shown, plotted as in b. The examples in b–d are from bat 2. e, Population-vector correlations as a function of position for CA1 place cells for prospective (left, black; to-straight versus to-turn), retrospective (right, green; from-straight versus from-turn) and two controls (grey; Methods), for bat 2 (top) and all bats (bottom). The grey rectangular shading indicates short compartments; peach rectangular shading indicates the positions with turn-related differences in flight behaviour (Extended Data Fig. 13b). The red arrow indicates the position at which green correlation reached a value of 0.8, reflecting convergence of the two neural maps. The solid lines show the population-vector correlation using all neurons; green and black shading show the 25–75% confidence intervals of the correlation values (Methods); n = 141 (bat 2)and n = 316 (all bats) CA1 place cells in the forward flight direction (black); n = 163 (bat 2) and n = 334 (all bats) CA1 place cells in the returning flight direction (green). f, Magnified view of the convergence area of neural maps for retrospective coding in bat 2. The thick green curve shows the population-vector correlation pooled over all recording sessions (as in e (top right), retrospective). The thin green lines show the population-vector correlations for five example sessions, showing very rapid convergence in single sessions. g, The variability of retrospective coding (high variability means less-robust retrospective coding; Methods). Left, using all data from bat 2, the retrospective code in CA3 (purple) was less robust and exhibited greater variability than the retrospective code in CA1 (grey). Cell populations in CA1 and CA3 were randomly subsampled to equalize the number of cells (n = 50 cells; 1,000 repetitions). The box plots show the median (horizontal line), 25–75% (box limits) and 10–90% (whiskers), across subsampling repetitions. Statistical analysis was performed using the two-sided Wilcoxon rank-sum test; *****P = 10–300. Right, the same analysis using only neurons with single fields (controlling for sparseness); here the robustness of retrospective coding was similar between CA1 and CA3 (Wilcoxon rank-sum test, P = 0.94). Prominent and long-range retrospective coding in hippocampal neurons in a large multicompartment environment. a, Top, session 1 (multicompartment, with choice): schematic of forward flights (left) to-straight (dark-blue) or to-turn (red), and returning flights (right) from-straight (dark-blue) or from-turn (red). Bottom, session 2 (single compartment, no-choice; light blue). b, An example cell (cell 10), showing forward flight direction (left, prospective) and returning flight direction (right, retrospective). Top, firing-rate maps for each flight type (colours are as in a); the three bottom panels show the spike rasters for each flight-type. The green solid circles show significant retrospective place fields. The grey empty circles represent place fields for which the firing-rate change cannot be solely attributed to prospective/retrospective coding, due to significant behavioural differences (Methods). The vertical arrows on the right dark blue raster show a single flight that resembled the red raster, suggesting ‘confusion’ of maps. c,d, Two additional example cells (cell 11 (CA1; c) and cell 12 (CA1; d)): only returning flights (retrospective) are shown, plotted as in b. The examples in b–d are from bat 2. e, Population-vector correlations as a function of position for CA1 place cells for prospective (left, black; to-straight versus to-turn), retrospective (right, green; from-straight versus from-turn) and two controls (grey; Methods), for bat 2 (top) and all bats (bottom). The grey rectangular shading indicates short compartments; peach rectangular shading indicates the positions with turn-related differences in flight behaviour (Extended Data Fig. 13b). The red arrow indicates the position at which green correlation reached a value of 0.8, reflecting convergence of the two neural maps. The solid lines show the population-vector correlation using all neurons; green and black shading show the 25–75% confidence intervals of the correlation values (Methods); n = 141 (bat 2)and n = 316 (all bats) CA1 place cells in the forward flight direction (black); n = 163 (bat 2) and n = 334 (all bats) CA1 place cells in the returning flight direction (green). f, Magnified view of the convergence area of neural maps for retrospective coding in bat 2. The thick green curve shows the population-vector correlation pooled over all recording sessions (as in e (top right), retrospective). The thin green lines show the population-vector correlations for five example sessions, showing very rapid convergence in single sessions. g, The variability of retrospective coding (high variability means less-robust retrospective coding; Methods). Left, using all data from bat 2, the retrospective code in CA3 (purple) was less robust and exhibited greater variability than the retrospective code in CA1 (grey). Cell populations in CA1 and CA3 were randomly subsampled to equalize the number of cells (n = 50 cells; 1,000 repetitions). The box plots show the median (horizontal line), 25–75% (box limits) and 10–90% (whiskers), across subsampling repetitions. Statistical analysis was performed using the two-sided Wilcoxon rank-sum test; *****P = 10–300. Right, the same analysis using only neurons with single fields (controlling for sparseness); here the robustness of retrospective coding was similar between CA1 and CA3 (Wilcoxon rank-sum test, P = 0.94). We found prominent differences in CA1 firing-rate maps between returning flights from-turn and from-straight, depending on where they started. The spatial tuning of many cells completely remapped in a large portion of the long tunnel between these two cases (Fig. 5b, right, and 5c,d, and Extended Data Figs. 11a and 12a–c; compare the dark blue versus red flights in the firing-rate maps (top) and spike-raster plots (bottom); note that the flights from-turn and from-straight were interleaved). This remapping effect sometimes reached as far as 130 m from the junction, which corresponds to about 15 s of flight (example: Extended Data Fig. 11a, cell 56). Notably, in the second session, in which the junction was blocked, the firing-rate maps resembled closely the maps of from-straight trajectories (Fig. 5b–d and Extended Data Fig. 11a; compare light blue versus dark blue). In contrast to these strong effects of past trajectories, we found a much weaker effect of future trajectories on the firing-rate maps, when comparing flights to-straight and to-turn (Fig. 5b, left, and Extended Data Fig. 12d,e). Next, we constructed population vectors for each of the four flight types (to-straight, to-turn, from-straight, from-turn) and calculated the correlation between them as a function of position along the tunnel. In the forward flight direction, the population vector correlations between to-straight and to-turn were high throughout the tunnel, and decreased substantially only near the junction (Fig. 5e, left, black lines). This indicates high similarity between firing-rate maps for flights to-turn and to-straight—that is, weak prospective coding. By contrast, the same analysis for returning flights resulted in low similarity between firing-rate maps of flights from-turn versus flights from-straight (Fig. 5e, right, green lines, and Extended Data Fig. 13a). The retrospective population vector correlation was lower for around 90 m after the turn (Fig. 5e (right), compare green versus top grey control traces at positions around 90–180 m), and then, in the middle of the tunnel, the correlation increased abruptly, indicating convergence to the same map (Fig. 5e, right); the red arrow indicates the convergence point of the green and top grey curves). This transition was even more abrupt when examining individual sessions, and it occurred at slightly different locations across sessions (Fig. 5f). Taken together, these results suggest strong retrospective coding (past coding) but weak prospective coding (future coding). We also observed retrospective coding in CA3 place cells (Extended Data Fig. 11b; a population vector analysis is shown in Extended Data Fig. 13a, bottom), but it was less robust than in CA1, even after matching the number of neurons between the two subregions (Fig. 5g (left, for bat 2) and Extended Data Fig. 13e, left, for all cells from all bats, and 13f, left, for only simultaneously recorded CA1 and CA3 cells). Thus, the retrospective information exists already in CA3, but becomes more robust in CA1. Notably, when we restricted the analysis to sparse single-field maps in both CA1 and CA3, the advantage of CA1 in robust retrospective coding disappeared or was strongly reduced (Fig. 5g, right, and Extended Data Fig. 13e–f, right). This suggests that the enhanced retrospective coding in CA1 arises from the denser spatial coding in CA1, rather than from some additional retrospective inputs arriving into CA1 from other brain areas. The two distinct retrospective maps, which depend on where the bat came from, reflect contextual coding. We hypothesized that learning of context-dependent spatial maps is facilitated by the sparse-to-dense coding transformation from CA3 to CA1. To test this hypothesis, we used a modelling framework similar to that shown in Fig. 3d–f but here the learning process optimized a single set of synaptic weights between CA3 and CA1 to minimize the error across two spatial maps, therefore allowing the simultaneous formation of two context-dependent CA1 representations. We found that this context-dependent map learning in CA1 was substantially faster if the input maps from CA3 had sparse representations (Extended Data Figs. 8e and 13g). We therefore propose that the sparse-to-dense architecture of the CA3–CA1 network may be useful for rapid learning and compression of information both about the current position (Figs. 2 and 3) and about past trajectories and contexts (Fig. 5). We hypothesized that the retrospective coding is a memory effect, owing to the differences in the start compartment. We also tested alternative explanations. First, we showed that retrospective coding could not be attributed to the increase in echolocation rate, attention or arousal during the challenging motor action of a 90° turn at the junction; this was shown by using U-turn flights as a control (Extended Data Fig. 14). Second, we showed that the retrospective coding could not be attributed to differences in the 3D flight trajectory or flight speed after the turn (Extended Data Fig. 13b–d). We therefore conclude that the strong retrospective coding is probably due to the differences in the identity of the originating compartment—that is, differences in past context: the memory of which compartment the bat has arrived from. Discussion By examining neural activity in very large environments, we identified two new insights into the functional principles of hippocampal computation. First, we identified a fundamental and substantial difference between the neural coding in two consecutive anatomical subregions of the hippocamps: sparse coding in CA3 → dense coding in CA1 (Figs. 1 and 2). Second, we found strong and long-range retrospective coding in hippocampal place cells (Fig. 5). Overall, our findings suggest that the sparse-to-dense coding transformation in the CA3–CA1 network may be useful for accurate coding of current position (Fig. 3), for robust coding of past trajectories (Fig. 5) and for rapid learning (Fig. 3). Past studies, which have examined spatial coding of relatively large environments in the rodent hippocampus, hinted at a key difference between CA1 and CA3 representations. One study30 used a 48-m zig-zag track and reported multiple fields in CA1 neurons, whereas another study29 used an 18-m straight linear track and reported single fields in CA3 neurons. It remained unclear whether this is a genuine difference between CA1 and CA3, or whether it merely arose from differences in environment size and geometry—in particular, the straight track may have favoured single place fields, while the zig-zag layout may have promoted multiple fields due to remapping in the turning points of the zig-zag. Here we controlled for these differences in environment size and geometry by performing recordings from CA1 and CA3 neurons simultaneously in the same large environment (and in the same animals and sessions), which enabled us to directly demonstrate that the contrast between neural coding in CA1 and that in CA3 is genuine. Previous theoretical studies had suggested that dense and sparse codes offer both computational advantages and disadvantages (see the ‘Additional discussion’ section in Methods). Our results suggest that the hippocampus may use the advantages of both dense and sparse coding: while the CA1 dense code allows high-efficiency positional encoding (Fig. 3a–c), the CA3 sparse code allows faster learning (Fig. 3e–f). A major drawback of the sparse coding observed in CA3 is its lower accuracy of spatial coding. As CA3 is a major input into CA1, and CA1 is a main output projection from the hippocampus to the cortex, we propose that the functional role of CA3 is to serve as a hidden layer in the hippocampal system, which facilitates learning, while the functional role of CA1 is to reformat the information from CA3 into a more efficient and compressed code, therefore representing a similar amount of positional information in CA1 as in CA3 but using fewer neurons (Fig. 3c and Extended Data Fig. 7b). This compression may be achieved mechanistically through random projections from CA3 to CA1 (refs. 51,52). The compressed information is then sent from hippocampal area CA1 to the cortex, where cortical regions can decode the information accurately even from a relatively small subset of CA1 neurons. This notion of reformatting may also explain why the CA3–CA1 coding transformation and compression are more prominent in large environments than in small environments (Fig. 2g). We propose that this occurs due to the higher representational load that the system faces during large-scale navigation. Consequently, we predict that the sparse → dense coding transformation would be even more prominent in larger, multi-kilometre environments: CA3 neurons would start exhibiting more than one place field, to allow coverage of the huge environment—but the number of fields in CA1 would grow even faster, reaching dozens or hundreds of fields per neuron. This prediction awaits future testing. Another possible explanation for the sparse → dense coding transformation (which is not mutually exclusive with the reformatting explanation) is that the sparse code in CA3 may mostly represent the animal’s position in space—while the dense code in CA1 may encode diverse additional information, such as navigational goals, rewards or social information—all of which are strongly represented in CA1 neurons in bats and rodents53–58. Furthermore, the sparse coding through single fields in CA3 may support rapid learning of conjunctive maps for space × other variables in CA1 (ref. 57), where each place field in CA1 functions as an independent unit that binds information on the animal’s experience in that specific location. This additional information on other aspects of the animal’s experience could arrive from outside the hippocampus (for example, from entorhinal cortex) into CA1, where it could be integrated with the mostly single-field inputs arriving from CA3. Finally, we note that the sparse-to-dense coding transformation between CA3 and CA1 may constitute only one stage in a broader sparse-to-dense information-processing hierarchy, extending from the sparsest region, the dentate gyrus, through CA3, to CA1, and possibly ending with the highly dense subiculum10,28 (see the ‘Additional discussion’ section of the Methods). We further investigated hippocampal place cells in a very large multicompartment environment and found a strong and long-range retrospective signal, but a much weaker prospective signal. These results are notable for two reasons. First, this demonstrates retrospective coding over a very large spatial scale of >100 m. Second, the retrospective coding occurred in only half of the environment (Fig. 5e, right)—a type of remapping that to our knowledge has not previously been reported in rodents in small environments. This is particularly interesting considering the established role of the hippocampus in spatial working memory47,59. By using a much larger environment than typically studied, we were able to observe the retrospective signal effectively ‘running out’ mid-flight, revealing a possible functional limit of the working-memory buffer. Both CA1 and CA3 place cells showed this strong long-range retrospective coding, contrasted by a relatively weak prospective coding. Yet the retrospective code found in the sparse-coding CA3 place cells was less robust than the retrospective code found in the dense-coding CA1 place cells (Fig. 5g, left). Furthermore, our learning simulations showed that sparse CA3 input allows faster learning of context-dependent maps in CA1 (Extended Data Fig. 13g). Together, these results suggest that the sparse-to-dense coding transformation between CA3 and CA1 allows compression of information and faster learning—both about the current position and about the past trajectory. The bats in our experiment were not engaged in an explicit memory task, in contrast to many multicompartment experiments in rodents in which the animals needed to alternate right–left trajectories to receive reward, relying on their working memory to make correct choices45–47. The lack of a memory task in our experiment may explain the weaker prospective coding that we observed, because the future choice is arbitrary and non-consequential. Alternatively, the weak prospective coding could be due to a last-minute choice, very close to the junction. It would be interesting in subsequent studies to explore other experimental designs, which require memory-based navigation over long distances. Overall, our findings highlight the importance of studying the hippocampal navigation circuit in naturalistic, large-scale and complex environments. We propose that to fully understand the contributions of different components to the function of a system, it is often necessary to explore the system’s limits—for example, by expanding the spatial scale. We showed that taking this more naturalistic approach can reveal the computational constraints of the hippocampal system and the fundamental principles of its spatial coding. Finally, this study raises the need for future investigations of the brain’s navigation and memory systems under the increased demands of real-life navigation. Methods Bats Fifteen adult male Egyptian fruit bats (Rousettus aegyptiacus) were included in this study for neural recording experiments (weight, 160–200 g). Information on individual bats is summarized in Extended Data Table 1. All experimental procedures for the neural recordings were approved by the Institutional Animal Care and Use Committee of the Weizmann Institute of Science. An additional 12 bats were included in a behavioural-control experiment in a smaller setup, without neural recordings (see below). Behavioural setups for neural recordings Four different behavioural setups were used in this study, shown in Extended Data Fig. 1a,b. All of the setups used tunnels with identical cross-section shape, with a width of 2.3 m and maximal height of 2.35 m (ref. 12), with uniform illumination (5 lux). Details on individual bats in each setup are found in Extended Data Table 1.Linear flight sessions in long tunnel: ten of the recorded bats flew back and forth in fixed-size linear tunnels of lengths 200 m or 130 m, shuttling between two landing balls positioned at the two ends of the tunnel (Extended Data Table 1, bats 1, 3 and 7–14; Extended Data Fig. 1a). Note that these lengths are rounded: The 200-m tunnel had an effective length of 194 m, and the 130-m tunnel had a length that varied between 129–134 m across sessions.Flight sessions in short linear segment: four bats were recorded in an additional separate session in which they flew in a short segment of the tunnel: either 6 m (bats 1, 14 and 15) or 15 m (bat 4). These segments were blocked with opaque curtains or solid blocks at both ends.Landmark perturbation: two bats (bats 2 and 4) performed two recording sessions, separated by a short sleep session of 5–10 min. A single prominent landmark was moved 7.5 m between session 1 and session 2 (the positions of the perturbed landmark are shown in Extended Data Fig. 1b (orange triangles); photograph of the perturbed landmark is shown in Extended Data Fig. 1d). The perturbed landmark was moved daily between the exact same two positions for these two bats.Switching between multicompartment session and linear-flight session in long tunnel: four bats (bats 2, 4, 5 and 6) performed two recording sessions, separated by a short sleep session. In the first recording session (session 1) the bats flew in the large multicompartment tunnel (Extended Data Fig. 1b, top); 193 m length) between 3 landing balls positioned at the 3 ends of the tunnel. Rewards were given equally after landing at each landing ball, and there were therefore no correct or incorrect choices in this paradigm. In the second recording session (session 2), the junction leading to the two short compartments was blocked with a black opaque curtain, and a landing ball was positioned just before the curtain, leaving a 180 m straight tunnel for the bats to fly back and forth between the two landing balls (Extended Data Fig. 1b, bottom). Note that the 180-m tunnel had an effective length of 174 m. Linear flight sessions in long tunnel: ten of the recorded bats flew back and forth in fixed-size linear tunnels of lengths 200 m or 130 m, shuttling between two landing balls positioned at the two ends of the tunnel (Extended Data Table 1, bats 1, 3 and 7–14; Extended Data Fig. 1a). Note that these lengths are rounded: The 200-m tunnel had an effective length of 194 m, and the 130-m tunnel had a length that varied between 129–134 m across sessions. Linear flight sessions in long tunnel: ten of the recorded bats flew back and forth in fixed-size linear tunnels of lengths 200 m or 130 m, shuttling between two landing balls positioned at the two ends of the tunnel (Extended Data Table 1, bats 1, 3 and 7–14; Extended Data Fig. 1a). Note that these lengths are rounded: The 200-m tunnel had an effective length of 194 m, and the 130-m tunnel had a length that varied between 129–134 m across sessions. Flight sessions in short linear segment: four bats were recorded in an additional separate session in which they flew in a short segment of the tunnel: either 6 m (bats 1, 14 and 15) or 15 m (bat 4). These segments were blocked with opaque curtains or solid blocks at both ends. Flight sessions in short linear segment: four bats were recorded in an additional separate session in which they flew in a short segment of the tunnel: either 6 m (bats 1, 14 and 15) or 15 m (bat 4). These segments were blocked with opaque curtains or solid blocks at both ends. Landmark perturbation: two bats (bats 2 and 4) performed two recording sessions, separated by a short sleep session of 5–10 min. A single prominent landmark was moved 7.5 m between session 1 and session 2 (the positions of the perturbed landmark are shown in Extended Data Fig. 1b (orange triangles); photograph of the perturbed landmark is shown in Extended Data Fig. 1d). The perturbed landmark was moved daily between the exact same two positions for these two bats. Landmark perturbation: two bats (bats 2 and 4) performed two recording sessions, separated by a short sleep session of 5–10 min. A single prominent landmark was moved 7.5 m between session 1 and session 2 (the positions of the perturbed landmark are shown in Extended Data Fig. 1b (orange triangles); photograph of the perturbed landmark is shown in Extended Data Fig. 1d). The perturbed landmark was moved daily between the exact same two positions for these two bats. Switching between multicompartment session and linear-flight session in long tunnel: four bats (bats 2, 4, 5 and 6) performed two recording sessions, separated by a short sleep session. In the first recording session (session 1) the bats flew in the large multicompartment tunnel (Extended Data Fig. 1b, top); 193 m length) between 3 landing balls positioned at the 3 ends of the tunnel. Rewards were given equally after landing at each landing ball, and there were therefore no correct or incorrect choices in this paradigm. In the second recording session (session 2), the junction leading to the two short compartments was blocked with a black opaque curtain, and a landing ball was positioned just before the curtain, leaving a 180 m straight tunnel for the bats to fly back and forth between the two landing balls (Extended Data Fig. 1b, bottom). Note that the 180-m tunnel had an effective length of 174 m. Switching between multicompartment session and linear-flight session in long tunnel: four bats (bats 2, 4, 5 and 6) performed two recording sessions, separated by a short sleep session. In the first recording session (session 1) the bats flew in the large multicompartment tunnel (Extended Data Fig. 1b, top); 193 m length) between 3 landing balls positioned at the 3 ends of the tunnel. Rewards were given equally after landing at each landing ball, and there were therefore no correct or incorrect choices in this paradigm. In the second recording session (session 2), the junction leading to the two short compartments was blocked with a black opaque curtain, and a landing ball was positioned just before the curtain, leaving a 180 m straight tunnel for the bats to fly back and forth between the two landing balls (Extended Data Fig. 1b, bottom). Note that the 180-m tunnel had an effective length of 174 m. Each behavioural session started and ended with sleep sessions (each sleep session lasting 5–10 min). For the sleep sessions the bat was placed inside a small covered cage, which was positioned in a quiet location inside the tunnel. In all of the experiments, human experimenters were sitting at the ends of the tunnel (beyond the landing balls). The humans were outside of the area in which the bats were flying. Training of bats and recording sessions All 15 bats were initially pretrained for a few days in a flight-room or in a short segment of the tunnel (6 m or 10 m), with the aim of getting used to handling by humans and learning to perform direct flights between two landing balls. Then, 12 bats were further trained for an average of 3 weeks in the 200 m tunnel (8 bats) or in the 180 m multicompartment environment (4 bats) to fly continuous long flights. After this training, the neural recordings began. Two additional bats were recorded in the 130 m tunnel: Neural recordings in these bats were conducted from the first day of exposure to the long tunnel; we note that in our previous study12, we did not find any change in neural coding in CA1 along days in these two bats. Three of these 14 bats were also neuronally recorded in shorter tunnels (6 m or 15 m; see Extended Data Table 1). One additional bat (bat 15) was neuronally recorded only in the short 6 m tunnel. After training, all of the bats were implanted with a microdrive for electrophysiological recordings in the dorsal hippocampus (see below). Animal localization system We tracked the position of recorded bats using wireless ultra-wideband radio-frequency localization tags (weight 6.6 g, including battery; BeSpoon), which received and transmitted signals to an array of ground-based antennas that were distributed around the tunnel, as was done in our previous work12 (14–40 ground-based antennas, depending on the experimental setup). This localization method yielded a good precision of 5–10 cm in the longitudinal axis (x) and lateral axis (y) of the tunnel. Specifically, we used two setups: The first setup (all of the bats recorded in the 200 m or 130 m tunnels; Extended Data Table 1) had 14 ground-based localization antennas, which yielded a localization precision of 10 cm in x and y. The second setup (all of the bats recorded in the 180 m tunnel and the multicompartment experiments) had 40 localization antennas with a large vertical span, which yielded a localization precision of 5 cm in x and y, and a precision of 20 cm in the vertical axis (z). The position of the bats was acquired at a sampling rate of between 12.8 and 18 Hz. The localization system and the neural recording system were synchronized using a non-periodic sequence of TTL pulses (with temporal precision of <1 ms). Surgery and neural recordings All of the surgical procedures were performed as described previously12,57. In brief, after completion of training, bats were implanted with either a 4-tetrode microdrive (weight, 2.1 g; Neuralynx) or a 16-tetrode microdrive (weight, 3.4 g; modified from ref. 60), loaded with tetrodes, with each tetrode constructed from four strands of insulated wire (17.8-μm diameter platinum-iridium wire). Tetrodes were gold-plated to reduce the wire impedance to 0.3 MΩ (at 1 kHz). The microdrive was implanted above the right dorsal hippocampus (3.0–3.6 mm lateral to the midline and 5.8 mm anterior to the transverse sinus that runs between the posterior part of the cortex and the cerebellum); the craniotomy was then covered with an inert silicone elastomer (Kwik Sil or Kwik-Cast). During the implantation surgery, we used an injectable anaesthesia cocktail composed of medetomidine (0.08 mg per kg), midazolam (2.5 mg per kg), fentanyl (0.025 mg per kg) and ketamine (17 mg per kg) (or, in some bats, medetomidine (0.25 mg per kg), midazolam (2.5 mg per kg) and fentanyl (0.025 mg per kg)), and added supplemental injections as needed, on the basis of the bat’s breathing and heart rate (as measured using an SA Instruments model 1025T Small Animal Monitoring System). The microdrive was attached to the skull with bone screws, using a layer of adhesive (Super-Bond C&B) followed by dental acrylic. We attached the ground wire from the microdrive to a bone-screw that touched the dura in the skull’s frontal plate. After surgery, the tetrodes were slowly lowered toward the CA1 pyramidal layer; positioning of tetrodes in the layer was provisionally performed on the basis of the presence of high-frequency field oscillations (ripples) and associated neuronal firing. After recording cells in the CA1 cell layer, in five of the recorded bats we further lowered some of the tetrodes to reach the CA3 cell layer, and subsequently conducted recordings simultaneously in CA3 and CA1 (Extended Data Table 1). For each bat, one tetrode was left in an electrically quiet zone and served as a reference, and the remaining tetrodes served as recording probes. The tetrodes’ exact recording location was later verified histologically (Fig. 1b and Extended Data Fig. 5b). During recordings, a wireless neural-recording device (neural logger; 16 channels or 64 channels, Deuteron Technologies) was attached to a connector on the microdrive. Signals from all channels were amplified (×200) and bandpass filtered (1–7,000 Hz), and were then sampled continuously at 31.25 or 32 kHz per channel, and stored on board the neural logger. During subsequent processing, the neural recording was further high-pass filtered with a 600 Hz cut-off for spikes, creating a spike bandwidth of 600–7,000 Hz and then a voltage threshold was used for extracting 1 ms spike waveforms. Histology At the end of recordings, the bats were anaesthetized, and electrolytic lesions (DC positive current of 30 μA for 15 s duration) were made in a subset of the tetrodes, to facilitate the reconstruction of tetrode positions. The bat was then given an overdose of sodium pentobarbital and, with tetrodes left in situ, was perfused transcardially using PBS followed by 4% paraformaldehyde or 4.5% Histofix. The brain was removed and post-fixed. Thin coronal sections were then cut at 30 or 40 μm intervals on a freezing microtome. The sections were Nissl-stained with cresyl violet and were photographed to determine the locations of tetrode tracks in dorsal CA1 or CA3 (Fig. 1b and Extended Data Fig. 5b). Positions of tetrode-tracks were then mapped onto coronal plates of a stereotaxic brain atlas of the Egyptian fruit bat61, and were then projected onto a 3D reconstruction of CA1 and CA3 cell layers, which we prepared on the basis of our stereotaxic brain atlas. Finally, we used these projections to estimate the tetrode-track position along the longitudinal axis and proximodistal axis of CA1 and CA3 (Extended Data Fig. 5; both the proximodistal axis and longitudinal axis are curved anatomical axes within the 3D space of the bat brain; we therefore estimated the distances along these curved axes). In the analysis in Extended Data Fig. 5, we did not include tetrodes with poor histology, for which we were able to localize the tetrode tracks to CA1 or CA3 but were not able to localize with sufficient accuracy the exact tetrode location within each subregion (this excluded data from 3 out of the 14 bats recorded in the long tunnels). Spike sorting Spike-sorting procedures were identical to those described previously12,57. In brief, spike waveforms were sorted manually using Plexon Offline Sorter, on the basis of their relative amplitudes on different channels of each tetrode. Data from all of the behavioural sessions and sleep sessions from the same recording day were spike-sorted together. Well-isolated clusters of spikes were manually selected, and a refractory period (<2 ms) in the interspike-interval histogram was verified. Spike sorting was performed in consecutive time windows to allow for drift correction of the spike clusters. We included only neurons that were stably isolated throughout the recording. We further analysed only putative pyramidal cells with mean firing rate <5 Hz, which met behavioural-coverage criteria as described below for the different behavioural setups. A summary of the number of cells analysed for each type of behavioural session is provided in Extended Data Table 1. Statistics For all of the pairwise comparisons, we used two-tailed (two-sided) statistical tests, with a probability threshold of α = 0.05. Correlations were based on Spearman’s correlation coefficient (two-tailed test), unless noted otherwise. We used the Wilcoxon rank-sum test to compare distribution medians, and the two-sided Kolmogorov–Smirnov test to compare distribution shapes. To determine the significance of place tuning, we compared the real data with shuffled data (see below). No power analysis was used to predetermine the sample size. Extracting flights Flight behaviour was analysed separately for the experiments in the linear tunnels (130 m and 200 m: Extended Data Fig. 1a) and for the experiments in the multicompartment and 180 m tunnel (Extended Data Fig. 1b), as follows: In the linear tunnels, the bat flight behaviour was mostly restricted to a 1D narrow horizontal corridor at the middle of the tunnel12. Thus, for these linear environments, all of the analyses and statistical tests were performed strictly on the basis of 1D firing-rate maps (projections on the long axis of the tunnel), as described previously12. In brief, location data were first processed to remove outliers (we removed datapoints that were outside the tunnel’s walls (>80 cm), or data with velocity higher than 20 m s−1). We then linearized the data by projecting the valid positional data onto the long 1D axis of the tunnel (the tunnel’s ‘backbone’, which was measured using the radio-frequency localization tag). We then filled short gaps where localization data were missing. We used linear interpolation to fill gaps up to 1.5 s, only if flight speed was stable during the gap. This gap-filling procedure yielded a maximal error of no more than 25 cm on average, as tested by introducing simulated gaps in real data that had no gaps. Finally, the 1D positional data were upsampled to 100 Hz. Directional flight epochs were detected as periods during which the bat’s speed was >1 m s−1 and reached a peak speed >4 m s−1, without changes in flight direction. In the multicompartment environment, to capture the 2D shape of the environment, we used 2D raw positional data from which we extracted the 2D flight speed. Thus, to define flight epochs, we increased the flight speed threshold to >2 m s−1, while maintaining the same criterion for peak speed >4 m s−1 and requiring the absence of changes in flight direction (note that typical flight speeds were actually much higher than 4 m s−1)12. We then extracted for each flight its start and end positions, and assigned these positions to one of the environment’s compartments: long, straight or turn compartments (compartments are defined in Extended Data Fig. 10b). Next, we linearized each flight to a 1D axis, while keeping the identity of the flight’s start and end compartments. Gaps in the flights were filled in a manner similar to that described above for the linear flights. As in this multi-compartment setup we had an improved localization precision of 5 cm, it enabled us to fill gaps up to 5 s (instead of 1.5 s); only gaps that occurred in the long part of the tunnel (away from the junction) were filled, provided that the flight speed was stable during the gap, and that the bat’s wingbeat-rate was highly stable (as assessed using an on-board accelerometer). Similar to the linear flight setup, the gap-filling procedure was tested by introducing simulated gaps in real data which had no gaps, and it yielded a maximal error of no more than 25 cm on average. Finally, the 1D positional data were upsampled to 100 Hz. Computing firing-rate maps Firing-rate maps were constructed for flight periods only—separately for the two flight directions. For the multicompartment experiments we also separated the data on the basis of the flight start and end compartments. To compute 1D firing-rate maps, we counted the number of spikes and the time spent in each spatial bin (20-cm bins). Bins with time spent <0.75 s per metre were discarded. We smoothed both the spike-count and time-spent 1D map with a Gaussian kernel (σ = 2.5 bins, namely 0.5 m), and then divided, bin by bin, the smoothed 1D spike-count by the smoothed 1D time spent, to produce a firing-rate map. We included for further analysis only sessions with (1) more than 10 flights per direction and (2) valid firing-rate map with no gaps for at least 100 m. For the short tunnels (6 m and 15 m) we used 1D speed threshold of 1 m s−1, threshold for peak speed of 2 m s−1, smaller spatial bins of 10-cm and a smoothing kernel of σ = 2 bins, namely 0.2 m. We also analysed U-turns, as shown in Extended Data Fig. 14. Quantifying spatial coding, definition of place cells and defining place fields To quantify the spatial coding of firing-rate maps, we used the spatial information (SI) index, measured in bits/spike (Fig. 2d): \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathrm{SI}\left(\frac{\mathrm{bits}}{\mathrm{spike}}\right)={\sum }_{i}{p}_{i}\left(\frac{{r}_{i}}{\bar{r}}\right){\log }_{2}\left(\frac{{r}_{i}}{\bar{r}}\right)$$\end{document}SIbitsspike=∑ipirir¯log2rir¯, where ri is the firing rate of the cell in the ith bin, pi is the probability of the bat to be in the ith bin, and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\bar{r}$$\end{document}r¯ is the overall mean firing rate of the cell. Place cells in CA1 and CA3 were classified as significant place cells only on the basis of the linear flight data (using the linear tunnels and the blocked session, excluding the multicompartment session) if they met the following criteria: (1) significant spatial information compared to spike shuffles (>99% of shuffles): to shuffle the spike trains, we rigidly and circularly shifted in time the spikes of each flight, using a uniform random shift; the value of the shift differed randomly between individual flights, so each shuffle consisted of a unique set of temporal shifts that differed randomly across flights. We performed 1,000 such random shuffles for each neuron. (2) Spatial information was >0.25 bits per spike. (3) A cell emitted a minimal number of spikes in-air per flight direction during the entire session: ≥50 spikes in the 130 m and 200 m tunnel experiments; and ≥20 spikes in the blocked session of the multicompartment experiment (we used here a lower spike-count threshold because the two behavioural sessions resulted in fewer straight-flight trials per session); we also required ≥20 spikes in the short tunnel experiments, where the reduced time in-air limited the spike count. (4) The cell had at least one significant place field, as described next. To detect place fields, we used the same algorithm as we used previously12 and applied it to both CA1 and CA3 data. (1) First, we extracted local peaks in the firing-rate map, with a peak-rate of >1 Hz. (2) To remove small local peaks ‘riding’ on a large field, we searched for shallow ‘dips’—that is, cases in which the dip between two adjacent peaks was >50% of the firing rate of the larger peak—and then disregarded the lower peak. (3) We then defined the boundaries of the field as follows: we identified the zone covering 20% of the peak firing rate of that place field. Then, to overcome the smearing caused by the smoothing of the firing-rate map, we defined the field size as the 5–95% percentile of the positions of the spikes that occurred inside the 20% zone. (4) Field stability criterion: we required at least 10 different laps inside the place field, out of which there were at least 5 different laps with spikes inside the place field, or 20% of the laps with spikes, whichever is larger. (5) Field significance criterion: to capture clear distinct fields, we treated a place field as significant only if it had significant spatial information in its local area, near the place field. To quantify this, we looked at the area surrounding the field (specifically, the field itself plus 50% of the field’s size on each side). Focusing on this local area around the place field, we calculated the spatial information for the real spikes and compared it to 1,000 shuffles (same rigid shuffling as above), and considered the field to be significant only if it had spatial information of >95% of the shuffles in this constrained local area. For each neuron we computed four indices: (1) spatial information, in bits per spike, as defined above (Fig. 2d). (2) Total coverage of all of the fields, defined as the sum of all field sizes per direction, normalized by the length of the flight track (Fig. 2e). (3) Sparsity (Fig. 2f), defined as \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\frac{{\langle {r}_{i}\rangle }^{2}}{\langle {r}_{i}^{2}\rangle }={\left(\sum {p}_{i}{r}_{i}\right)}^{2}/\sum {p}_{i}{r}_{i}^{2}$$\end{document}⟨ri⟩2⟨ri2⟩=∑piri2/∑piri2, which is bounded between 0 and 1, with low values indicating high spatial selectivity and sparser coding. (4) Map correlation, an index of map stability, computed as the Pearson correlation coefficient between maps constructed separately for the first half versus second half of the session (Fig. 2c) or for odd versus even flights (Extended Data Fig. 4c). These four indices were computed separately for each flight direction. All of the comparisons of spatial coding in CA3 versus CA1 in Fig. 2 were performed using only data from the linear flight sessions (using data from the linear tunnels (200 m and 130 m) and from the session in which the tunnel was blocked (180 m linear tunnel); here we excluded the data from the multicompartment session). Generating model maps and decoding simulations For the decoding simulations (Fig. 3a–c), we created populations of neurons with simulated place fields, using the multifield multiscale encoding scheme described before12 for CA1 maps, and a single-field encoding scheme for CA3 maps. We used a maximum-likelihood decoder to study the decoding accuracy implied by these two encoding schemes, for populations of CA1 neurons and CA3 neurons. Decoding was done with an integration time window of 500 ms. Encoding In our simulations, the environments had a 0.2-m resolution (0.2-m bin size); the same binning as was used to analyse the real data. We varied the size of the environment, L, between 20 m and 1,000 m. The neurons had rectangular fields, did not fire outside their fields, and fired at a fixed rate m0 within their fields (with Poisson statistics). CA3 scheme For each neuron, we picked a single field, with a field location that was sampled from a uniform distribution over the environment of length L (measured in metres). The field size was sampled randomly from a gamma distribution (which is very similar to a log-normal distribution12), with a shape parameter α and a scale parameter θ, which were calculated from the experimental distribution of CA1 and CA3 field sizes for the 200 m and 180 m environments (L = 200 metres) (α = 3.46 and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\theta =1.46\times \sqrt{L/200}\,\mathrm{metres}$$\end{document}θ=1.46×L/200metres). The square-root scaling of the field-size distribution with the environment size L is consistent with field-size distributions measured at multiple environment sizes (Fig. 2h and Extended Data Fig. 3h). CA1 scheme For each neuron, the field sizes were randomly chosen from a gamma distribution identical to the distribution used for the CA3 scheme. The number of fields was chosen such that the cumulative coverage of all of the fields together reached \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$0.139\times L\times \sqrt{200/L}\,{\rm{metres}}$$\end{document}0.139×L×200/Lmetres. The pre-factor 0.139 represents the neurons’ average coverage at the 200 m environment size in our experiments (Fig. 2i and Extended Data Fig. 3i). Field locations were randomly distributed along the environment, with no overlaps. The square-root scaling of the coverage with the inverse of the environment size is consistent with our recordings at multiple environment sizes (Fig. 2i). We denote each neuron’s spatial selectivity map by \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${f}_{i}^{a}(x)$$\end{document}fia(x), where i is the neuron index (i = 1, …, N), and a is the scheme index (a = CA3 or CA1). \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${f}_{i}^{a}(x)$$\end{document}fia(x) is equal to 1 if the neuron has a field in position x and 0 if it does not, that is, the field shapes in our model were taken to be rectangular. Generating spike counts We assumed that the animal starts each simulation trial at a position x = x0, and flies at speed v = 8 m s−1 (the typical empirical flight-speeds) for a time interval Δt = 500 ms. The expected spike count of the neuron during that trial is given by:\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${m}_{i}={m}_{0}\underset{{x}_{0}}{\overset{{x}_{0}+v\Delta t}{\int }}{f}_{i}^{a}(x){\rm{d}}x,$$\end{document}mi=m0∫x0x0+vΔtfia(x)dx, where m0 is the expected spike count if the animal spent the entire interval within a field. We used m0 = 5 in all our simulations (taken together with the integration time window of 500 ms, this gives a typical in-field firing rates of 10 Hz). The actual spike-count in each trial was drawn from a Poisson distribution with rate mi and is denoted below as ni. Maximum-likelihood decoding We computed the log-likelihood of each simulated neuron’s spike count, and summed it over the N neurons:\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${A}_{\mathrm{ML}}(x)=\mathop{\sum }\limits_{i=1}^{N}{n}_{i}\log [{m}_{0}\,{f}_{i}^{a}(x)]-{m}_{0}\mathop{\sum }\limits_{i=1}^{N}{f}_{i}^{a}(x)$$\end{document}AML(x)=∑i=1Nnilog[m0fia(x)]−m0∑i=1Nfia(x)where the first term corresponds to a sum of the spatial tuning of all neurons, weighted by their activity. The second term corresponds to the correction for unequal coverage in different locations. The decoded location was then taken as the one that maximizes AML(x). Figure 3a,b show results from 105 simulation-trials generated by drawing random field locations 100 times, then drawing random spike counts from the Poisson distribution 20 times, and then performing decoding at 50 equally spaced locations x0 spanning the entire environment (100 × 20 × 50 = 105). Figure 3c shows results from 5,000 simulation trials for each value of N. Note that the probability of catastrophic decoding errors (errors larger than 5% of the environment size) shown in Fig. 3b is not a monotonic function of environment size—it first decreases and then increases again. This non-monotonic behaviour arises because catastrophic errors were defined as a fixed percentage of the environment size (namely 5%), whereas the spatial coverage of the simulated firing-rate maps scaled with the square root of the environment size (a choice that was motivated by the experimental data (Fig. 2i)). The interaction between these differently scaled quantities resulted in the observed non-monotonic dependence of catastrophic error probability on environment size. Decoding using matched firing rates between CA1 and CA3 We controlled here for the possibility that the better decoding performance in CA1 stems from higher mean firing rates in that region compared with CA3. Notably, CA1 neurons show higher mean firing rates because they have more fields and larger coverage than CA3 neurons, and not because of differences in the in-field firing rates (Extended Data Fig. 4a). We controlled for the mean firing-rate differences by performing similar decoding simulations as in Fig. 3a–c, but after matching the mean firing rate for the maps in CA1 and CA3 (Extended Data Fig. 7c–f). Specifically, we kept the parameters for CA1 maps as before (and therefore the decoding performance for CA1 was as in Fig. 3a–c), whereas, for CA3 maps, we matched the mean firing rate to the mean firing rate of CA1 maps, by multiplying the parameter m0 by the ratio between the average coverage of CA1 maps and the average coverage of CA3 maps. Note that this ratio depends on the environment size L, but for all values of L the ratio was greater than 1, resulting in higher peak firing rate in CA3 neurons compared with CA1 neurons. Target-map learning simulations and quantifying the learning time For the target-map learning simulations (Fig. 3d–f and Extended Data Figs. 8, 9g and 13g), we implemented node perturbation (NP) and weight perturbation (WP) learning algorithms to obtain the synaptic weights that minimize the reconstruction error of a target CA1 map \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${f}_{i}^{\mathrm{CA}1}(x)$$\end{document}fiCA1(x) for CA1 neuron i, based on banks of CA3 maps \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${f}_{k}^{\mathrm{CA}3}(x)$$\end{document}fkCA3(x). We considered banks of N = 200 independently sampled CA3 maps—namely, 200 CA3 inputs to a CA1 neuron—for which we systematically varied the number of fields nf that each CA3 map had (nf = 1, ..., 6 fields; k = 1, ..., 200 CA3 maps; different 200 maps for each value of nf; note that 200 maps in CA3 provide sufficient coverage for each CA1 map to yield all possible fields locations, without any empty spaces). We assumed that synaptic weights Uik are learned to minimize the reconstruction error. Specifically, given the target map, the input maps, and a set of synaptic weights \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${U}_{{ik}}$$\end{document}Uik, the squared location-specific reconstruction error was defined as\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${{\epsilon }}_{i}^{2}(x)={\left[{f}_{i}^{\mathrm{CA}1}(x)-\mathop{\sum }\limits_{k=1}^{N}{U}_{{ik}}{f}_{k}^{\mathrm{CA}3}(x)\right]}^{2}.$$\end{document}ϵi2(x)=fiCA1(x)−∑k=1NUikfkCA3(x)2. In NP, following ref. 37, in each iteration t, we perturbed the output neuron (node) by adding to its response a random number \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${\xi }_{i}(t) \sim $$\end{document}ξi(t)~\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${\mathcal{N}}(0,{\sigma }_{\mathrm{NP}}^{2})$$\end{document}N(0,σNP2). The squared location-specific reconstruction error including the node perturbation is then\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${{\epsilon }}_{i,\mathrm{NP}}^{2}(x)={\left[{f}_{i}^{\mathrm{CA}1}(x)-\left(\mathop{\sum }\limits_{k=1}^{N}{U}_{{ik}}{f}_{k}^{\mathrm{CA}3}(x)+{\xi }_{i}(t)\right)\right]}^{2}.$$\end{document}ϵi,NP2(x)=fiCA1(x)−∑k=1NUikfkCA3(x)+ξi(t)2. The NP learning rule for the synapses between CA3 neuron k and CA1 neuron i is implemented as\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\Delta {U}_{{ik}}^{\mathrm{NP}}({t})=-{\eta }_{\mathrm{NP}}{\xi }_{i}(t)\mathop{\sum }\limits_{x=1}^{L}{({\epsilon }}_{i,\mathrm{NP}}^{2}(x)-{{\epsilon }}_{i}^{2}(x)){f}_{k}^{\mathrm{CA}3}(x).$$\end{document}ΔUikNP(t)=−ηNPξi(t)∑x=1L(ϵi,NP2(x)−ϵi2(x))fkCA3(x). In WP, the weights are perturbed with synapse-specific noise \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${\xi }_{{ik}}(t) \sim {\mathcal{N}}(0,{\sigma }_{{\rm{WP}}}^{2})$$\end{document}ξik(t)~N(0,σWP2) rather than perturbing the output. Now the squared error is\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${{\epsilon }}_{i,\mathrm{WP}}^{2}(x)={\left[{f}_{i}^{\mathrm{CA}1}(x)-\mathop{\sum }\limits_{k=1}^{N}({U}_{{ik}}+{\xi }_{{ik}}(t)){f}_{k}^{\mathrm{CA}3}(x)\right]}^{2},$$\end{document}ϵi,WP2(x)=fiCA1(x)−∑k=1N(Uik+ξik(t))fkCA3(x)2,and the WP learning rule is implemented as\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\Delta {U}_{{ik}}^{\mathrm{WP}}({t})=-{\eta }_{\mathrm{WP}}{\xi }_{{ik}}(t)\mathop{\sum }\limits_{x=1}^{L}{({\epsilon }}_{i,\mathrm{WP}}^{2}(x)-{{\epsilon }}_{i}^{2}(x)).$$\end{document}ΔUikWP(t)=−ηWPξik(t)∑x=1L(ϵi,WP2(x)−ϵi2(x)). We ran each simulation for 1,000 time-steps for each spatial bin. We used the parameters \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${\sigma }_{{\rm{NP}}}=1$$\end{document}σNP=1 and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${\sigma }_{{\rm{WP}}}=0.2$$\end{document}σWP=0.2. The learning rate parameter η η was optimized for single-field maps in CA3 (nf = 1), to yield the fastest learning, namely the fastest monotonic decrease of the average reconstruction error. We then used a grid search over different values of η and nf, and confirmed that, similar to the birdsong literature36, the optimal learning rate η is inversely proportional to the number of CA3 fields nf (in the birdsong study, η scaled inversely with the number of bursts in a song); specifically, we found \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${\eta }_{\mathrm{NP}}={5\times 10}^{-6}/{n}_{{\rm{f}}}$$\end{document}ηNP=5×10−6/nf and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${\eta }_{\mathrm{WP}}={5\times 10}^{-6.5}/{n}_{{\rm{f}}}$$\end{document}ηWP=5×10−6.5/nf. We therefore scaled η inversely with nf in our simulations. For each learning algorithm and each number of fields of CA3 maps, we learned separately the weights to reconstruct 500 target maps in CA1 (namely, i = 1, ..., 500). As the learning process of a single map can be noisy, we smoothed the learning curve as follows. For each specific target error, we drew randomly 250 of the 500 target maps, averaged those 250 learning-curves and computed the learning time from this averaged learning curve; this process (of drawing 250 maps and computing the learning-time) was repeated 200 times and the resultant learning time—shown in Fig. 3e and Extended Data Fig. 8—was computed as the median of these 200 learning-times. Note that our theoretical model is deliberately simplified and does not account for contributions from other regions, such as inputs from CA2 or the entorhinal cortex into CA1. This simplification was motivated by our previous finding showing independent dynamics of different place fields of the same CA1 neuron12. This previous finding is more consistent with synaptic plasticity that potentiates or depresses independent inputs from single-field neurons12, such as inputs from the sparse CA3 neurons (Figs. 1 and 2), rather than inputs which have multiple fields, such as inputs from grid cells in entorhinal cortex, where single neurons have multiple fields62. In other words, our previous findings suggested that the most plastic inputs into CA1 are coming from CA3 neurons with single fields, rather than from entorhinal cortex; this is why we ignored the entorhinal cortex in our model. Nevertheless, even when we incorporated into the model additional non-plastic inputs to CA1 (non-CA3 inputs, see the next paragraph), the sparse CA3 inputs provided an advantage in the learning speed of CA1 output maps compared with dense CA3 inputs (Extended Data Fig. 8c). Learning with input from both CA3 and EC/CA2 In these simulations (Extended Data Fig. 8c), the target map was set to fi(x) + zi(x), where fi(x) is the original target map and zi(x) arises due to non-plastic spatial input representing an additional external input into CA1, such as from the entorhinal cortex (EC) or from CA2 (this input is constant throughout the learning, but different from one position to the next). For each spatial bin x, zi(x) is sampled from a Gaussian distribution with mean 0 and variance ϕ(1 − ϕ), independently of every other bin, where ϕ is the average coverage of all CA1 target maps. As fi(x) for every x is a binary variable, its variance is ϕ(1 − ϕ). Thus, setting the variance of zi(x) to ϕ(1 − ϕ) ensures that the magnitudes of the learned component and the external component are equal. Learning after a local perturbation to an already-learned environment In these simulations (Fig. 3f and Extended Data Figs. 8d and 9g), the local perturbations were performed by increasing the firing rate of target CA1 maps by a factor of 4 in an 8-m region within the map, and learning the weights that best reconstruct this modified map. For each map these simulations were initialized using the final value of the synaptic weights obtained from the original learning simulation described above. Learning of context-dependent maps In these simulations (Extended Data Figs. 8e and 13g), each neuron in CA1 received inputs from a set of CA3 neurons, each of which had a context-dependent spatial representation. Specifically, each CA3 neuron represented the animal’s location based on two maps generated independently, corresponding to two different contexts (for example, flights from two different start locations: retrospective coding). Each CA1 neuron was required to produce two distinct output target maps, one for each context, using a single set of synaptic weights linking input and output maps. The synaptic weights were updated according to the node-perturbation learning rule, with a training protocol that alternated between the two contexts. Firing-rate map changes with respect to landmark perturbation Bats flew in two behavioural sessions, and one prominent landmark was moved by 7.5 m between the two sessions, keeping in place all of the other landmarks (Fig. 4a,c: the two locations of this landmark are marked with dashed and solid orange lines). This manipulation was performed in two bats, during 27 and 18 recording days in bats 2 and 4, respectively. In all of these recording days, in the first behavioural session the landmark position was x = 70.5 m, and in the second session the landmark was moved to position x = 78 m. The two sessions differed not only by the perturbed landmark location but also in the environment’s structure: in the first session, the environment included two short 10-m segments at one end of the 180-m tunnel, while in the second session, these segments were blocked, resulting in a linear 180-m tunnel (Extended Data Fig. 1b). Importantly, the two environments were identical in the first 180 m, with the only difference being the perturbed landmark in positions between 70.5–78 m, which was more than 100 m away from the blocked short segments (the block was positioned at x = 180 m). Nevertheless, to isolate the effects of the perturbed landmark from any potential effects of prospective or retrospective coding at the far end of the tunnel (close to x = 180 m; Fig. 5), we limited our analysis of the landmark-perturbation effects (Fig. 4) as follows. For forward flights (eastward), we analysed the first 140 m of the tunnel (x = 0–140 m) and, for returning flights (westward), we analysed the last 100 m of the flight trajectory, corresponding to the first 100 m of the tunnel (x = 0–100 m). These areas were chosen for the analysis on the basis of the range of prospective and retrospective coding effects (prospective coding was overall weak (Fig. 5e, left), and retrospective coding (for returning flights) was mostly limited to the eastern half of the tunnel, x > 100 m (Fig. 5e, right)—which is why we focused the analysis of landmark-perturbation on the area x = 0–100 m, which was unaffected by retrospective coding). Only days with a minimum of 10 flights in each of the two sessions and valid firing-rate maps of at least 100 m were included for further analysis (n = 45 experimental days). Firing rate versus position for individual flights was calculated with 1-m spatial bins and smoothed with a Gaussian kernel (σ = 2.5 bins, namely 2.5 m). The firing-rate values of all of the flights within each spatial bin were compared between the two behavioural sessions (t-test with Bonferroni correction for the number of spatial bins: we corrected for the number of non-zero firing-rate bins that were compared between the two sessions). Significantly changed positions in the tunnel were defined as two or more consecutive spatial bins which were significant on the basis of the t-test, and were located within the position range as described above (Fig. 4a, orange dots above the firing-rate maps; population: Fig. 4c, grey and purple bins). The number of changes across place cell maps per spatial bin were compared to a shuffle distribution, in which the significantly changed bins of each map were shuffled with a random rigid circular shift across all of the bins of the map that had valid behaviour and non-zero firing rates. We performed 1,000 such shuffles (1,000 sets of these random shifts) and calculated in the same way as for the original map the distribution of changed bins as a function of position along the tunnel. Only one spatial bin had a larger number of changed firing-rate bins as compared to 99% of the shuffles; this significant bin was located close to the perturbed landmark position, and this spatially focused change occurred only in the CA1 maps (Fig. 4c, top left). The over-representation of firing-rate changes near the perturbed landmark was further assessed using a binomial test, under the assumption of a uniform probability of change along the tunnel. This probability was defined as the number of observed changes across all locations divided by the number of spatial bins eligible for comparison (that is, bins with non-zero spiking activity in at least one of the two sessions). The test revealed a significantly higher than chance number of changes near the perturbed landmark in CA1 (Fig. 4c, top left, two spatial bins (asterisks)). In both the binomial and shuffle tests, no significant changes were found in the population of CA3 maps (Fig. 4c, top right). To account for the different numbers of place cells in CA1 and CA3, we matched (subsampled) the number of CA1 cells to that of CA3 (n = 22) and repeated the analysis over 1,000 subsampling repetitions. In 95% of these repetitions, place cells in CA1 still showed a greater number of firing-rate changes near the perturbed landmark than place cells in CA3. Furthermore, the over-representation of changes near the perturbation site was statistically significant (on the basis of the binomial test) in 45% of the subsampling repetitions (45% at the α = 5% chance level for an individual test is highly significant: P < 10–300, population-wise binomial test). Population vector correlations for prospective and retrospective coding For multicompartment recording sessions, we constructed population vectors from the firing-rate maps of the entire place cells population (separately for each bat, pooled over all of the recording days of the bat). These population vectors were computed separately for four different flight types (Fig. 5a, dark blue and red arrows): (1) forward flight direction ending in the straight compartment (to-straight) or (2) ending in the turn compartment (to-turn); and (3) returning flight direction starting from the straight compartment (from-straight), or (4) starting from the turn compartment (from-turn). The population vectors were then smoothed by averaging over a sliding window of 10 m (boxcar smoothing), with 0.2 m steps, and then the firing-rate map of each cell was normalized separately to a firing-rate range of 0–1, by dividing the smoothed map by its peak firing rate. Then, for each spatial bin (each position), we calculated the Pearson correlation between pairs of population vectors: (1) correlations between to-straight versus to-turn flights, which quantifies prospective coding in the neuronal population (Fig. 5e, left, black); (2) correlations between from-straight versus from-turn flights, which quantifies retrospective coding in the neuronal population (Fig. 5e, right, green); (3) correlations between opposite flight directions, which served as a control, capturing the baseline near-zero correlation due to the global remapping that is known to occur in 1D environments between two opposite movement directions12,31 (Fig. 5e, lower grey curves; shown is the average per spatial bin of the correlation of to-turn versus from-turn and correlation of to-straight vs. from-straight, both of which are for flights in opposite directions); and (4) correlations between maps for odd and even flights in the same directions, which served as another control, capturing the high correlations expected for stable tuning (Fig. 5e, top grey curves). The population vector correlations were plotted as a function of position (Fig. 5e and Extended Data Fig. 13a). Correlations in the short compartments were calculated by correlating the data for the turn and straight compartments; the low correlations there reflects remapping. Confidence intervals for the correlation values were determined by randomly drawing 50% of all of the neurons without replacements, with 1,000 repetitions (25–75% of correlation values across repetitions for each position; plotted as green, black and grey shading, for the retrospective, prospective and control population-vectors, respectively, in Fig. 5e and Extended Data Fig. 13a). This analysis was done fully in three bats: bat 2 (Fig. 5e (top) and Extended Data Fig. 13a (rows 1 and 5), bat 5 (Extended Data Fig. 13a (row 3); a small number of neurons were recorded in this bat), and bat 6 (Extended Data Fig. 13a (row 4); recordings in CA1 only). Bat 4 allowed only partial analysis because it always flew stereotypically from the straight 10-m tunnel to the long tunnel, and never turned left from the turn-compartment to the long tunnel, which did not permit analysis of retrospective coding, but only of prospective coding (this bat is shown in Extended Data Fig. 13a, row 2). Variability of retrospective coding Variability of retrospective coding. To quantify the variability of retrospective coding (high variability means low robustness), we analysed the population-vector correlation curves for the retrospective case (green curves for CA1 in Fig. 5e and for CA3 in Extended Data Fig. 13a, rows 5–6). Variability was computed separately for populations of CA1 and CA3 place cells. To allow direct comparison between CA1 and CA3, both cell populations were randomly subsampled to include an equal number of cells (n = 50 place cells; 1,000 repetitions). For each of the 1,000 subsamples, the variability of the population-vector retrospective curve was quantified as the median of the s.d. of this curve in 10-m spatial windows, therefore reflecting local fluctuations in the population-vector correlation curve on a 10-m scale. The distribution of variability values across subsampling iterations was summarized using box plots, comparing CA1 versus CA3 (Fig. 5g, left, and in Extended Data Fig. 13e,f, left). To further examine the contribution of multi-field coding to robustness, the analysis was repeated after restricting the dataset to neurons with single spatial fields (in both CA1 and CA3; right panels in Fig. 5g and in Extended Data Fig. 13e,f). Prospective and retrospective place-field classification To analyse significant prospective/retrospective changes in individual place fields (Extended Data Fig. 13c,d), we performed the following analysis on the long arm of the tunnel (180 m). Place fields were detected as described above (see the ‘Quantifying spatial coding, definition of place cells and defining place fields’ section). The fields were detected separately for firing-rate maps for the four conditions: to-straight, to-turn, from-straight, from-turn. Owing to significant differences in behaviour within the 20 m closest to the junction (positions between x = 160 and 180 m), all place fields in this region were excluded from the analysis in Extended Data Fig. 13c,d (this range is marked by peach shading in Fig. 5e and Extended Data Fig. 13c-d; on average, across recording sessions and bats, there were significant changes in trajectory and speed for 22 m after the turn (x = 158–180 m)). For positions 0–160 m, place fields were classified as significant prospective or retrospective fields if they met the following two criteria: (1) firing rate during flight passes inside the place field was significantly different for straight-compartment versus turn-compartment flights (two-sided t-test over all of the individual flights of a session). (2) No difference in behavioural variables: y position (flight position along the lateral axis of the tunnel width), z position (flight height) and flight speed were all not significantly different for straight-compartment flights versus turn-compartment flights that passed inside the place field (t-test for each variable separately; 228 fields out of total of 1,668 fields were excluded from this analysis due to significant differences in behaviour in either of these 3 behavioural variables). These requirements ensured that the firing-rate changes inside the place field were genuinely representing effects of the future or past compartment—namely prospective or retrospective coding—and were not due to behavioural differences in flight trajectory or speed. In cases in which one or more behavioural variables was significantly different inside the place field, between flights ending in the straight and turn compartments, a matching procedure was performed, such that only flights that overlapped in y-position, z-position and speed were included as valid flights for the firing-rate comparison. If, after removal of unmatched flights, the firing rate inside the place field was significantly different for straight-compartment versus turn-compartment flights, then the place field was considered as a significant prospective or retrospective field. All statistical comparisons required a minimum of five valid flights passes through the examined place field in each of the flight types (5 flights after flight removal based on matching of the behaviour). We then classified all of the place fields in the multicompartment behavioural session, which were located at the long compartment of the tunnel (0–160 m), to one of four categories: (1) prospective fields; (2) retrospective fields; (3) non-significant prospective or retrospective fields; or (4) fields with non-valid behaviour (a field was classified in this fourth category if within the field any one of the behavioural variables was significantly different between flight types, or if there were fewer than 5 flight passes in one of the flight types). The percentage of significant prospective and retrospective fields versus position in the tunnel was plotted in Extended Data Fig. 13c, separately for CA1 and CA3 place cells. We also computed a contrast index for prospective, retrospective and non-significant fields, as follows (Extended Data Fig. 13d): \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathrm{Contrast}\,\mathrm{index}=\frac{|{\mathrm{FR}}_{a}-{\mathrm{FR}}_{b}|}{{\mathrm{FR}}_{a}+{\mathrm{FR}}_{b}}$$\end{document}Contrastindex=|FRa−FRb|FRa+FRb, where FRa is the mean firing rate inside the field for flights starting or ending in the turn compartment, and FRb is the mean firing rate for flights starting or ending in the straight compartment. Echolocation analysis in the long tunnel To assess whether differences in echolocation can explain retrospective coding (Fig. 5), we performed an analysis of echolocation click rate in the multicompartment experiments (Extended Data Fig. 14a–e). To detect the echolocation clicks, we used an ultrasonic microphone on board the neural logger. In all of the experimental sessions in the long tunnel, we recorded simultaneously the audio signal, together with the neuronal signal (both were saved on the neural logger, synchronized at a microsecond precision). The audio signal was filtered (in hardware on the logger) between 4–40 kHz, and was recorded at a 100 kHz sampling rate. Detection of echolocation clicks emitted during flight was then performed offline similarly to ref. 57. We first further high-pass-filtered the audio signal at 10 kHz. We then normalized the signal by its mean absolute deviation (MAD) over the entire session—transforming the amplitude to an SNR. We then used an amplitude threshold of 50 MADs (that is, SNR = 50), which detected clicks reliably. We also applied several additional criteria for click-detection, as described in detail in ref. 57. To exclude the possibility that the observed strong retrospective coding after 90° turns (Fig. 5) is directly linked to the observed increase in echolocation clicks—that is, that the retrospective coding reflects direct sensory or motor neuronal responses, or changes in attention levels (as echolocation click-rate is known to be a proxy of attention57)—we used U-turns as a control. The rationale is that the motor action of mid-flight U-turns is at least as challenging as 90° turns. For each experimental day we calculated the echolocation click-rate maps for individual flights, in the same way, with the same parameters and bin-sizes as for the neural firing-rate maps, and compared the echolocation click-rate in 90° turns versus U-turns. We found that echolocation click rates were similar between the two types of turn flights (90° turns and U-turns; Extended Data Fig. 14d), which suggests that a similar sensory input and similar attention levels are required for 90° turns and U-turns—yet the neural representations after 90° turns and U-turns were very different (Extended Data Fig. 14h–j). We therefore conclude that differences in echolocation or attention level cannot explain the strong retrospective coding that we found in the hippocampus (Fig. 5)—rather, the retrospective coding probably reflects memory of where the bat came from. Behavioural control experiments and echolocation analysis in small L-shaped setup As a further behavioural control for the potential origin of retrospective coding (Fig. 5), we also performed a separate experiment to assess the possible effects of echolocation beam aim (direction of the echolocation beam in space; Extended Data Fig. 14f,g). The purpose of this additional control experiment was to further examine the relationship between echolocation and turning behaviour during flight. To this end, we performed a separate set of behavioural experiments on an additional cohort of bats without neural recordings. These bats were flying in a separate small L-shaped environment that was constructed with similar dimensions to the turn in the large tunnel (Extended Data Fig. 14f). These behavioural control experiments were performed at Johns Hopkins University and were approved by the Institutional Animal Care and Use Committee of Johns Hopkins University. The walls of this L-shaped setup were made from cardboard and were lined with felt to minimize echo reflections that could interfere with sonar signal analysis. Twelve Egyptian fruit bats (6 males, 6 females) participated in these control experiments. The bats were released from both ends of the tunnel. Opening or closing the central door at the L-junction prompted bats to make different navigational choices: fly straight or perform 90° turns or 180° turns (U-turns). The conditions were pseudorandomized across bats and trials. Echolocation clicks were recorded with a 32-channel microphone array consisting of 32 electret condenser microphones (D500X Ultrasound Detector, Pettersson Elektronik). The sensitivity of each microphone was calibrated using a precision microphone (40DP 1/8′′, GRAS, and 7016 1/4′′, ACO Pacific). Signals picked up by each microphone were band-pass filtered between 10 and 100 kHz, amplified with a gain of 10× (SBPBP-S1, Alligator Technologies) and recorded at a 250 kHz sampling rate. Bat flight trajectories were recorded using a motion-capture camera system with 15 cameras (Vicon T40 and T40S), operating at 200 fps. Three reflective markers were affixed to a lightweight crown that was glued on the bat’s head. These markers served as reference points for reconstructing 3D flight paths63. Moreover, three markers were placed on each of the microphones in the room to capture the microphones’ positions and directions. Infrared cameras (Phantom Miro 310, Vision Research) were used to record the bats’ flight behaviour and confirm their position in the tunnel. Sonar gaze deviation and click-rate patterns were compared across different navigation trajectories: straight flights, 90° turns and 180° turns (U-turns). Sonar gaze deviation was defined as the angular deviation between each echolocation click’s directional vector63 and the bat’s instantaneous flight direction, with 0° representing alignment between the two. Instantaneous flight direction was calculated as the vector between the bat’s position in the current video-frame and its position in the subsequent video-frame. A three-point boxcar filter was applied to each click’s sonar gaze measurement, and the absolute value of this smoothed average was used as a measure of the sonar gaze deviation. Sonar gaze deviation and click-rate were then measured relative to the time of the bat’s turn. For each flight trajectory, the moment of maximum curvature was identified and set as time zero (turn time). All clicks were then aligned relative to this timepoint. The median sonar-gaze deviation across all clicks that occurred within a time window of 1 s centred around time zero was compared between U-turns and 90° turns, and showed similar sonar gaze deviation values between the two trajectory types (Extended Data Fig. 14g). This result further supports the finding that the echolocation behaviour of Egyptian fruit bats is comparable between U-turns and 90° turns in the main experiment (Extended Data Fig. 14d). Thus, the fact that we observed strong retrospective coding after the 90° turns (Fig. 5), but not after the U-turns in the long multicompartment tunnel (Extended Data Fig. 14h–j), suggests that the retrospective effect is not due to the motor action of turning, or attention levels, but is instead due to the past trajectory or context (the originating compartment). Additional discussion Previous theoretical studies had suggested that dense and sparse codes offer both computational advantages and disadvantages. Dense distributed codes—whereby each neuron represents many inputs (locations) and, consequently, many neurons are active at any moment—allow efficient coding, whereby a large number of different stimuli can be represented by a small number of neurons51,64. Sparse codes—whereby each neuron represents only a few inputs, and where, consequently, only a small fraction of neurons are active at any moment—allow higher memory capacity, efficient use of associative memory for storage and retrieval, and faster learning compared with dense codes36,64,65. Furthermore, studies of artificial neural networks have demonstrated additional advantages of sparse coding. When sparse neural representations are enforced in the hidden layers of a network through regularization, this sparsification reduces computational complexity, helps avoid overfitting and enhances the network’s generalization ability66,67. Our results suggest that the hippocampus may use the advantages of both dense and sparse coding: Our spatial decoding analysis showed that the CA1 dense code allows high-efficiency positional encoding (Fig. 3a–c), and our neural network simulations showed that the CA3 sparse code allows faster learning of spatial maps in CA1 (Fig. 3d–f). Such rapid learning of CA1 maps is consistent with experimental findings on rapid emergence of place fields in CA1, supported by mechanisms of behavioural timescale synaptic plasticity41,68. Sparse representations can have multiple manifestations. We found here that spatial maps in CA3 are much sparser than those in CA1 within the same environment, in the sense that place cells in CA3 have much fewer fields than in CA1. Although previous studies of place cells in rodents have not found such large differences in spatial coding between the CA3 and CA1, it has been observed that CA3 cells are less likely to be active in each environment than CA1 place cells, that is, a smaller fraction of CA3 cells participates in spatial encoding for a given space3,11,27,69. Even stronger population-level sparsity was reported in the dentate gyrus70–72. In our study, we also observed stronger population-level sparsity in CA3 than in CA1 in bats (Fig. 2j). This form of sparsity in the rodent CA3 and dentate gyrus has been a key ingredient for several computational models of hippocampal function72–75, which highlights again the theoretical advantages of this architecture. We propose that the sparse-to-dense coding transformation between CA3 and CA1 that we identified here may constitute one stage in a broader sparse-to-dense information-processing hierarchy, extending from the sparsest region, the dentate gyrus, through CA3, to CA1, and possibly ending with the highly dense subiculum10,28,76–79. A similar proposal can be found in the literature28. We view our model focusing on the CA3-to-CA1 connectivity as a first approximation for the hippocampal computation, and suggest that future neural recordings should be performed in large environments from all of these subregions, as well as from entorhinal cortex and CA2, to elucidate the contribution of these areas to hippocampal spatial computations. Finally, we found in the landmark perturbation experiment (Fig. 4) that in response to a local spatial perturbation in the environment, CA1 neurons—but not CA3 neurons—showed over-representation of firing-rate changes around the perturbed landmark. We note that this difference in responses between CA1 and CA3 place cells may be consistent with previous rodent studies showing that CA3 place fields typically tile environments rather uniformly, whereas CA1 place fields tend to accumulate around locations associated with learning, such as reward sites80,81 (although we note that we did not observe accumulation of place fields but rather accumulation of changes in fields near the perturbation area). Reporting summary Further information on research design is available in the Nature Portfolio Reporting Summary linked to this article. Online content Any methods, additional references, Nature Portfolio reporting summaries, source data, extended data, supplementary information, acknowledgements, peer review information; details of author contributions and competing interests; and statements of data and code availability are available at 10.1038/s41586-026-10537-0. Supplementary information Reporting Summary Peer Review file Reporting Summary Peer Review file