Cortical neurons fire in complex patterns of activity during behavior and cognition. In sensory regions of the cortex, animals' interactions with the sensory world evoke neural activity in the cortex. But not all patterns of cortical activity can be elicited by sensory stimuli. We study how non-sensory, artificially induced activity patterns can be used by animals to make behavioral responses. These studies shed light on the limits of cortical function, and how circuit properties like neural connections constrain the set of activity patterns the cerebral cortex can process. We have trained mice (Emx1-Cre or Slc17a7-Cre) to report non-sensory optogenetic stimuli delivered to excitatory cells (Flex-ChrimsonR) in primary visual cortex and find that animals improve their detection performance for such stimuli over the course of days, exhibiting learning in both sensitivity (more accurate responses to stimuli) and speed (faster responses to stimuli) . To do this, animals are first trained to detect visual stimuli, and when performance is stable, an optogenetic stimulus is added to the near-threshold visual stimulation. The visual stimulus is removed once animals reliably report the optogenetic stimulus and learning is tracked. Mice (n=9) show a mean decrease in reaction time per session for constant stimulus intensity (p<0.01, Wilcoxon rank sum test against median of 0). Over many days, mice improve their detection sensitivity by several orders of magnitude in stimulus intensity. Two-photon calcium imaging is performed at the site of optogenetic stimulation and at a retinotopically distinct non-stimulated control location before and after learning. Imaging experiments in an example animal reveal population-wide changes in orientation/direction selectivity (less selective; p<0.05, Kolmogorov-Smirnov test) and response magnitude (more responsive; p<0.01) at the site of stimulation, but not at the control location. These findings suggest local circuitry in sensory cortex is restructured to support learning of a novel stimulus in a context-dependent manner. In a second aim, to understand how neuronal activity patterns give rise to behavior, we are changing the activity of populations of neurons with one-photon stimulation, and also of single neurons with two-photon stimulation. This approach allows changes in neural activity patterns in mammals during behavior, and it opens the door to studying how animals' choices depend on patterns of neuronal activity. We have achieved stable psychophysical performance in mice in the laboratory, and used the two-photon optogenetic approach to evoke activity in targeted single cells in vivo. We hypothesize that the brain regards as similar, for behavioral decisions, many different patterns that share similar statistical structure. A third aim examines the flow of information from one area to the next within the cerebral cortex to understand the circuits that underlie decoding. We are labeling, both anatomically and functionally, neurons that project among several visual cortical areas. By activating and inactivating these projections during behavior, we are measuring which projections are used in decision making.