The signal and resolution during in vivo imaging of the mouse brain is limited by sample-induced optical aberrations. We find that, although the optical aberrations can vary across the sample and increase in magnitude with depth, they remain stable for hours. As a result, two-photon adaptive optics can recover diffraction-limited performance to depths of 450 μm and improve imaging quality over fields of view of hundreds of microns. Adaptive optical correction yielded fivefold signal enhancement for small neuronal structures and a threefold increase in axial resolution. The corrections allowed us to detect smaller neuronal structures at greater contrast and also improve the signal-to-noise ratio during functional Ca 2 imaging in single neurons.T he ability to visualize biological systems in vivo has been a major attraction of optical microscopy, because studying biological systems as they evolve in their natural, physiological state provides relevant information that in vitro preparations often do not allow (1). However, for conventional optical microscopes to achieve their optimal, diffraction-limited resolution, the specimen needs to have identical optical properties to those of the immersion media for which the microscope objective is designed. For example, one of the most widely applied microscopy techniques for in vivo imaging, two-photon fluorescence microscopy, often uses water-dipping objectives. Because biological samples are comprised of structures (i.e., proteins, nuclear acids, and lipids) with refractive indices different from that of water, they induce optical aberrations to the incoming excitation wave and result in an enlarged focal spot within the sample and a concomitant deterioration of signal and resolution (2, 3). As a result, the resolution and contrast of optical microscopes is compromised in vivo, especially deep in tissue.Many questions related to how the brain processes information on both the neuronal circuit level and the cell biological level can be addressed by observing the morphology and activity of neurons inside a living and, preferably, awake and behaving mouse (1). In a typical experiment, an area of the skull is surgically removed and replaced with a cover glass to provide optical access to the underlying structure of interest (4). For imaging during behavior, the cover glass is often attached to an optically transparent plug embedded in the skull to improve mechanical stability and to prevent the skull from growing back and blocking the optical access (5, 6) (Fig. 1A). Before the excitation light of a two-photon microscope reaches the desired focal plane inside the brain, it has to traverse first the cranial window and then the brain tissue, both with optical properties different from water. Thus, they both impart optical aberrations on the excitation light, which leads to a distorted focus, even at the surface of the brain.These sample-induced aberrations can be corrected with adaptive optics (AO) to recover diffraction-limited resolution. In AO, a wavefront-shaping device m...