Background: Cognitive neuroscientists aim to understand behavior often based on the underlying activity of individual neurons. Recently developed miniaturized epifluorescence microscopes allow recording of cellular calcium transients, resembling neuronal activity, of individual neurons even in deep brain areas in freely behaving animals. At the same time, molecular markers allow the characterization of diverse neuronal subtypes by post hoc immunohistochemical labeling. Combining both methods would allow researchers to increase insights into how individual neuronal activity and entities contribute to behavior. New Method: Here, we present a novel method for identifying the same neurons, recorded with calcium imaging using a miniaturized epifluorescence microscope, post hoc in fixed histological sections. This allows immunohistochemical investigations to detect the molecular signature of in vivo recorded neurons. Our method utilizes the structure of blood vessels for aligning in vivo acquired 2D images with a reconstructed 3D histological model. Results:We automatically matched, 60 % of all in vivo recorded cells post hoc in histology. Across all animals, we successfully matched 43 % to 89 % of the recorded neurons. We provide a measure for the confidence of matched cells and validated our method by multiple simulation studies. Comparison with existing methods: To our knowledge, we present the first method for matching cells, recorded with a miniaturized epifluorescence microscope in freely moving animals, post hoc in histological sections. Conclusions: Our method allows a comprehensive analysis of how cortical circuits relate to freely moving animal behavior by combining functional activity of individual neurons with their underlying histological profiles.