IntelliHQ - AWS - ECG Live Stream

IntelliHQ uses Machine Learning on AWS to create a web-based ECG live stream

The coming 4th Industrial Revolution – an exponential convergence of digital, physical, technological and biological advances – will transform industries over the course of the 21st century. No single innovation will lead this impending revolution, but one thing is clear: Artificial Intelligence (AI) will be at the forefront.

Healthcare is among the foremost industries ripe to be revolutionized by AI and the 4th Industrial Revolution. By enabling ground-breaking advances in healthcare digitisation, AI is expected to significantly contribute to medical advances and lead to marked improvements to healthcare delivery.

 

Embracing AI to revolutionize healthcare

A not-for-profit partnership between Gold Coast Health, industry and universities, IntelliHQ (Intelligent Health Queensland) is dedicated to promoting research, investment, and monetization of next-generation AI and machine learning technologies in the health sector. It aims to enhance patient outcomes, improve quality of care, create opportunities for skills, jobs and venture development, and encourage investment. By harnessing trusted AI, IntelliHQ aspires to become a globally recognised healthcare innovation and commercialization hub.

Building a global healthcare AI capability promises to deliver significant benefits, not only by relieving pressure on the medical system resulting from spiralling costs, but also by contributing to broader technological economic growth, global competitiveness, and skill creation.

But to realize its aspirations, IntelliHQ has to overcome several challenges and obstacles to AI adoption in healthcare. It needs to build community trust, and maintain secure access to patient data. As such, IntelliHQ needed a technology partner to enable it to achieve its goals.

 

IntelliHQ engages TechConnect

To enable its key initiatives, IntelliHQ worked with AWS Partner Network (APN) Advanced Consulting Partner, TechConnect to create a web-based ECG live stream with machine learning annotations as a proof-of-concept. This requires numerous cloud technologies for data security, storage, transformation, and means for deployment.

An ECG signal can be categorised into either a normal (healthy) signal or various types of abnormal (unhealthy) classifications, such as atrial fibrillation. Key health indicators are the standard deviation of the length of time between peaks and troughs in an ECG signal, and the ratio between low frequency vs high frequency signals.

It’s possible to generate annotations of these intervals and apply an algorithm to the resulting data to make classifications without machine learning. But given the ability for machine learning to make increasingly sophisticated classifications and predictions, applying these technologies to health data presents many advantages.

 

The Solution

To extract ICU data to the cloud, IntelliHQ used TechConnect’s Panacea toolset, a C# library and Windows service that connects to a GE Carescape Gateway High Speed Data Interface, subscribe to data feeds and push these data feeds to the cloud via AWS Kinesis Firehose, Amazon’s high speed data ingestion service.

As actual ICU data could not be streamed from a hospital to the cloud until all custodianship processes has been finalised, this proof-of-concept utilised a demonstration monitor to simulate a typical healthy heartbeat, several abnormal rhythms, and test with various combinations of leads connected.

Once subscribed to a data feed, the Windows service inspects each packet to identify source information, and then converts the ECG waveform and extra numeric data into a hexadecimal representation for transport to the cloud. The source information is parsed by an AWS Lambda function, which then writes the data into an Amazon S3 folder structure that uses folder names for a simple organisational scheme.

Parameters are extracted from the AWS Kinesis Firehose stream data by the Amazon Lambda function in a structure format that reflects the default naming convention for Hive partitions on Amazon S3. Many AWS and Hadoop compatible tools (like Amazon Athena) can use this partitioning scheme to efficiently select subsets of data when queried by these parameters.

Once the data was uploaded to Amazon S3 via Panacea in its proprietary raw hex format, they required conversion to a broadly supported file format using an Amazon EMR cluster to handle the parallel transform operations, for which Zeppelin was chosen. It exposes a web-accessible notebook interface to run code and display resulting visualisations, and each notebook consists of a sequence of cells which can utilise a different parser. This provided easy access to Spark, SQL and Scala for data analytics.

IntelliHQ then unpackaged the raw waveform and numerics data into a human readable tabular file format using a combination of PySpark and SparkSQL code. They chose the widely supported csv format, and created annotation files that labelled normal vs abnormal waveform periods. The next data preparation steps took place in Amazon Sagemaker, which gave access to serverless resources for training and deployment. After the addition of front end graphics, the resulting visualization displays in a simple UI. The code is then packaged with Amazon Elastic Container Service for deployment.

ECG Live Stream - IntelliHQ - AWS

 

The Benefits

The proof-of-concept process results in significant query time improvements and, for tools like Amazon Athena, substantial query cost savings. Furthermore, the folder structure is self documenting and unambiguous, allowing a highly decoupled architecture that can handle any future growth in data volume.

Also the data is non-public, and AWS Identity and Access Management (IAM) credentials establish who has access rights. Security tags and security groups enable IntelliHQ to allocate who has access to data at different stages of preparation. Because these cloud services come with baked-in security, IntelliHQ can ensure they have strong control over health data.

 

The Outcome

