Simultaneous prediction and community detection for networks with application to neuroimaging