Scientists have used scans to shed more light on how the brain deals with the memory of unpleasant or traumatic events during sleep.
The University of California, Berkeley team showed emotional images to volunteers, then scanned them several hours later as they saw them again.
Those allowed to sleep in between showed less activity in the areas of the brain linked to emotion.
Instead, the part of the brain linked to rational thought was more active.
The study, published in the journal Current Biology, said it showed the links between dreams and memory.
Most people have to deal with traumatic events at some point in their lives, and, for some, these can produce post-traumatic stress disorder (PTSD), leaving them emotionally disturbed long after the event itself.
Mapping blood flow
There is significant evidence that the 20% of sleep in which we dream, also called REM sleep, plays a role in the processing of recent memories, and researchers believe that better understanding of this could eventually help PTSD patients.
The researchers recruited 35 volunteers, splitting them into two groups.
After showing them 150 images designed to provoke an emotional reaction, half were allowed a good night's sleep.
While inside an MRI scanner to map blood flow in the brain - a good way to work out which regions are most active - the volunteers were shown the images a second time.
Those who had slept properly had less activity in the amygdala, a part of the brain associated with heightened emotions, and more activity in the prefrontal cortex, a brain region linked to more rational thinking.
The non-sleepers reported a far more emotional response to seeing the pictures again.
The scientists believe that chemical changes in the brain during REM sleep may help explain how the body makes this change.
Dr Matthew Walker, who led the study, said: "We know that during REM sleep there is a sharp decrease in norepinephrine, a brain chemical associated with stress.
"By reprocessing previous emotional experiences in this neurochemically safe environment of low norepinephrine during REM sleep, we wake up the next day, and those experiences have been softened in their emotional strength.
"We feel better about them, we feel we can cope."
Consultant clinical psychologist Dr Roderick Orner said that although sleep was believed by many to play a crucial role in the processing of traumatic memories, there were likely to be many other factors at work in PTSD patients.
He said: "In cases of more severe trauma, it may be just too difficult for the patient to process it during sleep, especially if the event has had a significant impact on that person's day to day life."