Atrial Insights
Atrial Fibrillation, also known as Afib impacts daily life for millions of people worldwide. If untreated it can increase the risk of stroke and heart failure. Atrial Insights is a tool to empower users to discover patterns in their Afib episodes and seek better treatment.
Current solutions for Afib detection are black boxes providing little clarity about their inner workings and few actionable insights for patients. Our project seeks to fix these shortfalls with an AI model that can explain its predictions and a dashboard that lets users annotate their own Afib. Users are given insights into their atrial burden, and when their Afib episodes are happening so they can identify triggers and work with their doctors to plan treatment.
Atrial Fibrillation and Detection
Atrial fibrillation is a condition where the heart beats quickly and irregularly. Episodes can anywhere from a few seconds to multiple days. This can be painful but it also increases the risk for other cardiovascular health problems including stroke and heart failure. Today, it is estimated that Afib affects more than 30 million people around the world. As the population ages, this number is expected to double by 2050 placing more strain on our healthcare systems. Afib can be managed through a variety of medications and lifestyle changes, but a detecting Afib remains a key challenge.
Electrocardiogram (ECG) monitoring is the most reliable way to detect Afib. Traditionally this monitoring has been done at medical offices or at home by wearing a device such as a Holter monitor. Afterwards a doctor or technician would have to review the recording to identify instances of atrial fibrillation. Today, computers can detect Afib and ECG monitors are more available. In fact, some wearable fitness trackers such as newer Apple Watch models can detect Afib as it is happening. Still, these technologies leave a few questions unanswered. Doctors and patients may ask: How is the computer making this determination? How often and when is my Afib happening? Is my Afib getting worse?
Atrial Insights aims to answer these questions. We introduce a machine learning model that can accurately detect Afib and which can justify its conclusions. We also create a personalized dashboard where users can upload and annotate their ECG data. This allows them and their doctors to identify patterns, and trends. Ultimately, these tools should help people understand their own Afib behavior better and be more proactive in developing treatment plans.
Datasets
There are a large number of publicly available ECG datasets for atrial fibrillation classification at physionet.org. We used the MIT-BIH Atrial Fibrillation Database to train and evaluate our machine learning model. After publishing that model we evaluated it again on the Long Term AF Database. This second dataset allowed us to see how the model performed on people in different countries (USA vs Poland), decades (1983 vs 2007), and on recordings made with different ECG monitors.
Before passing raw ECG data into any AI models we process it to identify every individual heartbeat in the recording. We also extract descriptive information from the heartbeats including the timing between different electrical pulses from the heart.
Modelling
The engine of Atrial Insights is a Long Short-Term Memory (LSTM) AI model. This model looks at every heartbeat that a user uploads and makes a determination on whether it is an example of Afib or not. LSTMs are a good choice for this type of task because they can remember important information about the current and past heartbeats and forget information that is not important. We also incorporate a layer in our model to extract SHAP values. These calculate how each input feature contributes to the model's decision. For example, on a scale from 0 to 1, a value greater than 0.5 could indicate an Afib heartbeat. By looking at the SHAP values we could see that a short time between two heartbeats added 0.02 to the outcome score. By stacking all of the contributions of each feature and presenting them on the dashboard, we provide some justification to the end user. They can look the the stackup and understand, for example, that the computer's Afib determination was made based on the short timing between many electrical pulses in recent heartbeats.
After the LSTM model produces its Afib classifications, we run the results through a smoothing function. This step helps to reduce most of the false positive (erroneous Afib) predictions and create crisper delineations between periods of Afib and normal sinus rhythm. This function uses a K-means clustering algorithm to find heartbeats at similar times that look similar but which the LSTM model classified differently. We can use this to catch incorrect classifications and increase the model's total accuracy.
Dashboard Architecture
Our overall architecture relies heavily on Google Colab for initial model development and AWS SageMaker for fine-tuning and deployment. The final model parameters were stored in an S3 bucket to be deployed using a SageMaker Endpoint. The image for the containerized app is stored in AWS ECR, which will pull the model parameters, instantiate S3 buckets for temporary data storage, and create a SageMaker endpoint for model inference. We deployed the Dash app using Fargate. We registered our domain using Route 53 and leveraged a load balancer to manage security and traffic flow while connecting our dashboard to the domain name.
Key Components
- AWS SageMaker - Supports model deployment
- AWS S3 Buckets - Model artifact and data storage
- AWS ECR/ECS - Deployed app to the web using ECS via images hosted in ECR