We describe an adaptive optics method that modulates the intensity or phase of light rays at multiple pupil segments in parallel to determine the sample-induced aberration. Applicable to fluorescent protein-labeled structures of arbitrary complexity, it allowed us to obtain diffraction-limited resolution in various samples in vivo. For the strongly scattering mouse brain, a single aberration correction improved structural and functional imaging of fine neuronal processes over a large imaging volume.