Neural computations are implemented in densely interconnected networks of excitable neurons as temporal sequences of coactive neuronal ensembles. Ensemble activity is produced by the interaction of external stimuli with internal states but has been difficult to directly study in the past. Currently, high-resolution optical imaging techniques are emerging as powerful tools to investigate neuronal ensembles in living animals and to characterize their spatiotemporal properties. Here we review recent advances of two-photon calcium imaging and highlight ongoing technical improvements as well as emerging applications. Significant progress has been made in the extent and speed of imaging and in the adaptation of imaging techniques to awake animals. These advances facilitate studies of the functional organization of local neural networks, their experience-dependent reconfiguration, and their functional impairment in diseases. Optical probing of neuronal ensemble dynamics in vivo thus promises to reveal fundamental principles of neural circuit function and dysfunction.