DSA_SS24/notebooks/first_signal_processing.ipynb

611 lines
992 KiB
Plaintext
Raw Permalink Normal View History

2024-05-01 12:53:33 +02:00
{
"cells": [
2024-05-15 20:20:01 +02:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Signal Processing\n",
"\n",
"The notebook goes into more detail on the processing of the 12 ECG data per patient. First, the signal itself is considered and then the ECG signal processing methods integrated in the 'wfdb' module are explored. Various approaches are then used to normalize the data and reduce noise in order to make the signals as comparable as possible."
]
},
{
"cell_type": "code",
2024-06-11 19:04:23 +02:00
"execution_count": 4,
2024-05-15 20:20:01 +02:00
"metadata": {},
"outputs": [],
"source": [
"from matplotlib import pyplot as plt\n",
2024-05-25 21:02:16 +02:00
"import wfdb.processing\n",
"import scipy.signal\n",
2024-06-11 19:04:23 +02:00
"import sys\n",
"\n",
"sys.path.append('../scripts')\n",
"import data_helper"
2024-05-15 20:20:01 +02:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Load Data"
]
},
{
"cell_type": "code",
2024-06-11 19:04:23 +02:00
"execution_count": 5,
2024-05-01 12:53:33 +02:00
"metadata": {},
2024-05-07 20:16:12 +02:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Reading GSVT\n",
2024-06-11 19:04:23 +02:00
"Reading AFIB\n",
2024-05-07 20:16:12 +02:00
"Reading SR\n",
2024-06-11 19:04:23 +02:00
"Reading SB\n",
"Number of patients per category:\n",
"GSVT: 1027\n",
"AFIB: 9787\n",
"SR: 10426\n",
"SB: 15826\n"
2024-05-07 20:16:12 +02:00
]
}
],
2024-05-01 12:53:33 +02:00
"source": [
2024-06-11 19:04:23 +02:00
"data = data_helper.load_data(only_demographic=False)\n",
2024-05-15 20:20:01 +02:00
"\n",
2024-06-11 19:04:23 +02:00
"print(\"Number of patients per category:\")\n",
"for cat_name in data.keys():\n",
" print(f\"{cat_name}: {len(data[cat_name])}\")"
2024-05-01 12:53:33 +02:00
]
2024-05-07 20:16:12 +02:00
},
2024-05-15 20:20:01 +02:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For a better understanding of the structure and dimensions of the individual data sets, there are printed."
]
},
2024-05-07 20:16:12 +02:00
{
"cell_type": "code",
2024-06-11 19:04:23 +02:00
"execution_count": 6,
2024-05-07 20:16:12 +02:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Keys of first record of SB: dict_keys(['record_name', 'n_sig', 'fs', 'counter_freq', 'base_counter', 'sig_len', 'base_time', 'base_date', 'comments', 'sig_name', 'p_signal', 'd_signal', 'e_p_signal', 'e_d_signal', 'file_name', 'fmt', 'samps_per_frame', 'skew', 'byte_offset', 'adc_gain', 'baseline', 'units', 'adc_res', 'adc_zero', 'init_value', 'checksum', 'block_size'])\n",
"{'record_name': 'JS00002', 'n_sig': 12, 'fs': 500, 'counter_freq': None, 'base_counter': None, 'sig_len': 5000, 'base_time': None, 'base_date': None, 'comments': ['Age: 59', 'Sex: Female', 'Dx: 426177001,164934002', 'Rx: Unknown', 'Hx: Unknown', 'Sx: Unknown'], 'sig_name': ['I', 'II', 'III', 'aVR', 'aVL', 'aVF', 'V1', 'V2', 'V3', 'V4', 'V5', 'V6'], 'p_signal': array([[-0.01 , 0.01 , 0.02 , ..., 0.054, 0.049, 0. ],\n",
" [-0.024, -0.02 , 0.005, ..., 0.034, 0.034, -0.015],\n",
" [-0.02 , -0.02 , 0. , ..., 0.034, 0.034, -0.01 ],\n",
" ...,\n",
" [ 0.015, 0.01 , -0.005, ..., -0.015, -0.02 , 0.005],\n",
" [ 0.01 , 0.01 , 0. , ..., -0.02 , -0.024, 0. ],\n",
2024-05-08 08:26:31 +02:00
" [ 0.01 , 0.01 , 0. , ..., -0.024, -0.029, -0.005]]), 'd_signal': None, 'e_p_signal': None, 'e_d_signal': None, 'file_name': ['JS00002.mat', 'JS00002.mat', 'JS00002.mat', 'JS00002.mat', 'JS00002.mat', 'JS00002.mat', 'JS00002.mat', 'JS00002.mat', 'JS00002.mat', 'JS00002.mat', 'JS00002.mat', 'JS00002.mat'], 'fmt': ['16', '16', '16', '16', '16', '16', '16', '16', '16', '16', '16', '16'], 'samps_per_frame': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 'skew': [None, None, None, None, None, None, None, None, None, None, None, None], 'byte_offset': [24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24], 'adc_gain': [1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0], 'baseline': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 'units': ['mV', 'mV', 'mV', 'mV', 'mV', 'mV', 'mV', 'mV', 'mV', 'mV', 'mV', 'mV'], 'adc_res': [16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16], 'adc_zero': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 'init_value': [-10, 10, 20, 0, -15, 15, -10, -54, 63, 54, 49, 0], 'checksum': [12346, 26962, 14528, -13537, -6991, 14569, -383, 16468, -29512, -7548, -22267, 31542], 'block_size': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}\n",
"(5000, 12)\n"
2024-05-07 20:16:12 +02:00
]
}
],
"source": [
"# print keys of first record\n",
"print(f\"Keys of first record of SB: {data['SB'][0].__dict__.keys()}\")\n",
2024-05-15 20:20:01 +02:00
"print(data['SB'][0].__dict__)\n",
"print(data['SB'][0].__dict__['p_signal'].shape)"
]
},
{
"cell_type": "code",
2024-06-11 19:04:23 +02:00
"execution_count": 7,
2024-05-15 20:20:01 +02:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2024-06-11 19:04:23 +02:00
"Number of records with p_signal: 10426\n",
2024-05-15 20:20:01 +02:00
"Number of records with e_p_signal: 0\n",
"Number of records with d_signal: 0\n",
"Number of records with e_d_signal: 0\n"
]
}
],
"source": [
"# count how many different signals are available\n",
2024-05-07 20:16:12 +02:00
"counter_p = 0\n",
"counter_e_p = 0\n",
"counter_d = 0\n",
"counter_e_d = 0\n",
"for record in data['SR']:\n",
" if record.p_signal is not None:\n",
" counter_p += 1\n",
" if record.e_p_signal is not None:\n",
" counter_e_p += 1\n",
" if record.d_signal is not None:\n",
" counter_d += 1\n",
"\n",
"print(f\"Number of records with p_signal: {counter_p}\")\n",
"print(f\"Number of records with e_p_signal: {counter_e_p}\")\n",
"print(f\"Number of records with d_signal: {counter_d}\")\n",
2024-05-15 20:20:01 +02:00
"print(f\"Number of records with e_d_signal: {counter_e_d}\")"
2024-05-08 08:26:31 +02:00
]
},
{
"cell_type": "code",
2024-06-11 19:04:23 +02:00
"execution_count": 8,
2024-05-08 08:26:31 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-05-15 20:20:01 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAksAAAHHCAYAAACvJxw8AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd1xT1xfAv0nYe6MgCogLB05w761Va7XWDmfbX7W2tbZaba2j1tVa27qqHa5a667WvbXuvTcKCrIEZENCkvf7AwkJMyAQou/7+eQD7+a9l3PfuPfcc849VyIIgoCIiIiIiIiIiEi+SA0tgIiIiIiIiIhIRUZUlkRERERERERECkFUlkRERERERERECkFUlkRERERERERECkFUlkRERERERERECkFUlkRERERERERECkFUlkRERERERERECkFUlkRERERERERECkFUlkRERERERERECkFUlkRERMqNI0eOIJFIOHLkSKmdMzo6mgEDBuDs7IxEIuGnn34qtXM/D97e3gwbNkyzXRZ1B5BIJIwZM6ZUz2lIJBIJ06ZNM7QYIiI6iMqSiEgFYeXKlUgkkgI/p0+fNrSIFZJPP/2UvXv3MmnSJP7880+6d+9uaJFKhfv37/O///0PX19fLCwssLOzo1WrVvz888+kp6cbWjwRkZcKE0MLICIio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KzNmzKBly5aMGjWK2NhYzT7ZI37tEf6ZM2c4depUmcgUERHBP//8o9lOSkpi9erVNGzYMF8XHECTJk2oXr068+bNIyUlJc/
2024-05-08 08:26:31 +02:00
"text/plain": [
"<Figure size 640x480 with 12 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
2024-05-15 20:20:01 +02:00
}
],
"source": [
"#Plot a complete Record\n",
"wfdb.plot_wfdb(data['SB'][24],title=\"Example for all Channels\")"
]
},
{
"cell_type": "code",
2024-06-11 19:04:23 +02:00
"execution_count": 9,
2024-05-15 20:20:01 +02:00
"metadata": {},
"outputs": [
2024-05-08 08:26:31 +02:00
{
"data": {
2024-05-15 20:20:01 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAABN0AAAGJCAYAAAC+dUXNAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAADoxklEQVR4nOydd5wT1frGnyRb2QYssHSWKh0UBEHBhoIg9u5V8FquBcv1p1exgIqCvVzFy7VgV7z2AoKKYANEQZDel76N7btsS+b3RzKTmckkmzKT7Eye7+fjx+xkkjnL2TNzznue93ltgiAIIIQQQgghhBBCCCGE6IY91g0ghBBCCCGEEEIIIcRqMOhGCCGEEEIIIYQQQojOMOhGCCGEEEIIIYQQQojOMOhGCCGEEEIIIYQQQojOMOhGCCGEEEIIIYQQQojOMOhGCCGEEEIIIYQQQojOMOhGCCGEEEIIIYQQQojOMOhGCCGEEEIIIYQQQojOMOhGCCGEEEIIIYQQQojOMOhGCCGEENJMWb58OWw2G5YvX67bdxYUFOCiiy5CdnY2bDYbnn/+ed2+O1KmTp2K9PT0WDdDN6ZOnYrc3NxYN4MQQgghMYJBN0IIIYSYkjfffBM2m83vf6tWrYp1E5sl//znP7FkyRJMnz4d77zzDiZMmGD4NWtra/Hcc89h5MiRyMrKQkpKCvr06YNp06Zh+/bthl+/uRPo7/iMM86IdfMIIYQQEiYJsW4AIYQQQkgkPPLII+jevbvP8V69esWgNc2fH374Aeeeey7uuuuuqFyvuLgYEyZMwJo1a3D22WfjiiuuQHp6OrZt24YFCxbglVdeQX19fVTa0lx55513fI798ccfeOGFF3DmmWfGoEWEEEII0QMG3QghhBBias466ywMHz481s0wDYWFhWjZsqVu31dbW4ukpCTY7doJFFOnTsWff/6Jjz/+GBdeeKHivVmzZuH+++/XrS1m5W9/+5vPMTG1+PLLL49BiwghhBCiB0wvJYQQQoilmTlzJux2O5YuXao4fsMNNyApKQnr168HANTX12PGjBkYNmwYsrKykJaWhjFjxmDZsmWKz+Xl5cFms+Hpp5/G3Llz0aNHD7Ro0QJnnnkm9u/fD0EQMGvWLHTu3Bmpqak499xzUVJSoviO3NxcnH322fj2228xdOhQpKSkoH///vj000+D+p1+++03TJgwAVlZWWjRogVOPvlk/PrrrwE/I6bjCoKAuXPnSumLIrt378bFF1+M1q1bo0WLFjjhhBOwcOFCxXeIgaAFCxbggQceQKdOndCiRQtUVFT4befChQtx7bXX+gTcACA5ORlPP/20z/GDBw/ivPPOQ3p6Otq2bYu77roLTqdTcc7TTz+N0aNHIzs7G6mpqRg2bBg+/vhjn++y2WyYNm0aPv/8cwwcOBDJyckYMGAAFi9erDjvoYcegs1mw86dOzF16lS0bNkSWVlZuOaaa1BTU+Pzve+++y6GDRuG1NRUtG7dGpdddhn279+v+e8QKnV1dfjkk09w8skno3Pnzrp8JyGEEEKiD4NuhBBCCDE15eXlKC4uVvx35MgR6f0HHngAQ4cOxbXXXovKykoAwJIlS/Dqq69ixowZGDJkCACgoqICr732Gk455RQ88cQTeOihh1BUVITx48dj3bp1Ptd977338PLLL+PWW2/F//3f/+HHH3/EJZdcggceeACLFy/GPffcgxtuuAFfffWVZirnjh07cOmll+Kss87CnDlzkJCQgIsvvhjfffddwN/3hx9+wNixY1FRUYGZM2di9uzZKCsrw2mnnYbVq1f7/dzYsWOlNMYzzjgD77zzjvRzQUEBRo8ejSVLluDmm2/GY489htraWpxzzjn47LPPfL5r1qxZWLhwIe666y7Mnj0bSUlJmtf88ssvAQBXXXVVwN9JjtPpxPjx45GdnY2nn34aJ598Mp555hm88sorivNeeOEFHHvssXjkkUcwe/Zs6d9PHSgEgF9++QU333wzLrvsMjz55JOora3FhRdeqPg7EbnkkktQWVmJOXPm4JJLLsGbb76Jhx9+WHHOY489hquvvhq9e/fGs88+izvuuANLly7F2LFjUVZWFvTv6o9FixahrKwMV155ZcTfRQghhJAYIhBCCCGEmJA33nhDAKD5X3JysuLcDRs2CElJScJ1110nlJaWCp06dRKGDx8uNDQ0SOc0NjYKdXV1is+VlpYKOTk5wt///nfp2J49ewQAQtu2bYWysjLp+PTp0wUAwpAhQxTfe/nllwtJSUlCbW2tdKxbt24CAOGTTz6RjpWXlwsdOnQQjj32WOnYsmXLBADCsmXLBEEQBJfLJfTu3VsYP3684HK5pPNqamqE7t27C2eccUaT/24AhFtuuUVx7I477hAACD///LN0rLKyUujevbuQm5srOJ1ORXt69Ogh1NTUNHmt888/XwAglJaWNnmuIAjClClTBADCI488ojh+7LHHCsOGDVMcU1+/vr5eGDhwoHDaaacpjgMQkpKShJ07d0rH1q9fLwAQXnzxRenYzJkzBQCKvhZ/h+zsbOnnvLw8weFwCI899pjivA0bNggJCQmK41OmTBG6desWxG+u5MILLxSSk5OD/ncjhBBCSPOESjdCCCGEmJq5c+fiu+++U/z3zTffKM4ZOHAgHn74Ybz22msYP348iouL8dZbbyEhwWtv63A4JMWWy+VCSUkJGhsbMXz4cKxdu9bnuhdffDGysrKkn0eOHAnA7c8l/96RI0eivr4eBw8eVHy+Y8eOOP/886WfMzMzcfXVV+PPP/9Efn6+5u+6bt067NixA1dccQWOHDkiKfuqq6tx+umn46effoLL5Qr2n05i0aJFGDFiBE466STpWHp6Om644Qbk5eVh8+bNivOnTJmC1NTUJr9XTDvNyMgIqT033nij4ucxY8Zg9+7dimPy65eWlqK8vBxjxozR7Ktx48ahZ8+e0s+DBw9GZmamz3f6u/aRI0ek3+XTTz+Fy+XCJZdcolBXtm/fHr179/ZJRw6ViooKLFy4EBMnTtTVe48QQggh0YeFFAghhBBiakaMGBFUIYW7774bCxYswOrVqzF79mz079/f55y33noLzzzzDLZu3YqGhgbpuFZ11K5duyp+FgNwXbp00TxeWlqqON6rVy+FpxoA9OnTB4DbN659+/Y+19yxYwcAd9DLH+Xl5WjVqpXf97XYu3evFDSU069fP+n9gQMHSse1/j20yMzMBABUVlYGHUBKSUlB27ZtFcdatWrl8+/39ddf49FHH8W6detQV1cnHVf/mwK+feXvO7XOFf8tS0tLkZmZiR07dkAQBPTu3Vuz/YmJiX5+s+D45JNPUFtby9RSQgghxAIw6EYIIYSQuGD37t1S0GrDhg0+77/77ruYOnUqzjvvPNx9991o164dHA4H5syZg127dvmc73A4NK/j77ggCBG03o2oYnvqqacwdOhQzXPS09Mjvk5TBKNyA4C+ffsCcP97jxkzJqjP+Pv3k/Pzzz/jnHPOwdixY/Hyyy+jQ4cOSExMxBtvvIH3338/6O/U6pOmznW5XLDZbPjmm280z4303/+9995DVlYWzj777Ii+hxBCCCGxh0E3QgghhFgel8uFqVOnIjMzE3fccQdmz56Niy66CBdccIF0zscff4wePXrg008/VailZs6caUibdu7cCUEQFNfavn07AHd1Uy3EFMnMzEyMGzdOt7Z069YN27Zt8zm+detW6f1wmDx5MubMmYN333036KBbMHzyySdISUnBkiVLkJycLB1/4403dLuGP3r27AlBENC9e3dJmagXhw8fxrJlyzB16lTF70UIIYQQc0JPN0IIIYRYnmeffRYrVqzAK6+8glmzZmH06NG46aabUFxcLJ0jqpbk6qfffvsNK1euNKRNhw4dUlQGraiowNtvv42hQ4dqppYCwLBhw9CzZ088/fTTqKqq8nm/qKgorLZMnDgRq1evVvyu1dXVeOWVV5Cbm6uZihsMo0aNwoQJE/Daa6/h888/93m/vr5es7JrUzgcDthsNjidTulYXl6e5jX05oILLoDD4cDDDz/
2024-05-08 08:26:31 +02:00
"text/plain": [
"<Figure size 1500x400 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
2024-05-15 20:20:01 +02:00
}
],
"source": [
"#Plot specific Channel of Record\n",
"fig = wfdb.plot_items(data['SB'][24].p_signal[:,0],title=\"Example for Channel 7\",figsize=(15,4),return_fig=True)"
]
},
{
"cell_type": "code",
2024-06-11 19:04:23 +02:00
"execution_count": 10,
2024-05-15 20:20:01 +02:00
"metadata": {},
"outputs": [],
"source": [
"#Find peaks in Channel 6 of Record 25\n",
"hard = wfdb.processing.find_local_peaks(data['SB'][24].p_signal[:,6],radius=3)\n",
"record = data['SB'][24].p_signal[:,6]\n",
"wholeRecord = data['SB'][24]\n",
"peak_points_y = [record[i] for i in hard] "
]
},
{
"cell_type": "code",
2024-06-11 19:04:23 +02:00
"execution_count": 11,
2024-05-15 20:20:01 +02:00
"metadata": {},
"outputs": [
2024-05-08 08:26:31 +02:00
{
"data": {
2024-05-15 20:20:01 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA2IAAAHWCAYAAAAVazrYAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAADadElEQVR4nOydd3wT9f/HX5d0t5RuCpQhG0SGIFP2tCpiRYZ83YIiiAiI4k9UtrJkOEHBhYBg3cgUBBVRUQRlqAgyC7SFltKR5HK/Py53ubvcJXdp2oy+n49HH20ul+STTz/rvRmO4zgQBEEQBEEQBEEQlYbJ3w0gCIIgCIIgCIKoapAgRhAEQRAEQRAEUcmQIEYQBEEQBEEQBFHJkCBGEARBEARBEARRyZAgRhAEQRAEQRAEUcmQIEYQBEEQBEEQBFHJkCBGEARBEARBEARRyZAgRhAEQRAEQRAEUcmQIEYQBEEQBEEQBFHJkCBGEARBVBj169fHfffd5+9mAABOnDgBhmHwzjvvVMj733fffahfv77ue+Pi4iqkHRUJwzAYN26cv5tBEAQREp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HsSGDRtw4sQJpKSk4Oabb8aiRYswcOBA3HXXXbhw4QJeffVVNGrUCAcOHNB8/06dOuGzzz5DZmYmhgwZgk8//RTh4eHo378/0tPT0bVrV9SoUQOHDx/GK6+8gptvvtnFckYQBFGVIYsYQRAEYYgFCxagV69e2LhxIyZ
2024-05-08 08:26:31 +02:00
"text/plain": [
"<Figure size 1000x500 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.figure(figsize=(10, 5))\n",
"plt.plot(record)\n",
"plt.plot(hard, peak_points_y, 'ro', label='Peaks')\n",
"plt.xlabel('Time')\n",
"plt.ylabel('Amplitude')\n",
"plt.title('Signal with Peaks')\n",
"plt.legend()\n",
"plt.grid(True)\n",
"plt.show()"
]
},
{
"cell_type": "code",
2024-06-11 19:04:23 +02:00
"execution_count": 12,
2024-05-08 08:26:31 +02:00
"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",
"[ 484 1038 1590 2131 2675 3219 3758 4300 4838]\n"
]
}
],
"source": [
2024-05-15 20:20:01 +02:00
"# Normalize data by setting qrs peaks to index position 0 (“X-axis normalization”)\n",
2024-05-08 08:26:31 +02:00
"indicies = wfdb.processing.xqrs_detect(wholeRecord.p_signal[:,6],wholeRecord.fs,0,5000)\n",
"print(indicies)"
]
},
{
"cell_type": "code",
2024-06-11 19:04:23 +02:00
"execution_count": 13,
2024-05-08 08:26:31 +02:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2024-05-15 20:20:01 +02:00
"For normalization: [0.059 0.068 0.083 ... 0.068 0.063 0.049]\n",
"After normalization: [0.27931363 0.28789323 0.30219256 ... 0.28789323 0.28312679 0.26978074]\n"
2024-05-08 08:26:31 +02:00
]
2024-05-15 20:20:01 +02:00
}
],
"source": [
"# Normalization through upper and lower bounds (“Y-axis normalization”)\n",
"print(\"For normalization: \", wholeRecord.p_signal[:,0])\n",
"wholeRecord.p_signal[:,0] = wfdb.processing.normalize_bound(wholeRecord.p_signal[:,0],0,1)\n",
"print(\"After normalization: \",wholeRecord.p_signal[:,0])\n",
"\n"
]
},
{
"cell_type": "code",
2024-06-11 19:04:23 +02:00
"execution_count": 14,
2024-05-15 20:20:01 +02:00
"metadata": {},
"outputs": [
2024-05-08 08:26:31 +02:00
{
"data": {
2024-05-15 20:20:01 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAksAAAHHCAYAAACvJxw8AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd3xT1RfAv0m69y50QFvKKqPMlr03yBJkqEz1J4iKqAiKBUSWIiII4mKpyBYEZMiUvfcutFBa2tKW7jZpkvf7ozRNOtPSNg287+eTT/tu3ns59417zz3n3HMlgiAIiIiIiIiIiIiIFIjU0AKIiIiIiIiIiFRmRGVJRERERERERKQIRGVJRERERERERKQIRGVJRERERERERKQIRGVJRERERERERKQIRGVJRERERERERKQIRGVJRERERERERKQIRGVJRERERERERKQIRGVJRERERERERKQIRGVJRESkwjh06BASiYRDhw6V2TljYmIYNGgQzs7OSCQSFi1aVGbnfhZ8fHwYNWqUZrs86g4gkUiYMGFCmZ7TkEgkEmbMmGFoMUREdBCVJRGRSsKqVauQSCSFfk6ePGloESslH3zwAXv27GHq1Kn89ttv9OjRw9AilQl3797lf//7H35+flhYWGBnZ0fr1q357rvvyMjIMLR4IiIvFCaGFkBERESXL774Al9f33zl/v7+BpCm8nPgwAH69evHRx99ZGhRyoydO3cyePBgzM3NGTFiBPXr10ehUHD06FE+/vhjrl27xk8//WRoMUVEXhhEZUlEpJLRs2dPmjVrZmgxjIbY2FgcHBzK7HyZmZmYmZkhlRrG8B4WFsbQo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iEjZIwZ4i4hUMoKCgvQK8P74449Zt24dp0+fZs6cOQQEBOTbZ/Xq1XzzzTfcvHmTrKwsTXlBs+2qVaums52jOHl7exdY/uTJE51yf39/nc4VoFatWkB2XFSVKlXy/eadO3eAbGWlMJKSknB0dCz0+4K4f/++RtnTpm7duprv69evrykv6HoUxo4dO/jyyy+5ePEicrlcU5637qXBzs4OyI7TKQl57x2Ao6Ojzj3KyMhg7ty5rFy5ksjISARB0HyXlJRU7Dlz7kHe+67Pb9+5c4fLly/j6upaoPyxsbEFlkN2DNfIkSPx9vamadOm9OrVixEjRuDn51foMSIiZY2oLImIGCn37t3TKBtXrlzJ9/3vv//OqFGj6N+/Px9//DFubm7IZDLmzp3L3bt38+0vk8kK/J3CyrU729KSYzX6+uuvadSoUYH72NjYPPPvFIe+VqUjR47Qt29f2rVrx7Jly6hatSqmpqasXLmStWvXPrMcdnZ2eHh4cPXq1RIdp889evfdd1m5ciUTJ06kZcuW2NvbI5FIGDp0aIHWO33vuz77qdVqunbtyuTJkwvcN0epLohXXnmFtm3b8tdff7F3716+/vpr5s+fz5YtW+jZs2ehx4mIlCWisiQiYoSo1WpGjRqFnZ0dEydOZM6cOQwaNIiBAwdq9tm0aRN+fn5s2bJFx+oxffr0cpEpNDQUQRB0fuv27dtA9qypgshxHdnZ2dGlS5cyk6V69ercunUrX/nNmzc135eGzZs3Y2FhwZ49ezA3N9eUr1y5snSCFkCfPn346aefOHHiBC1btiyz827atImRI0fyzTffaMoyMzNJTEwss98ojBo1apCamlrqe1y1alXGjx/P+PHjiY2NpUmTJsyePVtUlkQqDDFmSUTECFm4cCHHjx/np59+YtasWbRq1Ypx48YRFxen2SdnxK89wj916hQnTpwoF5mioqL466+/NNvJycmsWbOGRo0aFeiCA2jatCk1atRgwYIFpKam5vs
2024-05-08 08:26:31 +02:00
"text/plain": [
"<Figure size 640x480 with 12 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
2024-05-15 20:20:01 +02:00
}
],
"source": [
"wfdb.plot_wfdb(wholeRecord,title=\"Example for all Channels\")\n"
]
},
{
"cell_type": "code",
2024-06-11 19:04:23 +02:00
"execution_count": 15,
2024-05-15 20:20:01 +02:00
"metadata": {},
"outputs": [
2024-05-08 08:26:31 +02:00
{
"data": {
2024-05-15 20:20:01 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAABNEAAAGJCAYAAACkSaVDAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAADly0lEQVR4nOydd5gUVdrFT3dPzsQhM+QgUZKgoCiKqBjXvAbWrBjXxKeCEcy6a1jMGTHruiCoCIqCIBnJCEOeGSYwkUnd9f3RXdWVejpW91T1+T0PD93Voe7Mnbp173vPe16bIAgCCCGEEEIIIYQQQgghPrHHugGEEEIIIYQQQgghhDR3GEQjhBBCCCGEEEIIIcQPDKIRQgghhBBCCCGEEOIHBtEIIYQQQgghhBBCCPEDg2iEEEIIIYQQQgghhPiBQTRCCCGEEEIIIYQQQvzAIBohhBBCCCGEEEIIIX5gEI0QQgghhBBCCCGEED8wiEYIIYQQQgghhBBCiB8YRCOEEEIIiRJLliyBzWbDkiVLIvadhYWF+Nvf/oZWrVrBZrPhxRdfjNh3h8vVV1+NjIyMWDcjYlx99dXIy8uLdTMIIYQQEiMYRCOEEEJIs+Ddd9+FzWbz+e/333+PdRObJXfeeScWLlyIadOm4YMPPsDpp59u+Dlra2vxwgsvYNSoUcjOzkZKSgp69+6NqVOnYvv27Yafv7mzcuVK3HzzzRg2bBgSExNhs9li3SRCCCGERICEWDeAEEIIIUTOo48+im7dummO9+zZMwataf789NNPOOecc3D33XdH5XzFxcU4/fTTsXr1apx11lm47LLLkJGRgW3btmHu3Ll4/fXXUV9fH5W2NFfmz5+PN998E4MGDUL37t0ZWCSEEEIsAoNohBBCCGlWTJo0CcOHD491M0xDUVERcnJyIvZ9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/0+oABA6Tjer8PPbKysgAAlZWVARczSElJQZs2bRTHWrRoofn9/e9//8Pjjz+OdevWoa6uTjqu/p0C2r7y9Z167xV/l2VlZcjKysKOHTsgCAJ69eql2/7ExEQfPxkhhBBC4g0G0QghhBBiSnbt2iUFoTZu3Kh5/cMPP8TVV1+Nc889F/fccw/atm0Lh8OBWbNm4a+//tK83+Fw6J7H13FBEMJovRtRZfbMM89gyJAhuu/JyMgI+zz+CNQEv2/fvgDcv++xY8cG9Blfvz85S5cuxdlnn41x48bh1VdfRfv27ZGYmIh33nkHc+bMCfg79frE33tdLhdsNhu+++473fdG4/dPCCGEEHPAIBohhBBCTIfL5cLVV1+NrKws3HHHHZg5cyb+9re/4fzzz5fe8/nnn6N79+748ssvFWqmGTNmGNKmnTt3QhAExbm2b98OwF29Uw8xJTErKwsTJkyIWFu6du2Kbdu2aY5v3bpVej0UJk+ejFmzZuHDDz8MOIgWCF988QVSUlKwcOFCJCcnS8ffeeediJ3DFz169IAgCOjWrZukHCSEEEII0YOeaIQQQggxHc8//zyWLVuG119/HY899hjGjBmDm266CcXFxdJ7RFWRXJ20YsUKLF++3JA2HTx4UFH5sqKiAu+//z6GDBmim8oJAMOGDUOPHj3w7LPPoqqqSvP64cOHQ2rLGWecgZUrVyp+1urqarz++uvIy8vTTX0NhNGjR+P000/Hm2++ia+//lrzen19vW7lUn84HA7YbDY4nU7pWH5+vu45Is35558Ph8OBRx55RKNkEwRBt+InIYQQQuITKtEIIYQQ0qz47rvvJMWUnDFjxqB79+7YsmULHnroIVx99dWYPHkyAODdd9/FkCFDcPPNN+PTTz8FAJx11ln48ss
2024-05-08 08:26:31 +02:00
"text/plain": [
"<Figure size 1500x400 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
2024-05-15 20:20:01 +02:00
"wfdb.plot_items(data['SB'][24].p_signal[:,0],title=\"Example for Channel 1\",figsize=(15,4))"
2024-05-07 20:16:12 +02:00
]
2024-05-25 21:02:16 +02:00
},
{
"cell_type": "code",
2024-06-11 19:04:23 +02:00
"execution_count": 16,
2024-05-25 21:02:16 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-06-11 19:04:23 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd5gURfrHvz15I0vYQF6CIoiIgCAIiEpQVMRwZzoJeuipmNYzYAAxYUDlzIqiiNzJ6c87PUUEEQQURUEEJAmSwxKXzRP790fP9HSamZ6enp2Z2vfzPDx093T31NRWd9W33lAcz/M8CIIgCIIgCIIgCFOwpLoABEEQBEEQBEEQLEEiiyAIgiAIgiAIwkRIZBEEQRAEQRAEQZgIiSyCIAiCIAiCIAgTIZFFEARBEARBEARhIiSyCIIgCIIgCIIgTIREFkEQBEEQBEEQhImQyCIIgiAIgiAIgjARElkEQRAEQRAEQRAmQiKLIAgiRZSWlmLcuHGpLgYAYOfOneA4Du+9915S7j9u3DiUlpbqPjc3Nzcp5TCTpUuXguM4LF26NCn3HzJkCIYMGaL73O7duyelHA3No48+Co7jZMfS6VkhCILQA4ksgiAIk1m/fj2uvPJKtG/fHi6XC61bt8awYcPw8ssvp7poaUNtbS0effTRpAkUFtm/fz8effRRrF27NtVFkTF//nw8+uijus8fMmQIOI7T/Ld582Zd99i4cSMeffRR7Ny501ihCYIgkowt1QUgCIJgie+//x7nnnsu2rVrhwkTJqCkpAR79uzBDz/8gH/84x+4/fbbxXO3bNkCi6VxzHXNnDkTgUBA3K+trcXUqVMBQLe1prGxcOFC2f7+/fsxdepUlJaWomfPnqkplAbz58/Hq6++GpfQatOmDaZNm6Y63qpVKzz88MN44IEHol6/ceNGTJ06FUOGDNFtISUIgmhISGQRBEGYyJNPPokmTZrgp59+QkFBgeyzQ4cOy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8FxHAYOHKjrnlro/S0lJSW45pprxGN2ux133HEHqqur8e233xr+/ngoLS3FokWLZP/uu+++hO+7aNEiVFRU4JprrsGRI0fEf1arFf369cOSJUtU18SyjBIEQRiB3AUJgiBM5swzz8Qnn3wCj8eDX3/9Ff/5z3/w4osv4sorr8TatWvRrVs3zet27dqF/v37q4537txZ8/x27dqpjjVt2hTHjx8X9wOBAP7xj3/gtddew44dO2RxSc2bN4/3p4nCafny5WjTpg1++eUXPPHEEygsLMT06dPFz/Lz83H66afHff8QLpdLjNsKofxtkfjtt9/w8MMP45tvvkFlZaXssxMnTsj227Rpo4r/adq0KdatWyfu79q1C507d1ad16VLF12/ZdCgQfD5fFi5ciXatm2LQ4cOYdCgQfjtt99kIqtbt25o1qyZrntqofe3nHTSSaqsliFXu127dhn+/njIycnB0KFDTb/v77//DgA477zzND/Pz8+X7dtsNrRp08b0chAEQZDIIgiCSBIOhwNnnnkmzjzzTJx88skYP348PvroI0yZMsWU+1utVs3jvCQBxVNPPYVHHnkEN9xwAx5//HE0a9YMFosFd911lyylul5atWqFDh06YNmyZSgtLQXP8+jfvz8KCwtx5513YteuXVi+fDkGDBiQUHr6SL8tFhUVFTjnnHOQn5+Pxx57DJ06dYLL5cKaNWtw//33q36znjpMlD59+sDlcmHZsmVo164dioqKcPLJJ2PQoEF47bXX4Ha7sXz5clx22WUJfY+ZvyVS4gk9iUdSSejvO2fOHFnilRDKrIVSSy9BEISZkMgiCIJoAPr06QMAOHDgQMRz2rdvj23btqmOax3
2024-05-25 21:02:16 +02:00
"text/plain": [
"<Figure size 1000x500 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
2024-06-11 19:04:23 +02:00
"test_data = data['SB'][50].p_signal[:,0]\n",
2024-05-25 21:02:16 +02:00
"\n",
"\n",
"from scipy.signal import butter, lfilter\n",
"\n",
"def butter_lowpass(cutoff, fs, order=5):\n",
" nyq = 0.5 * fs\n",
" normal_cutoff = cutoff / nyq\n",
" b, a = butter(order, normal_cutoff, btype='low', analog=False)\n",
" return b, a\n",
"\n",
"def butter_lowpass_filter(data, cutoff, fs, order=5):\n",
" b, a = butter_lowpass(cutoff, fs, order=order)\n",
" y = lfilter(b, a, data)\n",
" return y\n",
"\n",
"# Filter requirements.\n",
"\n",
"order = 1\n",
"fs = 500.0\n",
"cutoff = 25#25\n",
"\n",
"# Get the filter coefficients so we can check its frequency response.\n",
"b, a = butter_lowpass(cutoff, fs, order)\n",
"\n",
"# Apply filter to the signal\n",
2024-06-11 19:04:23 +02:00
"filtered_signal = butter_lowpass_filter(test_data, cutoff, fs, order)\n",
2024-05-25 21:02:16 +02:00
"\n",
"# Plot the signal\n",
"plt.figure(figsize=(10, 5))\n",
"plt.plot(test_data, 'b-', label='data')\n",
2024-06-11 19:04:23 +02:00
"plt.plot(filtered_signal, 'g-', linewidth=2, label='filtered data')\n",
2024-05-25 21:02:16 +02:00
"plt.xlabel('Time')\n",
"plt.ylabel('Amplitude')\n",
2024-06-11 19:04:23 +02:00
"plt.title('Signal with and without Filter')\n",
2024-05-25 21:02:16 +02:00
"plt.legend()\n",
"plt.grid(True)\n",
"plt.show()"
]
},
{
"cell_type": "code",
2024-06-11 19:04:23 +02:00
"execution_count": 17,
2024-05-25 21:02:16 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-06-11 19:04:23 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydeXzUZP7HP5n0BspVytFyCAjKJZdcUkHlUFYFKyqeiIquioL1WnQV0RU8EXRVvPW3q+KK9VpRQAQFAXFFBTkUlaul0INCW3rNZPL7I5NMMsnMJJlMO/P0+369lE6aZJ48ffI8z/fmRFEUQRAEQRAEQRAEQTiCq7EbQBA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ZtKx49elQ5/vHHH4sAxE8//VTzjIG8++67IgDxm2++UY7Jf8O9e/eGfL6+ffuKl156qfJ58ODB4iWXXCICEHft2iWKoijm5+eLAMSff/5ZOa9r166av+37778vAhDXrl2r+46uXbvq2ldcXCwmJyeLd955Z8j2iaIoAhCvv/56saSkRCwuLha/++478ZxzzhEBiE8//bQoiqJ4zjnniP379xdra2uV67xerzhq1Cjx5JNPVo7V1taKgiBo7r93714xOTlZfPjhh5Vj8th7//33xcrKSnHMmDFiRkaG+OOPP2qubdmypXjrrbeGfQaCIIjGgtwFCYIgYoznn38eq1ev1vwXKaIo4oMPPsAFF1wAURRRWlqq/Ddx4kQcP35c52o1ffp0pKamKp9/+ukn7NmzB1dccQXKysqU60+cOIFzzjkH33zzDbxeLwRBwMqVKzFlyhR06dJFuf7UU0/FxIkTTbV3/vz5eOeddzBo0CCsXLkS999/P4YMGYLBgwdj165dQa87dOgQtm/fjmuuuQbNmzdXjo8ZMwb9+/c3vOayyy5D69atlc85OTkAJOuLjLofamtrUVpaihEjRgCALRe1nJwcrF+/HoDk+vbzzz/jxhtvREZGhnJ8/fr1aNWqFfr162f5/jJ9+vRRngcA2rVrh969e2ueLRSvvfYa2rVrh8zMTAwfPhzffvst8vLyMGfOHBw9ehRfffUVLr30UlRWVirjoaysDBMnTsSePXtQWFgIQIolk+P5BEFAWVkZmjdvjt69exv23/HjxzFhwgTs3r0b69atw8CBAzW/b9WqFb777jscOnTIZs8QBEFEF3IXJAiCiDGGDRsWNPGFXUpKSnDs2DG8/PLLePnllw3PUSeUAKDLcLhnzx4AkvAVjOPHj6Ourg41NTU4+eSTdb/v3bs3VqxYYarNl19+OS6//HJUVFTgu+++w5tvvol33nkHF1xwAX755RfDhBf79+8HAMWdTU3Pnj0NN/RqQRCAInCVl5crx44ePYr58+dj2bJlun46fvy4qedRk5OTg6VLl+L333/HH3/8AY7jMHLkSEX4mjlzJtavX48zzjgjomQjgc8GSM+nfrZQTJ48GbNmzQLHcWjRogX69u2LZs2aAZBcEUVRxAMPPIAHHnjA8Pri4mJkZWXB6/ViyZIleOGFF7B3714IgqCc07ZtW911c+bMQW1tLX788UdDt8YnnngC06dPR+fOnTFkyBBMmjQJ11xzDbp3727quQiCIKINCVkEQRBNAK/XCwC46qqrggpJcnyQjNp6o77Hk08+qbMsyDRv3hx1dXURtlZLeno6xo8fj/HjxyMxMRFvvfUWvvvuO4wZM8aR+/M8b3hcFEXl50svvRQbN27E3XffjYEDB6J58+bwer0499xzlX6xwujRowEA33zzDf78808MHjwYzZo1Q05ODp599llUVVXhxx9/xKOPPmrvoXyYebZQZGdnY9y4cYa/k5/7rrvuCmqhlIXdBQsW4IE
2024-05-25 21:02:16 +02:00
"text/plain": [
"<Figure size 1000x500 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"#Find peaks in Channel 6 of Record 25\n",
2024-06-11 19:04:23 +02:00
"hard = wfdb.processing.find_local_peaks(filtered_signal,radius=3)\n",
"record = filtered_signal\n",
2024-05-25 21:02:16 +02:00
"peak_points_y = [record[i] for i in hard] \n",
"\n",
"plt.figure(figsize=(10, 5))\n",
"plt.plot(record)\n",
"plt.plot(hard, peak_points_y, 'ro', label='Peaks')\n",
"plt.xlabel('Time')\n",
"plt.ylabel('Amplitude')\n",
"plt.title('Filtered Signal with Peaks')\n",
"plt.legend()\n",
"plt.grid(True)\n",
"plt.show()"
]
},
{
"cell_type": "code",
2024-06-11 19:04:23 +02:00
"execution_count": 18,
2024-05-25 21:02:16 +02:00
"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",
2024-06-11 19:04:23 +02:00
"[ 530 1076 1631 2174 2725 3281 3828 4378 4938]\n"
2024-05-25 21:02:16 +02:00
]
},
{
"data": {
2024-06-11 19:04:23 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAC2xElEQVR4nOzdd5hU5dk/8O/U7b3vsoVepIMgomIBRYwlpqgxMWI0iYmJb0j8JSTva03UGDWWGI0tmmKJplkQQQQFQZBelw67bO99p57fH+c8Z8rO7M7CtDPz/VyXl+zs7OyzO7PnzH3u+7lvnSRJEoiIiIiIiCgo9JFeABERERERUSxhkEVERERERBREDLKIiIiIiIiCiEEWERERERFREDHIIiIiIiIiCiIGWUREREREREHEIIuIiIiIiCiIGGQREREREREFEYMsIiIiIiKiIGKQRURENEwnTpyATqfDK6+8EumlAABeeeUV6HQ6nDhxItJLISIiMMgiIqIocvToUXzve9/DqFGjkJiYiPT0dMyfPx9PPvkk+vr6hv14GzduxL333ov29vaAv+bdd9/FggULkJ+fj+TkZIwaNQpf//rXsXLlymF/fyIiik/GSC+AiIgIAN5//3187WtfQ0JCAm666SZMnjwZVqsVGzZswF133YV9+/bh+eefH9Zjbty4Effddx9uvvlmZGZmDnn/Rx99FHfddRcWLFiA5cuXIzk5GUeOHMFHH32EN954A4sXLwYAlJeXo6+vDyaT6XR+VCIiinEMsoiIKOKOHz+O66+/HuXl5fj4449RVFSkfu6HP/whjhw5gvfffz+ka7Db7XjggQewaNEirFq1asDnGxsb1X/rdDokJiaGdD1ERKRdLBckIqKIe+SRR9Dd3Y2XXnrJI8ASxowZgzvvvBPA4PuhdDod7r33XgDAvffei7vuugsAMHLkSOh0ukH3LTU3N6OzsxPz58/3+fn8/Hz13/7W8NZbb2HSpElITEzE5MmT8e9//xs333wzKioqBnzto48+iueffx6jR49GQkICzj77bHzxxRcej7d7927cfPPNavlkYWEhbrnlFrS0tPhcIxERRQdmsoiIKOLeffddjBo1Cueee27QHvPaa6/FoUOH8Prrr+P3v/89cnNzAQB5eXk+75+fn4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Ree+01XHfddZg4cSJuuukmTJ48GVarFRs3bsRbb72Fm2++Wb3/rbfeiocffhi33norZs+ejU8//RSHDh0a8LizZs0CAPzqV7/C9ddfD5PJhCuvvFINvtz19vbi3HPPxTnnnIPFixejtLQU7e3t+M9//oP169fjmmuuwYwZM/z+DA8++CCuvvpqzJ8/H0uXLkVbWxv+8Ic/YPLkyR6BV6DS09NxwQUX4JFHHoHNZkNJSQlWrVqF48ePD/uxiIgovBhkERFRVLjqqquwe/du/O53v8N///tfPPvss0hISMDUqVPx2GOP4bbbblPve/fdd6OpqQlvv/02/vGPf+Dyyy/HBx984DEwGADOPvtsPPDAA3juueewcuVKOJ1OHD9+3GeQlZmZiRdeeAHvv/8+/vznP6O+vh4GgwHjx4/H7373O/z4xz8edP1XXnklXn/9ddx77734xS9+gbFjx+KVV17Bq6++in379p3W7+S1117Dj370IzzzzDOQJAmXXnopPvjgAxQXF5/W4xERUXjoJO86BCIiIgqa6dOnIy8vD6tXr470UoiIKEy4J4uIiCgIbDYb7Ha7x23r1q3Drl27cOGFF0ZmUUREFBHMZBEREQXBiRMnsHDhQnzzm99EcXExKisr8dxzzyEjIwN79+5FTk5OpJdIRERhwj1ZREREQZCVlYVZs2bhxRdfRFNTE1JSUnDFFVfg4YcfZoBFRBRnmMkiIiIiIiIKIu7JIiIiIiIiCiIGWUREREREREHEPVlDcDqdqK2tRVpaGnQ6XaSXQ0REREREESJJErq6ulBcXAy93n++ikHWEGpra1FaWhrpZRARERERUZSorq7GiBEj/H6eQdYQ0tLSAMi/yPT09IiuxWazYdWqVbj00kthMpkiuhYKPz7/8Y3Pf3zj8098DcQ3Pv/Ro7OzE6WlpWqM4A+DrCGIEsH09PSoCLKSk5ORnp7OP7A4xOc/vvH5j298/omvgfjG5z/6DLWNiI0viIiIiIiIgohBFhERERERURAxyCIiIiIiIgoiBllERERERERBxCCLiIiIiIgoiBhkERERERERBRGDLCIiIiIioiBikEVERERERBREDLKIiIiIiIiCiEEWERERERFREDHIIiIiIiIiCiIGWUREREREREHEIIuIiIiIiCiIGGQRERH5YHM48cO/b8efPzse6aUQEZHGMMgiIiLyYW1lI97fU4f73t0f6aUQEZHGMMgiIiIaQle/LdJLICIiDWGQRURE5INOp1P/Xd3aF8GVEBGR1jDIIiIi8qHXalf/Xd3WG8GVEBGR1jDIIiIi8qHP6lD/Xd3KIIuIiALHIIuIiMiHXrcgq6nbEsGVEBGR1jDIIiIi8qHP5gqyrHZnBFdCRERawyCLiIjIB/c9WRYGWURENAwMsoiIiHxwLxfsd8tqERERDYVBFhERkQ/ujS+YySIiouFgkEVEROSDeybLYmOQRUREgWOQRURE5INHkGVnuSAREQWOQRYREZEPfTY2viAiotPDIIuIiMiHXu7JIiKi08Qgi4iIyAePxhfsLkhERMPAIIuIiMgH9+wVhxETEdFwMMgiIiLywT2w4pwsIiIaDgZZREREPtidriCLe7KIiGg4GGQRERH5YHdI6r8ZZBER0XBoLsh65plnUFFRgcTERMydOxdbtmwJ6OveeOMN6HQ6XHPNNaFdIBERxQSbwz2TxXJBIiIKnKaCrDfffBPLli3DPffcg+3bt2PatGm47LLL0NjYOOjXnThxAj/72c9w/vnnh2mlRESkdTa3TJbNIcHhlAa5NxERkYumgqzHH38ct91
2024-05-25 21:02:16 +02:00
"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",
2024-06-11 19:04:23 +02:00
"indicies = wfdb.processing.xqrs_detect(filtered_signal,500,0,5000)\n",
2024-05-25 21:02:16 +02:00
"print(indicies)\n",
"\n",
"# detected = [ 530 1076 1631 2174 2725 3281 3828 4378 4938]\n",
2024-06-11 19:04:23 +02:00
"cut_signal = filtered_signal[indicies[0]:indicies[2]]\n",
2024-05-25 21:02:16 +02:00
"\n",
"# plot the cut signal\n",
"plt.figure(figsize=(10, 5))\n",
"plt.plot(cut_signal)\n",
"plt.xlabel('Time')\n",
"plt.ylabel('Amplitude')\n",
2024-06-11 19:04:23 +02:00
"plt.title('Cut Signal')\n",
2024-05-25 21:02:16 +02:00
"plt.grid(True)\n",
"plt.show()"
]
},
{
"cell_type": "code",
2024-06-11 19:04:23 +02:00
"execution_count": 19,
2024-05-25 21:02:16 +02:00
"metadata": {},
"outputs": [
2024-06-11 19:04:23 +02:00
{
"name": "stdout",
"output_type": "stream",
"text": [
"1076\n",
"(array([15, 46], dtype=int64),)\n",
"[[1061 1092]]\n"
]
},
2024-05-25 21:02:16 +02:00
{
"data": {
2024-06-11 19:04:23 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd5wU5f3HP9uuckeHoxwgqBRRqgUVIQpizhprNImCxkQNakISDb8kirFg7CUmRhRJESXYouFEiiAgKErv9Y6jXIO74/rW+f2x+8xO3Z2Znb3bffi+Xy9ld3Z29pnnnnme59sdgiAIIAiCIAiCIAiCIGzB2d4NIAiCIAiCIAiC4AkSsgiCIAiCIAiCIGyEhCyCIAiCIAiCIAgbISGLIAiCIAiCIAjCRkjIIgiCIAiCIAiCsBESsgiCIAiCIAiCIGyEhCyCIAiCIAiCIAgbISGLIAiCIAiCIAjCRkjIIgiCIAiCIAiCsBESsgiCIAhbKS0thcPhwLx589q7KQCAefPmweFwoLS0NCnXHzBgAKZOnWr43Kuuuiop7YjF1KlTMWDAAEvfnTVrFhwOh70NIgiC4BwSsgiCINKEAwcO4Oc//zkGDhyIrKws5Ofn46KLLsLLL7+MlpYW09dbu3YtZs2ahbq6OsPf+fTTTzFhwgT06NEDOTk5GDhwIG6++WYsXrzY9O/zys6dOzFr1qykCHUOhwMOhwM//elPNT///e9/L55z/Phx23+fIAiCMIZDEAShvRtBEARBxGbRokW46aabkJmZidtvvx3Dhw+Hz+fDmjVr8MEHH2Dq1Kl44403TF3zueeew29/+1uUlJQYsnKw8ydMmIBrr70WOTk52L9/P5YtW4YRI0aIlitBEOD1euHxeOByuSzcrb3MmzcP06ZNM3yfZvF6vXA6nfB4PACA999/HzfddBNWrFiBiRMnys4dMGAAhg8fjv/973+WfsvhcCArKwtZWVmorKxERkaG7POBAweivLwcra2tqK6uRrdu3QAAfr8foVAImZmZpn8zEAggEAggKyvLUpsJgiBORdzt3QCCIAgiNiUlJfjhD3+I/v3744svvkCvXr3Ez37xi19g//79WLRoUVLbEAgE8Pjjj2Py5MlYsmSJ6vOqqirxNRMEThWsCC6JcMUVV+CTTz7BZ599hmuvvVY8vnbtWpSUlOCGG27ABx98IPsOEwCt4Ha74XbTdoEgCMIM5C5IEASR4jzzzDNobGzEW2+9JROwGKeffjoefPBBALHjoRwOB2bNmgUgHGfz29/+FgBw2mmniS5mei5ux48fR319PS666CLNz3v06CG+1mvDwoULMWzYMGRlZWH48OH46KOPVLFC7LvPPfcc3njjDQwaNAiZmZk499xz8e2338qut3XrVkydOlV0nywoKMCdd96JEydOaLYxFp988gkcDge2bt0qHvvggw/gcDhw/fXXy84dOnQobrnlFvG9NCZr3rx5uOmmmwAA3/ve98R+Xblypewaa9aswXnnnYesrCwMHDgQ//znPw23tU+fPrjkkkswf/582fF33nkHZ599NoYPH676TiL9rBWT5XA4MH36dPFvmp2djXHjxmHbtm0AgL///e84/fTTkZWVhYkTJ6rG1erVq3HTTTehX79+yMzMRGFhIX71q1+p3F4rKiowbdo09O3bF5mZmejVqxeuvfbapMXXEQRB2AWppgiCIFKcTz/9FAMHDsSFF15o2zWvv/567N27F++++y5efPFF0a2se/fumuf36NED2dnZ+PTTT3H//fejS5cupn5v0aJFuOWWW3D22Wdj9uzZqK2txV133YU+ffponj9//nw0NDTg5z//ORwOB5555hlcf/31OHjwoGiVWbp0KQ4ePIhp06ahoKAAO3bswBtvvIEdO3bg66+/NpWs4eKLL4bD4cCqVatwzjnnAAgLAk6nE2vWrBHPq66uxu7duzF9+nTN61xyySV44IEH8Morr+D//u//MHToUAAQ/wWA/fv348Ybb8Rdd92FO+64A3PnzsXUqVMxZswYnHXWWYbae9ttt+HBBx9EY2MjOnTogEAggIULF2LGjBlobW01fN9G+lmP1atX45NPPsEvfvELAMDs2bNx1VVX4aGHHsJf//pX3HfffaitrcUzzzyDO++8E1988YX43YULF6K5uRn33nsvunbtivXr1+PVV1/FkSNHsHDhQvG8G264ATt27MD999+PAQMGoKqqCkuXLkVZWVlSXD8JgiBsQyAIgiBSlpMnTwoAhGuvvdbQ+SUlJQIA4e2331Z9BkB49NFHxffPPvusAEAoKSkxdO1HHnlEACDk5uYK3//+94Unn3xS2LBhg6E2nH322ULfvn2FhoYG8djKlSsFAEL//v1V3+3atatQU1MjHv/vf/8rABA+/fRT8Vhzc7Pqt999910BgLBq1Srx2Ntvv23oPs866yzh5ptvFt+PHj1auOmmmwQAwq5duwRBEIQPP/xQACBs2bJFPK9///7CHXfcIb5fuHChAEBYsWKF6jf69++val9VVZWQmZkp/PrXv47ZPkEI/w1/8YtfCDU1NUJGRobwr3/9SxAEQVi0aJHgcDiE0tJS4dFHHxUACNXV1eL37rjjDsv9zK6nbEdmZqasT//+978LAISCggKhvr5ePD5z5kxV/2v97WbPni04HA7h0KFDgiAIQm1trQBAePbZZ+P2C0EQRKpB7oIEQRApTH19PQAgLy+vnVsCPPbYY5g/fz5GjRqFzz//HL///e8xZswYjB49Grt27dL93rFjx7Bt2zbcfvvt6NChg3h8woQJOPvsszW/c8stt6Bz587i+/HjxwMADh48KB7Lzs4WX7e2tuL48eO44IILAAAbN240fX/jx4/H6tWrAQANDQ3YsmULfvazn6Fbt27i8dWrV6NTp06aLnlGGTZsmHg/QNh6OHjwYNm9xaNz58644oor8O677wIIW6QuvPBC9O/f31RbjPSzHpdddpnMmnT++ecDCFufpOOVHdf72zU1NeH48eO48MILIQgCNm3aJJ6TkZGBlStXora21tR9EQRBtDckZBEEQaQw+fn5AMKb/lTg1ltvxerVq1FbW4slS5bgtttuw6ZNm3D11VfruqkdOnQIQDh2TInWMQDo16+f7D0TBKSb7ZqaGjz44IPo2bMnsrOz0b17d5x22mkAgJMnT5q+t/Hjx6O8vBz79+/H2rVr4XA4MG7cOJnwtXr1alx00UVwOq0vn8p7A8L3Z1aQuO2220TXuY8//hi33XZbwm3R6mej3+3YsSMAoLCwUPO49JplZWWYOnUqunTpgg4dOqB79+6YMGECgOjfLjMzE3/+85/x2WefoWfPnrjkkkvwzDPPoKKiwswtEgRBtAskZBEEQaQw+fn56N27N7Zv327ofL04pGAwaGezkJ+fj8mTJ+Odd97BHXfcgQMHDuCbb76x7fp6qd8FSdWRm2++GXPmzME999yDDz/8EEuWLBHrdYVCIdO/efHFFwMAVq1ahdWrV2P06NHIzc0VhazGxkZs2rRJZoWygpF7M8I111yDzMxM3HHHHfB6vbj55pvbtC163413zWAwiMmTJ2PRokV4+OGH8fHHH2Pp0qViohTp3+6Xv/wl9u7di9mzZyMrKwt//OMfMXToUNHaRRAEkaqQkEUQBJHiXHXVVThw4ADWrVsX91xmiVAWGGbWJClmEkPEYuzYsQCA8vJyzc+ZC9v+/ftVn2kdM0JtbS2WL1+O3/3ud3jsscfwgx/8AJMnT8bAgQMtXQ8IW2b69euH1atXY/Xq1aIwdckll6C0tBQLFy5EMBjEJZdcEvM6dvVrPLKzs3Hddddh5cqVmDx5spi8JNXZtm0b9u7di+effx4PP/wwrr32WkyaNAm9e/fWPH/QoEH49a9/jSVLlmD79u3w+Xx4/vnn27jVBEEQ5iAhiyAIIsV56KGHkJubi5/+9KeorKxUfX7gwAG8/PLLAMIWpm7dumHVqlWyc/7617+qvpebmwtALZBp0dzcrCvkffbZZwCAwYMHa37eu3dvDB8+HP/85z/R2NgoHv/yyy/FlN9mYdYSpcXlpZd
"text/plain": [
"<Figure size 1000x500 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import numpy as np\n",
"# get the local minimas around the peaks\n",
"peak = indicies[1]\n",
"print(peak)\n",
"start_idx = 30\n",
"end_idx = 30\n",
"signal_section = filtered_signal[peak-start_idx:peak+end_idx]\n",
"minimas = scipy.signal.argrelextrema(signal_section, comparator=np.less, order=5)\n",
"print(minimas)\n",
"# map the minimas to the original signal\n",
"minimas = minimas + peak - start_idx\n",
"print(minimas)\n",
"minimas_y = [filtered_signal[i] for i in minimas]\n",
"\n",
"# plot the cut signal with the minimas\n",
"plt.figure(figsize=(10, 5))\n",
"plt.plot(filtered_signal)\n",
"plt.plot(minimas, minimas_y, 'ro', label='Minimas')\n",
"plt.xlabel('Time')\n",
"plt.ylabel('Amplitude')\n",
"plt.title('Cut Signal with Minimas')\n",
"plt.legend()\n",
"plt.grid(True)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd5wU5f3HP9tur9PhACmCCiJSBFFQBBVEz1hijSY/BUtiQU1IoiGJgjGKsZeYGFEkJqIGWzQgUgQBQVF6r3cc5RrluL51fn/sPrNTd2dmZ+92H77v10vZnZ2dfea5Z57n+XaHIAgCCIIgCIIgCIIgCFtwtnYDCIIgCIIgCIIgeIKELIIgCIIgCIIgCBshIYsgCIIgCIIgCMJGSMgiCIIgCIIgCIKwERKyCIIgCIIgCIIgbISELIIgCIIgCIIgCBshIYsgCIIgCIIgCMJGSMgiCIIgCIIgCIKwERKyCIIgCIIgCIIgbISELIIgCMJWSktL4XA4MHv27NZuCgBg9uzZcDgcKC0tTcn1e/fujYkTJxo+90c/+lFK2hGPiRMnonfv3pa+O336dDgcDnsbRBAEwTkkZBEEQWQIe/fu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v2icdycnLE183NzThy5AjOP/98AMC6detM39/o0aOxYsUKAEBdXR02btyIn//85+jYsaN4fMWKFWjbtq2mS55RBgwYIN4PELEe9uvXT3ZviWjXrh0uv/xyvPfeewAiFqlRo0ahV69eptpipJ/1uPTSS2XWpPPOOw9AxPokHa/suN7frqGhAUeOHMGoUaMgCALWr18vnpOVlYVly5bh+PHjpu6LIAiitSEhiyAIIo0pLCwEENn0pwO33HILVqxYgePHj2PhwoW49dZbsX79elx11VW6bmr79+8HEIkdU6J1DAB69uwpe88EAelm+9ixY3jooYfQpUsX5OTkoFOnTjj11FMBACdOnDB9b6NHj0Z5eTn27NmDVatWweFwYOTIkTLha8WKFbjgggvgdFpfPpX3BkTuz6wgceutt4quc59++iluvfXWpNui1c9Gv9umTRsAQI8ePTSPS69ZVlaGiRMnon379sjPz0enTp0wZswYALG/ndfrxV/+8hd88cUX6NKlCy666CI888wzqKioMHOLBEEQrQIJWQRBEGlMYWEhunXrhi1bthg6Xy8OKRQK2dksFBYWYvz48Xj33Xdx++23Y+/evfjuu+9su75e6ndBUnXkpptuwsyZM3HPPffg448/xsKFC8V6XeFw2PRvXnjhhQCA5cuXY8WKFTjnnHOQl5cnCln19fVYv369zAplBSP3ZoSrr74aXq8Xt99+O3w+H2666aYWbYvedxNdMxQKYfz48Zg3bx4eeeQRfPrpp1i0aJGYKEX6t/vlL3+JXbt2YcaMGcjOzsajjz6KM888U7R2EQRBpCskZBEEQaQ5P/rRj7B3716sXr064bnMEqEsMMysSVLMJIaIx/DhwwEA5eXlmp8zF7Y9e/aoPtM6ZoTjx49jyZIl+N3vfofHH38cP/7xjzF+/Hj06dPH0vWAiGWmZ8+eWLFiBVasWCEKUxdddBFKS0sxd+5chEIhXHTRRXGvY1e/JiInJwfXXnstli1bhvHjx4vJS9KdzZs3Y9euXXj++efxyCOP4JprrsG4cePQrVs3zfP79u2LX//611i4cCG2bNkCv9+P559/voVbTRAEYQ4SsgiCINKchx9+GHl5ebjrrrtQWVmp+nzv3r14+eWXAUQsTB07dsTy5ctl5/ztb39TfS8vLw+AWiDTorGxUVfI++KLLwAA/fr10/y8W7duGDhwIN555x3U19eLx7/++msx5bdZmLVEaXF56aWXLF2
2024-05-25 21:02:16 +02:00
"text/plain": [
"<Figure size 1000x500 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
2024-06-11 19:04:23 +02:00
"[-0.027759944001706754, -0.042024054853653535]\n"
2024-05-25 21:02:16 +02:00
]
}
],
"source": [
"plt.figure(figsize=(10, 5))\n",
2024-06-11 19:04:23 +02:00
"plt.plot(filtered_signal)\n",
2024-05-25 21:02:16 +02:00
"plt.xlabel('Time')\n",
"plt.ylabel('Amplitude')\n",
2024-06-11 19:04:23 +02:00
"plt.title('Cut Signal with Minimas')\n",
2024-05-25 21:02:16 +02:00
"plt.grid(True)\n",
"\n",
"for peak in indicies:\n",
" start_idx = 20\n",
" end_idx = 25\n",
2024-06-11 19:04:23 +02:00
" signal_section = filtered_signal[peak-start_idx:peak+end_idx]\n",
2024-05-25 21:02:16 +02:00
" minimas = scipy.signal.argrelextrema(signal_section, comparator=np.less, order=5)\n",
" \n",
" # map the minimas to the original signal\n",
" minimas = minimas[0] + peak - start_idx\n",
2024-06-11 19:04:23 +02:00
" minimas_y = [filtered_signal[i] for i in minimas]\n",
2024-05-25 21:02:16 +02:00
" # if minimas more than 2 take those with biggest difference in y\n",
" if len(minimas) > 2:\n",
2024-06-11 19:04:23 +02:00
" minimas_y = [filtered_signal[i] for i in minimas]\n",
2024-05-25 21:02:16 +02:00
" minimas_y = sorted(minimas_y)\n",
" minimas_y = minimas_y[:2]\n",
" minimas = [minimas[i] for i in range(0,2)]\n",
"\n",
" # plot the minimas\n",
" plt.plot(minimas, minimas_y, 'ro')\n",
"\n",
"plt.legend(['Signal', 'Minimas'])\n",
"plt.show()\n",
"\n",
"#print y values of minimas\n",
"print(minimas_y)"
]
},
{
"cell_type": "code",
2024-06-11 19:04:23 +02:00
"execution_count": 21,
2024-05-25 21:02:16 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-06-11 19:04:23 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAADGGElEQVR4nOzdd5hU5dkG8PtM2d5736UX6SBIR6UoNiTYDYo1KkZDNIr5oqKJGitqjMSuiaJCsAVEEEFAEJTelrqU7b3vTj3fH2fOmZnd2d1ZmD7377q8ZGenvFP2nHne53mfVxBFUQQRERERERG5hMrbAyAiIiIiIgokDLKIiIiIiIhciEEWERERERGRCzHIIiIiIiIiciEGWURERERERC7EIIuIiIiIiMiFGGQRERERERG5EIMsIiIiIiIiF2KQRURERERE5EIMsoiIyCtOnjwJQRDwwQcfeHsoAIAPPvgAgiDg5MmTbrn/vLw83HrrrU5f9/LLL3fLONxlw4YNEAQBy5cv9/ZQiIi8jkEWEVGAOX78OO6++2707NkTYWFhiImJwfjx4/Hqq6+ipaWl2/e3ZcsWPPnkk6itrXX6Nt988w0mT56MlJQUREREoGfPnrj22muxevXqbj9+oDp48CCefPJJtwR1giAo/6lUKmRkZGD69OnYsGGDyx+LiIja03h7AERE5DorV67ENddcg9DQUMydOxeDBg2CXq/H5s2b8fDDD+PAgQN46623unWfW7ZswaJFi3DrrbciLi6uy+u/+OKLePjhhzF58mQsXLgQEREROHbsGL7//nt8+umnuOSSSwAAubm5aGlpgVarPZun6ncOHz4Mlco6t3nw4EEsWrQIU6ZMQV5enssfb9q0aZg7dy5EUURBQQH++c9/4qKLLsLKlStx6aWXuvzxiIjIikEWEVGAKCgowPXXX4/c3Fz88MMPSE9PV35333334dixY1i5cqVbx2A0GvH0009j2rRpWLNmTbvfl5eXK/8WBAFhYWFuHY8vCQ0N9ejj9e3bFzfff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/fqet3tA7JZDK5cliIiYnBtGnTMG3aNGi1Wnz44YfYtm0bJk+e7JL7V6vVDi8XRVH597XXXostW7bg4YcfxrBhwxAVFQWz2YxLLrkEZrO52485YcIEAMDGjRtx4sQJjBgxApGRkZg4cSJee+01NDY2YteuXfjb3/52dk/Kwpnn1pmsrCxMnTrV4e/k5/3QQw9hxowZDq8jB7bPPPMM/vKXv+C2227D008/jYSEBKhUKjz44IMOX7+rrroKn376KZ577jl89NFH7QLNa6+9FhMnTsQXX3yBNWvW4IUXXsDf//53rFixgl0PiShgMMgiIgoQl19+Od566y1s3boVY8eO7fS6csan7QbDcjbJVncaQ3Rm1KhR+PDDD1FSUuLw97m5uQCkhg9tObrMGTU1NVi3bh0WLVqExx9/XLn86NGjZ3V/gJRhysnJwaZNm3DixAmlpG/SpElYsGABli1bBpPJhEmTJnV6P656Xc9Gz549AQBarbbDQEy2fPlyXHjhhXj33XftLq+trVUaodiaNWsWpk+fjltvvRXR0dF48803210nPT0d9957L+69916Ul5djxIgR+Nvf/sYgi4gCBssFiYgCxJ/+9CdERkbijjvuQFlZWbvfHz9+HK+++ioAKcOUlJSEjRs32l3nn//8Z7vbRUZGAmgfkDnS3NyMrVu3Ovzdt99+CwDo16+fw99nZGRg0KBB+Oijj9DY2Khc/uOPP2Lfvn1dPrYjcjaobfZn8eLFZ3V/sokTJ+KHH37A9u3blSBr2LBhiI6OxnPPPYfw8HCMHDmy0/vozuv
2024-05-25 21:02:16 +02:00
"text/plain": [
"<Figure size 1000x500 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# find peaks in the cut signal\n",
"hard = wfdb.processing.find_local_peaks(cut_signal,radius=3)\n",
"#peak_points_y = [cut_signal[i] for i in hard]\n",
"\n",
"tolerance = 1\n",
"# get standard deviation of the hard peaks\n",
"std = cut_signal[hard].std() * tolerance\n",
"# filter peaks with std\n",
"hard = [i for i in hard if cut_signal[i] > std]\n",
"# get the y values of the peaks\n",
"peak_points_y = [cut_signal[i] for i in hard]\n",
"\n",
"plt.figure(figsize=(10, 5))\n",
"plt.plot(cut_signal)\n",
"plt.plot(hard, peak_points_y, 'ro', label='Peaks')\n",
"plt.xlabel('Time')\n",
"plt.ylabel('Amplitude')\n",
2024-06-11 19:04:23 +02:00
"plt.title('Cut Signal with Peaks')\n",
2024-05-30 10:13:20 +02:00
"plt.legend()\n",
"plt.grid(True)\n",
"plt.show()"
]
2024-05-01 12:53:33 +02:00
}
],
"metadata": {
2024-05-07 20:16:12 +02:00
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
2024-05-01 12:53:33 +02:00
"language_info": {
2024-05-07 20:16:12 +02:00
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
2024-05-12 13:31:54 +02:00
"version": "3.10.4"
2024-05-01 12:53:33 +02:00
}
},
"nbformat": 4,
"nbformat_minor": 2
}