{'fraction_non_alphanumeric': 0.03195042966060637, 'fraction_numerical': 0.020909299538465462, 'mean_word_length': 5.067141089108911, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Identification of cellular-activity dynamics across large tissue volumes in the mammalian brain

Tracking the coordinated activity of cellular events through volumes of intact tissue is a major challenge in biology that has inspired significant technological innovation. Yet scanless measurement of the high-speed activity of individual neurons across three dimensions in scattering mammalian tissue remains an open problem. Here we develop and validate a computational imaging approach (SWIFT) that integrates high-dimensional, structured statistics with light field microscopy to allow the synchronous acquisition of single-neuron resolution activity throughout intact tissue volumes as fast as a camera can capture images (currently up to 100 Hz at full camera resolution), attaining rates needed to keep pace with emerging fast calcium and voltage sensors. We demonstrate that this large field-of-view, single-snapshot volume acquisition method—which requires only a simple and inexpensive modification to a standard fluorescence microscope—enables scanless capture of coordinated activity patterns throughout mammalian neural volumes. Further, the volumetric nature of SWIFT also allows fast in vivo imaging, motion correction, and cell identification throughout curved subcortical structures like the dorsal hippocampus, where cellular-resolution dynamics spanning hippocampal subfields can be simultaneously observed during a virtual context learning task in a behaving animal. SWIFT’s ability to rapidly and easily record from volumes of many cells across layers opens the door to widespread identification of dynamical motifs and timing dependencies among coordinated cell assemblies during adaptive, modulated, or maladaptive physiological processes in neural systems.


Introduction
The ability to record activity from intact tissue at physiologically relevant timescales and at appropriate resolution is central to any attempt to model and understand the dynamic behavior of complex biological systems. The mammalian nervous system represents a particularly challenging example of such a system, due to the complex, three-dimensional spatiotemporal activity patterns that diverse populations of neurons exhibit as they store, retrieve, and process information at millisecond time scales across large volumes of tissue. Consequently, capturing the coordinated neural firing and statistical dependencies among cells that are thought to be important in behavior (and disease) will ultimately require simultaneous high-speed observation of neuronal timing relationships throughout large tissue volumes.
Since the introduction of synthetic (Tsien 1980) , genetically-encoded Ca 2+ (Miyawaki et al. 1997;Tian et al. 2009) , and voltage sensors (Akemann et al. 2010;Kralj et al. 2011;Jin et al. 2012;St-Pierre et al. 2014;Gong et al. 2014) , a number of powerful new technologies for optically recording activity signals in neurons have been introduced. Recent advances in single-cell Ca 2+ imaging have yielded impressive results using fast three-dimensional scanning of single (Göbel, Kampa, and Helmchen 2007;Duemani Reddy et al. 2008) or multiple (Niesner et al. 2007;Cotton et al. 2013) laser beams, or by scanning a sheet of light (Tomer et al. 2012;Ahrens et al. 2013;Bouchard et al. 2015) to image many neurons by sequentially illuminating parts of a volume over time. However, such methods capture the volume (and therefore the activity of neurons across the volume) asynchronously, and are fundamentally limited by the inertial and settling constraints of the moving components. Although scanless volumetric microscopy technologies including holographic (Rosen and Brooker 2008) , extended depth-of-field (Quirin et al. 2014) , and multi-focus (Abrahamsson et al. 2012) microscopy exist, these methods require acquisition of multiple images for each volume, projection from three into two dimensions, or suballocation of the camera sensor for each axial plane, thereby limiting rapid three-dimensional imaging and full volumetric reconstruction. To date, no mammalian activity imaging approach has allowed synchronous full-volume acquisition with validated cellular resolution using the full scope and speed of fast cameras. Compounding this challenge, analytical tools necessary for accurate discovery of neurons in such large volumetric time series data over time remain to be developed.
In considering these challenges, we noted that certain features of light field microscopy---a method that allows the reconstruction of a full volume from a single camera frame (Marc Levoy et al. 2006;Marc Levoy, Zhang, and McDowall 2009;Broxton et al. 2013;Cohen et al. 2014) ---might support synchronous volumetric imaging in mammalian preparations at rates appropriate for new generations of fast calcium and voltage sensitive dyes. Several proof-of-concept experiments have developed and demonstrated the basics of light field deconvolution (Broxton et al. 2013;Prevedel et al. 2014) and light field microscopy has been shown to work for volumetric functional imaging of neuronal activity in small, optically transparent neurobiological systems, first in a single brain region (Grosenick, Anderson, and Smith 2009) and subsequently across a zebrafish brain-all of these approaching but not fully attaining cellular resolution (Deisseroth and Schnitzer 2013;Prevedel et al. 2014;Tomer et al. 2015) , and most recently across the Drosophila brain (Aimon et al. 2015) . However, adapting and scaling the technology for millimeter-scale volumes in scattering mammalian preparations and achieving single-cell resolution have remained the biggest challenges.
We hypothesized that with our volume reconstruction method (Broxton et al. 2013) , it might be possible to attain camera-limited imaging rates at a resolution that would allow identification and activity recording from individual neurons over significant tissue volumes in mammalian systems both in vitro and in vivo during behavior. However, beyond the volume reconstruction---already a challenging computational problem to scale to many volumes---significant analytical advances would also be required, since identification of neurons and dynamics over time in volumes consisting of ~5-100 million voxels at rates up to 100 Hz (terabytes per data set) would require substantial development of statistical and computational methodology. In particular, machine learning methods appropriate for motion correction and cell localization in terabyte-scale data sets would be needed. To address this challenge, here we develop, validate, and apply an integrative computational imaging approach (SWIFT) enabling the synchronous acquisition and analysis of single-neuron resolution activity throughout intact scattering tissue volumes at high frame rates. Open source code implementing SWIFT will be made available online.

Single-snapshot volumetric imaging of biological neural networks in mammalian tissue
By inserting an array of thousands of microlenses at the intermediate image plane of a standard epifluorescence microscope and positioning the camera sensor at the image plane formed by this array (Fig. 1A,B), it is possible to capture the four-dimensional light field in a single, synchronous exposure of the camera sensor (Marc Levoy et al. 2006;Marc Levoy, Zhang, and McDowall 2009) . This light field image ( Fig. 1D) encodes information about the entire volume under the objective, albeit at somewhat reduced lateral resolution ( Supplementary Fig. 1).
However, this modest reduction in lateral resolution is acceptable so long as we can still identify individual cell bodies, and worthwhile as it fundamentally enables synchronous, high-speed volumetric functional imaging. A single light field volume can be reconstructed from a single camera frame to obtain a volume by solving a large maximum likelihood problem (e.g., inverting a 5.5 million pixel by 2-100 million voxel linear system per volume; Fig. 1C), thereby estimating the most likely intensity distribution in the volume given the captured image on the sensor. Our algorithm is analogous to tomographic reconstruction and deconvolution techniques in medical imaging, but has been adapted here for single-snapshot volume fluorescence imaging (Broxton et al. 2013) . We use a wave optics (i.e., physical optics) model of light transport through the microscope and the microlens array and a noise model that correctly accounts for noise sources on the image sensor (principally photon shot noise). Due to the manner in which light is focused by the microlenses, this inverse problem is well conditioned and cell-scale details can be recovered much deeper into scattering tissue than standard epifluorescence imaging allows. Fig. 1E and Supplementary Movie 1 demonstrate that such reconstruction is achievable for a complex living neural system at cell-resolution in mammalian tissue; hippocampal neurons in an acute mouse slice preparation are shown expressing the genetically-encoded Ca 2+ sensor GCaMP6f (T.-W.  . With a 40x 0.8 NA objective, apical dendrites and the largest spines are just visible. Each full volume in a time series is reconstructed using a single camera exposure, thus the imaging rate is limited only by the available light from the sample and the maximum frame rate of the camera. However, the rapid collection of large volume data immediately creates a problem: many tens of thousands of images recorded during a single experiment must be reconstructed into volumes, motion aligned, and then further processed to extract and analyze the spatial locations and time courses of the large numbers of neurons. To meet this challenge, we developed our own distributed data processing system that runs on the Amazon Elastic Compute Cloud (EC2) and the Google Compute Engine (GCE) cloud computing services (see Methods). Our GPU-accelerated volumetric deconvolution system is capable of reconstructing 9000 volumes per hour on 300 compute instances. Subsequent motion alignment, source extraction, and time series analysis is carried on clusters ranging from 128-1024 cores using the Apache Spark cluster computing framework (Zaharia et al. 2016) and the Thunder data analysis framework (Freeman et al. 2014) .
For extraction of the locations of neural sources and their time series from motion aligned volumetric time series data, we developed new, scalable machine learning methods based on previous work in high dimensional settings (Jenatton, Obozinski, and Bach 2009;Allen, Grosenick, and Taylor 2014) to seek smooth, local spatial structures with global sparsity so that these resolved "sources" were cell-sized and cell-shaped, i.e. sparse but structured nonnegative matrix factorization. Similar methods have recently yielded state-of-the-art results on smaller problems (Pnevmatikakis et al. 2016) . Along with methods to significantly accelerate computational extraction of the neural sources (Methods; runtime is about one hour for 3000 sources in a volume with two million voxels over 27000 time points), we also developed automated screening and validation procedures to increase confidence that sources used in all subsequent analyses are of neural origin (See Methods; runtime is about 10 minutes on the same data). We validated these methods and the quality of the spatial and temporal sources (see Methods). This integration of physical optics, computational optics, and statistical methods enables extraction of neural locations and activity time series simultaneously across mm-scale tissue volumes; we term this method SWIFT (Statistical Wave-optics Identification of Features in Tissue) volume imaging.

SWIFT: fast functional recording of volumes of neurons
Standard light field deconvolution microscopy is compatible with imaging neural activity in largely transparent animals such larval zebrafish (Grosenick, Anderson, and Smith 2009;Prevedel et al. 2014;Cohen et al. 2014) and certain invertebrates such as C. elegans and Drosophila (Prevedel et al. 2014;Aimon et al. 2015) , but most vertebrate neural tissues, including mammalian brains, are turbid and highly scattering (Ntziachristos 2010) . However, we found that due to its light field deconvolution model SWIFT was effective for volumetric functional imaging in living mammalian neural circuitry. Beginning with acute mouse prefrontal cortical (PFC) slices virally transduced with a genetically encoded Ca 2+ indicator (GECI) using an adeno-associated virus (AAVdj::CamKIIa::GCaMP6f; Methods) and using a 10x 0.6NA objective, we were able to simultaneously image 1.1 mm x 1.0 mm x 0.4 mm volumes spanning all cortical layers and all of prelimbic cortex (PL) in vitro with parts of cingulate cortex (Cg) and/or infralimbic cortex (IL) in a single field of view (Supplementary Fig. 2A,B; Supplementary Video 2). We found that SWIFT was in fact well suited to identifying neurons and their time series through this scattering volume of tissue even using wide-field illumination Methods). Indeed, the larger size of mouse neurons (20-30 µm soma relative to 5-10 µm soma in, for example, zebrafish fry) enabled efficient segmentation of individual cells with computationally-optimized, high-dimensional machine learning identification of smooth, local spatial structures ("structured sparsity") (Jenatton, Obozinski, and Bach 2009;Grosenick et al. 2013) so that resolved sources of high temporal variance were the size and shape of cell bodies ( Supplementary Fig. 2B). Supplementary Fig. 2C shows 12 Ca 2+ imaging fluorescence traces with numbers corresponding to the numbered spatial filters shown in Supplementary Fig. 2B, with cells exhibiting a diversity of activity, from sparse spiking to concentrated bursts of activity similar to "UP" states previously reported in cortical slices (Cossart, Aronov, and Yuste 2003) . Supplementary Fig. 2D-H further characterize the autocorrelations and signal-to-noise using whole-cell patch clamp, and by comparing 25 Hz two-photon laser scanning microscopy to 25 Hz SWIFT volume imaging in the same cells. No cross-talk was detectable between reconstructed neurons, we confirmed that the spatial sources resembled the somata of patched, back-filled cells, and found that SWIFT exhibited an approximately 2x improvement in SNR over a commercial, resonant scanning 2PSLM system (Leica SP5; See Supplementary Fig. 2 and Methods).

Synchronous volumetric imaging across hippocampal subfields
This success of SWIFT for imaging volumes of neurons in vitro led us to explore imaging of large subcortical brain volumes in behaving mice. Following the techniques shown in previous groundbreaking work imaging in dorsal hippocampus (subfield CA1) (Dombeck et al. 2007;Barretto, Messerschmidt, and Schnitzer 2009) , we implanted glass windows just above the dorsal hippocampus in C57BL/6J mice ( Fig. 2A,B; Methods), moving our coordinates anterior and lateral relative to previous studies in order to allow simultaneous optical access with a 10x 0.6 NA long-working-distance water-dipping objective to parts of hippocampal subfields CA1, CA2, and CA3 virally transduced with GCaMP6f (AAVdj-CamKIIa-GCaMP6f, Methods). Starting at 2-3 weeks after viral transduction and implantation, mice could be imaged with SWIFT while head-fixed and running on an axially-fixed spherical treadmill ( Fig. 2C) (Dombeck et al. 2007) .
Volumes were reconstructed as in the in vitro experiments above, however, in a behaving animal brain motion relative to the sensor resulted in motion artifacts between temporally adjacent volumes, as previously described (Dombeck et al. 2007) . Such artifacts can significantly degrade accurate estimation of cell location and sensor transients, making image alignment a critical first step for SWIFT as for other calcium and voltage imaging modalities. However image alignment is considerably easier in SWIFT because each volume can be treated as a frame captured at a single period of time. This avoids nonlinear sampling effects known to make motion correction difficult in data acquired by scanning methods (Dombeck et al. 2007) . Even so, the high dynamic range and low background signal of GCaMP6 required statistically partitioning large calcium transients from the static background fluorescence, the latter being necessary for motion correction. To accomplish this we developed a motion correction protocol using the Robust Alignment by Sparse and Low Rank (RASL) algorithm (Peng et al. 2012) (Methods), and scaled it to work on terabyte-scale data using Apache Spark (Zaharia et al. 2016) . This method identifies set of three-dimensional translation and rotation corrections to each volume and allows the entire dataset to be decomposed into sparse neural dynamics superimposed upon a low-rank background signal (Peng et al. 2012) . We found that RASL outperformed normalized volumetric cross-correlation ( Supplementary Fig. 3D).

Volumetric imaging with cellular resolution during a contextual learning behavior
To leverage synchronous volumetric imaging across hippocampal subfields, we developed a virtual environment apparatus appropriate for contextual learning, a task in which the different subfields are thought to have distinct roles (McNaughton and Nadel 1990;Sekino et al. 1997;Chevaleyre and Siegelbaum 2010;Wintzer et al. 2014) . The apparatus is similar to others reported previously (Harvey et al. 2009) . Two video projectors presented a virtual environment onto a spherical screen placed 20 cm from the mouse and covering 220 degrees of the mouse's visual field of view ( Figure 3A; Methods). Head-restrained mice ran on an axially-constrained spherical treadmill, with forward or backward movement of the ball read out by an optical mouse (Dombeck et al. 2007) . Automated delivery of odorants via an olfactometer, auditory cues by two speakers placed behind the mouse, and a small feeding tube placed immediately under the animal's mouth allowed multisensory stimulation and training using water rewards in water-deprived animals ( Fig 3A, Methods).
Standard video game development software (Unity3D) interfacing with custom Python code was used to present virtual environments with motor activity and licking behavior (measured via infrared movies of the mouse) as behavioral outputs (Methods). During training animals (n=3) ran through a series of two possible 120 cm long virtual "contexts", pseudo-randomly ordered and with each context defined by a distinct combination of visual environment, auditory cue, and odorant ( Figure 3B). One context was not visible from the other (animals ran through an opaque black doorway into the next context). Odorants were delivered for 1 second immediately at the start of the context (Stettler and Axel 2009) (Methods), and auditory cues were presented through the duration of the context starting immediately upon context entry (~75 dB, see Methods). Of the two context types encountered by the animal, one was rewarded (and occurred in only ~20% of all context presentations) while the other was not rewarded (~80% of contexts;  Fig. 3D. We next looked at neurons that were active >80% of the time within a 2 second window centered around water reward onset (reward occurred reliably 1s after context entry; 139/1043 identified neurons responded >80%). Ordering these by the first time point at which their reliability exceeded the 80% threshold yielded a reliability heat map where each column represents a time point (relative to water reward onset) and each row corresponds to an identified neuron. Pixel color indicates the percentage of times the cell was active in that time bin across rewarded trials (Fig 3E). This plot reveals a ramping up of behavior beginning ~50 ms before the reward is delivered, and persisting for at least 1s after reward onset in many cells. All three animals showed this similar pattern of reliability (n=3, 8.6% +-0.44% SD of neurons showing >80% reliability; all starting after context entry and before reward onset). To determine if this activity was significantly different than expected by chance, we circularly permuted the time series within each trial (n=999 circular permutations) and show the empirically observed mean percent reliability in firing across neurons for each time bin (red) relative to the mean percent reliability in firing for circularly permuted time series. The observed trace clearly diverges from the empirical null significantly (p<0.001, uncorrected) ~25ms prior to reward onset. All animals showed this divergence pattern over time, with initial significant divergence starting 25ms-50ms post context onset (n=3).

Discussion
By integrating computational optics for volume reconstruction from two-dimensional camera images with high-dimensional statistics for motion correction and cell localization, SWIFT volume imaging enables fast, synchronous, cellular resolution recording and quantitative modeling of neural population activity across cortical layers and regions in scattering mammalian tissue. The frame rates of large-format scientific cameras and the kinetics of available fluorescent activity indicators therefore now represent the primary limiting factors for action-potential resolution imaging of large neural populations across brain regions. Increasing quality and speed of scientific cameras, and continued progress in the signal and speed of both calcium and voltage sensors will likely expand the spatiotemporal reach of the methods described here.
Computational imaging has spurred a revolution in photography (Giles 2009;Raskar 2009;M. Levoy 2010;Ehrenberg 2012) , but so far has been relatively limited in its applications in biological light microscopy. Our findings highlight the recent promise of computational imaging to extend the reach of microscopy, using a combination of physical and statistical models, paired with new computational architectures for large data, to push the limits of classical imaging.

Light Field Microscopy
Imaging data were acquired using light field microscopes (Marc Levoy et al. 2006;Zhang and Levoy 2009;Broxton et al. 2013;Cohen et al. 2014) . A standard commercial epifluorescence microscope (an Olympus BX51WI) was modified to be a light field microscope by placing a 125 µm pitch microlens array (RPC Photonics, see below for more details) at the intermediate image plane (i.e., the location of the camera sensor in a standard microscope). The back focal plane of the microlens array was then re-imaged via relay optics (see below) onto the sCMOS camera sensor (Andor Zyla, pixel size: 6.5µm). The microlens array and camera were placed on motorized linear stages (Thorlabs) for easy focusing adjustment.
We used microlens arrays with a square lenslet aperture (truncated, 100% fill factor) and a spherical lenslet surface profile. The f-number ( ) of the lenslets was chosen to match the magnification (M) and numerical aperture (NA) of the microscope objective via the formula: . An f/10, 125 µm microlens array and a 10x 0.6 NA water-dipping objective (Olympus) were used in mouse in vivo/in vitro experiments. The relay optics between the microlens array and the camera sensor (Nikon NIKKOR) were chosen to demagnify the sensor pixels and increase the angular sampling rate in the light field. A 135:85 mm relay yielded 31 pixels per lenslet diameter.
Samples were illuminated evenly using LED epifluorescence illumination (Leica SP5 wide-field light engine or Lumencor Spectra X). All samples were imaged at wavelengths standard for GCaMP6f using fluorescence filters (Semrock filters: excitation 475/35 nm; dichroic 495 nm; emission 535/50 nm). Mouse in vitro volumes were recorded at 4 Hz or 25 Hz and mouse in vivo images at 50 Hz. We note that the maximum acquisition frame rate in our experiments is limited only by the frame rate of the camera. Although we started in mouse slice with longer integration times to ensure image data of sufficient quality to identify neurons in scattering tissue, we discovered that faster frame rates (up to 100 Hz in tests with GCaMP6f in vivo) were also effective. Volume imaging with frame rates up to 100 Hz and beyond are therefore possible using this technique, limited only by the speed and signal-to-noise ratio of the camera and calcium/voltage sensor signal to noise.
Light field images were recorded over a Camera Link 10-tap PCI interface onto a SSD RAID-0 disk array in a desktop workstation (Dell or Colfax Intl.). Images were recorded using our own custom image acquisition software as well as the open-source Micro-Manager image acquisition software (Edelstein et al. 2014) . Dark frames and radiometric calibration frames were recorded before each experiment and used to correct for bias on the camera sensor and vignetting introduced by the microscope optics, respectively.

Light field volume reconstruction/deconvolution
Volume data were reconstructed from raw light field frames using our light field three-dimensional deconvolution algorithm, which uses wave optics to model diffraction and other light transport phenomenon in the light field microscope. Three-dimensional reconstruction is formulated as an inverse problem that we solve using a GPU-accelerated iterative algorithm based on Richardson-Lucy iteration (Kralj et al. 2011;Gong et al. 2014) . For more information on this algorithm and its implementation, we refer the reader to our previous study (Broxton et al. 2013) .
Runtimes for our algorithm depend on the optical parameters used in a given experiment. In this study it took ~2 minutes per camera frame for mouse in vivo and in vitro experiments. Between 3,000-27,000 frames are recorded for each experiment, so up to 1,000 machine hours are therefore required to process some data sets. To address this, we developed a distributed deconvolution data processing pipeline that runs on the Amazon Elastic Compute Cloud (Amazon EC2). Our Amazon EC2 cluster consists of 300 "g2.2xlarge" spot instances, each with a Kepler GK104 GPU (NVidia). We run four deconvolution jobs concurrently on each GPU, with jobs scheduled and managed using the Celery distributed task queuing system (http://www.celeryproject.org/). This GPU cluster has a theoretical peak computing power of 1,373 teraflops and is capable of processing all of the frames in a mouse in vivo dataset with 27,000 frames in 3 hours.

Resolution limits
In light field microscopy, spatial resolution must be sacrificed in order to record different angles of light incident on the microscope's image plane using different camera pixels (it is this angular information that permits scanless volumetric reconstruction). As a result, the resolution limit of a three dimensional light field reconstruction is higher than the Rayleigh limit encountered in wide field imaging. In general, spatial resolution gradually decreases at greater depths relative to the microscope's native plane. We show in (Broxton et al. 2013) that this fall-off in lateral resolution is well approximated by a light field resolution criterion: , where is the pitch of the microlens array, is the emission wavelength of the sample, M is the magnification of the microscope objective, z is the distance relative to the microscope's native image plane, and is the lateral spatial band limit (in cycles / mm) of a three-dimensional reconstruction for a given depth and set of optical parameters. This equation holds where . Extended Data Fig. 1f shows this resolution limit plotted for various optical recipes used in this study. For a more in-depth discussion of these resolution limits, as well as experimental results validating them, we refer the reader to our previous study (Broxton et al. 2013) . This results in non-overlapping sets of coefficients each of which is connected in space. The augmented problem is non-convex, so we solved it heuristically using alternating minimization between the time series and spatial coefficients (Journée et al. 2010) . We identified sources sequentially and initialized the optimization for each source using the highest scoring voxel that

Sparse, structured matrix factorization for cell identification
has not yet been included.

Initialization
Time series for each voxel were preprocessed to discount the effects of bleaching and baseline drift. A moving baseline (30 second window) was subtracted from each time series before it was standardized to have zero mean and unit norm. Due to the non-convex nature of the technique, it is sensitive to initialization. We initialized sources by choosing voxels that exhibit a large amount of positive deviation (peak) from a noisy baseline. Peaks were defined as the maximum difference between a smoothed time series with width , and a smoothed time series with a width of 30 seconds. The noise level was computed as the mean absolute deviation between the raw time series and a smoothed time series (30 second window). The final initialization score was computed as the ratio of the peak to the noise level. This metric is highly sensitive to neurons firing a single spike throughout the entire experiment and is used to initialize, sort and screen candidate sources.

Screening
Candidate sources were screened to remove artifacts and other signals that were not likely to have originated from cell bodies. The screening criteria on sources were: (1) centroids could not be within 5 voxels (19.28 µm for mouse ex vivo and mouse in vivo datasets; the higher scoring source was chosen in the event of violation), (2) centroids could not be within 10 voxels of the lateral borders of the volume reconstruction, or within 5 voxels of the axial borders, (3) the number of nonzero voxels in a source must be between 2 and 1000, (4) the aspect ratio of the source (width / height of bounding box) must be between 0.5 and 2, and (5) the initialization score (defined above) must be greater than 2.

Time series and raster plots
For time series plots, Delta F-over-F (dF/F) was computed as where x was the time series, and is its global mean. In raster plots, baseline and slow drift in baseline signal was removed from raw time series using a zero-phase temporal high pass filter (Butterworth, 1st order). Spiking events were then determined to be those that exceeded a 95 median absolute deviation (MAD) confidence interval. Finally, sources were hierarchically clustered (i.e. represented as a dendrogram) using the Pearson correlation coefficient a distance metric to compare pairs of time series.

Mouse slice experiments
Female or male C57BL/6J mice (The Jackson Laboratory), aged 3-5 months at the time of imaging, were used for all experiments. They were housed on a 12-hour light/dark cycle in groups of 3-5 for acute slice imaging experiments and 2-3 for in vivo imaging experiments. The latter were also housed with a running wheel. All subjects were afforded ad libitum access to food and water, except during behavioral training as described below. All experimental protocols were approved by the Stanford University Institutional Animal Care and Use Committee.
Cloning of pAAV-CaMKIIa-GCaMP6f. The GCaMP6f was amplified from Addgene Plasmid #40755 using primers ccggatccgccaccatgggttctcatcatcatc and gataagcttgtcacttcgctgtcatcatttg , digested with BamHI and HindIII, and ligated to a AAV-CaMKIIa backbone cut with the same enzymes. Clones were verified by sequencing, and then the DNA was amplified and packaged as AAVdj at the Stanford Neuroscience Genomic Viral and Vector Core.

Stereotactic viral injections
Viral injection was performed in mice anesthetized with 1.5-3.0% isoflurane and placed in a sterotaxic apparatus (Kopf Instruments). For in vitro imaging of the prefrontal cortex, mice were injected with 1000 nL of AAVdj-CKIIa-GCaMP6f (Stanford Vector Core) into the medial prefrontal cortex (coordinates relative to Bregma: AP +1.35 mm, ML -0.35 mm, DV -2.5 mm).

Acute slice preparation for in vitro imaging
These experiments commenced 3-5 weeks after viral injections. Subjects were deeply anesthetized with 5% isoflurane and transcardially perfused with 20 mL of an ice-cold with this solution may enhance slice viability by reducing excitotoxicity (Peça et al. 2011;Zhao et al. 2011) . After perfusion, the brain was removed rapidly and cut into 350 um slices on a Leica vibratome using the same ice-cold NMDG-ACSF solution, and prefrontal slices were transferred immediately to a warm (32-34 o C) recovery solution with the same composition. After 15 minutes of recovery, the slices were transferred to a modified HEPES-ACSF solution for 15 minutes (composition as above, except substituting 92 mM NaCl for NMDG), followed by a transfer to a second HEPES-ACSF solution to ensure complete washout of the NMDG. After 15 minutes the slices were transferred one more time to oxygenated ACSF solution and remained in this solution until imaging commenced (> 30 minutes later).
Imaging was conducted at a controlled 35°C in oxygenated ACSF (composition: 123 mM NaCl, 3 mM KCl, 11 mM glucose, 1.25 mM NaH 2 PO 4 , 26 mM NaHCO 3 , 1 mM MgCl 2 , 2 mM CaCl 2 ) delivered to a Warner Instruments Ultra-Quiet Slice Chamber (RC-27LD) holding the slice through a in-line heater (Warner) at a constant rate of 8 mL/min through a peristaltic pump (Gilson). Standard "wide-field" illumination at 475/30 nm with a Lumencor Spectra X at less than 1 mW/mm 2 was used for all imaging. Slice imaging datasets were acquired using 10X / 0.3 NA and 10X / 0.6 NA objectives (Olympus).
Hippocampal window implantation for in vivo imaging. These surgeries were performed after allowing at least one day of recovery after viral injections. Prior to the surgery, mice were injected with 80mg/6mg/kg of ketamine/xylazine intraperitoneally, and 5mg/kg carpofen subcutaneously. Mice were kept under 0.5-1.0% isoflurane throughout the surgery. First, a metal headplate was centered over the CA1 and CA3 injection sites and adhered to the skull using adhesive cement (Metabond; Parkell). A ~3mm craniotomy was made in the center of the headplate opening using a trephine (Fisher). The cortex was then slowly aspirated using a 27 gauge blunt needle attached to a vacuum line while irrigating with lactated Ringer's solution.
Once a column of cortex had been removed, a 31 gauge blunt needle was used to peel away the white matter lying above the hippocampus. A glass implant was then lowered until the bottom coverslip rested against the hippocampus. The implant was constructed from 3.0mm diameter glass capillary tubes (Friedrich & Dimmock) custom cut to 1.5-1.75mm length, adhered on one end to a 3.0mm diameter coverslip of #0 thickness (Warner Instruments) using optical glue (Norland Products). The top of the implant extruding from the brain was then secured to the skull using adhesive cement.

Virtual Environment
Experiments were performed using a custom-designed virtual environment setup, inspired by previous work (Harvey et al. 2009) . A 200mm diameter styrofoam ball (Graham Sweet Studios) was fixed on a single rotational axis using a metal rod (6mm diameter cage assembly rods; Thorlabs) passing through the center axis of the ball and epoxied into place. The rod rested in two 90 deg post holders (Thorlabs), allowing free forwards and backwards rotation of the ball.
Mice were head-fixed in place above the center of the ball using a headplate mount (Niell and Stryker 2010) . Water rewards were delivered to mice through a small animal feeding tube (Cadence Science) connected to a 10mL syringe. A motorized syringe pump (Chemyx Inc.) delivered small water rewards triggered by a TTL pulse driven by custom control software (Python). Odorants were delivered through a multi-solenoid valve system (Parker Hannifin) connected to a pressurized air source using parameters from Stettler et al. (Stettler and Axel 2009) . Auditory stimuli were uploaded into the virtual environment software and played over speakers (Logitech) located 40 cm symmetrically behind the mice. The mouse's movements on the ball were recorded using an optical computer mouse (Logitech) that interfaced with the virtual environment software (Dombeck et al. 2007;Harvey et al. 2009) . Virtual environments were designed in game development software Unity3d (unity3d.com). The virtual environment was displayed by back-projection onto projector screen fabric stretched over a clear acrylic hemisphere with a 14 inch diameter placed ~20 cm in front of the center of the mouse. The screen encompasses ~220 deg of the mouse's field of view. The virtual environment was back-projected onto this screen using two laser-scanning projectors (Microvision), each projector covering one half of the screen. To create a flat image on the 3d screen, we warped the 2d image of the virtual environment using video manipulation software (Madmapper). The game engine allowed scripts written in Javscript or C# to trigger external events based on the mouse's interactions with the virtual environment by communicating over a TCP socket to custom Python control software. A LabJackU6 (http://labjack.com/) was used both to time-lock virtual environment events and imaging frame times, and to send TTL pulses to deliver water rewards and odorants. The mouse's licking behavior was recorded using a high-speed camera (Allied Guppy Pro; AVT) and 18mm lens (Edmund Optics), illuminated with an infrared LED (Thorlabs).

Behavioral Task
Mice were water restricted for ~5 days, or until reaching 80% of their starting weight, prior to the start of behavioral training. The behavioral paradigm consisted of two contexts, each a corridor of the same width (15 cm) and length (variable per mouse, see below). Each context differed in terms of the visual, olfactory, and auditory stimuli present. Context 1 was a black corridor with broad backwards-slanting magenta stripes on the walls. During Context 1 trials, a linear-sweeping tone (10 kHz to 25 kHz) was played, and a single puff of octanol was delivered at the start of the trial (odor delivery parameters were taken from Stettler et al. (Stettler and Axel 2009) . Context 1 was never associated with a water reward. Context 2 was a magenta corridor with broad forwards-slanting black stripes on the walls. During Context 2 trials, a logarithmic-sweeping tone (between 20 kHz and 22 kHz) was played, and a single puff of ethyl acetate was delivered at the start of the trial. Mice were given a water reward in Context 2. For each mouse, the lengths of the two contexts were set by adjusting the linear sensitivity of the optical mouse so that the non-rewarded Context 1 trials were completed in an average of 4-6 seconds. This was generally ~120 cm. For a given mouse, the effective lengths of the two contexts were equal. Each training session consisted of 20 minutes, during which Context 1 and Context 2 trials were pseudo-randomly interleaved, with Context 1 trials occurring 80% of the time. Mice were trained on a task in which they were given water rewards 1s after entering Context 2.   For a fixed 125 μm pitch microlens array, a larger objective magnification results in better peak resolution but a more rapid fall-off and hence a diminished axial range over which good resolution can be achieved (Broxton et al. 2013) .