The ongoing activity of neuronal populations represents an internal brain state that influences how sensory information is processed to control behaviour. Conversely, external sensory inputs perturb network dynamics, resulting in lasting effects that persist beyond the duration of the stimulus. However, the relationship between these dynamics and circuit architecture and their impact on sensory processing, cognition and behaviour are poorly understood. By combining cellular-resolution calcium imaging with mechanistic network modelling, we aimed to infer the spatial and temporal network interactions in the zebrafish optic tectum that shape its ongoing activity and state-dependent responses to visual input. We showed that a simple recurrent n...