There's an unnerving, specific kind of dream — a nightmare, really — that can happen when your body and your brain are out of sync.

Blake Stone-Banks, 39, says that when it first happened to him, he had accidentally fallen asleep on a friend's sofa.

"In the dream, the bathtub was running for whatever reason. And I knew the bathtub was overflowing, and I also knew that there was a stranger wandering around the house," Stone-Banks says. "And there was nothing I could do about it. I couldn't move to hide or defend myself against the stranger, and I couldn't get up to turn off the bathwater. And it seemed to go on for hours ... My eyes are open. I can see the room I'm in. But I'm unable to move at all."

That inability to move, sometimes accompanied by hallucinations or a distinct feeling that there's a presence in the room, is called sleep paralysis. It's a half-awake dream that occurs as the result of glitches in the brain when you're emerging from REM sleep.

Cambridge University Neuroscientist Baland Jalal started studying sleep paralysis after experiencing it himself. He says REM (or rapid eye movement) is the stage of sleep when we have our most vivid dreams.

"Your heart rate is elevated. Your blood pressure rises. And you have all this neural activity going on in your brain," he says.

During REM, the part of your brain that experiences emotion — the limbic system — lights up so much that it looks the same as when we're awake. Some scientists think that the reason we dream is to make sense of all those random emotional fireworks.

Other parts of our brain turn totally off during REM sleep — like the part that controls logic. That's why, in a dream, you can have tea with the queen on the moon, naked.

Jalal says that some scientists think these highly emotional, illogical dreams during REM act as a survival mechanism, preparing us for potential danger — even if it that danger seems improbable.

"So if you in your dreams see yourself, I don't know, wrestling with a bear, that is going to make you more likely to, when you encounter that in real life, be able to deal with a situation like that," he says.

In order to keep us from acting these dreams out while we're still asleep — wrestling your dresser like it's a bear, or jumping out the window because you think you can fly — the brain stem paralyzes the body.

Every night, each of us are paralyzed for a little while as we sleep. But there are some people who occasionally wake up during REM with their bodies still paralyzed. That's sleep paralysis.

Jalal describes what happens to most people once they realize their bodies are frozen: "The first thing you do is like, my God, get me out of here! So you start sending all these command neurons down to your body to your arms to your legs. Move! Move!"

That panic, that fierce attempt to move your limbs when it's physically impossible, confuses your brain. So it tries to fill in the gaps by creating hallucinations of things like a presence in the room.

Jalal has done studies of sleep paralysis in different countries around the world, and so far it seems like it's present everywhere. But he found something else that surprised him: countries that have specific beliefs about sleep paralysis experience the phenomena much more often.

Essentially, if you have a cultural narrative around sleep paralysis, you're more likely to experience it. And if you've experienced it once, you're more likely to experience it again, and to tell people about it and enforce that cultural narrative.

For example, if you live somewhere like Denmark, where Jalal says people are historically not very spiritual and there's no local story around sleep paralysis, you're likely to take the event for what it is — some weird dream experience. About 10 percent of people who live in places like Denmark experience sleep paralysis.

But in a country with ingrained cultural beliefs in the supernatural, the rate of people who experience sleep paralysis can be much higher — by as much as 20 percent.

Jalal offers a hypothetical example: a little girl named Lisa who was raised in a place like Egypt, which he says has long history of spirituality.

"Lisa is told by her grandmother that this creature known as the boogeyman is going to attack you at night. It's going to strangle you," he says. "It's going to press on your chest. So be careful when you go to sleep!"

Jalal says that, because of what her grandmother told her, Lisa is primed to have sleep paralysis; going to bed anxious makes sleep paralysis more likely, and Lisa is probably going to unconsciously start paying close attention to sensations in her body, waiting to feel that boogeyman holding her down.

And when she does wake up unable to move?

"Given all the aspects of REM sleep and dreams, she's going to create this very colorful and exotic narrative around what's going on," Jalal says.

"Now the next day, my God, Lisa is terrified. She's scared, right? She goes around the village, tells everyone about the boogeyman. And then she's even more terrified to go to bed the next night, which makes her ironically more predisposed to having sleep paralysis," he says.

This cycle of predisposition and anxiety means sleep paralysis in Egypt is more common than somewhere like Denmark.

So, if you wake up to this horror in the middle of the night, what can you do to make it stop?

Jalal is studying that now. He says your best bet is to stay as calm as possible and put some emotional distance between yourself and the experience. Tell yourself, "There's no reason for me to be afraid. There's no reason for me to be worried," he says.

Know that the experience will pass soon, and that, terrifying as it may be, sleep paralysis is perfectly normal.

Liz Tung contributed to this story.