Categories
Quantum Engineering

Cardiac Anomaly Detection using Azure Quantum Workspace

We begin with a simple goal:
How to speed up cardiac anomaly detection?

Current technology uses classical computing to apply Fast Fourier Transforms (FFT) to wavelets or spectrograms using input signals from ECG sensors. But classical computing involves a very long time to calculate the output, thus being useful only in research of ECG anomaly detection.

What if there is a way to use Quantum Computing to apply the Quantum Fourier Transform algorithm to the same problem? If we can pull this off, we could potentially disrupt Cardiac Anomaly Detection into a dramatic shift in treatment speed and methodology for cardiac care!

To understand how to apply Quantum Computing to solve this problem, there are several engineering steps with a plethora of decisions to be made in order to execute a solution:

We look at existing data sets on Electrocardiogram (ECG) that are publicly available for research.

We look at current methods to detect ECG anomalies.

We begin a hypothesis to design experiments to prove or disprove it.

We select the right tools to implement, run and analyze the experiments and its results.

We select the platform and develop the software to conduct the experiments on the platform of choice.

We pre-process the data set to get it ready to supply the platform running the software in the required form.

We design and standup the system architecture on the platform of choice and conduct “stub runs” using the software to develop and debug it.

We run the full dataset on the software as a simulation to learn how to post-process the results in a concise presentable (and interpretable) form.

We also measure the usage patterns to project the exact resolution to obtain results that fit in a budget allocated for the use of the platform and optimize it for usable results within the budget allocated for the project.

We finally run it on the platform using the real device with the same software.

We post-process the real device results and compare with the simulated results to obtain the delta between the two and determine if the platform chosen is usable to extend to real-life scenarios.

Each of these steps requires active decisions and agility that a tightly integrated platform must provide in order to develop the code, version it, as well as deploy it to the platform for execution and capturing results in a resilient manner.

Using the above points, lets examine our journey as Pivotport, Inc. embarked on this experiment to get to a real-world scenario.

In August 2021, Pivotport, Inc. applied to the Microsoft Azure Quantum Credits program with intent to conduct the above experiment and obtain results on the IonQ provider via a new Pivotport Azure Quantum Workspace. Since then, we received three approvals for $10,000 in Azure Quantum Credits via the program for IonQ, Quantinuum and Rigetti providers respectively.

In September 2021, we embarked on the project. Using the Azure Quantum Workspace instructions, we built the Pivotport Azure Quantum Workspace as well as an Azure DevOps environment with a Repository for this project.

We chose Visual Studio Enterprise as well as Visual Studio Code to develop our Python codebase via the Azure DevOps Repository. Installing Python and viewing Jupyter Notebooks is much easier in VS Enterprise as its fairly easy to keep the Python packages updated in the Python environment. But running the Jupyter Notebooks with our Python code was found to be possible in VS Code. This link shows how to use your IDE to submit jobs to Azure Quantum. If you prefer to run Jupyter Notebooks directly in your Azure Quantum Workspace, here is how to do so.

We installed Python with all necessary modules in Visual Studio Enterprise on our dev machines to develop Python based Jupyter Notebooks for the Quantum Fourier Transform algorithm to apply to ECG records to detect anomalies. These included WFDB, Numpy, Matplotlib, Scipy and Azure Quantum with the IonQ provider.

To visualize a Quantum Fourier Transform Circuit in action, you can use an online simulator such as this one.

We also precalculated the gate-shot estimates using Excel to ensure we were using the right qubit count, gate count in our quantum circuit to get the right resolution which fit in our budgeted Azure Quantum Credits. Below is an example of how we approached this, before the Azure Quantum Resource Estimator became available.

We then proceeded to try out our Jupyter Notebook using the Pivotport Azure Quantum Workspace connection declared within it, integrated with the Azure Active Directory user ID and MFA to conduct secure execution via the IonQ provider on the IonQ Simulator as well as IonQ Harmony and Aria platforms. This took several months of debugging and we finally succeeded in tachycardia and ventricular ectopy records being executed on IonQ simulator, as described in this blog.

We have successfully demonstrated our code detects ECG anomalies in a single standardized Quantum Cardiac Spectrogram of an ECG of any given record length, provided we have sufficient Azure Quantum Credits or subscription allocation to support the required IonQ gate-shot estimates.

We are currently working towards executing single records on IonQ Harmony, Aria, Quantinuum Simulator and H1, H2 and Rigetti M1, M2, M3 platforms to demonstrate comparability between results using the same resolution and circuit depths and gate-shot counts.

We are looking for further support in our research on Quantum Cardiac Spectrograms using QFT algorithm driven Quantum Computing tied to a hybrid Azure IoT solution for ECG monitoring as a real life hybrid cloud-quantum service that we intend to bring to market as a global cardiac anomaly detection and identification solution.

We thank Microsoft for having provided support for our egalitarian project through over $50000 in Azure Quantum Credits for our work, and hope to do more during next year with this support!

Happy Holidays to all! This blog is one of the entries for 12/22/2022 on https://devblogs.microsoft.com/qsharp/q-holiday-calendar-2022/

PS:

Please consider donating to our research through visiting this link. It will help us tremendously as we have been running in bootstrap mode and are in need of funding support!

The Pivotport Quantum Engineering Team:

Jonathan Ortega: Quantum Development Intern

Rajiv Mistry: CEO, Pivotport, Inc.