Artificial intelligence could one day change the lives of people facing an Alzheimer’s diagnosis, according to a new study by researchers at UC, San Francisco.

“One of the difficulties with Alzheimer’s disease is that by the time all the clinical symptoms manifest and we can make a definitive diagnosis, too many neurons have died, making it essentially irreversible,” said Jae Ho Sohn, a resident in the school’s Department of Radiology and Biomedical Imaging and the study’s lead researcher, in a statement.

For the study, published in Radiology, Sohn and his team fed a common type of brain scans to a machine-learning algorithm, and it learned to diagnose early-stage Alzheimer’s disease about six years before a clinical diagnosis could be made. The AI’s diagnostic skills could give doctors a much-needed headstart on treating the degenerative disease.

Sohn and his team focused on PET scans that monitored glucose levels across the brain, because glucose is the primary source of fuel for brain cells. Once the cells become diseased, they eventually stop using glucose, making it an important level to track. However, the changes are subtle—at least to the human eye. “Human radiologists are really strong at identifying tiny focal finding like a brain tumor, but we struggle at detecting more slow, global changes,” Sohn said. “Given the strength of deep learning in this type of application, especially compared to humans, it seemed like a natural application.”

Sohn and his team trained the algorithm on PET scans from patients who were eventually diagnosed with either Alzheimer’s disease, mild cognitive impairment, or no disorder. The algorithm began to figure out how to predict Alzheimer’s disease. Eventually, it was able to correctly identify 92% of patients who developed Alzheimer’s disease in the first test set and 98% in the second test set, making correct predictions on average 75.8 months (for the math-impaired, that’s almost over six years) before the patient received an Alzheimer’s diagnosis.

While the algorithm isn’t quite ready for clinical use, it could eventually help doctors start treating patients much earlier.

Update: In what can only be considered mathematical karma, 75.8 months is not “almost” six years, but is actually over six years.