DSA_SS24/notebooks/signal_processing.ipynb

777 lines
1.3 MiB
Plaintext
Raw 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-05-30 10:13:20 +02:00
"execution_count": 36,
2024-05-15 20:20:01 +02:00
"metadata": {},
"outputs": [],
"source": [
"import pickle\n",
"from matplotlib import pyplot as plt\n",
2024-05-25 21:02:16 +02:00
"import wfdb.processing\n",
"import scipy.signal"
2024-05-15 20:20:01 +02:00
]
},
2024-05-01 12:53:33 +02:00
{
"cell_type": "code",
2024-05-30 10:13:20 +02:00
"execution_count": 37,
2024-05-15 20:20:01 +02:00
"metadata": {},
"outputs": [],
"source": [
"path = \"C:/Studium/dsa/data\"\n",
"#path = \"C:/Users/Nils/Documents/HS-Mannheim/0000_MASTER/DSA/EKG_Prog/data\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Load Data"
]
},
{
"cell_type": "code",
2024-05-30 10:13:20 +02:00
"execution_count": 38,
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 SB\n",
2024-05-15 20:20:01 +02:00
"Length of SB: 16559\n",
2024-05-07 20:16:12 +02:00
"Reading AFIB\n",
2024-05-15 20:20:01 +02:00
"Length of AFIB: 9839\n",
2024-05-07 20:16:12 +02:00
"Reading GSVT\n",
2024-05-15 20:20:01 +02:00
"Length of GSVT: 948\n",
2024-05-07 20:16:12 +02:00
"Reading SR\n",
2024-05-15 20:20:01 +02:00
"Length of SR: 9720\n"
2024-05-07 20:16:12 +02:00
]
}
],
2024-05-01 12:53:33 +02:00
"source": [
2024-05-15 20:20:01 +02:00
"\n",
2024-05-01 12:53:33 +02:00
"# read pickle files and check len and print first record and first record keys\n",
"\n",
2024-05-15 20:20:01 +02:00
"\n",
2024-05-01 12:53:33 +02:00
"\n",
2024-05-07 20:16:12 +02:00
"categories_dict = {\n",
2024-05-01 12:53:33 +02:00
"'SB': [426177001],\n",
"'AFIB': [164889003, 164890007],\n",
"'GSVT': [426761007, 713422000, 233896004, 233897008, 713422000],\n",
"'SR': [426783006, 427393009]\n",
"}\n",
"\n",
"\n",
"data = {}\n",
2024-05-07 20:16:12 +02:00
"for cat_name in categories_dict.keys():\n",
2024-05-01 12:53:33 +02:00
" print(f\"Reading {cat_name}\")\n",
2024-05-07 20:16:12 +02:00
" with open(f'{path}/{cat_name}.pkl', 'rb') as f:\n",
2024-05-01 12:53:33 +02:00
" records = pickle.load(f)\n",
" data[cat_name] = records\n",
" print(f\"Length of {cat_name}: {len(records)}\")"
]
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-05-30 10:13:20 +02:00
"execution_count": 39,
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-05-30 10:13:20 +02:00
"execution_count": 40,
2024-05-15 20:20:01 +02:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Number of records with p_signal: 9720\n",
"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-05-30 10:13:20 +02:00
"execution_count": 41,
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+kp6cbWjwRkZcKE0MLICIioss333yDj49PnnI/Pz8DSFPxOXToEH379uXzzz83tCilxs6dOxk4cCDm5uYMGTKEevXqoVAoOH78OOPHj+fGjRv8+uuvhhZTROSlQVSWREQqGD169KBp06aGFsNoiImJwcHBodTOl5GRgZmZGVKpYQzvISEhvPHGG1SrVo1Dhw5RuXJlzXcffvghwcHB7Ny50yCyiYi8rIhuOBERI2Pq1KlIpVIOHjyoU/7+++9jZmbGlStXAFAoFEyZMoUmTZpgb2+PtbU1bdq04fDhwzrHhYaGIpFImDdvHosXL8bX1xcrKyu6du1KWFgYgiAwY8YMqlSpgqWlJX379iU+Pl7nHN7e3vTu3Zt9+/bRsGFDLCws8Pf3Z8uWLXrV6cyZM3Tv3h17e3usrKxo164dJ06cKPSYbLelIAgsXrxY467M5sGDBwwcOBAnJyesrKxo3rx5HiUjO45o3bp1TJ48GU9PT6ysrEhKSirwd+fNm0fLli1xdnbG0tKSJk2asGnTJr3qqQ/fffcdKSkp/PHHHzqKUjZ+fn588sknecq3bt1KvXr1MDc3p27duuzZs0fn+4cPHzJ69Ghq1aqFpaU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mz57N/fv38+wvk8ny/Z2CyrU725KSbTX6/vvvadiwYb772NjYPPfvFIW+VqVjx47Rp08f2rZty5IlS6hcuTKmpqasWLGCtWvXPrccdnZ2eHh4cP369WIdp889+uijj1ixYgVjx46lRYsW2NvbI5FIeOONN/K13ul73/XZT61W06VLFyZMmJDvvtlKdX68/vrrtGnThn/++Yd9+/bx/fffM3fuXLZs2UKPHj0KPE5EpDQRlSURESNErVYzbNgw7OzsGDt2LLNmzWLAgAH0799fs8+mTZvw9fVly5YtOlaPqVOnlolMwcHBCIKg81t3794FsmZN5Ue268jOzo7OnTuXmizVqlXjzp07ecpv376t+b4kbN68GQsLC/bu3Yu5ubmmfMWKFSUTNB969+7Nr7/+yqlTp2jRokWpnXfTpk0MHTqUH374QVOWkZFBQkJCqf1GQVSvXp2UlJQS3+PKlSszevRoRo8eTUxMDI0bN2bmzJmisiRSbogxSyIiRsj8+fM5efIkv/76KzNmzKBly5aMGjWK2NhYzT7ZI37tEf6ZM2c4depUmcgUERHBP//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-05-30 10:13:20 +02:00
"execution_count": 42,
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+dUXNAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAADoxklEQVR4nOydd5wT1frGnyRb2QYssHSWK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7bXX+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/XwAgl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mm280z4303/+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-05-30 10:13:20 +02:00
"execution_count": 43,
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-05-30 10:13:20 +02:00
"execution_count": 44,
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": "iVBORw0KGgoAAAANSUhEUgAAA2IAAAHWCAYAAAAVazrYAAAAOXRFWHRTb2Z0d2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X/yxEEQYQAFCNGEARBGGLHjh0yi5TAxo0bAQBNmzbVfO2AAQOwZ88e7N+/X7yWn5+P1atXe90es9ns0p7169fjzJkzXr9nt27dcOLECaxbt050VTSZTOjSpQsWLVoEq9XqMT4sJiYGAC8Q+oOhQ4diz5492Lx5s8tzly9fhs1mA8D3H8MwMpfOEydO4NNPP9V871atWmHjxo04fPgwbr31VpSUlIjP5eXlye6NiIhAixYtwHEcrFZrOb8VQRBE6EAWMYIgCMIQjz32GIqLi3H77bejWbNmsFgs+OGHH7Bu3TrUr18f999/v+Zrp0yZgg8++AD9+vXDY489htjYWLz11luoW7cu8vPzvbIi3XLLLZgxYwbuv/9+dOnSBQcPHsTq1avRoEEDr7+jIGQdPXoUc+bMEa93794dX3/9NSIjI3HDDTe4fY/o6Gi0aNEC69atQ5MmTZCUlISWLVuiZcuWXrfLCE8++SQ+//xz3HLLLbjvvvvQrl07XL16FQcPHsSGDRtw4sQJpKSk4Oabb8aiRYswcOBA3HXXXbhw4QJeffVVNGrUCAcOHNB8/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-05-30 10:13:20 +02:00
"execution_count": 45,
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-05-30 10:13:20 +02:00
"execution_count": 46,
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-05-30 10:13:20 +02:00
"execution_count": 47,
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//WRoMUVEXhhEZUlEpJLRs2dPmjVrZmgxjIbY2FgcHBzK7HyZmZmYmZkhlRrG8B4WFsbQoUOpXr06Bw4coGrVqprv3nnnHUJDQ9m5c6dBZBMReVER3XAiIkbG9OnTkUql7N+/X6f8rbfewszMjEuXLgGgUCgICQmhadOm2NvbY21tTdu2bTl48KDOceHh4UgkEhYsWMDSpUvx8/PDysqKbt26ERERgSAIzJo1Cy8vLywtLenXrx8JCQk65/Dx8aFPnz7s3buXRo0aYWFhQUBAAFu2bNGrTqdOnaJHjx7Y29tjZWVF+/btOXbsWJHH5LgtBUFg6dKlGndlDvfu3WPw4ME4OTlhZWVFixYt8ikZOXFE69atY9q0aXh6emJlZUVycnKhv7tgwQJatWqFs7MzlpaWNG3alE2bNulVT3346quvSE1N5ddff9VRlHLw9/fn/fffz1e+detW6tevj7m5OfXq1WP37t0639+/f5/x48dTu3ZtLC0tcXZ2ZvDgwYSHh+vsl3Ndjx07xqRJk3B1dcXa2poBAwbw+PFjnX1z7vvRo0cJCgrCwsICPz8/1qxZk0++xMREJk6ciLe3N+bm5vj7+zN//nzUanWR1yMlJYWJEyfi4+ODubk5bm5udO3alfPnzxd5nIhImSKIiIhUClauXCk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+/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-05-30 10:13:20 +02:00
"execution_count": 48,
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+T0PD93Voe7Mnbp173vPe16bIAgCCCGEEEIIIYQQQgghPrHHugGEEEIIIYQQQgghhDR3GEQjhBBCCCGEEEIIIcQPDKIRQgghhBBCCCGEEOIHBtEIIYQQQgghhBBCCPEDg2iEEEIIIYQ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GjBmDm266CcXFxdJ7RFWRXJ20YsUKLF++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-05-30 10:13:20 +02:00
"execution_count": 92,
2024-05-25 21:02:16 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-05-30 10:13:20 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd3gU1frHv7ubzaZXUiCUQJDepEoJHaIoCCoq+pMqKoqoUVSuV4qoIE3EgkoRxXrxKnoRqYKAICAdqdJbKIH0sm1+f8zu7LRNdncm2dnk/TxPnuz0s2fPnHPe8zYdwzAMCIIgCIIgCIIgCFXQ+7sABEEQBEEQBEEQVQkSsgiCIAiCIAiCIFSEhCyCIAiCIAiCIAgVISGLIAiCIAiCIAhCRUjIIgiCIAiCIAiCUBESsgiCIAiCIAiCIFSEhCyCIAiCIAiCIAgVISGLIAiCIAiCIAhCRUj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qSlPebb76RtNXo6GjmmWeecfsd9+3bxwBgVqxY4VGd8HH+rtevXxfs79Gjh+A3lGvzzzzzjGyb2Lp1KwOA+eqrrwT716xZI9nvbH9r1qzxqLxydTZjxgxGp9Mx586d4/Z5+l6sXLmSAcDMmjWL22e1Wpn09PSAe8ed3+XNN98UnPfAAw8wOp2O+eeffxiGKbv/Epdh9uzZkve7LJxlFf8525JcfyFua7t375Ytn91uZ2677TYmIyODsdvt3P6ioiKmfv36TL9+/bh9znY9bNgwj8p
2024-05-25 21:02:16 +02:00
"text/plain": [
"<Figure size 1000x500 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
2024-05-30 10:13:20 +02:00
"test_data = data['SB'][0].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-05-30 10:13:20 +02:00
"butter_filtered_sig = 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-05-30 10:13:20 +02:00
"plt.plot(butter_filtered_sig, 'g-', linewidth=2, label='filtered data')\n",
2024-05-25 21:02:16 +02:00
"plt.xlabel('Time')\n",
"plt.ylabel('Amplitude')\n",
2024-05-30 10:13:20 +02:00
"plt.title('Signal with butter lowpass filter 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-05-30 10:13:20 +02:00
"execution_count": 50,
2024-05-25 21:02:16 +02:00
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydeXzUZP7HP5n0BspVytFyCAjKJZdcUkHlUFYFKyqeiIquioL1WnQV0RU8EXRVvPW3q+KK9VpRQAQFAXFFBTkUlaul0INCW3rNZPL7I5NMMsnMJJlMO/P0+369lE6aZJ48ffI8z/fmRFEUQRAEQRAEQRAEQTiCq7EbQBAEQRAEQRAEwRIkZBEEQRAEQRAEQTgICVkEQRAEQRAEQRAOQkIWQRAEQRAEQRCEg5CQRRAEQRAEQRAE4SAkZBEEQRAEQRAEQTgICVkEQRAEQRAEQRAOQkIWQRAEQRAEQRCEg5CQRRAEQRAEQRAE4SAkZBEEQcQJ+/btA8dxePPNN5VjDz30EDiOa7xGWcTp9hr1SWPy5ptvguM47Nu3Lyr379atG6699lrT555//vlRaUe0WLduHTiOw/Llyxu7KQRBEBFBQhZBEESMIG/Qjf7729/+Zvo+CxYswEcffRS9hjYQn376KcaMGYPMzEykpaWhe/fuuPTSS/HFF180dtNihp07d+Khhx6KilCnHn8ulwudOnXChAkTsG7dOse/iyAIgjUSGrsBBEEQhJaHH34YJ510kuZYv3790LVrV9TU1CAxMTHk9QsWLMDUqVMxZcqUKLYyujz11FO4++67MWbMGMydOxdpaWn4/fff8eWXX2LZsmU499xzAcB0n7DCr7/+CpfLrx/duXMn5s+fj7Fjx6Jbt26Of9/48eNxzTXXQBRF7N27Fy+88ALOPvtsfPbZZzjvvPMc/z6CIAhWICGLIAgixjjvvPMwdOhQw9+lpKQ0cGskamtrkZSUpNngRwuPx4NHHnkE48ePx6pVq3S/Ly4uVn7mOK7R+qQxSE5ObtDv69WrF6666irl80UXXYQBAwZg8eLFJGQRBEGEgNwFCYIg4gQz8Uccx+HEiRN46623FFcvdQxPYWEhrrvuOrRv3x7Jycno27cvXn/9dc095LiYZcuW4e9//zuysrKQlpaGiooKAMB3332Hc889Fy1btkRaWhrGjBmDb7/9VteWDRs24PTTT0dKSgp69OiBl156ydRzlpaWoqKiAmeccYbh7zMzM8P2yfvvv48+ffogJSUF/fr1w4cffohrr71WY+2Rr33qqafw8ssvo0ePHkhOTsbpp5+O77//XnO/bdu24dprr0X37t2RkpKCDh064LrrrkNZWZmpZ1LzySefgOM4bNu2TTn2wQcfgOM45Obmas499dRTcdlllymf1TFZb775Ji655BIAwFlnnaX8vQPd+TZs2IBhw4YhJSUF3bt3x//93/9ZbrNM//79kZGRgb179yrHdu/ejalTp6JNmzZISUnB0KFD8cknn2iuO3r0KO666y70798fzZs3R3p6Os477zz8/PPPYb+zrq4O559/Plq2bImNGzcCACorKzFnzhx069YNycnJyMzMxPjx47F161bbz0YQBOEkZMkiCIKIMY4fP47S0lLNsYyMDFPX/utf/8INN9yAYcOG4cYbbwQA9OjRAwBw5MgRjBgxAhzHYdasWWjXrh0+//xzXH/99aioqMCcOXM093rkkUeQlJSEu+66C3V1dUhKSsJXX32F8847D0OGDMG8efPgcrnwxhtv4Oyzz8b69esxbNgwAMD27dsxYcIEtGvXDg899BA8Hg/mzZuH9u3bh32GzMxMpKam4tNPP8Vtt92GNm3amHp2mc8++wyXXXYZ+vfvj4ULF6K8vBzXX389srKyDM9/5513UFlZiZtuugkcx+GJJ55Abm4u/vzzT8UNcfXq1fjzzz8xY8YMdOjQATt27MDLL7+MHTt2YPPmzZaSeYwePRocx+Gbb77BgAEDAADr16+Hy+XChg0blPNKSkqwe/duzJo1y/A+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OuLjLofamtrUVpaihEjRgCALRe1nJwcrF+/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
"text/plain": [
"<Figure size 1000x500 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"#Find peaks in Channel 6 of Record 25\n",
2024-05-30 10:13:20 +02:00
"hard = wfdb.processing.find_local_peaks(butter_filtered_sig,radius=3)\n",
"record = butter_filtered_sig\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-05-30 10:13:20 +02:00
"execution_count": 74,
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",
"[ 530 1076 1631 2174 2725 3281 3828 4378 4938]\n"
]
},
{
"data": {
2024-05-30 10:13:20 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAADLOUlEQVR4nOzdd3hUZdoG8HtaJr33EBJ6h9ClK12wsOraF0FFV0VdcXWX9VsVe0XsrAV77w0RRKogSK+hJgTSe8/U8/1x5pyZSWaSCUzJZO7fdXlJJpOZN3Mm58zzPs/7vApBEAQQERERERGRWyh9PQAiIiIiIqLOhEEWERERERGRGzHIIiIiIiIiciMGWURERERERG7EIIuIiIiIiMiNGGQRERERERG5EYMsIiIiIiIiN2KQRURERERE5EYMsoiIiIiIiNyIQRYRdUq5ublQKBR49913fT0UAMC7774LhUKB3NzcVu83b948hIeHe2dQbqRQKPDwww/7ehhEZPHwww9DoVD4ehhEAYtBFhG1y4kTJ3Drrbeie/fuCA4ORmRkJMaNG4cXX3wRjY2N7X68LVu24OGHH0ZVVZXLP/PDDz9g0qRJSExMRGhoKLp3744rr7wSq1atavfzU+ezfv16KB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Skpy+vyCIOCSSy7BunXrcNNNNyErKwu//PIL7rvvPuTn5+OFF16wu//mzZvx9ddf4/bbb0dERAReeuklXH755cjLy0NcXBwAoLi4GOedd54clCUkJODnn3/GTTfdhJqaGvzjH/9wOp6ff/4ZJpMJc+fOdXqfuXPnYt26dVi1ahVuuukmp/czGo04c+ZMi+ObkZGBX3/9Fb/99hsmT57s9Oed2bdvHyZMmACNRoNbbrkFmZmZOHHiBH744Qc8/vjjAMS/swkTJiAyMhL3338/NBoN/ve//+H888/Hhg0bMHr0aLvHvPPOO5GcnIwlS5bgjz/+wBtvvIHo6Ghs2bIFXbt2xRNPPIGVK1fi2WefxcCBA1u8Pu+//z5qa2txxx13oKmpCS+++CImT56M/fv3t3r8H3/8cfz3v//FlVdeiZtvvhmlpaV4+eWXMXHiROzevRvR0dGYP38+vv76ayxatAjTpk1Deno69u/fjyVLluCmm27CrFmz2v0aEgUkgYioDdXV1QIA4dJLL3Xp/jk5OQIA4Z133mnxPQDCQw89JH/97LPPCgCEnJwclx77wQcfFAAIYWFhwoUXXig8/vjjws6dO10aw6BBg4QuXboItbW18m3r168XAAgZGRktfjYuLk6oqKiQb//uu+8EAMIPP/wg39bQ0NDiuT/55BMBgLBx40b5tnfeecel3/OGG24QAAh33nmnfJvZbBZmz54tBAUFCaWlpU6fW6/XCwMHDhQmT54s3/bCCy8IAOx+rrkPPvhAUCqVwqZNm+xuX758uQBA+P333wVBEIQ9e/YIAITbb7/d7n7XXntti+PqyLJlywQAwocffmg35jFjxgjh4eFCTU2NIAjte/0dWbdunQBAWLFihVBaWioUFBQIq1atEnr27CkoFAph+/btrf68IDh/X0qvwc0332x3+z//+U8BgPDbb7+1+riuvgc3bdokABA++ugju59ftWpVi9sHDBggTJo0qc3fSRAE4dtvvxUACI899pjd7VdccYWgUCiE48ePy7cBEIKCguxu27t3rwBAePnll+XbbrrpJiElJUUoKyuze8yrr75aiIqKcvg3IvnHP/4hABB2797t9D67du0SAAiLFi2Sb8vIyBCmT58ulJaWCqWlpcL+/fuFv/3tbwIA4Y477rD7+QMHDgghISECACErK0u4++6
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-05-30 10:13:20 +02:00
"indicies = wfdb.processing.xqrs_detect(butter_filtered_sig,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-05-30 10:13:20 +02:00
"cut_signal = butter_filtered_sig[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-05-30 10:13:20 +02:00
"plt.title('Cut Signal based on R to get one QRS complex')\n",
2024-05-25 21:02:16 +02:00
"plt.grid(True)\n",
"plt.show()"
]
},
{
"cell_type": "code",
2024-05-30 10:13:20 +02:00
"execution_count": 73,
2024-05-25 21:02:16 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-05-30 10:13:20 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd5wU5f3HP9tur9PhAClSQhEpgigKggqiZ8MGavITsBfUBI2GWJAowVhRozGixAoqFqLxQI4mVUB6r3cccB04rm+d3x97Mzttd2dmZ+92H77v10vZnZ2dfea5Z57n+XYLx3EcCIIgCIIgCIIgCFOwNnUDCIIgCIIgCIIgWIKELIIgCIIgCIIgCBMhIYsgCIIgCIIgCMJESMgiCIIgCIIgCIIwERKyCIIgCIIgCIIgTISELIIgCIIgCIIgCBMhIYsgCIIgCIIgCMJESMgiCIIgCIIgCIIwERKyCIIgCIIgCIIgTISELIIgiBiRn58Pi8WCjz/+uKmbAgD4+OOPYbFYkJ+fH5Prd+3aFZMmTdJ87nXXXReTdoRj0qRJ6Nq1q6HvvvDCC7BYLOY2iFCwcuVKWCwWrFy5sqmbYgiLxYIXXnihqZtBEEQTQ0IWQRAJx+HDh/HAAw+gW7duSE5ORmZmJi699FK89dZbqKur0329devW4YUXXkBFRYXm7/z4448YOXIk2rZti9TUVHTr1g3jx4/H4sWLdf8+q+zZswcvvPBCTIQ6i8UCi8WCe++9V/XzZ555RjinvLzc9N9PNNauXYubbroJ7dq1g9PpRNeuXfHggw/i2LFjUV3X7XbjrbfewqBBg5CZmYnmzZvjvPPOw/333499+/aZ1HrtGHmWjZCTk0OCFEEQYSEhiyCIhOKnn37C+eefj6+//hrXX3893nnnHcyaNQudO3fGn//8Zzz++OO6r7lu3TrMmDFD88bstddeww033ACLxYJp06bhzTffxC233IKDBw/iyy+/FM7r0qUL6urq8H//93+625SI7N+/H3PmzBHe79mzBzNmzIiZ5Sw5ORnffvst3G634rP58+cjOTlZcXzOnDnYv3+/od979tlnDQnxTc0777yDESNGYOfOnXj00Ufx3nvv4dZbb8WXX36J/v3749dffzV87VtuuQVPPPEE+vXrh5dffhkzZszAZZddhkWLFkV1XaPofZaNkpOTgxkzZqh+VldXh2effTamv08QRPxjb+oGEARBaCUvLw+33347unTpguXLl6N9+/bCZ4888ggOHTqEn376KaZt8Hq9ePHFFzFmzBgsWbJE8Xlpaanw2mKxqG70WcXpdDbq71199dX44YcfsGjRItx4443C8XXr1iEvLw+33HILvv32W8l3HA6H4d+z2+2w2xNr2Vy7di3++Mc/Yvjw4Vi8eDFSU1OFzx566CFceumluOWWW7B79240b95c17U3bdqE//3vf5g5cyb++te/Sj775z//GXNBJ145m555giBCQ5YsgiAShldeeQXV1dX46KOPJAIWT48ePQRLVrh4KHHMxAsvvIA///nPAIBzzz1XcDELZX0pLy9HZWUlLr30UtXP27ZtK7wO1YYFCxagb9++SE5ORr9+/fD9998rYoX477722mv44IMP0L17dzidTlx44YXYtGmT5Ho7duzApEmTBPfJrKws3H333Th58qRqG8Pxww8/wGKxYMeOHcKxb7/9FhaLBTfffLPk3D59+mDChAnCe3FM1scff4zbbrsNAHD55ZcL/SqPs1mzZg2GDh2K5ORkdOvWDZ9++qnmtnbs2BGXXXYZ5s2bJzn+xRdf4Pzzz0e/fv0U34mmn9VisiwWC6ZMmSL8TVNSUjBs2DDs3LkTAPDvf/8bPXr0QHJyMkaNGqUYV6tXr8Ztt92Gzp07w+l0olOnTvjTn/6ksJgVFxdj8uTJOOecc+B0OtG+fXvceOONEa2EL774IiwWCz755BOJgAUA3bt3xyuvvILCwkJ88MEHYa+jxuHDhwFA9Vmw2Wxo1apVxGscP34c48aNQ1paGtq2bYs//elPcLlcqudu2LABV199NZo1a4bU1FSMHDkSa9euFT7X8ix//vnnGDx4MFJSUtCyZUvcfvvtqi6TGzZsQHZ2Nlq0aIG0tDT0798fb731FoDAGHr33XcBBN1WxeNCLSZr69atuOaaa5CZmYn09HRceeWVCksfHzO5du1aTJ06FW3atEFaWhpuuukmlJWVRexLgiDii8RSyREEcVbz448/olu3brjkkktMu+bNN9+MAwcOYP78+XjzzTfRunVrAECbNm1Uz2/bti1SUlLw448/4tFHH0XLli11/d5PP/2ECRMm4Pzzz8esWbNw+vRp3HPPPejYsaPq+fPmzUNVVRUeeOABWCwWvPLKK7j55ptx5MgRwSqTm5uLI0eOYPLkycjKysLu3bvxwQcfYPfu3fj11191JWsYPnw4LBYLVq1ahf79+wMICAJWqxVr1qwRzisrK8O+ffswZcoU1etcdtlleOyxx/D222/jr3/9K/r06QMAwr8AcOjQIdx666245557MHHiRMydOxeTJk3C4MGDcd5552lq75133onHH38c1dXVSE9Ph9frxYIFCzB16lTU19drvm8t/RyK1atX44cffsAjjzwCAJg1axauu+46PPXUU3jvvffw8M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JXGHDx8WjhUWFnIZGRncZZddJhzjn8/Ro0dLfutPf/oTZ7PZuIqKCtXfIwgiPiF3QYIgEoLKykoAQEZGRhO3BJgxYwbmzZuHQYMG4eeff8YzzzyDwYMH44ILLsDevXtDfq+wsBA7d+7EXXfdhfT0dOH4yJEjcf7556t+Z8KECWjRooXwfsSIEQCAI0eOCMdSUlKE1/X19SgvL8fFF18MANiyZYvu+xsxYgRWr14NAKiqqsL27dtx//33o3Xr1sLx1atXo3nz5qoueVrp27evcD9AwOLQq1cvyb1FokW
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": [
"[-0.027759944001706754, -0.042024054853653535]\n"
]
}
],
"source": [
"plt.figure(figsize=(10, 5))\n",
2024-05-30 10:13:20 +02:00
"plt.plot(butter_filtered_sig)\n",
2024-05-25 21:02:16 +02:00
"plt.xlabel('Time')\n",
"plt.ylabel('Amplitude')\n",
2024-05-30 10:13:20 +02:00
"plt.title('Cut Signal with Minimas Q, S detection')\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-05-30 10:13:20 +02:00
" signal_section = butter_filtered_sig[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-05-30 10:13:20 +02:00
" minimas_y = [butter_filtered_sig[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-05-30 10:13:20 +02:00
" minimas_y = [butter_filtered_sig[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-05-30 10:13:20 +02:00
"execution_count": 72,
2024-05-25 21:02:16 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-05-30 10:13:20 +02:00
"image/png": "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
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-05-30 10:13:20 +02:00
"plt.title('Cuted Signal with Peaks (STD)')\n",
"plt.legend()\n",
"plt.grid(True)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 102,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(5000, 2)\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd3gU1frHv7ubTTa9N0JI6EWaEECQKiCKiKBY8VL0AlcBxahX+V0FsYFKVRFs6BVRsctVRBAIRRAQDL1DCCW9923z+2M2Ozs7s8nuziw7m7yf5+Fh58yZ2bMnZ86c73nf8x4VwzAMCIIgCIIgCIIgCFlQe7sABEEQBEEQBEEQTQkSWQRBEARBEARBEDJCIosgCIIgCIIgCEJGSGQRBEEQBEEQBEHICIksgiAIgiAIgiAIGSGRRRAEQRAEQRAEISMksgiCIAiCIAiCIGSERBZBEARBEARBEISMkMgiCIIgCIIgCIKQERJZBEE0e1JTUzFlyhRvFwMAkJWVBZVKhU8//dQj958yZQpSU1OdzhsSEuKRcshJRkYGVCoVMjIyPHL/oUOHYujQoU7n7dq1q0fKQXgGsfbjynNCEAQhBoksgiCaLEePHsWECROQkpICnU6HpKQ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3D27FnebwGAadOmQaPRSP5ugiCUDQW+IAiiydKnTx98//330Ov1OHz4MH744QcsW7YMEyZMQGZmJm/AZ8ulS5fQv39/QXq7du1E87dq1Uq
"text/plain": [
"<Figure size 1000x500 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"from statsmodels.nonparametric.smoothers_lowess import lowess\n",
"\n",
"org_signal = butter_filtered_sig \n",
"#org_signal = test_data\n",
"x = org_signal\n",
"y = np.arange(len(org_signal))\n",
"\n",
"# Apply lowess function\n",
"frac = 0.003#0.01\n",
"lowess_filtered_sig = lowess(x, y, is_sorted=True, frac=frac, it=1)\n",
"print(lowess_filtered_sig.shape)\n",
"# Plot the signal\n",
"plt.figure(figsize=(10, 5))\n",
"plt.plot(org_signal, 'b-', linewidth=2, label='filtered data')\n",
"plt.plot(lowess_filtered_sig[:, 0], lowess_filtered_sig[:, 1], 'g-', linewidth=2, label='loess data')\n",
"plt.xlabel('Time')\n",
"plt.ylabel('Amplitude')\n",
"plt.title('Signal with and without LOESS Filter')\n",
"plt.legend()\n",
"plt.grid(True)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 103,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd5gUVdaHf9VxcmIiaYYkQQQkKSpBAVEU1rRi+CSo4CooimnRXYKKoIKgqGBClDVgYBWVKGGJApJzHBjS5Jw61f3+qO7qUD0zXV01dPfMeZ+Hh67q29Wn79y6dc89iWOMMRAEQRAEQRAEQRCqoAm0AARBEARBEARBEA0JUrIIgiAIgiAIgiBUhJQsgiAIgiAIgiAIFSEliyAIg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3b5ZYCbzRuXNnxMXFufXZ5s2bodFosH//fpSWlgIAeJ7Htm3b0K9fP6/X6dixI1577TUAwLhx48Q+c23v628ZMGAAlixZgocffhjvvPMOYmNjMXr06BrHWW088cQTGDx4MACIMi1ZssSnz06cOBHx8fF1xnPl5OTghhtuwOrVq/HUU09hxowZqK6uxvDhw/Hf//5X0n7WrFn473//ixdeeAGTJ0/Gn3/+iYcfflj2b6uJadOmYfz48WjatCnmzJmDe++9Fx9//DFuvfVWWCwWsd3atWvRr18/HDlyBBMnTsScOXNw880347fffnNrc+bMGYwZMwbz58/HAw88gO+++w5Dhw5127SQS79+/dC8eXN888034rmlS5ciKioKd9xxh6Q9z/MYPnw4Zs+ejWHDhmH+/Pm46667MHfuXIwYMcKt7YIFC5Ceno5XXnkFc+bMQYsWLfDUU0+JyrYrvsxR06ZNw/Tp03HzzTfjgw8+wKuvvoqWLVv6pHzXxn333Yfw8HA3l9ucnBxcf/31+OOPPzBhwgS89957aNu2LR577DHMmzdPcg1fxtLixYtx//33Q6vVYubMmRg7diyWLVuGm266yavi7eDw4cO48847YTKZ8Nprr2HOnDkYPnw4tm7dWudv82V+5Hkew4YNw7fffotRo0ZhxowZuHz5MkaNGlV35xFEqMMIgmhwrFmzhmm1WqbValmfPn3YSy+9xFavXs3MZrOkbXp6Ohs1apR4/PTTTzOO49jevXvFcwUFBSwhIYEBYJmZmW6fBcA2bdoknsvNzWVGo5E9//zz4rnq6mpms9ncvjczM5MZjUb22muvuZ0DwL744otaf9/48eNZSkqKeDxp0iTWr18/lpyczBYsWCDKzHEce++998R2o0aNYunp6eJxXl4eA8CmTp0q+Y5Ro0YxAG7yMcbYtddey3r06FGrfIwxVllZKTn3xBNPsIiICFZdXS2e69+/PwPAvvrqK/GcyWRiqamp7N577xXPzZs3jwFg33//vXiuoqKCtW3blgFgGzZsqFWeO+64g/Xu3Vs8vueee9g999zDtFotW7lyJWOMsT179jAA7JdffnGTr3///uLxrl27avwbyf0t//nPf8RzZrOZ9enTh0VFRbHS0lLGGGMbNmzw+tu8jZPx48czOY+0/v37s6uvvpoxxtj06dMZALZ7926367/zzjti+2effZYBYJs3bxbPlZWVsVatWrGMjAxxfDtk7tixIzOZTGLb9957jwFgBw8elCWbN3Jzc5nBYGC33nqr2331wQcfMABs0aJFjDHGrFYra9WqFUtPT2dFRUVu1+B5Xnztbax+++23knv7iy++kMwB3pg6dSoDwPLy8tgLL7zA2rZtK77Xq1cvNmbMGMYYYwDY+PHjxfeWLFnCNBqNWx8zxtjChQsZALZ169ZaZR4yZAhr3bq12zlf56iuXbuyO+64o9bf5Q3
"text/plain": [
"<Figure size 1000x500 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import cv2 as cv\n",
"\n",
"\n",
"org_signal = lowess_filtered_sig[:, 1]\n",
"#org_signal = test_data\n",
"\n",
"# Reshape the signal to a 2D array for OpenCV (camera image processing library)\n",
"org_signal_2d = np.reshape(org_signal, (-1, 1))\n",
"\n",
"# Scale the signal to the range [0, 255] (normal pixel range for images)\n",
"org_signal_2d_scaled = np.uint8((org_signal_2d - np.min(org_signal_2d)) / (np.max(org_signal_2d) - np.min(org_signal_2d)) * 255)\n",
"\n",
"# Apply Non-Local Means denoising\n",
"\n",
"filter_strength = 50\n",
"template_window_size = 7\n",
"search_window_size = 21\n",
"\n",
"nlm_filtered_sig_2d = cv.fastNlMeansDenoising(org_signal_2d_scaled, None, filter_strength, template_window_size, search_window_size)\n",
"\n",
"# Rescale the denoised signal back to the original range\n",
"nlm_filtered_sig = np.reshape(nlm_filtered_sig_2d, -1) * (np.max(org_signal) - np.min(org_signal)) / 255 + np.min(org_signal)\n",
"\n",
"\n",
"# Plot the original and denoised signal\n",
"plt.figure(figsize=(10, 5))\n",
"plt.plot(org_signal, label='Original signal')\n",
"plt.plot(nlm_filtered_sig, label='Denoised signal')\n",
"plt.xlabel('Time')\n",
"plt.ylabel('Amplitude')\n",
"plt.title('Signal with and without Non-Local Means Denoising')\n",
"plt.legend()\n",
"plt.grid(True)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 104,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd5wT1drHfzNJtu+yu7CNtkuTKr0I0rugXDuWVwEVvSqKYkWvFBVBBUFRQFFEURELV71KlSJV6b33uo1l2b4pc94/kkwymexuJjMhZZ/v54PuTE4mT07OnDnPeRrHGGMgCIIgCIIgCIIgNIH3twAEQRAEQRAEQRChBClZBEEQBEEQBEEQGkJKFkEQBEEQBEEQhIaQkkUQBEEQBEEQBKEhpGQRBEEQBEEQBEFoCClZBEEQBEEQBEEQGkJKFkEQBEEQBEEQhIaQkkUQBEEQBEEQBKEhpGQRBEEQBEEQBEFoCClZBFHNycjIwMiRI/0tBgDgzJkz4DgOCxcu9Mn1R44ciYyMDI/bxsTE+EQOLVm/fj04jsP69et9cv3evXujd+/eHrdt1aqVT+Qg/M/ChQvBcRzOnDnjb1EIL5k0aRI4jlP0Hl/PywQRqpCSRRAhyv79+3H33XcjPT0dERERqFOnDgYMGIDZs2f7W7SAoaSkBJMmTfKZghKKXLp0CZMmTcKePXv8LYqEZcuWYdKkSR637927NziOw2233SZ7zb6onD59uoYSek6wK6v2hTzP8zh//rzs9YKCAkRGRoLjOIwZM8YPEmqHfZPD/i88PBwpKSno3bs33nnnHeTk5PhbRIIg/AQpWQQRgmzZsgUdO3bE3r17MXr0aHz88cd47LHHwPM8PvzwQ0nbo0ePYv78+X6S9Poyf/58HD16VDwuKSnB5MmTScmqhFWrVmHVqlXi8aVLlzB58uSAVLImT56s+H2///47du7c6QOJiPDwcCxevFh2funSpX6Qxrc8++yzWLRoET777DO89NJLSExMxMSJE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RkJGrVqoX/+7//w8WLFyVt3MVkrV69Gt27d0d8fDxiYmLQtGlTvPbaa+Lr7mKy7DGrnsyPV65cwUMPPYS4uDjEx8djxIgR2Lt3L8V5ESEPKVkEEYKkp6dj586dOHDggOL3Xrx4EX369MHBgwcxfvx4PP/88/j2229lboZ2Tpw4gbvvvhsDBgzAjBkzkJCQgJEjR+LgwYNim1OnTuGXX37Brbfeig8++AAvvfQS9u/fj169euHSpUuK5IuPj0erVq2wYcMG8dymTZvAcRzy8vJw6NAh8fzGjRvRo0cPt9dJSkoSF2V33HEHFi1ahEWLFuHOO+8U21gsFgwaNAg1a9bE9OnT0atXL8yYMQOfffZZlXIuXLgQMTExGDduHD788EN06NABEyZMwKuvvipre/XqVQwePBht2rTBjBkz0KxZM7zyyitYvny52Ka0tBT9+vXDypUrMWbMGLz++uvYuHGjzErgjlatWiE+Pl7SZxs3bgTP89i7dy8KCgoAAIIgYMuWLejZs6fb6zRv3hxvvvkmAODxxx8X+8y5vaffpXfv3li0aBEefPBBvP/++6hRowZGjhxZ4TirjCeeeAIDBgwAAFGmRYsWefTesWPHIiEhocp4rqysLHTr1g0rV67EU089hSlTpqCsrAzDhg3Df//7X1n7adOm4b///S9efPFFjB8/Hn///TcefPBBxd+tIiZNmoSnn34atWvXxowZM3DXXXfh008/xcCBA2EymcR2q1evRs+ePXHo0CGMHTsWM2bMQJ8+ffD7779L2pw6dQqjRo3C7Nmzcd999+H777/HkCFDJJsWSunZsyfq1q2L7777Tjy3ZMkSxMTEYOjQobL2giBg2LBhmD59Om677TbMnj0bt99+O2bOnInhw4dL2s6dOxfp6el47bXXMGPGDNSrVw9PPfWUqGw748kcNWnSJEyePBl9+vTBxx9/jNdffx3169f3SPmujLvvvhuRkZESl9usrCzcdNNN+PPPPzFmzBh8+OGHaNy4MR599FHMmjVLdg1PxtLChQtx7733QqfTYerUqRg9ejSWLl2K7t27u1W87Rw8eBC33norysvL8eabb2LGjBkYNmwYNm/eXOV382R+FAQBt912GxYvXowRI0ZgypQpuHz5MkaMGFF15xFEsMMIggg5Vq1axXQ6HdPpdKxr167s5ZdfZitXrmRGo1HWNj09nY0YMUI8fuaZZxjHcWz37t3iuStXrrDExEQGgJ0+fVryXgBsw4YN4rns7GwWHh7OXnjhBfFcWVkZs1gsks89ffo0Cw8PZ2+++abkHAD25ZdfVvr9nn76aZaSkiIejxs3jvXs2ZMlJyezuXPnijJzHMc+/PBDsd2IESNYenq6eJyTk8MAsIkTJ8o+Y8SIEQyARD7GGGvXrh3r0KFDpfIxxlhJSYns3BNPPMGioqJYWVmZeK5Xr14MAPv666/Fc+Xl5Sw1NZXddddd4rlZs2YxAOyHH34QzxUXF7PGjRszAGzdunWVyjN06FDWuXNn8fjOO+9kd955J9PpdGz58uWMMcZ27drFALBff/1VIl+vXr3E4+3bt1f4Gyn9Lt988414zmg0sq5du7KYmBhWUFDAGGNs3bp1br+bu3Hy9NNPMyWPtF69erGWLVsyxhibPHkyA8B27twpuf77778vtn/uuecYALZx40bxXGFhIWvQoAHLyMgQx7dd5ubNm7Py8nKx7YcffsgAsP379yuSzR3Z2dksLCyMDRw4UHJfffzxxwwAW7BgAWOMMbPZzBo0aMDS09PZ1atXJdcQBEH8291YXbx4seze/vLLL2VzgDsmTpzIALCcnBz24osvssaNG4uvderUiY0aNYoxxhgA9vTTT4uvLVq0iPE8L+ljxhibN28eA8A2b95cqcyDBg1iDRs2lJzzdI5q06YNGzp0aKXfyx323/vHH3+ssE2
"text/plain": [
"<Figure size 1000x500 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Plot the original and denoised signal\n",
"plt.figure(figsize=(10, 5))\n",
"plt.plot(test_data, label='Original signal')\n",
"plt.plot(nlm_filtered_sig, label='Denoised signal')\n",
"plt.xlabel('Time')\n",
"plt.ylabel('Amplitude')\n",
"plt.title('Signal with and without Non-Local Means Denoising')\n",
"plt.legend()\n",
"plt.grid(True)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 115,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48ie+++w7XXnstunXrhuLiYvzzn//ExIkTcfDgQXTq1Enx8+rr63H11Vfj999/x5o1azBq1CgAwL333otly5Zh7ty56N+/Py5cuIBNmzbh0KFDGD58uOrfiyAIQnd4giAIwi/4+OOPeQCK//E8z+fl5fEA+I8//lh8zVNPPcU7T+VRUVH8bbfd5vL+d955J5+WlsafP39edv2GG27g4+Li+Lq6Op7neX7dunU8AL579+7iNZ7neZvNxvfq1YufPn06b7PZxOt1dXV8t27d+KlTp4rXZs2axYeHh/OnT58Wrx08eJA3Go0u7VXiySef5AHwUVFR/GWXXcY/99xz/I4dO1zuU+qTQYMG8RkZGXx1dbV4bf369TwAvmvXri6v7dixI19WViZe//7773kA/I8//ij7HZ354osveAD8hg0bxGvsb5iXl9fs7zdgwAD+uuuuE78fPnw4f+211/IA+EOHDvE8z/M5OTk8AH7Pnj3ifV27dpX9bb/++mseAL9u3TqXz+jatatL+0pKSviwsDD+kUceabZ9PM/zAPg777yTLy0t5UtKSvht27bxl156KQ+Af/XVV3me5/lLL72UHzRoEN/Q0CC+zmaz8ePHj+d79eolXmtoaOCtVqvs/fPy8viwsDD+mWeeEa+xsff111/z1dXV/MSJE/nExER+165dstfGxcXxDzzwQIu/A0EQhK+gcEGCIAg/Y8mSJVi9erXsP63wPI9vvvkGV155JXiex/nz58X/pk+fjsrKSpdQq9tuuw0RERHi97t378axY8dw00034cKFC+Lra2trcemll2LDhg2w2WywWq1YuXIlZs2ahS5duoiv79evH6ZPn+5RexcuXIjPP/8cw4YNw8qVK/HXv/4VI0aMwPDhw3Ho0CG3rzt37hz27duHW2+9FdHR0eL1iRMnYtCgQYqvuf7665GQkCB+n5WVBUDwvjCk/dDQ0IDz589j7NixAOBViFpWVhY2btwIQAh927NnD+6++24kJiaK1zdu3Ij4+HgMHDhQ9fsz+vfvL/4+AJCUlIQ+ffrIfrfm+PDDD5GUlITk5GSMGTMGmzdvxvz58zFv3jyUlZXh119/xXXXXYfq6mpxPFy4cAHTp0/HsWPHUFBQAEDIJWP5fFarFRcuXEB0dDT69Omj2H+VlZWYNm0aDh8+jPXr12Po0KGyn8fHx2Pbtm04d+6clz1DEATRulC4IEEQhJ8xevRot8IX3lJaWoqKigq89957eO+99xTvkQpKAHBRODx27BgAwfhyR2VlJRobG1FfX49evXq5/LxPnz5Yvny5R22+8cYbceONN6Kqqgrbtm3DJ598gs8//xxXXnkl9u/fryh4cfr0aQAQw9mk9OzZU3FDLzUEAYgGV3l5uXitrKwMCxcuxJdffunST5WVlR79PlKysrKwdOlSHD9+HCdOnADHcRg3bpxofN11113YuHEjLrroIk1iI86/GyD8ftLfrTmuvvpqzJ07FxzHISYmBgMGDEBUVBQAIRSR53n8/e9/x9///nfF15eUlCA9PR02mw1vvPEG3nnnHeTl5cFqtYr3dOzY0eV18+bNQ0NDA3bt2qUY1vjSSy/htttuQ+fOnTFixAjMnDkTt956K7p37+7R70UQBNHakJFFEATRDrDZbACAm2++2a2RxPKDGFLvjfQ9Xn75ZRfPAiM6OhqNjY0aWysnNjYWU6dOxdSpU2EymfDpp59i27ZtmDhxoi7vbzQaFa/zPC9+fd1112HLli34y1/+gqFDhyI6Oho2mw0zZswQ+0UNEyZMAABs2LABJ0+exPDhwxEVFYWsrCy8+eabqKmpwa5du/Dcc89590vZ8eR3a46MjAxMmTJF8Wfs93700UfdeiiZsfv888/j73//O+644w48++yz6NChAwwGA+b
"text/plain": [
"<Figure size 1000x500 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"#Find peaks in Channel 6 of Record 25\n",
"hard = wfdb.processing.find_local_peaks(nlm_filtered_sig,radius=50)\n",
"record = nlm_filtered_sig\n",
"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",
"execution_count": 129,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAADlFElEQVR4nOydd5gUVdbG3+qenhxhIkMYcs4ZQUBJYgBZ1NVVlHXV1cWw6H4r7q4ruitmMbNmdEVcESNIFCSDknMcGGaYnPN0qO+P6ltd1V0909VVPR04v+dRpquru2/fvnXrnnvOeQ/H8zwPgiAIgiAIgiAIQhcM/m4AQRAEQRAEQRBEKEFGFkEQBEEQBEEQhI6QkUUQBEEQBEEQBKEjZGQRBEEQBEEQBEHoCBlZBEEQBEEQBEEQOkJGFkEQBEEQBEEQhI6QkUUQBEEQBEEQBKEjZGQRBEEQBEEQBEHoCBlZBEEQBEEQBEEQOkJGFkEQRJBw/vx5cByHjz/+WDz21FNPgeM4/zVKJXq3V6lP/MnHH38MjuNw/vx5n7x/VlYW7rrrLo/Pve6663zSDl+xefNmcByHFStW+LspBEEQmiAjiyAIIkBgC3Sl/x5//HGP3+fZZ5/FN99847uGthLff/89xo8fj9TUVERHR6NLly64+eabsWbNGn83LWA4duwYnnrqKZ8YddLxZzAY0K5dO0yZMgWbN2/W/bMIgiBCjTB/N4AgCIKQ8/TTT6Nz586yY/369UOnTp1QX18Pk8nU7OufffZZzJ49GzNnzvRhK33LSy+9hL/85S8YP348FixYgOjoaJw5cwYbNmzA8uXLMW3aNADwuE9ChZMnT8JgcOyPHjt2DAsXLsSECROQlZWl++dNnjwZc+bMAc/zyM7Oxttvv42rrroKq1atwjXXXKP75xEEQYQKZGQRBEEEGNdccw2GDRum+FxkZGQrt0agoaEB4eHhsgW+r7BYLHjmmWcwefJkrFu3zuX5oqIi8W+O4/zWJ/4gIiKiVT+vR48euP3228XHN954IwYMGIDFixeTkUUQBNEMFC5IEAQRJHiSf8RxHGpra7F06VIx1Euaw5OXl4ff//73SEtLQ0REBPr27YsPP/xQ9h4sL2b58uX4+9//jszMTERHR6OqqgoAsHv3bkybNg0JCQmIjo7G+PHjsX37dpe2bNu2DcOHD0dkZCS6du2K//znPx59z5KSElRVVeGKK65QfD41NbXFPvnyyy/Rp08fREZGol+/fvj6669x1113ybw97LUvvfQS3n33XXTt2hUREREYPnw4fvnlF9n7HTp0CHfddRe6dOmCyMhIpKen4/e//z1KS0s9+k5SvvvuO3Ach0OHDonHvvrqK3Ach1mzZsnO7d27N2655RbxsTQn6+OPP8ZNN90EAJg4caL4ezuH823btg0jRoxAZGQkunTpgk8++UR1mxn9+/dHcnIysrOzxWMnTpzA7Nmz0aZNG0RGRmLYsGH47rvvZK8rKyvDY489hv79+yM2Nhbx8fG45pprcPDgwRY/s7GxEddddx0SEhKwY8cOAEB1dTUeeeQRZGVlISIiAqmpqZg8eTL27dvn9XcjCILQE/JkEQRBBBiVlZUoKSmRHUtOTvbotZ9++in+8Ic/YMSIEbj33nsBAF27dgUAFBYWYtSoUeA4DvPmzUNKSgp+/PFH3H333aiqqsIjjzwie69nnnkG4eHheOyxx9DY2Ijw8HD89NNPuOaaazB06FD885//hMFgwEcffYSrrroKW7duxYgRIwAAhw8fxpQpU5CSkoKnnnoKFosF//znP5GWltbid0hNTUVUVBS+//57PPjgg2jTpo1H352xatUq3HLLLejfvz8WLVqE8vJy3H333cjMzFQ8f9myZaiursZ9990HjuPwwgsvYNasWTh37pwYhrh+/XqcO3cOc+fORXp6Oo4ePYp3330XR48exa5du1SJeYwdOxYcx2HLli0YMGAAAGDr1q0wGAzYtm2beF5xcTFOnDiBefPmKb7PlVdeiYceegivv/46nnjiCfTu3RsAxH8B4MyZM5g9ezbuvvtu3Hnnnfjwww9x1113YejQoejbt6/HbWaUl5ejvLwc3bp1AwAcPXoUV1xxBTIzM/H4448jJiYG//vf/zBz5kx89dV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m1FdXS2Oh9LSUkydOhWnT59GXl4eACGXjOXzWa1WlJaWIjY2Fj179lTsv8rKSkyZMgUnTpzA5s2bMWjQINnziYmJ2L17Ny5duuRlzxAEQfgWChckCIIIMEaMGOFW+MJbiouLUVFRgXfffRfvvvuu4jlSQQkALgqHp0+fBiAYX+6orKxEY2Mj6uvr0b17d5fne/bsidWrV3vU5ltvvRW33norqqqqsHv3bnz88cdYtmwZrr/+ehw5ckRR8OLChQsAIIazSenWrZvigl5qCAIQDa7y8nLxWFlZGRYuXIjly5e79FNlZaVH30fKuHHjsGTJEpw5cwZnz54Fx3EYPXq0aHzdc8892Lp1K6644gpNYiPO3w0Qvp/0uzXHjBkzMG/ePHAch7i4OPTt2xcxMTEAhFBEnufxj3/8A//4xz8UX19UVITMzEzYbDa89tprePvtt5GdnQ2r1Sqe07ZtW5fXPfLII2hoaMD+/fsVwxpfeOEF3HnnnejQoQOGDh2K6dOnY86cOejSpYtH34sgCMLXkJFFEARxGWCz2QAAt99+u1sjieUHMaTeG+l7vPjiiy6eBUZsbCwaGxs1tlZOfHw8Jk+ejMmTJ8NkMmHp0qXYvXs3xo8fr8v7G41GxeM8z4t/33zzzdixYwf+8pe/YNCgQYiNjYXNZsO0adPEflHD2LFjAQBbtmzBuXPnMGTIEMTExGDcuHF4/fXXUVNTg/379+Pf//63d1/KjiffrTnat2+PSZMmKT7Hvvdjjz3m1kPJjN1nn30W//jHP/D73/8ezzzzDNq0aQODwYBHHnlEsf9
"text/plain": [
"<Figure size 1000x500 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"#Find peaks in Channel 6 of Record 25\n",
"hard, soft = wfdb.processing.find_peaks(nlm_filtered_sig)\n",
"record = nlm_filtered_sig\n",
"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",
2024-05-25 21:02:16 +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
}