Optogenetics has revolutionized neuroscience over the past several years by allowing researchers to modulate the activity of specific cell types, both in vitro and in vivo. One promising application of optogenetics is to use channelrhodopsin-2 (ChR2) mediated spiking to identify distinct cell types in electrophysiological recordings from awake behaving animals. In this paper, we apply this approach to in vivo recordings of the two major projection cell types in the striatum the direct- and indirect-pathway medium spiny neurons. We expressed ChR2 in the neurons of the direct or indirect pathways using a cre-dependent viral strategy and performed electrical recordings together with optical stimulation using an implanted microwire array that included an integrated optical fiber. Despite the apparent simplicity of identifying ChR2-expressing neurons as those that respond to light, we encountered multiple potential confounds when applying this approach. Here, we describe and address these confounds and provide a Matlab tool so that others can implement our analysis methods. This article is part of a Special Issue entitled Optogenetics (7th BRES).