During REM sleep, researchers theorize that the brain goes through a process known as synaptic efficacy refreshment.
Accumulated observation shows that dreams are strongly associated with REM sleep, during which an electroencephalogram shows brain activity to be most like wakefulness.