To understand computation in the brain, one needs to understand the input-output relationships for neural circuits and the anatomical and functional properties of individual neurons therein. Optical microscopy has emerged as an ideal tool in this quest, as it is capable of recording the activity of neurons distributed over millimeter dimensions with sub-micron spatial resolution. I will describe how we use concepts in astronomy and optics to develop next-generation microscopy methods for imaging the brain at higher resolution, greater depth, and faster speed. By shaping the wavefront of the light, we have achieved synapse-level spatial resolution through the entire depth of the primary visual cortex, optimized microendoscopes for imaging deeply buried nuclei, and developed video-rate volumetric and kilohertz voltage imaging methods. We apply these methods to understanding neural circuits, using the mouse brain as our model system.