Dendritic spines may be tiny in volume, but are of major importance for neuroscience. They are the main receivers for excitatory synaptic connections, and their constant changes in number and in shape reflect the dynamic connectivity of the brain. Two-photon microscopy allows following the fate of individual spines in brain slice preparations and in live animals. The diffraction-limited and non-isotropic resolution of this technique, however, makes detection of such tiny structures rather challenging, especially along the optical axis (z-direction). Here we present a novel spine detection algorithm based on a statistical dendrite intensity model and a corresponding spine probability model. To quantify the fidelity of spine detection, we generated correlative datasets: Following two-photon imaging of live pyramidal cell dendrites, we used serial block-face scanning electron microscopy (SBEM) to reconstruct dendritic ultrastructure in 3D. Statistical models were trained on synthetic fluorescence images generated from SBEM datasets via point spread function (PSF) convolution. After the training period, we tested automatic spine detection on real two-photon datasets and compared the result to ground truth (correlative SBEM data). The performance of our algorithm allowed tracking changes in spine volume automatically over several hours. Using a second fluorescent protein targeted to the endoplasmic reticulum, we could analyze the motion of this organelle inside individual spines. Furthermore, we show that it is possible to distinguish activated spines from non-stimulated neighbors by detection of fluorescently labeled presynaptic vesicle clusters. These examples illustrate how automatic segmentation in 5D (x, y, z, t, λ) allows us to investigate brain dynamics at the level of individual synaptic connections.