Closed loop optogenetic control and thalamic state