Cognitive dynamics during formation and revision of perceptual decisions