DSA_SS24/notebooks/features_detection.ipynb

741 lines
1.1 MiB
Plaintext
Raw Normal View History

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
2024-06-11 19:04:23 +02:00
"# Feature Detection\n",
"\n",
2024-06-11 19:04:23 +02:00
"This Notebook is used to test the detection ability of the NeuroKit2 library to detect features in the ECG dataset. Those features than are important to train the model to detect the different diagnostic groups. The features are generated using the NeuroKit2 library."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"from matplotlib import pyplot as plt\n",
"import wfdb.processing\n",
"import sys\n",
"import json\n",
"import scipy\n",
"import numpy as np\n",
"import neurokit2 as nk\n",
"import math\n",
"\n",
"sys.path.append('../scripts')\n",
"import data_helper\n",
"\n",
"# possible liberays to use:\n",
"# https://neuropsychology.github.io/NeuroKit/examples/ecg_delineate/ecg_delineate.html\n",
"# https://biosppy.readthedocs.io/en/stable/\n",
"# https://python-heart-rate-analysis-toolkit.readthedocs.io/en/latest/\n",
"# https://pywavelets.readthedocs.io/en/latest/"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Load Data"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Reading GSVT\n",
2024-06-11 19:04:23 +02:00
"Reading AFIB\n",
"Reading SR\n",
2024-06-11 19:04:23 +02:00
"Reading SB\n",
"Number of patients per category:\n",
2024-06-11 19:04:23 +02:00
"GSVT: 1027\n",
"AFIB: 9787\n",
"SR: 10426\n",
"SB: 15826\n"
]
}
],
"source": [
"data_org = data_helper.load_data(only_demographic=False)\n",
"\n",
"print(\"Number of patients per category:\")\n",
"for cat_name in data_org.keys():\n",
" print(f\"{cat_name}: {len(data_org[cat_name])}\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2024-06-11 19:04:23 +02:00
"# Noise Reduction\n",
"Load the parameters needed to filter the data"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"with open('../filter_params.json', 'r') as f:\n",
" filter_params = json.load(f)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"example_data = data_org['SB'][0]\n",
"sig_channel= 0"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"filtered_data = data_helper.filter_data(example_data, filter_params)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd5QUVdrGn6ruiUyAgQnEGXKGkSgoYABRDCuKuq6fIrro6mJYdFXWFUVFMCCIq6goooiKuqZVJEgOIznnNMwAExkmhw51vz+qq7qqw0xXVw0deH/neKSrq6tv37l16z73TRxjjIEgCIIgCIIgCIIwBD7QDSAIgiAIgiAIgggnSGQRBEEQBEEQBEEYCIksgiAIgiAIgiAIAyGRRRAEQRAEQRAEYSAksgiCIAiCIAiCIAyERBZBEARBEARBEISBkMgiCIIgCIIgCIIwEBJZBEEQBEEQBEEQBkIiiyAIgiAIgiAIwkBIZBEEccmRkZGB+++/P9DNAABkZ2eD4zgsXLiwUa5///33IyMjw+dz4+LiGqUdRrJ27VpwHIe1a9c2yvWvuuoqXHXVVT6f26tXr0ZpRyBZuHAhOI5Ddna2fExLv4QK/t5/4dgXBEEYC4ksgiDChn379mHcuHFIT09HdHQ0WrdujVGjRuHdd98NdNOChurqarz00kuNJlDCkXPnzuGll17C7t27A90UFUuXLsVLL73k12cHDRoEjuMwb948YxsFcROD4zhwHAee59G0aVP07t0bDz30ELZs2WL49xEEQQQj5kA3gCAIwgg2b96Mq6++Gu3atcPEiRORlpaG3Nxc/PH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Z2G+//cYYY2znzp0MAPvpp59U7RsxYoT8etu2bV7/Rlp/yxdffCEfs1gsbMiQISwuLo6Vl5czxhhbs2aNx9/maZz8/e9/Z1of45MmTWJt27ZlgiAwxsT7BoBq7DPG2Keffuo29l37xRvp6ensxhtv9Pr+7NmzVX2+YcMGBoAtXrxYdd6yZcvcjvt6/z355JMMANuwYYN8rKKigrVv355lZGTI96Zrv164cIEBYG+++Wa9v9G1L6S/W/fu3VldXZ18/J133mEA2L59+xhj4tho3rw5GzhwILNarfJ5CxcuZAB86l+CIEIDsmQRBBEWjBo1CllZWbjllluwZ88evPHGGxg9ejRat26tchnzxLJlyzBkyBBVUoOkpCS3HWiJHj16qKxFycnJ6Nq1K06ePCkfi4qKkpNr2O12nD9/HnFxcejatSt27typ+fcNGzYMBQUFOHLkCADRKjN8+HAMGzYMGzZsACBatxhjXi1ZvvK3v/3N7buVv80bMTEx8r8rKipQXFyMYcOGobq6GocPH1adGxcXp4rZiYyMxKBBg1Tfs3TpUrRs2RLjxo2Tj8XGxuKhhx7y6XcMGzYMO3fuRFVVFQCxf8aMGYPMzEy5zzZs2ACO43DllVf6dE1P+Ppb0tLScPfdd8vHIiIi8Pjjj6OyshLr1q3z+/t9xWazYcmSJbjrrrtk18JrrrkGKSkpF92aBYhjBAC+/fZbJCYmYtSoUSguLpb/69+/P+Li4rBmzRrV5325/5YuXYpBgwap/q5xcXF46KGHkJ2drbKiKYmJiUFkZCTWrl3r5qroCxMmTFDFa0ntlNq2fft2nD9/HhMnToTZ7AyLv+eee9CsWTPN30cQRPBCIosgiLBh4MCB+P7773HhwgVs3boVU6ZMQUVFBcaNG+d1UQUAp0+fRqdOndyOezoGAO3atXM71qxZM9WiTBAEOcA/KioKLVq0QHJyMvbu3YuysjLNv01arG3YsAFVVVXYtWsXhg0bhuHDh6sEQ0JCAvr
"text/plain": [
"<Figure size 1000x500 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"#data = filtered_data.p_signal[:,sig_channel]\n",
"ecg_signal = data_org['SB'][0].p_signal[:,sig_channel]\n",
"ecg_signal = filtered_data.p_signal[:,sig_channel]\n",
"\n",
"sampling_rate = 500 # Sampling rate of your ECG data\n",
"\n",
"\n",
"ecg_cleaned = nk.ecg_clean(ecg_signal, sampling_rate=sampling_rate)\n",
"\n",
"# Plot the original and denoised signal\n",
"plt.figure(figsize=(10, 5))\n",
"plt.plot(example_data.p_signal[:,0], label='Original signal')\n",
"plt.plot(ecg_cleaned, label='bib filtered signal')\n",
"#plt.plot(filtered_data.p_signal[:,0], label='self filtered signal')\n",
"plt.xlabel('Time')\n",
"plt.ylabel('Amplitude')\n",
"plt.title('Signal with and without All Denoising')\n",
"plt.legend()\n",
"plt.grid(True)\n",
"plt.show()\n"
]
},
2024-06-11 19:04:23 +02:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Detect Peaks"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[477, 1050, 1617, 2216, 2750, 3386, 3890, 4482]\n",
"[439, 1019, 1590, 2186, 2727, 3356, 3876, 4458]\n",
"[512, 1075, 1647, 2248, 2757, 3421, 3915, 4496]\n"
]
}
],
"source": [
"# Extract R-peaks\n",
"_, rpeaks = nk.ecg_peaks(ecg_cleaned, sampling_rate=sampling_rate)\n",
"\n",
"# Extract all ECG features\n",
"ecg_signals, info = nk.ecg_delineate(ecg_cleaned, rpeaks, sampling_rate=sampling_rate, method=\"dwt\")\n",
"\n",
"# Normalize data by setting qrs peaks to index position 0 (“X-axis normalization”)\n",
"p_peaks = info['ECG_P_Peaks']\n",
"p_onsets = info['ECG_P_Onsets']\n",
"p_offsets = info['ECG_P_Offsets']\n",
"print(p_peaks)\n",
"print(p_onsets)\n",
"print(p_offsets)\n",
"\n",
"p_peaks_y = [ecg_cleaned[i] for i in p_peaks] \n",
"p_onsets_y = [ecg_cleaned[i] for i in p_onsets]\n",
2024-06-11 19:04:23 +02:00
"p_offsets_y = [ecg_cleaned[i] for i in p_offsets]"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAsgAAAHgCAYAAAC4vJuwAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd3yN1xvAv/dm702ISJDYIXbNxAw1a9VeVWq1ihZtUataqxRFtWajdukPpaiovWrvvQkRIfOu8/vj5r7uzb2JhAz0/X4+l7znPeM5513P+7zPeY5CCCGQkZGRkZGRkZGRkQFAmdcCyMjIyMjIyMjIyLxOyAqyjIyMjIyMjIyMjBGygiwjIyMjIyMjIyNjhKwgy8jIyMjIyMjIyBghK8gyMjIyMjIyMjIyRsgKsoyMjIyMjIyMjIwRsoIsIyMjIyMjIyMjY4SsIMvIyMjIyMjIyMgYISvIMjIyMjIyMjIyMkbICrLMf56oqCgUCgUKhYIePXrktThvLdevX5fGOTw8XEr/+uuvpfTFixfnmXyvM0IIQkJCUCgUfPjhh3ktToYkJCTg4eGBQqFgypQpeS2OjIyMzEshK8gybyXGSpeln7u7e57K9vXXXzNjxow8k0HmzWLlypWcPn0agMGDB0vpixcvzvA8VygUPHnyxKy+w4cP07NnT4oVK4aDgwOenp5UqFCBzz//nHPnzpnlf/DgAaNHj6Zq1ap4eHhgZ2dH4cKFqVGjBqNGjeLEiRNSXicnJ0mJnzJlCvHx8dk7GDIyMjK5gHVeCyAj819j7NixAAQEBJgoO/9VevXqRYMGDQAoXrx4HkvzejJ16lQA3nnnHcqUKfNKdY0YMYLvvvvOJC05OZnY2FiOHz/OxYsXWb9+vbRv48aNdO7cmadPn5qUuXXrFrdu3WL//v38+eefHDlyRNrXu3dvpkyZwsOHD1m8eDEDBw58JZllZGRkchtZQZZ562nSpAlffPGFSZq19Z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v4HnLycKhYJz587x2WefAXD58uUXjoVhHDw8PF6YNyOMFdiCBQtmKb+rqysKhULa/uqrr1i7dq1J/p07d5oo5MbyGvogIyMj86YgK8gybz2WJunlz58/wzKXL19GCAHorbK1a9e2mM9g3bt48aKUZlDOXpXGjRubWQyN2zG26Hl7e1O0aFHOnTuHEEJSvHQ6HQBFixaVlOO0aLVaGjRowLFjx9KVxVKoMIDmzZubpV29elX6u0qVKtLfVatWTbf+tKTXT0M9hklrhnzGbRrnr169+gvbsnS81q1bl+GEOLA8JiVKlJAss56enlJ6pUqVJAXT29s7wzrSw3A+poelSXpubm4W/86MNd84f3R0NGq1Ghsbm8yK+0J5ZWRkZF5nZAVZ5q0nX758GVpqXwXDJ/6c4EVKfFqMLXxZYe/evZJyXKBAAb799luKFCnCnTt36NixI/Bc0X4VGV9WvqzWk9V2LPVh9uzZ0t89evSgU6dOODg4MG7cOLZt2wZYHhNjpVKpfO7Blp47Q2aUSG9vb27dukVsbGyG+dzc3DI8z8uXLy/9ffLkSZ49e2YS4SKj/FqtloMHD0r1G1yC3nnnHQ4ePGixvLG8xi8FMjIyMm8Csg+yjIwFgoKCJEWrWLFiaDQahH5Sq/RTqVSMGzcOMI3fu2nTpgzrNtSbntKZNp8xxu0cOnRI+jsmJoYrV65I5YKCgggKCpKUtKtXr3L+/HmL7dy5c0f6u1OnTnTr1i1di3lmZCxatKj0t7FrRnqKlCXS62fabUO+YsWKSWmHDx+W/t6/f/8L27LUB+MxmTVrFg0bNqRGjRom6bmFwfJ/48YNNBrNS9fTtGlTnJ2dAb37xIQJEyzmM3wV8ff3N7HAjxgxQvIJzwzG7iOlS5d+GZF
"text/plain": [
"<Figure size 640x480 with 3 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Process it\n",
"signals, info = nk.ecg_process(ecg_cleaned, sampling_rate=500)\n",
"\n",
"# Visualise the processing\n",
"nk.ecg_plot(signals, info)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[693, 1262, 1835, 2435, 3005, 3603, 4165, 4758]\n",
"[636, 1234, 1786, 2388, 2947, 3546, 4122, 4698]\n",
"[737, 1307, 1881, 2476, 3049, 3651, 4214, 4799]\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd5gUVdb/v9VpenJgMjMwBMlRkgojQRDERREx4LsroKKui8Cy+rr8dMG4sibAvOiruKwZMSNRQFQEJUjOYZhhIpNjp/r9UV3VVd3VM11d1XTgfJ6Hh+nq6qrbt29V3XPPOd/DsCzLgiAIgiAIgiAIgtAEXbAbQBAEQRAEQRAEEUmQkUUQBEEQBEEQBKEhZGQRBEEQBEEQBEFoCBlZBEEQBEEQBEEQGkJGFkEQBEEQBEEQhIaQkUUQBEEQBEEQBKEhZGQRBEEQBEEQBEFoCBlZBEEQBEEQBEEQGkJGFkEQBEEQBEEQhIaQkUUQBKGSM2fOgGEYrFixQtj2+OOPg2GY4DVKIeHW3ovNihUrwDAMzpw5E+ymAABmzJiBvLy8gBxbbjy3te8LL7wQkLYECn68V1RUBLspBEFEKGRkEQRBtAE/wZb79/e//93n4/zzn//EF198EbiGBpjm5mZ07doVPXr0gMVi8Xj/uuuuQ2JiIs6fPy/ZXlBQgPvvvx95eXmIiopCeno6brrpJvz8888ex9iyZYukf/V6PdLT0zF16lQcPnxYtl1ff/01Ro4cifT0dMTExKBz58649dZbsXbt2ja/k8ViwbJlyzBw4EAkJCQgKSkJvXv3xr333osjR4742DORz5o1a/D4449rflz339toNKJz58648847cerUKc3PRxAEcbEwBLsBBEEQ4cKTTz6JTp06Sbb16dMHHTt2RFNTE4xGY6uf/+c//4m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gLgM3NzWXr6uo89klKSmL79+/f6nHmzJnDAmD37dsn+Y7vvPMOW15ezp4/f55du3Yt27VrV5ZhGHbnzp2Szy9cuJAFwMbGxrLXXXcd+8wzz7C7du3y+TuMHDmSBcBmZGSw06ZNY1977TVJ3/DwY+D06dMsy7JsSUkJazAY2MmTJ0v2e/zxx1kAkt+Z/+zYsWMlv89f//pXVq/Xs9XV1cI28e/Kc99997ExMTFsc3OzsG369Olsx44dW/1+ZWVlLAD29ddfZ1mWZaurq1mdTsfecsstbEZGhrDfnDlz2JSUFKFtcuP5L3/5i+z44Pdt164dW1lZKWz/8ssvWQDs119/3Wob5X7vb7/9ls3Ly2MZhmF//fVXtq6ujk1KSmJnzZol+WxJSQmbmJgo2S7Xfx9++CELgP3hhx+Ebfz1WV5ezh4+fJjNzs5mhwwZIvkOe/bsYQGwn376aavfgSAIQg4KFyQIgvCR1157DRs2bJD8UwvLsvjss88wadIksCyLiooK4d/48eNRU1OD3bt3Sz4zffp0REdHC6/37t2L48eP44477sCFCxeEzzc0NOCaa67BDz/8AIfDAbvdjnXr1mHy5Mno0KGD8PmePXti/PjxitrNMIzgObryyisRFxfnsU9dXR3i4+NbPQ7/fl1dnWT7XXfdhbS0NGRnZ2PChAmoqanBypUrMWTIEMl+TzzxBD744AMMHDgQ69atw6OPPopBgwbh8ssv96pGKP4O69atw9NPP43k5GR8+OGH+Mtf/oKOHTvitttuk+RkubNp0ybYbDZJDhrAeau8ce+990o8Kfn5+bDb7Th79qywTfy71tXVoaKiAvn5+WhsbFSsdpiWloYePXrghx9+AMCJkOj1ejz88MMoLS3F8ePHAXCerBEjRqiS8L/tttskXkY+vNNXhUD
"text/plain": [
"<Figure size 1000x500 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"t_peaks = info['ECG_T_Peaks']\n",
"t_onsets = info['ECG_T_Onsets']\n",
"t_offsets = info['ECG_T_Offsets']\n",
"\n",
"print(t_peaks)\n",
"print(t_onsets)\n",
"print(t_offsets)\n",
"\n",
"t_peaks_y = [ecg_cleaned[i] for i in t_peaks] \n",
"t_onsets_y = [ecg_cleaned[i] for i in t_onsets]\n",
"t_offsets_y = [ecg_cleaned[i] for i in t_offsets]\n",
"\n",
"plt.figure(figsize=(10, 5))\n",
"plt.plot(ecg_cleaned)\n",
"plt.scatter(t_peaks, t_peaks_y, color='red', label='t_peaks')\n",
"plt.scatter(t_onsets, t_onsets_y, color='green', label='t_onsets')\n",
"plt.scatter(t_offsets, t_offsets_y, color='blue', label='t_offsets')\n",
"plt.xlabel('Time')\n",
"plt.ylabel('Amplitude')\n",
"plt.title('Filtered XQRS Signal with Peaks')\n",
"plt.legend()\n",
"plt.grid(True)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[477, 1050, 1617, 2217, 2788, 3386, 3890, 4543]\n",
"[438, 1018, 1589, 2184, 2763, 3355, 3876, 4511]\n",
"[514, 1076, 1648, 2248, 2820, 3421, 3914, 4574]\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd5wU9f3/X7PleucqdwdHLwrSpCgHiEgzKCJR8ZsIGNGoKIZEDT8LYu9ClGiMscTYCbHRpejRey/SD673frdl5vfH7MzO7M7e7ezMcrvL+/l48OB2dnbms+/9zMzn3RmO4zgQBEEQBEEQBEEQumBo7wEQBEEQBEEQBEGEEqRkEQRBEARBEARB6AgpWQRBEARBEARBEDpCShZBEARBEARBEISOkJJFEARBEARBEAShI6RkEQRBEARBEARB6AgpWQRBEARBEARBEDpCShZBEARBEARBEISOkJJFEARBEARBEAShI6RkEQRBaOTcuXNgGAYff/yx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OHAg1qxZgyeeeAKDBw/GoEGDPFYjlH6HNWvW4Pnnn0diYiK++OILPPjgg+jcuTNuv/12WU6WK+vXr4fNZpPloAG8t8oT9957r8yTkpubC7vdjvPnz4vbpL9rXV0dysvLkZubi8bGRtXVDlNSUtC7d2/88ssvAPgiJEajEY8++ihKSkpw8uRJALwna+TIkZpK+N9+++0yL6MQ3ulthUD
"text/plain": [
"<Figure size 1000x500 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"p_peaks = info['ECG_P_Peaks']\n",
"p_onsets = info['ECG_P_Onsets']\n",
"p_offsets = info['ECG_P_Offsets']\n",
"print(p_peaks)\n",
"print(p_onsets)\n",
"print(p_offsets)\n",
"\n",
"p_peaks_y = [ecg_cleaned[i] for i in p_peaks] \n",
"p_onsets_y = [ecg_cleaned[i] for i in p_onsets]\n",
"p_offsets_y = [ecg_cleaned[i] for i in p_offsets]\n",
"\n",
"plt.figure(figsize=(10, 5))\n",
"plt.plot(ecg_cleaned)\n",
"plt.scatter(p_peaks, p_peaks_y, color='red', label='p_peaks')\n",
"plt.scatter(p_onsets, p_onsets_y, color='green', label='p_onsets')\n",
"plt.scatter(p_offsets, p_offsets_y, color='blue', label='p_offsets')\n",
"plt.xlabel('Time')\n",
"plt.ylabel('Amplitude')\n",
"plt.title('Filtered XQRS Signal with Peaks')\n",
"plt.legend()\n",
"plt.grid(True)\n",
"plt.show()\n"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[523, 1086, 1658, 2256, 2830, 3430, 3990]\n",
"[563, 1132, 1701, 2300, 2873, 3471, 4034]\n",
"[482, 1055, 1622, 2221, 2794, 3391, 3957]\n",
"[580, 1151, 1720, 2317, 2893, 3491, 4055]\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIH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omgB0t97//79WLx4MVasWIEjR45I5hNBEESwQEoWQRCEl4waNQr9+vVz+55er7/Go+Goq6tDeHg4NJprE5gwbNgwPPTQQ5gzZw4mTJiATp06oby8HC+88AJuvPFGPPfcc8K+ZWVlGDduHCIjI7F9+3Z06NBBeG/69OkYMWIEnn/+efTu3Rs33XST5DxZWVkYN26c8Lpz58549tln8e9//xt///vfAQAWiwWvv/46hg0bhrVr17qM9cqVKw1+lz179uC3337Dm2++if/3//6f5L2PP/4Y5eXlwmutVgutVtu4gEIAhmGu+XwW/96TJk1Cp06dMGXKFCxduhQzZsy4pmMhCIJQAwoXJAiCUIg3OSwMw6C6uhpLly4VQqMeffRR4f28vDw89thjaNmyJSIiItC9e3d8+eWXkmPwoVXfffcd/vGPf6B169aIioqC0WgEAOzatQsjR45EXFwcoqKiMHjwYGzfvt1lLNu2bcONN94IvV6PDh064LPPPpP1fT/44ANERUXhmWeeAQC8/PLLKC4uxmeffSZR9j777DMUFhbinXfekShYABAZGYmlS5cC4DyEjZGVlQUAOHfunLCtpKQERqMRt956q9vPpKSkNHhM/ljuPq/VatGiRQvhtbucLJvNhlmzZqFVq1aIiorCbbfdhuPHjyMzM1Py2/Kf3b59O6ZPn47k5GRER0fj3nvvRXFxseS8v/zyC+688060atUKERER6NChA15//XVYrdYGv4s7pk+fjhYtWoBlWWHb888/D4Zh8OGHHwrbioqKwDAMPv30UwCu8/nRRx/FwoULAUAS2ufM4sWL0aFDB0RERODGG2/Enj17ZI+Z5/bbbwcA5OTkCNtWrVqFrKwsREdHIzY2FnfeeSeOHTsm+dzhw4fx6KOPon379tDr9UhNTcVjjz2Gq1evNnrOixcvomPHjrj++utRVFQEADhz5gzuu+8+pKamQq/XIz09HQ8++CAqKip8/m4EQTQPyJNFEAThJRUVFS6J8klJSV59dtmyZXjiiSfQv39/PPXUUwAgKB5FRUW46aabwDAMJk+ejOTkZKxatQqPP/44jEYjpk2bJjnW66+/jvDwcPztb39DfX09wsPDsXHjRowaNQp9+/bFz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y1bthT2mzJlCpuYmCiMzd18/stf/uJ2fvD7tmjRgi0tLRW2//LLLywA9tdff21wjO5+7xUrVrCZmZkswzDsnj172MrKSjY+Pp598sknJZ8tLCxk4+LiJNvdye/bb79lAbBbtmwRtvHXZ3FxMXvixAm2VatW7I033ij5DgcOHGABsD/++GOD34EgCMIdFC5IEAThJQsXLsS6desk/ymFZVn897//xV133QWWZVFSUiL8N2LECFRUVGD//v2Sz0ycOBGRkZHC64MHD+LMmTN46KGHcPXqVeHz1dXVuOOOO7BlyxbYbDZYrVasWbMGY8aMQZs2bYTPd+3aFSNGjJA1boZhBM/RzTffjJiYGJd9KisrERsb2+Bx+PcrKysl2x977DEkJyejVatWGDlyJCoqKrBs2TLceOONkv1mz56Nb775Br1798aaNWvwyiuvoG/fvujTp4/HaoTi77BmzRq88cYbSEhIwLfffou//OUvaNu2LR544AFJTpYzGzZsgMVikeSgAZy3yhNPPfWUxJOSlZUFq9WKixcvCtvEv2tlZSVKSkqQlZWFmpoa2dUOk5OT0aVLF2zZsgUAV4REq9XixRdfRFFREc6cOQOA82QNHDhQUQn/Bx54QOJl5MM7va0QKP6977zzTiG
"text/plain": [
"<Figure size 1000x500 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# 'ECG_Q_Peaks', 'ECG_R_Onsets', 'ECG_R_Offsets', 'ECG_S_Peaks'\n",
"\n",
"\n",
"q_peaks = info['ECG_Q_Peaks'][:-1]\n",
"s_peaks = info['ECG_S_Peaks'][:-1]\n",
"r_onsets = info['ECG_R_Onsets'][:-1]\n",
"r_offsets = info['ECG_R_Offsets'][:-1]\n",
"\n",
"print(q_peaks)\n",
"print(s_peaks)\n",
"print(r_onsets)\n",
"print(r_offsets)\n",
"\n",
"q_peaks_y = [ecg_cleaned[i] for i in q_peaks] \n",
"s_peaks_y = [ecg_cleaned[i] for i in s_peaks]\n",
"r_onsets_y = [ecg_cleaned[i] for i in r_onsets]\n",
"r_offsets_y = [ecg_cleaned[i] for i in r_offsets]\n",
"\n",
"plt.figure(figsize=(10, 5))\n",
"plt.plot(ecg_cleaned)\n",
"plt.scatter(q_peaks, q_peaks_y, color='red', label='q_peaks')\n",
"plt.scatter(s_peaks, s_peaks_y, color='green', label='s_peaks')\n",
"plt.scatter(r_onsets, r_onsets_y, color='blue', label='r_onsets')\n",
"plt.scatter(r_offsets, r_offsets_y, color='purple', label='r_offsets')\n",
"plt.xlabel('Time')\n",
"plt.ylabel('Amplitude')\n",
"plt.title('Filtered XQRS Signal with Peaks')\n",
"plt.legend()\n",
"plt.grid(True)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAi8AAAGdCAYAAADaPpOnAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAADLdklEQVR4nOy9d5xddZ3//zzt9j41vTdACFIiuyplg0SkCBL5AgLCLu4uX2QVLMsuYlm/oohZ/O2qKIi7q4SoKIoooICsAqEnNEMIkGRSppfb2ym/P24+J/fO3JnMJDNJZvg8H4/zgJx2P+fMKa/zrorjOA4SiUQikUgkkwT1UA9AIpFIJBKJZCxI8SKRSCQSiWRSIcWLRCKRSCSSSYUULxKJRCKRSCYVUrxIJBKJRCKZVEjxIpFIJBKJZFIhxYtEIpFIJJJJhRQvEolEIpFIJhX6oR7AeGPbNrt37yYcDqMoyqEejkQikUgkklHgOA7pdJrp06ejqiPbVqaceNm9ezezZs061MOQSCQSiUSyH+zYsYOZM2eOuM6UEy/hcBioHHwkEjnEo5FIJBKJRDIaUqkUs2bNct/jIzHlxItwFUUiESleJBKJRCKZZIwm5EMG7EokEolEIplUSPEikUgkEolkUiHFi0QikUgkkknFlIt5kUgkEsnE4zgOpmliWdahHopkEmEYBpqmHfB+pHiRSCQSyZgolU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jRIlavXo1t26xfv55I5NC2NJg+fTp
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Delineate the ECG signal and visualizing all peaks of ECG complexes\n",
"_, waves_peak = nk.ecg_delineate(ecg_signal, \n",
" rpeaks, \n",
" sampling_rate=500, \n",
" method=\"peak\", \n",
" show=True, \n",
" show_type='peaks')"
]
},
{
"cell_type": "code",
2024-06-11 19:04:23 +02:00
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAi8AAAGdCAYAAADaPpOnAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAACVNUlEQVR4nO29eZhk9V3v/z5r7WuvszIM20AwgIyMRDExzg2TxCWahXC5WUYk5irGOOhPUC9kUSdGwsM15opicmM0CJprNE+MkxsnyY3ICAGCSdjCNhszvda+nf33R/P5zreqq7qrl+ruqvm8nqcfmKpT1ae6zvec9/ks748SBEEAhmEYhmGYPkFd7x1gGIZhGIZZCixeGIZhGIbpK1i8MAzDMAzTV7B4YRiGYRimr2DxwjAMwzBMX8HihWEYhmGYvoLFC8MwDMMwfQWLF4ZhGIZh+gp9vXdgtfF9H6dOnUIikYCiKOu9OwzDMAzDdEEQBCiXy9i8eTNUdeHYysCJl1OnTmHbtm3rvRsMwzAMwyyDEydOYOvWrQtuM3DiJZFIAJj78Mlkcp33hmEYhmGYbiiVSti2bZu4ji/EwIkXShUlk0kWLwzDMAzTZ3RT8sEFuwzDMAzD9BUsXhiGYRiG6StYvDAMwzAM01cMXM0LwzAMs7oEQQDXdeF53nrvCtPnGIYBTdNW/D4sXhiGYZiO2LaN06dPo1arrfeuMAOAoijYunUr4vH4it6HxQvDMAzTFt/38dJLL0HTNGzevBmmabL5J7NsgiDA9PQ0Tp48i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njhBbHtf/7nf+Kzn/1skzi79tprxZiITnzgAx/A7//+7+PHfuzHcMcdd+C73/1uTz6XTM/Fy1133YWbbroJ+/fvxyWXXIJ77rkH0WgUn/nMZzq+xvM83HDDDfjwhz+MnTt39noXGWagCYIAjuMAgLB457QRs1oEQQDb9Zdd69KKpiqwXX9FAoOIxWI4//zzm36y2SwuvPBCAMAzzzyz4OsvuOACvPjii2L9AHMppfPPPx9btmxZ0r4kEgk88cQT+P73v49qtYpvfetbYj8W4sILL0SxWMSpU6fmPWfbNl544YV570M3KcCZ1Jbv+wCAD33oQ3jyySfx5je/GV//+tdxySWX4Itf/CIAoFKp4Jd/+ZebxN5//ud/4rnnnsN5553XcR9/6Zd+CS+++CLe9a534Xvf+x52796NT37yk4v/UVZAT8WLbdt47LHHsHfv3jO/UFWxd+9eHDlypOPrPvKRj2B0dBQ33njjor/DsiyUSqWmH4ZhzuA4DoIggKZp4qRGJzKGWSmKosDUVXj+ysUGAHh+AFNfeQpqId7whjdgeHgYH//4x9s+XygUAADXX389KpUK/tf/+l8r/p2qquL888/Hzp07EYlEun7dW9/6VhiGgU984hPznrvnnntQrVZx/fXXL2lfLrzwQvzGb/wG/u///b/4hV/4Bfzv//2/AQA//MM/jKeeemqe4Dv//PNhmnMOyKZptr352bZtG97//vfjH/7hH3DLLbfg3nvvXdI+LZWeOuzOzMzA8zyMjY01PT42NtZR8T744IP49Kc/jSeeeKKr33Hw4EF8+MMfXumuMszAQneNhmGIQWgsXpjVZFs2gkePrk4dVdXy8KrNqVV5L8uyMDHR3Hqt6zqGh4fxl3/5l3j729+On/3Zn8UHPvABnH/++ZiZmcHf/d3f4fjx47j//vtx9dVX45ZbbsEtt9yCY8eO4Rd+4Rewbds2nD59Gp/+9KeFb0sv2b59Oz7+8Y/jlltuQTgcxrve9S4YhoF/+qd/wu/8zu/glltuwZ49e7p6r3q9jt/6rd/C2972Npx77rk4efIkvv3tb+Otb30rgLm28B/90R/
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Delineate the ECG signal and visualizing all P-peaks boundaries\n",
"signal_peak, waves_peak = nk.ecg_delineate(ecg_signal, \n",
" rpeaks, \n",
" sampling_rate=500,\n",
" method=\"peak\", \n",
" show=True, \n",
" show_type='bounds_P')"
]
},
{
"cell_type": "code",
2024-06-11 19:04:23 +02:00
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAi8AAAGdCAYAAADaPpOnAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAACVIUlEQVR4nO29ebhkdX3n/z5r7etde28aGlpAAWnptOMW7YH+aTQkQYEwETs8mDwO0UxrJpJMRGNm2hhCUGOCMTpOEhVcQmLUdKKtTMbQEQFJBKFF6KbXu9a+nTrb74/L53u/Vbfq3rpL3Xur+vN6nvvQVJ2qOlVne5/P8v4ovu/7YBiGYRiG6RHUtV4BhmEYhmGYxcDihWEYhmGYnoLFC8MwDMMwPQWLF4ZhGIZhegoWLwzDMAzD9BQsXhiGYRiG6SlYvDAMwzAM01OweGEYhmEYpqfQ13oFVhrP83D27FnEYjEoirLWq8MwDMMwTAf4vo9isYiNGzdCVeePrfSdeDl79iy2bNmy1qvBMAzDMMwSOHXqFDZv3jzvMn0nXmKxGICZLx+Px9d4bRiGYRiG6YRCoYAtW7aI6/h89J14oVRRPB5n8cIwDMMwPUYnJR9csMswDMMwTE/B4oVhGIZhmJ6CxQvDMAzDMD1F39W8MAzDMCuH67qwbXutV4PpEwzDgKZpy34fFi8MwzBMS0qlEk6fPg3f99d6VZg+QVEUbN68GdFodFnvw+KFYRiGmYPrujh9+jTC4TCGhobY9JNZNr7vY3JyEqdPn8bOnTuXFYFh8cIwDMPMwbZt+L6PoaEhhEKhZb+f7/ssgBgMD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
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Delineate the ECG signal and visualizing all T-peaks boundaries\n",
"signal_peaj, waves_peak = nk.ecg_delineate(ecg_signal, \n",
" rpeaks, \n",
" sampling_rate=500, \n",
" method=\"peak\", \n",
" show=True, \n",
" show_type='bounds_T')"
]
},
{
"cell_type": "code",
2024-06-11 19:04:23 +02:00
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAi8AAAGdCAYAAADaPpOnAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdeXxU1fn48c+dfTKTPSEJkhBiEhJRDIIiCAo0YkAEt0CRioBiES1fJRSLVVxKtSLi1qoICq1sWoGfFFkUFBUBAU1wC4sIBDBkgWSyTDLbvb8/xhkzWSckAQbP+/W6L+Fuc2aIuc885znnSIqiKAiCIAiCIAQI1blugCAIgiAIQmuI4EUQBEEQhIAighdBEARBEAKKCF4EQRAEQQgoIngRBEEQBCGgiOBFEARBEISAIoIXQRAEQRACigheBEEQBEEIKJpz3YD2JssyP//8M8HBwUiSdK6bIwiCIAiCHxRFobKyks6dO6NSNZ9bueCCl59//pn4+Phz3QxBEARBEM7AsWPH6NKlS7PnXHDBS3BwMOB+8yEhIee4NYIgCIIg+KOiooL4+Hjvc7w5F1zw4ukqCgkJEcGLIAiCIAQYf0o+RMGuIAiCIAgBRQQvgiAIgiAEFBG8CIIgCIIQUC64mhd/KIqC0+nE5XKd66YIFxCtVotarT7XzRAEQbjg/eaCF7vdTmFhIVar9Vw3RbjASJJEly5dMJvN57opgiAIF7TfVPAiyzKHDx9GrVbTuXNndDqdmMhOaBeKolBSUsLx48dJSUkRGRhBEIQO9JsKXux2O7IsEx8fT1BQULvcU1EUEQAJAERHR3PkyBEcDocIXgRBEDrQbyp48Whp2uHmFFfU8v3PFRw9Xc2x0zXYnTI6jYr4CCNdI0z06BxCpxBDO7Z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Br15YsywA88cQTfP/999x44418/PHHXHLJJaxZswaAqqoq/vjHP/oEe3v37uXgwYNcfPHFTbbxnnvu4aeffuLOO+/k22+/pU+fPrzyyistfyjnKUVRvP/mnmUxRLeRIAiBrEODF7vdzldffUVmZuavL6hSkZmZyY4dO5q87qmnnqJTp07cfffdLb6GzWajoqLCZ2srSZLQaVS45LYFGx4uWUGnaXsXVFOGDh1KVFQUc+fObfR4eXk5AGPHjqWqqopXX321za+pUqlITk4mKSkJo9Ho93W33XYbWq2W559/vsGx119/nerqasaOHduqtqSmpvLQQw/x4Ycfcuutt7J48WIArrjiCn744YcGAV9ycjI6nXv2Y51O1+iDPD4+nilTprB69WpycnJYuHBhq9p0PnE4HCiKglqt9gaCnuBPEAQhEHXoDLulpaW4XC5iYmJ89sfExDSZJdi2bRtvvvkmeXl5fr3GM888w5NPPtnWpjYQH2Fkz5H2qQuotrno0Tm0zfex2WycPOk77Fqj0RAVFcWiRYvIzs5m5MiRTJs2jeTkZEpLS3n33XcpKChg5cqV9OvXj5ycHHJycjh69Ci33nor8fHxFBYW8uabb3rnbelICQkJzJ07l5ycHAwGA3feeSdarZb333+fRx55hJycHPr27evXvWpqavjzn//M7bffTrdu3Th+/Di7d+/mtttuA9zDwq+++moeeOAB7rnnHkwmEz/88AMfffQR//znPwH3PC+fffYZv//979Hr9URFRfHggw8ybNgwUlNTKSsr45NPPiE9Pb3DPpOO5sm6aLVa74KRIngRBCGQnVejjSorK7nzzjtZuHAhUVFRfl0za9YsLBaLdzt27Fi7tKVrhAmHq+1dPYqi4JRlEiLavor1xo0biYuL89kGDBgAwKhRo9i+fTtarZY77riDtLQ0xo4di8ViYc6cOd57zJs
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Delineate the ECG signal\n",
"signal_cwt, waves_cwt = nk.ecg_delineate(ecg_signal, \n",
" rpeaks, \n",
" sampling_rate=500, \n",
" method=\"cwt\", \n",
" show=True, \n",
" show_type='all')"
]
},
{
"cell_type": "code",
2024-06-11 19:04:23 +02:00
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAi8AAAGdCAYAAADaPpOnAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAADK7UlEQVR4nOy9d5xddZ3//zzl9n6npkz6pBCEUCMu0jZIRARBIgsoCC6uyyKrYPniItafKGLE3VVREHdVAiqKIgooAVaBgJQEAUMSIMmkTC+3t1N+f9x8Tu6duTOZSWaSzPB5Ph73kclp93POPeV13lWxbdtGIpFIJBKJZJKgHuoBSCQSiUQikYwFKV4kEolEIpFMKqR4kUgkEolEMqmQ4kUikUgkEsmkQooXiUQikUgkkwopXiQSiUQikUwqpHiRSCQSiUQyqZDiRSKRSCQSyaRCP9QDGG8sy2L37t2EQiEURTnUw5FIJBKJRDIKbNsmlUoxffp0VHVk28qUEy+7d++mpaXlUA9DIpFIJBLJfrBjxw5mzpw54jJTTryEQiGgvPPhcPgQj0YikUgkEsloSCaTtLS0OM/xkZhy4kW4isLhsBQvEolEIpFMMkYT8iEDdiUSiUQikUwqpHiRSCQSiUQyqZDiRSKRSCQSyaRiysW8SCQSiWTisW0bwzAwTfNQD0UyiXC5XGiadsDbkeJFIpFIJGOiWCzS3t5ONps91EORTDIURWHmzJkEg8ED2o4ULxKJRCIZNZZlsXXrVjRNY/r06bjdblkQVDIqbNumu7ubnTt30traekAWGCleJBKJRDJqisUilmXR0tKC3+8/4O3Zti3Fz1uIhoYGtm3bRqlUkuJFIpFIJAeXfZVvH46uZJ5XdyfZ3pdhR1+OomHh1lVa4j5mxwMsnR6mMewd59FKDhfGS6hK8SKRSCSSCWcgW+ThVzp4sa2fRK6ES1PxuzU0VaGQN3l+W551b/QS8bk4dlaMlUc2E/W7D/WwJYcpUr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ACK1as2PuFqsqKFSuGHIhKvvzlL9PY2MhHPvKRfX5HoVAgmUxWfSQSyV5KpRK2baNpmmN5qeXXlkjGC0VRcOsqpnXgYgPAtGzc+oG7oEbiXe96F/X19dxyyy015w8MDABlS0Q6neZ73/veAX+nqqosWLCAefPmOTErY6G5uZkFCxY4rhzBsccey6uvvsqcOXOGCLVAIEBvby+bNm3ixhtv5B//8R9ZsmQJ/f39Nb/jX//1X/n617/Oueeey//93/9VzfP5fLz3ve/lP//zP3niiSdYt24dL7/88pj3Y3+Y0Aq7PT09mKZJU1NT1fSmpqZh1e2TTz7Jj370o1EXxrn55pv50pe+dKBDlUimLOJNyOVyOY3QpHiRTDQtcR/Pbxuf2KpMwWTp9Mi+FxwFhUKBjo7q1Gtd16mvr+fOO+9k1apVnHvuuVx77bUsWLCAnp4efvGLX9DW1sa9997LSSedxPXXX8/111/P9u3bueCCC2hpaaG9vZ0f/ehHTt2WQ8m//du/cccdd3DxxRfzmc98hng8zuuvv869997LnXfeSSwWo66ujh/+8IdMmzaNtrY2/t//+3/Dbu/jH/84pmlyzjnn8NBDD3HyySfzP//zP5imyfLly/H7/fzsZz/D5/Mxe/bsg7KPh1W2USqV4kMf+hB33HEH9fX1o1rnhhtuIJFIOJ8dO3ZM8CglksmFcBFpmubcVG3blgJGMqHMjgcomQfu6rFtG8OymBU/8A7WUE4RnjZtWtXn5JNPBuC8887j6aefxuVycckll7B48WIuvvhiEokEX/3qV51t3HrrraxZs4b169dzzjnn0NrayqpVq7Asi3Xr1hEOH9qWBtOnT+epp57
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Visualize P-peaks and T-peaks\n",
"signal_cwt, waves_cwt = nk.ecg_delineate(ecg_signal, \n",
" rpeaks, \n",
" sampling_rate=500, \n",
" method=\"cwt\", \n",
" show=True, \n",
" show_type='peaks')"
]
},
{
"cell_type": "code",
2024-06-11 19:04:23 +02:00
"execution_count": 18,
"metadata":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+K6ampnDTTTfNeOyKK67Atm3bRDSJ+NjHPoabbroJe/fuxbZt23DttdeKSOtv//ZvwzRN/L//9//wk5/8BH/2Z38mXG7z+Tze9ra34bzzzsMPf/hDPPTQQxgfH8ev/dqvAQA+85nP4KKLLsINN9wgIkcbN27Exz/+cfzsZz/Dd77zHezbtw9/8zd/g8HBwS5/Mw1WRLx87nOfw+bNmxEMBnHhhReKENp83HfffZAkCe9617u6u4IM0+eYptn0NwkZhlkqh7IVaIq85BO6JElQZRmHs9Ulr9O3vvUtRKPRptuf/Mmf4MUXXwQAbN++fc7nv/DCC9iyZQtUdboh94477mh6vW5HMKn+5swzz2z7+Pbt22fU6Nx00034pV/6JWzbtg233norDh06hJdeegkAcPjwYfz8z/88Xve612HLli14xzvegTe/+c0AgL/6q7/Ceeedhz/5kz/B9u3bcd555+HLX/4yHnvsMbzwwgtIJBLQdR3hcFhEjhRFweHDh3Heeedh586d2Lx5M3bt2oUrrriii9/KNF0XL1/96lexZ88efOITn8DTTz+Nc889F5dddhkmJibmfN7Bgwdx00034eKLL+72KjJM32NZjUJITWtcHbeKGYZZLEeyNYT1pQ/aA4BIQFkW8fLWt74Ve/fubbq9//3vX1KNyHvf+17s3bsXn//851GpVFas3mQh73POOeeI/69btw4AxLn2gx/8ID75yU/i53/+5/GJT3wCzz77rFj2xz/+MR577LEmcUYC7+WXX571/f7n//yfuO+++7Bjxw589KMfxRNPPLGgz7YUui5e7rjjDtxwww3YvXs3zjrrLNx1110Ih8P48pe/POtzHMfBddddh1tvvRVbtmzp9ioyTF/jeZ6YChwOhwGA00bMsuB5HizbXXStSyuKLMGy3SULg0gkgtNPP73plk6nsW3bNgDA888/P+fzt27dildeeaVpmnYymcTpp5+O9evXL2ndOoXWdd++fW0f37dvn1iGoIsTYDq15bouAOC3fuu38Morr+A3fuM38JOf/AQ7d+7EZz/7WQCNAZxXXHHFDMH34osviuhMO37xF38Rhw4dwu/8zu/g+PHj+IVf+IW2aa5u0FXxYlkWfvSjH2HXrl3TbyjL2LVrV1MhUSv/63/9LwwPD+M3f/M3530P0zRRLBabbgzDTEMzahRFEQc3OqAxzFKQJAm6KsNxlycK4bgedHXpKajZuPTSSzE4OIhPfepTbR/P5/MAgGuvvRblchl//dd/3ZX16IRLL70U6XQaf/EXfzHjsQcffBAvvvgirr322gW95saNG/H+978fDzzwAD7ykY/gi1/8IgDg9a9/PZ577jls3rx5huiLRCIAAF3X2170DA0N4frrr8dXvvIV3HnnnfjCF76wiE+7cLoqXjKZDBzHwcjISNP9IyMjGBtr3xL3ve99D1/60pfElzoft912GxKJhLht3LhxyevNMP0EXT1qmiYGobF4YZaLjekQqtbyRPIqpoNN6fCSX8c0TYyNjTXdMpkMIpEI/vZv/xb/8i//gne+85145JFHcPDgQfzwhz/ERz/6Ubz//e8HAFx00UX4yEc+go985CPYs2cPvve97+HQoUP4/ve/jy996UuQJAmy3N3ERSQSwec//3l885vfxPve9z48++yzOHjwIL70pS/hPe95D6688kpRUNsJH/7wh/Hwww/jwIEDePrpp/HYY4+Jeprf/u3fRjabxbXXXosf/OAHePnll/Hwww9j9+7dQrBs3rwZ//Vf/4WDBw8ik8nAdV3ccsst+OY3v4mXXnoJzz33HL71rW/NWqOz3KypbqNSqYTf+I3fwBe/+MWOK5ZvvvlmFAoFcTty5EiX15Jhegs6+CiKIg64nuexgGGWhVPTEdSdpad6PM+D7brLIl4eeughrFu3run2pje
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Visualize T-waves boundaries\n",
"signal_cwt, waves_cwt = nk.ecg_delineate(ecg_signal, \n",
" rpeaks, \n",
" sampling_rate=500, \n",
" method=\"cwt\", \n",
" show=True, \n",
" show_type='bounds_T')"
]
},
{
"cell_type": "code",
2024-06-11 19:04:23 +02:00
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAi8AAAGdCAYAAADaPpOnAAAAOXRFWHRTb2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P4gMf+AA0rfE3e/7553HppZfizW9+M5544gncc889+OEPf4hrr70WAPCVr3wFGzduxEc/+lERyQKAP/qjP4Jpmvj+97+Pn//85/i7v/u7ZTvndspxES+f+tSnsGXLFoTDYVx44YV4+OGHO3rf3XffDUmS8Nu//dvd3UCG6XNM02z6NwkZhlkuB3JVaIq8bP8OSZKgyjIO5mrL3qZvfOMbiMfjTY+PfexjeO655wAAO3funPf9v/zlL7Ft2zao6rGG3FtvvbVpfUuJYD733HO4/fbbsWvXLiQSiQW3IZVKYd26dbNe03Ud27Ztm1Wj8zd/8zd41atehdNPPx0f+MAH8OCDD4pj/eDBg9i9ezd27tyJHTt24PLLL8fZZ58NALjppptw1VVX4brrrsOOHTvwspe9DH//93+PL37xizAMA9lsFoqiIJFIiEgWrfPlL385XvKSl2Dbtm14wxvegFe+8pWL/l2WQtfFyz333IO9e/fiwx/+MB577DGcffbZuOSSSxYsWNq/fz/e97734eKLL+72JjJM32NZjUJIutNqFTMMs1QO5eqI6ssftAcAsZCyIuLlNa95DR5//PGmx7vf/e5lzWh617vehccffxyf+cxnUK1WO15XsVhEPB5HNBrFqaeeipGREdx5551L3o75OOuss8T/k+iha+3evXvx+7//+9i9ezf+9m//Fs8//7xY9mc/+xm+8IUvNImzSy65BJ7nYd++fXN+3nvf+1789V//NV7+8pfjwx/+MJ544omufK92dF283HrrrbjmmmuwZ88enH766bj99tsRjUbx+c9/fs73uK6Lq666Ch/5yEewbdu2bm8iw/Q1vu+LqcDRaBQAOG3ErAi+78NyvCXXurSiyBIsx1v2IMhYLIbt27c3PbLZLE455RQAwDPPPDPv+3fs2IEXXnihaZp2Op3G9u3bsWHDhkVtSyKRwOOPP45f/OIXqFar+P73vy+2Yz5OOeUUFItFHD16dNZrlmXh+eefn7UeujkBjqW2PM8DAPzlX/4lnnzySfzGb/wGvve97+H000/HV7/6VQCNAZx/8Ad/0CT2fvazn+G5557DySefPOc2/v7v/z5eeOEFvP3tb8fPf/5z7Nq1C5/85CcX/lFWgK6KF8uy8Oijj2L37t3HPlCWsXv3bjz00ENzvu+jH/0ohoeH8Xu/93sLfoZpmiiVSk0PhmGOQTNqFEURJzc6oTHMcpAkCboqw/VWZuq06/nQ1eWnoObida97HQYHB3HzzTe3fb1QKAAArrzySlQqFfzjP/7jsj9TlmVs374d27ZtW9SMqDe/+c3QNA2f+MQnZr12++23o1qt4sorr1zUtpxyyin4kz/5E/zXf/0X3vSmN+Gf//mfAQAvfelL8dRTT80SfNu3b4euN9yPdV1ve9OzadMmvPvd78ZXvvIVXH/99bjjjjsWtU1LpasOu9PT03BdFyMjI03Pj4yMzKl8f/jDH+Kf/umf8Pjjj3f0GTfddBM+8pGPLHdTGaZvobtHTdPEIDQWL8xKsSkbwSP7V6aGqmq6OGN9atnrMU0T4+PNbdeqqmJwcBCf+9zncPnll+O3fuu38N73vhfbt2/H9PQ0/u3f/g0HDx7E3XffjYsuugjXX389rr/+ehw4cABvetObsGnTJoyNjeGf/umfhG9LN9m8eTNuvvlmXH/99QiHw3j7298OTdPwta99DR/84Adx/fXX48ILL+xoXfV6HX/6p3+Kt7zlLdi6dSsOHz6Mn/zkJ3jzm98MoNEW/mu/9mu49tpr8fu///uIxWJ46qmn8J3vfAf/8A//AKDh8/L9738fb3vb2xA
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Visualize P-waves boundaries\n",
"signal_cwt, waves_cwt = nk.ecg_delineate(ecg_signal, \n",
" rpeaks, \n",
" sampling_rate=500, \n",
" method=\"cwt\", \n",
" show=True, \n",
" show_type='bounds_P')"
]
},
{
"cell_type": "code",
2024-06-11 19:04:23 +02:00
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAi8AAAGdCAYAAADaPpOnAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qN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xNDQEr9eLTZs24YYbbsBzzz1X817f/va38brXvQ6xWAw+nw9nnXUW3vve9+JXv/pVS9vyta99TXy+LMsYGRnBFVdcgSNHjrT1nZ5++mm8+93vxsDAADweD84880zccsstS97Gfu211+Ltb3/7kn7mbLB4YZhTBMdxkMvlYJrmcm8K00P84OkxHEkUsL4v0HYxpiRJWN8XwJFEAXt+M7Yo23PppZdidHS05nHPPfcAAB588EG88pWvhGEYuOuuu7B//3584xvfQCQSwcc+9jHxHh/5yEdwxRVXYOvWrXjggQdw4MAB3H333diwYQN27drV8raEw2GMjo7i+PHj+Pa3v40DBw7g8ssvb3n9X/ziF9i+fTvK5TK+973v4bnnnsOnPvUpfO1rX8Mb3vAGlMsLF3zdCosXhjlFSCaTyGQySKfTy70pTI8wninhiSNJDIW9LUdc6lFkCUNhL544ksREprTgbfJ4PBgeHq55xGIxFAoFXHfddbjsssvwwAMPYMeOHTj99NOxfft23Hbbbfj85z8PoCoYbr31Vtx+++24/fbb8epXvxpr167FBRdcgL/8y7/Ef/zHf7S8LZIkYXh4GCMjI7j44otx/fXX45FHHkEmM3eazHEcXH/99diyZQu+853v4MILL8S6detw+eWX47vf/S727t2Lz3zmMzWf9aUvfQnveMc74Pf7sWnTJjzwwAPi9WQyiauuugoDAwPw+XzYtGkTvvrVr4rXjx49ine/+92IRqOIx+N429vehkOHDgEAPvGJT+D//b//h3//938X0aSHH34Y5XIZN954I0ZGRuD1erFu3Trs3r275d9nIbB4YZhTAMMwUCqVxL/Z8p1ZDJ45kUG6WEHMry3ofWJ+DeliBU+f6Fztyw9+8ANMTU3hwx/+cMPXo9EoAOCee+5BMBjE+9///obLzbfVd2JiAvfffz8URWnJ32Tfvn145plnsHPnzhlt6+eddx527NghIkrEJz/5Sbz73e/Gk08+icsuuwxXXXUVEokEAOBjH/sYnnnmGfzHf/wH9u/fj3/+539Gf38/AKBSqeCSSy5BKBTCT37yE/zsZz9DMBjEpZdeinK5jA996EN497vfXRPVuvjii/HZz34WDzzwAP71X/8VBw4cwF133YX169fP6/dplyURL5/73Oewfv16eL1ebN++HY888khL6917772QJGlF5dkYphsxDKPm/0nIMMxCOJzIQ1PkBXt3SJIEVZZxJLHwOo4HH3wQwWCw5vE3f/M3eP755wEAmzdvnnX95557Dhs2bICqnmzGvf3222ver9XoZTqdRjAYRCAQwNDQEP7rv/4L//t//28EAoE516UanC1btjR8fcuWLTPqdK699lpceeWV2LhxI/7mb/4GuVxOXG+PHDmC888/H9u2bcP69euxY8cOvPWtbwUA3HfffbBtG1/60pfwO7/zO9iyZQu++tWv4siRI3j44YcRDAbh8/lqolq6ruPIkSPYtGkTXvWqV2HdunV41atehSuvvLKl32ahdFy83Hfffdi5cyc+/vGP44knnsB5552HSy65BBMTE7Oud+jQIXzoQx/Cq1/96k5vIsP0PJQb17TqHXK9mGGY+XA0UYRfX/iQPQAIeJRFES+/93u/h3379tU83ve+98FxnHm/53vf+17s27cPn//855HP51t+r1AohH379uGxxx7Dpz/9abz85S/Hpz71qbY+u53tPvfcc8W/A4EAwuGwuNb+yZ/8Ce69915s3boVH/7wh/Hzn/9cLPvrX/8av/3tbxEKhYRAi8fjKJVKeOGFF5p+3rXXXot9+/bhrLPOwk033YT//M//bOu7LYSOi5fbb78dN9xwA6677jqcffbZuPPOO+H3+/GVr3yl6TqWZeGqq67CJz/5SWzYsKHTm8gwPY3jOKhUKgAg7N45bcQsFMdxUDbtede61KPIEsqmvSCRAVQv2hs3bqx5xONxnHnmmQCAZ599dtb1N23ahBdffFEcM0A1pbRx40acdtppbW2LLMvYuHEjtmzZgp07d+KVr3wl/uRP/qSldWl79+/f3/D1/fv3i2UIujkhJEmCbdsAgDe96U04fPgwPvjBD+LEiRN4/etfjw996EMAgFwuhwsuuGCG6Hvuuefwh3/4h0238eUvfzkOHjyIv/qrv0KxWMS73/1uvOtd72rp+y2UjoqXcrmMxx9/HDt27Dj5gbKMHTt2YO/evU3X+z//5/9gcHAQ119//ZyfYRgGMplMzYNhmJNUKhU4jgNFUcTJjU5oDDNfJEmCrsqw7IWJDcKyHejqwlNQzXjjG9+I/v5+3HrrrQ1fT6VSAIArr7wSuVwO//RP/7To2/DRj34U9913H5544ok5l926dSs2b96Mz3zmMzOO11//+tf40Y9+1HaKZmBgANdccw2+8Y1v4I477sAXvvAFAFUR8vzzz2NwcHCG8ItEIgAAXdcb3vSEw2FcccUV+OIXv4j77rsP3/72t0WdTSfpqHiZmpqCZVkYGhqqeX5oaAhjY43b4n7605/iy1/+Mr74xS+29Bm7d+9GJBIRjzVr1ix4uxmml6A7SE3TRKEgixdmMVgT96FQXpwoXt6wsDa+8EGQhmFgbGys5jE1NYVAIIAvfelL+N73voff//3fx49+9CMcOnQIjz32GD784Q/jfe97HwDgoosuws0334ybb74ZO3fuxE9/+lMcPnwYv/jFL/DlL39Z+LbMhzVr1uAd73gHbrnlljmXlSQJX/7yl/HMM8/gne98Jx555BEcOXIE3/zmN/HWt74VF110ET7wgQ+0/Nm33HIL/v3f/x2//e1v8fTTT+PBBx8U9TRXXXUV+vv78ba3vQ0/+clPcPDgQTz
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Visualize R-waves boundaries\n",
"signal_cwt, waves_cwt = nk.ecg_delineate(ecg_signal, \n",
" rpeaks, \n",
" sampling_rate=500, \n",
" method=\"cwt\", \n",
" show=True, \n",
" show_type='bounds_R')"
]
},
{
"cell_type": "code",
2024-06-11 19:04:23 +02:00
"execution_count": 21,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Learning initial signal parameters...\n",
"Failed to find 8 beats during learning.\n",
"Initializing using default parameters\n",
"Running QRS detection...\n",
"QRS detection complete.\n",
"[ 544 1114 1683 2281 2855 3452 4016 4606]\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwga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xwZ/brFkztqysTDj+ww8/sADYn376qcE2yv29f/nlFzYrK4tlGIbdtWsXW1VVxSYmJrL333+/5L0FBQVsQkKC5Lhc/3355ZcsAHbz5s3CMf76LC4uZo8ePcq2aNGCHThwoOQ37Nu3jwXAfvPNNw3+BoIgCDkoXJAgCMJDFi9ejLVr10r+qYVlWXz33XeYPHkyWJZFSUmJ8G/ChAmoqKjA3r17Je+ZPn06oqKihOf79+/HyZMncccdd6C0tFR4f01NDcaMGYPNmzfDZrPBarVi9erVmDJlClq3bi28v2vXrpgwYYKidjMMI3iOrr32WsTGxrqcU1VVhbi4uAY/h3+9qqpKcvyee+5BamoqWrRogYkTJ6KiogKfffYZBg4cKDnvueeewxdffIG+ffti9erVePrpp9G/f3/069fPrRqh+DesXr0aL774IpKSkvDll1/ir3/9K9q0aYPbbrtNkpPlzPr162GxWCQ5aADnrXLHAw88IPGkZGdnw2q14vz588Ix8d+1qqoKJSUlyM7ORm1trWK1w9TUVHTp0gWbN28GwImQ6PV6PPHEEygsLMTJkycBcJ6sYcOGqZLwv+222yReRj6801OFQPHf+7rrrhNCawc
"text/plain": [
"<Figure size 1000x500 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Normalize data by setting qrs peaks to index position 0 (“X-axis normalization”)\n",
"indicies = wfdb.processing.xqrs_detect(filtered_data.p_signal[:,sig_channel],example_data.fs,0,5000)\n",
"print(indicies)\n",
"\n",
"peak_points_y = [filtered_data.p_signal[:,sig_channel][i] for i in indicies] \n",
"\n",
"plt.figure(figsize=(10, 5))\n",
"plt.plot(filtered_data.p_signal[:,sig_channel])\n",
"plt.scatter(indicies, peak_points_y, color='red', label='Peaks')\n",
"plt.xlabel('Time')\n",
"plt.ylabel('Amplitude')\n",
"plt.title('Filtered XQRS Signal with Peaks')\n",
"plt.legend()\n",
"plt.grid(True)\n",
"plt.show()"
]
},
2024-06-11 19:04:23 +02:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Calculate R and T Axis for one datapoint"
]
},
{
"cell_type": "code",
2024-06-11 19:04:23 +02:00
"execution_count": 22,
"metadata": {},
2024-06-03 21:08:46 +02:00
"outputs": [],
"source": [
"def calculate_axis(data, leads, sampling_rate=500, aVF=5, I=0):\n",
" # warnining if leads not include 0 and 5 or one lead is over 5\n",
" if not (I in leads and aVF in leads) or any([lead > aVF for lead in leads]) or len(leads) > 6:\n",
" print(\"Warning: Leads should include 0 and 5, and should not include a lead over 5\")\n",
" return None, None\n",
" # Calculate the net QRS in each lead\n",
" net_qrs = {}\n",
" net_t = {}\n",
" for lead in leads:\n",
" # get data and peaks\n",
" ecg_signal = data.p_signal[:,lead]\n",
" signals, info = nk.ecg_process(ecg_signal, sampling_rate=500)\n",
" # r axis\n",
" # get amplitude of peaks\n",
" q_peaks = [ecg_signal[int(i)] for i in info['ECG_Q_Peaks'] if not math.isnan(i)]\n",
" s_peaks = [ecg_signal[int(i)] for i in info['ECG_S_Peaks'] if not math.isnan(i)]\n",
" _, rpeaks_idx = nk.ecg_peaks(ecg_signal, sampling_rate=sampling_rate)\n",
" rpeaks_idx = rpeaks_idx['ECG_R_Peaks']\n",
" r_peaks = [ecg_signal[int(i)] for i in rpeaks_idx if not math.isnan(i)]\n",
" # calculate avg peal amplitude\n",
" q_peaks_avg = np.mean(q_peaks) if q_peaks else 0\n",
" s_peaks_avg = np.mean(s_peaks) if s_peaks else 0\n",
" r_peaks_avg = np.mean(r_peaks) if r_peaks else 0\n",
" # Calculate net QRS in lead\n",
" net_qrs[lead] = r_peaks_avg - (q_peaks_avg + s_peaks_avg)\n",
"\n",
" # T axis\n",
" t_peaks = [ecg_signal[int(i)] for i in info['ECG_T_Peaks'] if not math.isnan(i)]\n",
" net_t[lead] = np.mean(t_peaks) if t_peaks else 0\n",
"\n",
2024-06-03 21:08:46 +02:00
" print(net_qrs.get(aVF, 0), net_qrs.get(I, 0))\n",
" # Calculate the R axis (Convert to degrees)\n",
" r_axis = np.arctan2(net_qrs.get(aVF, 0), net_qrs.get(I, 0)) * (180 / np.pi)\n",
"\n",
" # Calculate the T axis (Convert to degrees)\n",
" t_axis = np.arctan2(net_t.get(aVF, 0), net_t.get(I, 0)) * (180 / np.pi)\n",
" \n",
" return r_axis, t_axis\n",
"\n",
"\n",
2024-06-03 21:08:46 +02:00
"\n"
]
},
{
"cell_type": "code",
2024-06-11 19:04:23 +02:00
"execution_count": 23,
2024-06-03 21:08:46 +02:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.8047692058411333 0.5260930603345693\n",
"2 lead R Axis: 56.83 degrees\n",
"2 lead T Axis: 30.78 degrees\n",
"\n"
]
}
],
"source": [
"# print(data_org['SB'][0].__dict__) 'sig_name': ['I', 'II', 'III', 'aVR', 'aVL', 'aVF', 'V1', 'V2', 'V3', 'V4', 'V5', 'V6']\n",
"\n",
"i_sig = 0\n",
"avf = 5\n",
"sampling_rate = 500\n",
"\n",
2024-06-03 21:08:46 +02:00
"example_data = data_org['SB'][0]\n",
"filtered_data = data_helper.filter_data(example_data, filter_params)\n",
"\n",
"\n",
"r_ax, t_ax = calculate_axis(filtered_data, [0, 5], sampling_rate=500)\n",
"print(f\"2 lead R Axis: {r_ax:.2f} degrees\")\n",
"print(f\"2 lead T Axis: {t_ax:.2f} degrees\")\n",
2024-06-03 21:08:46 +02:00
"print(\"\")\n"
]
}
],
"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.10.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}