Most of us wake up from nightmares relieved that we're safe in bed. But a small fraction uncontrollably act out their dreams as they unfold, endangering themselves or others.
The recent movie "Sleepwalk With Me," about a struggling stand-up comedian and his issues with sleep, brings to light a rare condition called REM behavior disorder.
This film is not a documentary, but lead actor and director Mike Birbiglia has said that many events, including the dangerous behaviors while asleep, are based on his real life.
Matt Pandamiglio, Birbiglia's character, drives hundreds of miles to any comedy gig he can possibly get to, away from the girlfriend he isn't sure he wants to marry. In the midst of all this, Pandamiglio experiences dramatic episodes of acting out his dreams.
For instance, while staying at a hotel alone, he jumps through the window of his room because, in his dream, he's being pursued by a missile targeting him.
Although the film is called "Sleepwalk With Me," Pandamiglio isn't sleepwalking per se -- he's kicking, running, climbing on top of things and falling off them.
After repeatedly delaying a doctor's visit, he finally gets the diagnosis of REM behavior disorder, which affects less than 1% of the population, according to the American Sleep Association.
Unusual patterns of behavior that people exhibit while sleeping are called parasomnias. Most of them are most likely to happen when a person is sleep-deprived and under stress, said Philip Gehrman, assistant professor of psychiatry at the University of Pennsylvania.
Sleepwalking and REM behavior disorder are two examples of parasomnias. Sleepwalking happens during non-REM sleep; it usually involves walking around and perhaps mumbling.
REM is a stage of deep sleep during which certain parts of the body are normally paralyzed temporarily.
"The brain sends out the signals to move, but at the level of the spinal cord, the motor neurons are inhibited," said Dr. William C. Dement, a pioneer in the field of sleep research and professor at Stanford University School of Medicine.
But that inhibition fails in REM behavior disorder, allowing the person to move in the way that he or she is envisioning in a dream. "It can be very dangerous," Dement said.
REM behavior disorder and sleepwalking are defined as separate disorders, but in reality there may be some overlap, Dement said.
Dement and Dr. Rafael Pelayo, associate professor at Stanford medical school, said they have never seen patients who jumped out of windows, but some have punched windows.
Dement appears as himself in "Sleepwalk With Me," sitting in the passenger seat beside the struggling comedian while he's dreaming/listening to Dement's audio book in the car. (It's a little reminiscent of Cornel West's cameo in "The Matrix Reloaded," another widely known academic in surreal circumstances.)
"In the simplistic way of thinking, the brain is either awake, sleeping or dreaming," Pelayo said. "But we know that the brain is complicated enough that one part can be awake while another part can be sleeping at the same time."
In sleepwalking, the rational part of the brain is offline, while the emotional part is activated, he said.
Most people with REM behavior disorder are men, and they tend to be older, Pelayo said. The disorder can mark the start of Parkinson's disease.
It's unusual for someone as young as Birbiglia, 34, to exhibit REM behavior disorder, Pelayo said. But it's possible that he has a combination of sleepwalking and REM behavior disorder, he said.
The film portrayed Birbiglia's character exhibiting several risk factors: drinking alcohol, staying up late, sleeping in different environments and being under stress.
Sleepwalking by itself is more common, especially among children. Research suggests that as many as 30% of children have experienced sleepwalking. Most people stop once they hit puberty, Gehrman said. Sleepwalking has occurred among nearly one in three Americans at some point in their lives, a study in Neurology found in May.
As for whether someone should awaken people who are in one of these altered sleep states, it's more dangerous for others than for the sleepers, experts say. The sleepers' brains will not be impaired by waking up, but they may react violently.
Sleepwalking among adults is not necessarily a problem. For mild cases, education about the phenomenon and reassurance are enough, Gehrman said.
But if the person goes outside and gets into dangerous situations, he or she may need to sleep more and undergo stress management interventions.
If that doesn't work, especially among people who have been sleepwalking for their whole lives, medications may be necessary.