According to a study conducted through heartbeat measurement app Cardiogram and the University of California, San Francisco, the Apple Watch is 97 percent accurate in detecting the most common abnormal heart rhythm when paired with an AI-based algorithm.

The study involved 6,158 participants recruited through the Cardiogram app on Apple Watch . Most of the participants in the UCSF Health eHeart study had normal EKG readings. However, 200 of them had been diagnosed with paroxysmal atrial fibrillation (an abnormal heartbeat). Engineers then trained a deep neural network to identify these abnormal heart rhythms from Apple Watch heart rate data.

Cardiogram began the study with UCSF in 2016 to discover whether the Apple Watch could detect an oncoming stroke. About a quarter of strokes are caused by an abnormal heart rhythm, according to Cardiogram co-founder and data scientist for UCSF’s eHeart study Brandon Ballinger.

Cardiogram tested the deep neural network it had built against 51 in-hospital cardioversions (a procedure that restores the heart’s normal rhythm) and says it achieved a 97 percent accuracy in the neural network’s ability to find irregular heart activity.

So far this is just a study built on a preliminary algorithm but it holds promise in trying to identify and prevent stroke in the future. Atrial fibrillation, the most common abnormal heart rhythm, causes 1 in 4 strokes. Ballinger says two-thirds of those types of strokes are preventable with relatively inexpensive drugs.

And more people, including older populations most prone to stroke risk, are starting to use wearable technology such as Fitbit or the Apple Watch, which can double as heart monitors. Including algorithms trained to identify heart problems could help save lives in some of these more at-risk populations.

It should be noted mobile EKG readers have also made great strides in the past few years. The Mayo Clinic teamed up on a study involving AI and AliveCor’s version of an EKG reader, which sticks onto the back of a smartphone and uses the Kardia app to determine abnormal heart rhythm, and determined it was as good as other EKG devices used in the doctor’s office. The Mayo Clinic felt so strongly about this study it invested in AliveCor’s latest $30 million round.

In the meantime, Cardiogram and UCSF will continue its eHealth study and plan to further validate its deep neural network “against multiple gold standards, incorporating the results into the Cardiogram app itself, and investigating the ability to detect health conditions beyond atrial fibrillation,” according to Cardiogram.