Heterogeneity and dynamics of cortical populations coding visual detection