MONDAY, Sept. 26, 2016 (HealthDay News) -- Imagine you wake up, see a stranger running toward you with a knife and your legs won't move so there's no escape.

Terrifying episodes like these are known as sleep paralysis. They're not dangerous, it's just your brain telling your body it's still in dreamland, according to Texas A&M University researchers.

When you're in the stage of sleep where vivid dreams occur (known as REM sleep), your arms and legs are temporarily paralyzed so you can't act out your dreams. If you wake up during this REM stage, you feel unable to move and may even hallucinate, the researchers said.

"When people have a nightmare, they sleep, have a dream and then wake up. When they're experiencing sleep paralysis, they may have a dream when they are already awake," said Dr. Steven Bender, director of Texas A&M University's Center for Facial Pain and Sleep Medicine.

"Sleep paralysis is a frightening event," he said in a university news release.

Fortunately, it doesn't last more than a minute or two and it usually happens when people are falling asleep or just waking up.

"People who experience sleep paralysis can have vivid hallucinations because they are dreaming," Bender explained. "People have felt like they're levitating or that someone is in their bedroom or a variety of other strange experiences, like alien abductions."

Since breathing can be irregular during REM sleep, those experiencing sleep paralysis may feel like they're suffocating or are not able to breathe easily.

And it's more common than people realize, affecting up to 8 percent of people. It's especially common among young adults, women and blacks. People with depression, anxiety and the chronic sleep disorder narcolepsy are also more likely to experience it, the researchers said.

Improving sleep habits can help you avoid these episodes. Bender suggests:

  • Going to bed and waking up around the same time each day.
  • Avoiding TV right before bed.
  • Not using a laptop or cellphone in bed.
  • Avoiding daytime napping.
  • Avoiding stimulants close to bedtime.

Though it can be a frightening experience, Bender said sleep paralysis isn't a medical emergency.

"If it becomes a regular problem," he said, "then consult your primary health care provider, and they can help you manage it."

More information

The American Sleep Association provides more information on sleep and hallucinations.