Gravar-mail: Closed-loop functional optogenetic stimulation