To understand computation in the brain, one needs to understand the input-output relationships for neural circuits and the anatomical and functional relationships 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 neural circuits 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 primary visual cortex, optimized microendoscopes for imaging deeply buried nuclei, and developed video-rate (30 Hz) volumetric and kHz functional imaging methods. We apply these methods to understanding neural circuits, using the mouse primary visual cortex as our model system.