When neurologist Haoqi Sun falls asleep tonight, his brain will leave behind a trail of electrical whispers. These whispers, captured by a simple headband electrode — the kind used in sleep studies — might one day reveal whether his brain is aging faster than his years suggest.

Sun and a team of researchers at UC San Francisco and Beth Israel Deaconess Medical Center in Boston have built an artificial intelligence system that reads those nighttime brain signals to estimate a person's "brain age." Their study, published in JAMA Network Open, suggests that how our brains behave while we sleep could hint at dementia risk years before symptoms appear.

"Brain age is calculated from sleep brain waves," said Yue Leng, an associate professor of psychiatry at UCSF who co-led the research. "We know that brain activity during sleep provides a measurable window into how well the brain is aging."

The system examines 13 microscopic patterns within electrical signals collected through EEG — electroencephalography, a test that measures the brain's electrical activity using small sensors attached to the scalp. The researchers applied their machine-learning model to data from roughly 7,000 people between ages 40 and 94 who had participated in five separate studies. None had dementia when the studies began.

Over follow-up periods ranging from 3.5 to 17 years, about 1,000 of those participants developed dementia.

The pattern that emerged was striking: for every 10-year difference between a person's estimated brain age and their actual age, their likelihood of developing dementia rose by nearly 40 percent. Those whose brains appeared younger than their years faced lower risk.

"Broad sleep metrics don't fully capture the complex multidimensional nature of sleep physiology," Leng noted.

Some of the brain wave patterns the AI examined are already known to support memory and thinking. Delta waves, the slow rolling signals associated with deep sleep, help the brain repair itself. Sleep spindles — brief bursts of rapid brain activity during lighter sleep stages — appear to help the brain strengthen and store memories.

One surprising finding involved large, sudden spikes in EEG signals called kurtosis. Participants showing this feature had a lower risk of dementia.

The connection between brain age and dementia held true even after accounting for other risk factors like education, smoking, body weight, physical activity, and genetic predisposition.

The implications could extend beyond the clinic. Because EEG readings are non-invasive and can be collected during ordinary sleep, researchers believe wearable devices might someday record the necessary brain signals at home — opening a window into brain health without a hospital visit.

Sun emphasized that improving sleep could influence how brains age. "Better body management, such as lowering body mass index and increasing exercise to reduce the likelihood of apnea, may have an impact," he said. "But there's no magic pill to improve brain health."

Still, the researchers see promise in using sleep brain waves to flag people who might benefit from early interventions — buying precious time before cognitive decline takes hold.