(A) General framework. Our optical-genetic toolkit allows us to provide the subject with two types of inputs either separately or in combination: (i) visual (‘visual stimulus’) and (ii) direct optostimulation (‘optical write’). At the same time, we have access to two outputs: (i) neural responses measured by widefield optical imaging (‘optical read’) and (ii) behavioral responses (‘behavior’). Imaging allows us to measure the neural impact of the inserted signals, calibrate the evoked neural population responses, and compare them to those evoked by sensory stimuli. Finally, the neural and perceptual consequences of these inserted signals can be assessed and compared with theoretical predictions. Here, we use this toolkit to measure the interactions between visual and direct optostimulation in macaque V1. (B) Demonstration of visual masking. When fixating on the ‘x’ between the pair of panels, a visual target (a dim white Gaussian) can be easily detected when added to a uniform gray background (top), but is much harder to detect when added to a Gaussian pedestal mask (bottom), a phenomenon known as luminance masking (Cornsweet and Pinsker, 1965; Whittle and Swanston, 1974). The goal of the current study was to determine whether direct optogenetic stimulation of V1 can substitute for a visual mask and elevate detection threshold of a visual target. Note that in the actual behavioral task, only a single stimulus was presented in one hemifield. The animal had to distinguish between ‘target’ and ‘no-target’ and conditions with ‘pedestal’ and with ‘no pedestal’ were run in separate blocks (see panel C). (C) The behavioral task adopted to quantify the masking effects of optostimulation. Two monkeys were trained to detect a small white Gaussian target that appeared at a known location 250 ms after a temporal cue (dimming of the fixation point) in half of the trials. The monkeys indicated target absence by maintaining fixation at the fixation point and target presence by shifting gaze to the target location as soon as it was detected. The visual target was present for a maximum of 250 ms and was terminated as soon as the monkey initiated a saccade. The optostim was initiated 40 ms after the expected time of target onset (to account for the latency of V1 responses) and was terminated together with the visual stimulus. Blocks of trials without optostim (right top) and with optostim (right bottom) were run separately. In optostim blocks, optostim (orange) was applied on every trial, acting as a substitute for the visual mask ('pedestal') in B. The monkeys were always rewarded based on the presence or absence of the visual target only (right panels, black), irrespective of the optostim condition (orange).