This protocol describes the steps and data analysis required to successfully perform optogenetic functional magnetic resonance imaging (ofMRI). ofMRI is a novel technique that combines high-field fMRI readout with optogenetic stimulation, allowing for cell type-specific mapping of functional neural circuits and their dynamics across the whole living brain.