The web-based ECG live stream proof-of-concept showed that efficient, secure web services enable IntelliHQ to build effective, scalable cloud solutions. By embracing AI and machine learning, IntelliHQ will continue to advance the possibilities of commercialized healthcare innovation.

 

Download white paper here

What's the difference between Artificial Intelligence (AI) & Machine Learning (ML)?

What’s the difference between Artificial Intelligence (AI) & Machine Learning (ML)?

What’s the difference between Artificial Intelligence (AI) & Machine Learning (ML)?

The field of Artificial Intelligence encompasses all efforts at imbuing computational devices with capabilities that have traditionally been viewed as requiring human-level intelligence. 

This includes:

  • Chess, go and generalised game playing 
  • Planning and goal-directed behaviour in dynamic and complex environments 
  • Theorem proving, proof assistants and symbolic reasoning 
  • Computer vision  
  • Natural language understanding and translation 
  • Deductive, inductive and abductive reasoning 
  • Learning from experience and existing data 
  • Understanding and emulating emotion 
  • Fuzzy and probabilistic (Bayesean) reasoning 
  • Communication, teamwork, negotiation and argumentation between self-interested agents 
  • Early advances in signal processing (text to speech) 
  • Music understanding and creation 

Like intelligence itself it defies definition.

As a field, it predates Machine Learning and Machine Learning was seen as an early sub-field. Many things that are obvious or no longer considered AI have their roots in the field. Many database models (hierarchical, network and relational) have their roots in AI research. Optimisation and scheduling were early problems tackled under the umbrella of AI. Minsky’s Frame model reads like an early description of Object Oriented programming. LISP, Prolog and many other programming languages and programming language properties emerged as tools for or as a result of AI research.

Neural networks (a sub-field of machine learning) emerged in the 80s in the form of perceptrons and were heavily studied until it was demonstrated that a perceptron was unable to calculate XOR. However, with the invent of error back propagation over networks of perceptrons (a way to systematically train the weights between neurons) it was shown that neural networks have equivalent computational power to universal turing machines (if it can be computed on a turing machine a correctly configured neural network can also implement that same function).

With the invent of Deep Learning in the 2010s the popularity of machine learning has soared as great successes have been achieved using the approach. Due to limits on computational power, traditional neural networks were trained on meticulously human engineered features of the datasets, not the raw datasets themselves. With the progress in cloud, gpus and distributed learning it became possible to create much larger and deeper neural networks. This progressed to the point that large raw datasets could be used directly to train with and get predictions from. In so doing the neural networks extract their own features from the data as part of this process. Many of the recent advances have been achieved due to this (in addition to better neuron activation functions, faster training algorithms, new network architectures).  The successes have also inspired people to use Deep Learning as a means of solving some of the other problems in general AI (as discussed above) and this may explain why a convergence or confusion between AI and Machine Learning is perceived by many.

Machine Learning using Convolutional Neural Networks

Machine Learning with Amazon SageMaker

Computers are generally programmed to do what the developer dictates and will only behave predictably under the specified scenarios.

In recent years, people are increasingly turning to computers to perform tasks that can’t be achieved with traditional programming, which previously had to be done by humans performing manual tasks.   Machine Learning gives computers the ability to ‘learn’ and act on information based on observations without being explicitly programmed.

TechConnect entered the recent Get 2 the Core challenge on Unearthed’s crowd sourcing platformThis is TechConnect’s story, as part of the crowd sourcing approach, and does not imply or assert in any way that Newcrest Mining endorse Amazon Web Services or the work TechConnect have performed in this challenge.

Business problem

Currently a team at Newcrest Mining manually crop photographs of drill core samples before the photos can be fed into a system which detects the material type. This is extremely time-consuming due to the large number of photos. Hence why Newcrest Mining used crowd sourcing via the Unearthed platform, a platform bringing data scientists, start-ups and the energy & natural resources industry together.

Being able to automatically identify bounding box co-ordinates of the samples within an image would save 80-90% of the time spent preparing the photos.

Input Image

Machine Learning using Convolutional Neural Networks

Expected Output Image

Machine Learning using Convolutional Neural Networks

 

Before we can begin implementing an object-detection process, we first need to address a variety of issues with the photographs themselves, being:

  • Not all photos are straight
  • Not all core trays are in a fixed position relative to the camera
  • Not all photos are taken perpendicular to the core trays introducing a perspective distortion
  • Not all photos are high-resolution

In addition to the object-classification, we need to use an image-classification process to classify each image into a group based on the factors above. The groups are defined as:

Group 0 – Core trays are positioned correctly in the images with no distortion. This is the ideal case
Group 1 – Core trays are misaligned in the image
Group 2 – Core trays have perspective distortion
Group 3 – Core trays are misaligned and have perspective distortion
Group 4 – The photo has a low aspect ratio
Group 5 – The photo has a low aspect ratio and are misaligned

CNN Image Detection with Amazon Sagemaker

Solution

We tried to solve this problem using Machine Learning. In particular, we used supervised learning. When conducting supervised learning the system is provided with the input data and the classification/label desired output for each data point. The system learns a model that when provided a previously seen input will reliably output the correct labelling or the most likely label when an unseen input is provided.

