Updated

Ordinary bad dreams may be the brain's way of helping us regulate our negative emotions, while nightmares may reflect a glitch in that process, according to researchers.

Scientists and non-scientists alike have long puzzled over the exact function of dreams. In recent years, research into the psychology and brain activity associated with dreaming has given more clues as to why our sleep is filled with often bizarre, and sometimes frightening, images.

Writing in the journal Current Directions in Psychological Science, Drs. Ross Levin and Tore Nielsen suggest that run-of-the-mill bad dreams are part of the brain's method of processing emotions. In fact, they say, emotional regulation may be the primary function of REM sleep, the sleep stage during which most dreams occur.

Lacking Zzzs? 5 Ways to Get a Better Night's Sleep

10 Foods to Help You Sleep

In contrast to your standard dream, nightmares — technically, a bad dream that startles you out of sleep — may arise when that emotion-regulating process goes wrong.

Bad dreams are nothing out of the ordinary. Studies show that most of our dreams are not happy ones.

"The 'default' dream is basically the bad dream," explained Levin, a psychologist at Yeshiva University in New York who specializes in treating sleep disorders. We seem to be hardwired to attend to negative emotions — which, in the context of evolution, is not surprising, according to Levin, since vigilance offers a survival advantage.

"If you missed a threat, you were lunch," the researcher noted.

Dreams — or, more broadly, REM sleep — may serve to process fear memories so that the system does not become overwhelmed. Bits of our memories "get thrown into a room together and jumbled around," Levin explained, which puts them in a new context and diffuses the fear attached to them.

Studies show that during REM sleep, activity in certain brain regions — including the limbic system, which is involved in emotional regulation, as well as memory — spikes considerably.

With nightmares, though, the dreamer wakes up, disrupting normal emotion processing, according to Levin and Nielsen. Waking up is a relief in the moment, Levin noted, but it may ultimately serve to "reinforce" the feeling that the threat was real.

Most people have the occasional nightmare, particularly during times of high stress. Research suggests that 85 percent of adults have at least one per year.

Nightmares only become a problem when they distress people during the day as well, according to Levin.

People who are generally prone to anxiety in response to stress are at greater risk of problem nightmares. Their nightmares may lead to more distress in waking life, which may in turn spur more nightmares, Levin and Nielsen point out.

The good news is that the greater understanding of the origins of nightmares has allowed more effective therapies, according to Levin.

For example, he said, so-called imagery-rehearsal therapy — where a person imagines, then changes, the stuff of their nightmares while awake — has proven highly effective.