system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: Why do we sometimes violently jerk awake just as we are drifting off to sleep?

Sometimes, just as I am drifting off to sleep, I will suddenly and violently jerk awake (think flailing legs and arms, gasping for breath, scared or disoriented). What causes this? It occasionally happens from a deep sleep as well. I assume there's some kind of physical explanation.

On a side note, this also happens to me the few times I've been in the hospital and had morphine.  So I've always wondered what physically causes this kind of sleep disturbance? Blood flow? Brain wave disruption?
gpt
Great question. This is called a hypnagogic jerk. There is no real explanation to the phenomenon but its our body reacting to stimuli while transitioning into sleep. This stimuli can be external (sound, feeling, etc.) or from the first period called the Alpha/Thera stage where you see images before deep sleep due to increased brain activity. It can also be caused be going straight to REM and partially dreaming. It's thought that caffeine or any uppers will cause this more, but there isn't enough studies on the topic.