96 lines (95 with data), 2.9 kB
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Exercise 1: Plotting\n",
"\n",
"You have (hypothetically) built an algorithm that processes ECG data and detects R waves which correspond to ventricular contractions (you will actually build this algorithm in Lesson 4). The R waves have characteristically tall sharp peaks as shown below.\n",
"\n",
"\n",
"\n",
"Now you must validate the algorithm that you have built against a labeled reference dataset. You think about using the [European ST-T Database](https://physionet.org/content/edb/1.0.0/). This dataset contains ECG data along with annotations that mark the R wave peaks.\n",
"\n",
"As you are exploring the dataset you wonder how accurate its R wave annotations are. Ideally they should mark the apex of the R wave as shown in the Figure. You decide to plot the annotations on top of the ECG signal to qualitatively explore their accuracy.\n",
"\n",
"Find the exported part of this dataset in `folder`. The `.npz` file contains two numpy arrays. The array ecg is the raw ECG signal sampled at 250 Hz. The array annotations is the sample locations of the R peaks. Your task is to plot the R peaks on top of the ECG trace. The x-axis should be time in seconds. You should end up with something like the solution image.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Imports"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"from matplotlib import pyplot as plt"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Load Data\n",
"\n",
"Load the ECG snippet and annotations from the Europtean ST-T Database"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"npz = np.load(\"./exercise1.npz\")\n",
"ecg, annotations = npz['ecg'], npz['annotations']"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Visualize!\n",
"Plot the annotations markers on top of the ECG signal to see how accurate they are"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"## Your Code Goes Here"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}