This differs from unsupervised learning. When utilising unsupervised techniques, the target label is unknown and the system must group or derive the label from the inherent properties within the data set itself.

The Supervised Machine Learning process works by:

  1. Obtaining, preparing & labelling the input data
  2. Create a model
  3. Train the model
  4. Test the model
  5. Deploy & use the model

There are many specific algorithms for supervised learning that are appropriate for different learning tasks. The object detection and classification problem of identifying core samples in images is particularly suited to a technique known as convolutional neural networks. The model ‘learns’ by assigning and constantly adjusting internal weights and biases for each input of the training data to produce the specified output. The weights and biases become more accurate with more training data.

Amazon SageMaker provides a hosted platform that enabled us to quickly build, train, test and deploy our model.

Newcrest Mining provided a large collection of their photographs which contain core samples. A large subset of the photos also contained the expected output, which we used to train our model.

The expected output is a set of four (X, Y) coordinates per core sample in the photograph. The coordinates represent the corners of the bounding box that surrounds the core sample. Multiple sets of coordinates are expected for photos that contain multiple core samples.

The Process

We uploaded the supplied data to an AWS S3 bucket, using a separate prefix to separate images which we were provided the expected output for, and those with no output. S3 is an ideal store for the raw images with high durability, infinite capacity and direct integration with many other AWS products.

We further randomly split the photos with the expected output into a training dataset (70%) and a testing dataset (30%).

We created a Jupyter notebook on an Amazon SageMaker notebook instance to host and execute our code. By default the Jupyter notebook instance provides access to a wide variety of common data science tools such as numpy, tensorflow and matplotlib in addition to the Amazon SageMaker and AWS python SDKs. This allowed us to immediately focus on our particular problem of creating SageMaker compatible datasets with which we could build and test our models.

We trained our model by feeding the training dataset along with the expected output into an existing Sagemaker built object detection model to fine tune it to our specific problem. SageMaker has a collection of hyperparameters which influence how the model ‘learns’. Adjusting the hyperparameter values affects the overall accuracy of the model and how long the training takes. As the training proceeded we were able to monitor the changes to the primary accuracy metric and pre-emptively cancel any training configurations that did not perform well. This saved us considerable time and money by allowing us to abort poor configurations early.

We then tested the accuracy of our model by feeding testing data – data it has never seen – without the output, then comparing the model’s output to the expected output.

After the first round of training we had our benchmark for accuracy. From there we were able to tune the model by iteratively adjusting the hyperparameters, model parameters and by augmenting the data set with additional examples then retraining and retesting. Setting the hyperparameter values is more of an artform than a science – trial and error is often the best way.

We used a technique which dynamically assigned values to the learning rate after each epoch, similar to a harmonic progression:

Harmonic Progression

This technique allowed us to start with large values to allow the model to converge quickly initially, then reduce the learning rate value by an increasingly smaller amount after each epoch as the model gets closer to an optimal solution.  After many iterations of tuning, training and testing we had improved the overall accuracy of the model compared with our benchmark, and with our project deadline fast approaching we decided that it was accurate as possible in the timeframe that we had.

We then used our model to classify and detect the objects in the remaining photographs that didn’t exist in the training set.  The following images show the bounding boxes around the cores that our model predicted:

CNN Bounding
CNN Bounding

Lessons Learned

Before we began we had an extremely high expectation of how accurate our model would be. In reality it wasn’t as accurate as our expectations.
We discussed things that could have made the model more accurate, train faster or both, including:

  • Tuning the hyperparameters using SageMakers automated hyperparameter tuning tooling
  • Copying the data across multiple regions to gain better access to the specific machine types we required for training
  • Increasing the size of the training dataset by:
    • Requesting more photographs
    • Duplicating the provided photographs and modifying them slightly. This included:
      • including duplicate copies of images and labels
      • including copies after converting the images to greyscale
      • including copies after changing the aspect ratio of the images
      • including copies after mirroring the images
  • Splitting the problem into separate, simpler machine learnable stages
  • Strategies for identifying the corners of the cores when they are not a rectangle in the image

During these discussions we realised we hadn’t defined a cut-off for when we would consider our model to be ‘accurate enough’.

As a general rule the accuracy of the models you build improve most rapidly in the first few iterations, after that the rate of improvement slows significantly. Each subsequent improvement requires lengthier training, more sophisticated algorithms and models, more sophisticated feature engineering or substantial changes to approach entirely. This trend is depicted in the following chart:

Learning accuracy over time

Depending on the use case, a model with an accuracy of 90% often requires significantly less training time, engineering effort and sophistication than a model with an accuracy of 93%. The acceptance criteria for a model needs to carefully balance these considerations to maximise the overall return on investment for the project.

In our case time was the factor that dictated when we stopped training and started using the model to produce the outputs for unseen photographs.

 

Thank you to the team at TechConnect that volunteered to try Amazon Sagemaker to address the Get 2 the Core Challenge posted by Newcrest Mining on the Unearthered portal.  Also big thanks for sharing lessons learned and putting this blog together!