The first time I died in my sleep, I was 26 years old. I was in bed in my St. Louis apartment when my girlfriend shook me awake to say: “You stopped breathing!”

I died in my sleep this way many times — 20 to 30 times a night, my snoring was cut short with a gasp — before I saw a specialist who told me what was wrong.

I have obstructive sleep apnea, which affects 12 million American adults, according to the National Institutes of Health — 20 percent of adult men and 9 percent of women. Apnea is defined by blockage of the airway during sleep. This causes breathing to stop for seconds at a time, up to 30 times per hour: my nightly “deaths.”

“In sleep apnea, your life is saved by awakening,” said Clifford Saper, chair of neurology at Harvard Medical School (HMS). When you stop breathing, the brain wakes you up. But how the brain knows when to wake you is a mystery just now being resolved.

Saper and colleagues at Beth Israel Deaconess Medical Center recently discovered a brainstem area that senses oxygen dips and drives waking. Saper presented the finding last month at Sleep 2012, the 26th annual meeting of the Associated Professional Sleep Societies, which met this year in Boston.

The brainstem area, known as the parabracheal nucleus (PBN) of the pons, was already a focus of work by Saper’s lab. In a 2011 paper in the Journal of Comparative Neurology, Saper and colleagues reported that the PBN — but not the serotonin- and noradrenaline-secreting regions previously believed to drive waking — is needed to keep rats awake. In 1996, the same lab identified in the forebrain a “sleep switch” — the ventrolateral preoptic area (VLPO) — that turns off the brain’s “arousal system” and puts it to sleep.

When apnea happens, the brain wakes you up. These awakenings cause the disturbed sleep that plagues people who have apnea, also known as “sleep-disordered breathing.” Apnea tends to occur during sleep as the muscles that hold the airway open become relaxed. During rapid eye movement (REM) sleep, the body’s muscles are paralyzed, which prevents sleepers from enacting dreams but can also block the airways of people with apnea. The same thing can happen during the deep relaxation of slow-wave sleep. This leads to the constricted airway, failed breathing, and multiple awakenings characteristic of apnea.

Saper and colleagues asked: What mechanism in the brain detects oxygen levels and triggers awakenings when oxygen levels plunge? Because the group had discovered a brain region that drives arousal, the PBN, this region became its target. The PBN arouses the brain using the excitatory neurotransmitter glutamate, and is silenced by the inhibitory neutotransmitter GABA, released by the VLPO. Most hypnotic sleep drugs, such as barbiturates and benzodiazepines, fight insomnia through the GABA system, by increasing inhibition of the arousal system. Depressants like alcohol promote sleepiness in the same way, by counteracting arousal signals from the brainstem.

Using mice genetically modified not to express the glutamate transporter — a protein necessary for the neurotransmitter to bind to its receptor — in the PBN, Saper and colleagues could see what happens to mice whose “arousal trigger” is silenced.

To simulate apnea for the mice, the researchers used a special “gas chamber,” in which the levels of oxygen and carbon dioxide could be manipulated. When carbon dioxide was increased and oxygen was decreased for 30 seconds, healthy mice would awaken immediately from sleep, just like humans with sleep apnea do when they stop breathing. However, among the mice with the silenced PBN, mice failed to wake up between 30 percent and 40 percent of the time. The mice that did eventually wake up took two to three times longer than healthy mice — indicating that their mechanism for fast detection of oxygen and carbon dioxide level was broken.

Saper concluded that the PBN is even more important for sleep-wake function than simply as a switch for arousal. The region is also sensitive to danger signals, including oxygen loss, which it relays to the brain by sounding the arousing alarm.

A better understanding of the brain structures involved in sleep, waking, and apnea may one day aid the design of targeted medications for insomnia and sleep-disordered breathing.

I may not have to keep dying in my sleep forever, if sleep science keeps up this pace.