Alzheimer’s disease is a devastating brain disorder that has no known cure. Studies have shown that you can improve your chances of keeping it at bay by, say, drinking a lot of coffee, but that’s not going to eradicate the disease or make a positive Alzheimer’s diagnosis any less troubling.

As with any disease, early diagnosis can be a big advantage for doctors in treating Alzheimer’s, and drugs that combat the disease are most effective if used early on. Now, researchers from UC San Francisco have taught an AI to spot the signs of the disease in brain scans up to six years before a diagnosis would normally have been given.

The research, which was published in the journal Radiology, explains how UC San Francisco’s Jae Ho Sohn, MD, MS, recognized a potential area of treatment where machine learning could work in tandem with medical staff.

One of the ways Alzheimer’s can be diagnosed is by studying the glucose levels in different areas of the brain. PET scans that document glucose levels in brain tissue are heavily relied upon, but it can be difficult for a doctor to make a diagnosis if the changes taking place in the brain are subtle, as they often are with a slowly-progressing disease like Alzheimer’s.

Sohn sought the help of a machine learning algorithm to detect the changes with greater accuracy and found that the AI is quite skilled at spotting the earliest signs of Alzheimer’s.

“This is an ideal application of deep learning because it is particularly strong at finding very subtle but diffuse processes,” Sohn said in a statement. “Human radiologists are really strong at identifying tiny focal finding like a brain tumor, but we struggle at detecting more slow, global changes. Given the strength of deep learning in this type of application, especially compared to humans, it seemed like a natural application.”

The algorithm was taught using nearly 2,000 scans and then test against new scans that it had never seen before. In its very first outing it was 92% accurate, which is pretty impressive on its own. However, the information it learned from that test led to a 98% accuracy rating in the second test, which is rather incredible.

The AI won’t be used for actual Alzheimer’s diagnosis quite yet, but Sohn believes it might become a valuable tool in a doctor’s arsenal sooner rather than later.