The essence of optogenetics is introducing light-activated recombinant ion channels such as channelrhodopsin (ChR2) or halorhodopsin (NpHR) into excitable cells. Light activation of these molecules leads to an influx of ions which induces turning neurons on or off selectively. Halorhodopsin and channelrhodopsin together enable multicolor optical activation, silencing, and desynchronization of neural activity, creating a powerful neuroengineering toolbox. The photostimulation can be induced using visible or infrared light, while imaging is performed by a femtosecond IR laser. Switching between the stimulation and imaging is done at a sub-millisecond scale. Importantly the detectors are protected during the stimulation by a built-in gating system.