938 lines
1.7 MiB
Plaintext
938 lines
1.7 MiB
Plaintext
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"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",
|
||
|
"execution_count": 2,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import pickle\n",
|
||
|
"from matplotlib import pyplot as plt\n",
|
||
|
"import wfdb.processing\n",
|
||
|
"import scipy.signal\n",
|
||
|
"import numpy as np"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 3,
|
||
|
"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",
|
||
|
"execution_count": 4,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Reading SB\n",
|
||
|
"Length of SB: 16559\n",
|
||
|
"Reading AFIB\n",
|
||
|
"Length of AFIB: 9839\n",
|
||
|
"Reading GSVT\n",
|
||
|
"Length of GSVT: 948\n",
|
||
|
"Reading SR\n",
|
||
|
"Length of SR: 9720\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"\n",
|
||
|
"# read pickle files and check len and print first record and first record keys\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"categories_dict = {\n",
|
||
|
"'SB': [426177001],\n",
|
||
|
"'AFIB': [164889003, 164890007],\n",
|
||
|
"'GSVT': [426761007, 713422000, 233896004, 233897008, 713422000],\n",
|
||
|
"'SR': [426783006, 427393009]\n",
|
||
|
"}\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"data = {}\n",
|
||
|
"for cat_name in categories_dict.keys():\n",
|
||
|
" print(f\"Reading {cat_name}\")\n",
|
||
|
" with open(f'{path}/{cat_name}.pkl', 'rb') as f:\n",
|
||
|
" records = pickle.load(f)\n",
|
||
|
" data[cat_name] = records\n",
|
||
|
" print(f\"Length of {cat_name}: {len(records)}\")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"For a better understanding of the structure and dimensions of the individual data sets, there are printed."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 5,
|
||
|
"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",
|
||
|
" [ 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"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# print keys of first record\n",
|
||
|
"print(f\"Keys of first record of SB: {data['SB'][0].__dict__.keys()}\")\n",
|
||
|
"print(data['SB'][0].__dict__)\n",
|
||
|
"print(data['SB'][0].__dict__['p_signal'].shape)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 6,
|
||
|
"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",
|
||
|
"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",
|
||
|
"print(f\"Number of records with e_d_signal: {counter_e_d}\")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 7,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAksAAAHHCAYAAACvJxw8AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd1xT1xfAv0nYe6MgCogLB05w761Va7XWDmfbX7W2tbZaba2j1tVa27qqHa5a667WvbXuvTcKCrIEZENCkvf7AwkJMyAQou/7+eQD7+a9l3PfuPfcc849VyIIgoCIiIiIiIiIiEi+SA0tgIiIiIiIiIhIRUZUlkRERERERERECkFUlkRERERERERECkFUlkRERERERERECkFUlkRERERERERECkFUlkRERERERERECkFUlkRERERERERECkFUlkRERERERERECkFUlkRERERERERECkFUlkRERMqNI0eOIJFIOHLkSKmdMzo6mgEDBuDs7IxEIuGnn34qtXM/D97e3gwbNkyzXRZ1B5BIJIwZM6ZUz2lIJBIJ06ZNM7QYIiI6iMqSiEgFYeXKlUgkkgI/p0+fNrSIFZJPP/2UvXv3MmnSJP7880+6d+9uaJFKhfv37/O///0PX19fLCwssLOzo1WrVvz888+kp6cbWjwRkZcKE0MLICIioss333yDj49PnnI/Pz8DSFPxOXToEH379uXzzz83tCilxs6dOxk4cCDm5uYMGTKEevXqoVAoOH78OOPHj+fGjRv8+uuvhhZTROSlQVSWREQqGD169KBp06aGFsNoiImJwcHBodTOl5GRgZmZGVKpYQzvISEhvPHGG1SrVo1Dhw5RuXJlzXcffvghwcHB7Ny50yCyiYi8rIhuOBERI2Pq1KlIpVIOHjyoU/7+++9jZmbGlStXAFAoFEyZMoUmTZpgb2+PtbU1bdq04fDhwzrHhYaGIpFImDdvHosXL8bX1xcrKyu6du1KWFgYgiAwY8YMqlSpgqWlJX379iU+Pl7nHN7e3vTu3Zt9+/bRsGFDLCws8Pf3Z8uWLXrV6cyZM3Tv3h17e3usrKxo164dJ06cKPSYbLelIAgsXrxY467M5sGDBwwcOBAnJyesrKxo3rx5HiUjO45o3bp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JSYmFnnO7HuQ+77r89v37t3j6tWruLq65it/TExMvuWQFcM1dOhQvLy8aNKkCT179mTIkCH4+voWeIyISGkjKksiIkbKgwcPNMrGtWvX8ny/Zs0ahg0bRr9+/Rg/fjxubm7IZDJmz57N/fv38+wvk8ny/Z2CyrU725KSbTX6/vvvadiwYb772NjYPPfvFIW+VqVjx47Rp08f2rZty5IlS6hcuTKmpqasWLGCtWvXPrccdnZ2eHh4cP369WIdp889+uijj1ixYgVjx46lRYsW2NvbI5FIeOONN/K13ul73/XZT61W06VLFyZMmJDvvtlKdX68/vrrtGnThn/++Yd9+/bx/fffM3fuXLZs2UKPHj0KPE5EpDQRlSURESNErVYzbNgw7OzsGDt2LLNmzWLAgAH0799fs8+mTZvw9fVly5YtOlaPqVOnlolMwcHBCIKg81t3794FsmZN5Ue268jOzo7OnTuXmizVqlXjzp07ecpv376t+b4kbN68GQsLC/bu3Yu5ubmmfMWKFSUTNB969+7Nr7/+yqlTp2jRokWpnXfTpk0MHTqUH374QVOWkZFBQkJCqf1GQVSvXp2UlJQS3+PKlSszevRoRo8eTUxMDI0bN2bmzJmisiRSbogxSyIiRsj8+fM5efIkv/76KzNmzKBly5aMGjWK2NhYzT7ZI37tEf6ZM2c4depUmcgUERHBP//8o9lOSkpi9erVNGzYMF8XHECTJk2oXr068+bNIyUlJc/
|
||
|
"text/plain": [
|
||
|
"<Figure size 640x480 with 12 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"#Plot a complete Record\n",
|
||
|
"wfdb.plot_wfdb(data['SB'][24],title=\"Example for all Channels\")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 8,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAABN0AAAGJCAYAAAC+dUXNAAAAO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oviO3NxcnH322fj2228xdOhQpKSkoH///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/
|
||
|
"text/plain": [
|
||
|
"<Figure size 1500x400 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"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",
|
||
|
"execution_count": 9,
|
||
|
"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",
|
||
|
"execution_count": 10,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA2IAAAHWCAYAAAAVazrYAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAADadElEQVR4nOydd3wT9f/HX5d0t5RuCpQhG0SGIFP2tCpiRYZ83YIiiAiI4k9UtrJkOEHBhYBg3cgUBBVRUQRlqAgyC7SFltKR5HK/Py53ubvcJXdp2oy+n49HH20ul+STTz/rvRmO4zgQBEEQBEEQBEEQlYbJ3w0gCIIgCIIgCIKoapAgRhAEQRAEQRAEUcmQIEYQBEEQBEEQBFHJkCBGEARBEARBEARRyZAgRhAEQRAEQRAEUcmQIEYQBEEQBEEQBFHJkCBGEARBEARBEARRyZAgRhAEQRAEQRAEUcmQIEYQBEEQBEEQBFHJkCBGEARBVBj169fHfffd5+9mAABOnDgBhmHwzjvvVMj733fffahfv77ue+Pi4iqkHRUJwzAYN26cv5tBEAQREpAgRhAEQRjm4MGDGDJkCOrVq4eoqCjUrl0b/fr1w7Jly/zdtIChuLgYL7zwAnbu3Onz9+7ZsycYhhF/kpKScMMNN2DlypWw2+0+/zyCIAjC94T5uwEEQRBEcPHDDz+gV69eqFu3LkaNGoX09HScOnUKP/74I5YsWYLHHntMvPfo0aMwmaqGzm/FihUyIai4uBjTp08HwAtOviYjIwNz584FAFy8eBHvvfceHnzwQfz111948cUXff55BEEQhG8hQYwgCIIwxOzZs1G9enX8/PPPSEhIkD134cIF2ePIyMhKbJl/CQ8Pr9TPq169Ov73v/+Jjx9++GE0bdoUr7zyCmbOnFnp7SEIgiCMUTXUlARBEITPOHbsGK699loX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x4AcO7cOc176tWrh3/++cfluto1vWzYsAG9evXC22+/Lbt++fJlpKSkePWe3bp1w65du3DNNdegTZs2qFatGlq3bo3q1atj06ZN+PXXXz0KFWrWpMqkYcOGKCoqciusAcDHH3+MqKgobN68WVZuYNWqVar3N2rUCPPmzUPPnj0xcOBAbN++HdWqVZPdExsbi2HDhmHYsGGwWCzIysrC7NmzMXXqVERFRZX/yxEEQYQAFCNGEARBGGLHjh0yi5TAxo0bAQBNmzbVfO2AAQOwZ88e7N+/X7yWn5+P1atXe90es9ns0p7169fjzJkzXr9nt27dcOLECaxbt050VTSZTOjSpQsWLVoEq9XqMT4sJiYGAC8Q+oOhQ4diz5492Lx5s8tzly9fhs1mA8D3H8MwMpfOEydO4NNPP9V871atWmHjxo04fPgwbr31VpSUlIjP5eXlye6NiIhAixYtwHEcrFZrOb8VQRBE6EAWMYIgCMIQjz32GIqLi3H77bejWbNmsFgs+OGHH7Bu3TrUr18f999/v+Zrp0yZgg8++AD9+vXDY489htjYWLz11luoW7cu8vPzvbIi3XLLLZgxYwbuv/9+dOnSBQcPHsTq1avRoEEDr7+jIGQdPXoUc+bMEa93794dX3/9NSIjI3HDDTe4fY/o6Gi0aNEC69atQ5MmTZCUlISWLVuiZcuWXrfLCE8++SQ+//xz3HLLLbjvvvvQrl07XL16FQcPHsSGDRtw4sQJpKSk4Oabb8aiRYswcOBA3HXXXbhw4QJeffVVNGrUCAcOHNB8/06dOuGzzz5DZmYmhgwZgk8//RTh4eHo378/0tPT0bVrV9SoUQOHDx/GK6+8gptvvtnFckYQBFGVIYsYQRAEYYgFCxagV69e2LhxIyZ
|
||
|
"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",
|
||
|
"execution_count": 11,
|
||
|
"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": [
|
||
|
"# Normalize data by setting qrs peaks to index position 0 (“X-axis normalization”)\n",
|
||
|
"indicies = wfdb.processing.xqrs_detect(wholeRecord.p_signal[:,6],wholeRecord.fs,0,5000)\n",
|
||
|
"print(indicies)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 12,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"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"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"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",
|
||
|
"execution_count": 13,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAksAAAHHCAYAAACvJxw8AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd3xT1RfAv0m69y50QFvKKqPMlr03yBJkqEz1J4iKqAiKBUSWIiII4mKpyBYEZMiUvfcutFBa2tKW7jZpkvf7ozRNOtPSNg287+eTT/tu3ns59417zz3n3HMlgiAIiIiIiIiIiIiIFIjU0AKIiIiIiIiIiFRmRGVJRERERERERKQIRGVJRERERERERKQIRGVJRERERERERKQIRGVJRERERERERKQIRGVJRERERERERKQIRGVJRERERERERKQIRGVJRERERERERKQIRGVJRERERERERKQIRGVJRESkwjh06BASiYRDhw6V2TljYmIYNGgQzs7OSCQSFi1aVGbnfhZ8fHwYNWqUZrs86g4gkUiYMGFCmZ7TkEgkEmbMmGFoMUREdBCVJRGRSsKqVauQSCSFfk6ePGloESslH3zwAXv27GHq1Kn89ttv9OjRw9AilQl3797lf//7H35+flhYWGBnZ0fr1q357rvvyMjIMLR4IiIvFCaGFkBERESXL774Al9f33zl/v7+BpCm8nPgwAH69evHRx99ZGhRyoydO3cyePBgzM3NGTFiBPXr10ehUHD06FE+/vhjrl27xk8//WRoMUVEXhhEZUlEpJLRs2dPmjVrZmgxjIbY2FgcHBzK7HyZmZmYmZkhlRrG8B4WFsbQoUOpXr06Bw4coGrVqprv3nnnHUJDQ9m5c6dBZBMReVER3XAiIkbG9OnTkUql7N+/X6f8rbfewszMjEuXLgGgUCgICQmhadOm2NvbY21tTdu2bTl48KDOceHh4UgkEhYsWMDSpUvx8/PDysqKbt26ERERgSAIzJo1Cy8vLywtLenX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69evrykv6HoUxo4dO/jyyy+5ePEicrlcU5637qXBzs4OyI7TKQl57x2Ao6Ojzj3KyMhg7ty5rFy5ksjISARB0HyXlJRU7Dlz7kHe+67Pb9+5c4fLly/j6upaoPyxsbEFlkN2DNfIkSPx9vamadOm9OrVixEjRuDn51foMSIiZY2oLImIGCn37t3TKBtXrlzJ9/3vv//OqFGj6N+/Px9//DFubm7IZDLmzp3L3bt38+0vk8kK/J3CyrU729KSYzX6+uuvadSoUYH72NjYPPPvFIe+VqUjR47Qt29f2rVrx7Jly6hatSqmpqasXLmStWvXPrMcdnZ2eHh4cPXq1RIdp889evfdd1m5ciUTJ06kZcuW2NvbI5FIGDp0aIHWO33vuz77qdVqunbtyuTJkwvcN0epLohXXnmFtm3b8tdff7F3716+/vpr5s+fz5YtW+jZs2ehx4mIlCWisiQiYoSo1WpGjRqFnZ0dEydOZM6cOQwaNIiBAwdq9tm0aRN+fn5s2bJFx+oxffr0cpEpNDQUQRB0fuv27dtA9qypgshxHdnZ2dGlS5cyk6V69ercunUrX/nNmzc135eGzZs3Y2FhwZ49ezA3N9eUr1y5snSCFkCfPn346aefOHHiBC1btiyz827atImRI0fyzTffaMoyMzNJTEwss98ojBo1apCamlrqe1y1alXGjx/P+PHjiY2NpUmTJsyePVtUlkQqDDFmSUTECFm4cCHHjx/np59+YtasWbRq1Ypx48YRFxen2SdnxK89wj916hQnTpwoF5mioqL466+/NNvJycmsWbOGRo0aFeiCA2jatCk1atRgwYIFpKam5vs
|
||
|
"text/plain": [
|
||
|
"<Figure size 640x480 with 12 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"wfdb.plot_wfdb(wholeRecord,title=\"Example for all Channels\")\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 14,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data":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Kh5/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
|
||
|
"text/plain": [
|
||
|
"<Figure size 1500x400 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"wfdb.plot_items(data['SB'][24].p_signal[:,0],title=\"Example for Channel 1\",figsize=(15,4))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 15,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAO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g4BgBz5swZwbUAmC1btnD7rl27xphMJubFF1/k9pWUlDA2m03w3DNnzjAmk4l54403BPsAMJ999lmZ3++ZZ55hkpKSuO3MzEyme/fuTGJiIrNw4UKuzDqdjnnvvfe480aMGMHUq1eP275+/ToDgJkyZYrkGSNGjGAACMrHMAxz++23M+3atSuzfAzjqpv//ve/3L7c3FymZs2azO23387tmzJlCiPXVX/22WeS+m7evDnTo0cPybkrVqxgADCbNm0S7M/Pz2diYmKYsWPHCvZnZWUx0dHRgv3O7/vqq6+W+93kynft2jUmODiY6d+/v+C3/uCDDxgAzNKlSxmGYRibzcZERUUxL7/8MsMwDGO325n4+Hhm6NChjMFgYPLz8xmGYZh58+Yxer2euXXrFsMwrrYRGhrKXLx4kbv/zp07GQDMCy+8wO0rKiqSlPebb76RtNXo6GjmmWeecfsd9+3bxwBgVqxY4VGd8HH+rtevXxfs79Gjh+A3lGvzzzzzjGyb2Lp1KwOA+eqrrwT716xZI9nvbH9r1qzxqLxydTZjxgxGp9Mx586d4/Z5+l6sXLmSAcDMmjWL22e1Wpn09PSAe8ed3+XNN98UnPfAAw8wOp2O+eeffxiGKbv/Epdh9uzZkve7LJxlFf8525JcfyFua7t375Ytn91uZ2677TYmIyODsdvt3P6ioiKmfv36TL9+/bh9znY9bNgwj8p
|
||
|
"text/plain": [
|
||
|
"<Figure size 1000x500 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"test_data = data['SB'][0].p_signal[:,0]\n",
|
||
|
"\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",
|
||
|
"butter_filtered_sig = butter_lowpass_filter(test_data, cutoff, fs, order)\n",
|
||
|
"\n",
|
||
|
"# Plot the signal\n",
|
||
|
"plt.figure(figsize=(10, 5))\n",
|
||
|
"plt.plot(test_data, 'b-', label='data')\n",
|
||
|
"plt.plot(butter_filtered_sig, 'g-', linewidth=2, label='filtered data')\n",
|
||
|
"plt.xlabel('Time')\n",
|
||
|
"plt.ylabel('Amplitude')\n",
|
||
|
"plt.title('Signal with butter lowpass filter and without Filter')\n",
|
||
|
"plt.legend()\n",
|
||
|
"plt.grid(True)\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 16,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAADvrUlEQVR4nOydd3gU1frHv7Ob3iCdkFCkSO8diXQQrghGpFgoIqiIiFFR8EpTAQERQRCx3/tTQDAiXpEigoYmCiJKs1FMaEkIpCeb2fn9MTubnZ0tMzuT7Ozyfp6Hh+zs7MzZd8+cc97zNob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/HtGnTwDAMIiMj0apVK4SHhwPgXRE5jsOLL76IF1980eHnr169iuTkZJjNZrzxxhtYs2YNzp49C5ZlrefExsZKPjdjxgyUlZXh559/dujWuGTJEowfPx716tVDp06dMHToUIwbNw6NGjWS9b0IgiCqG1KyCIIgbgLMZjMA4IEHHnCqJAnxQQK21hvbayxdulRiWRCIiIhAeXm5ytaKiYqKwsCBAzFw4EAEBgbio48+wg8//IDevXtrcn2j0ejwOMdx1r9HjRqFAwcO4Nlnn0X79u0REREBs9mMO+64wyoXJfTq1QsA8P333+Pvv/9Gx44dER4ejtTUVKxcuRJFRUX4+eef8corr3j2pSzI+W6uSElJwYABAxy+J3zvZ555xqmFUlB2Fy5ciBdffBEPPfQQXnrpJcTExMBgMGDGjBkO5Td8+HBs2LABixc
|
||
|
"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(butter_filtered_sig,radius=3)\n",
|
||
|
"record = butter_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": 17,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Learning initial signal parameters...\n",
|
||
|
"Failed to find 8 beats during learning.\n",
|
||
|
"Initializing using default parameters\n",
|
||
|
"Running QRS detection...\n",
|
||
|
"QRS detection complete.\n",
|
||
|
"[ 544 1114 1683 2281 2855 3452 4016 4606]\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAC6+ElEQVR4nOzdd3xTdfcH8E9W0z2gi5bSUvYue4NsBEVc4AQRkUfFhaIPj89PxIkLUBw8qLj3wsGQvUFkzzIKpbR00z0y7++Pm3ubtGmbQpI27ef9evmSprfpt71pknPP+Z6jEARBABERERERETmFsr4XQERERERE1JgwyCIiIiIiInIiBllEREREREROxCCLiIiIiIjIiRhkERERERERORGDLCIiIiIiIidikEVEREREROREDLKIiIiIiIiciEEWERERERGREzHIIqJGKTk5GQqFAp999ll9LwUA8Nlnn0GhUCA5ObnG4+677z74+/u7Z1FOpFAo8MILL9T3MojI4oUXXoBCoajvZRA1WQyyiKhOkpKSMHv2bMTHx8Pb2xuBgYEYPHgw3nnnHZSVldX5/nbv3o0XXngB+fn5Dn/NH3/8geHDhyM8PBy+vr6Ij4/HlClTsG7dujp/f2p8tm7dCoVCIf+nUqkQHh6O2267DadOnXLoPq7mcVlfPvjggwZzMeFqGQwGvPvuu+jbty8CAgLg7++Pvn37YtmyZTAajVWOj4uLsznHfn5+6NevH7744gu795+cnIwZM2agTZs28Pb2RmRkJIYNG4YFCxa4+kcjoiZKXd8LICLPsXr1atx+++3QarWYNm0aunbtCr1ej507d2LevHk4ceIEVqxYUaf73L17NxYuXIj77rsPwcHBtR7/1ltvYd68eRg+fDjmz58PX19fnDt3Dhs3bsR3332H8ePHAwBiY2NRVlYGjUZzNT8q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/73/9w3XXXYdu2bejfv7/NfT766KOIjIzEwoULsXfvXqxYsQLBwcHYvXs3WrVqhVdffRVr1qzBm2++ia5du1b5/XzxxRcoKirCI488gvLycrzzzjsYOXIkjh07VuP5f+WVV/B///d/mDJlCh544AFkZ2dj2bJlGDZsGA4dOoTg4GDMmDEDv/zyC+bOnYsxY8YgJiYGx44dw8KFCzFz5kxMmDChzr9DoiZJICKqRUFBgQBAuOmmmxw6/sKFCwIA4dNPP63yOQDCggUL5I/ffPNNAYBw4cIFh+77+eefFwAIfn5+wvXXXy+88sorwoEDBxxaQ7du3YSWLVsKRUVF8m1bt24VAAixsbFVvrZ58+bClStX5Nt/++03AYDwxx9/yLeVlpZW+d7ffvutAEDYvn27fNunn37q0M85ffp0AYDw6KOPyreZzWZh4sSJgpeXl5CdnV3t99br9ULXrl2FkSNHyrctWbJEAGDzdZV9+eWXglKpFHbs2GFz+/LlywUAwq5duwRBEITDhw8LAISHH37Y5ri77rqrynm1Z+nSpQIA4auvvrJZ88CBAwV/f3+hsLBQEIS6/f7t2bJliwBAWLlypZCdnS1cvnxZWLdundC2bVtBoVAI+/btq/HrBaH6x6X0O3jggQdsbn/66acFAMLmzZtrvF9HH4M7duwQAAhff/21zdevW7euyu1dunQRhg8fXuvPJAiCsGrVKgGA8PLLL9vcfttttwkKhUI4d+6cfBsAwcvLy+a2I0eOCACEZcuWybfNnDlTaNGihZCTk2Nzn3fccYcQFBRk929E8sQTTwgAhEOHDlV7zMGDBwUAwty5c+XbYmNjhbFjxwrZ2dlCdna2cOzYMeHee+8VAAiPPPKIzdcfP35c8PHxEQAICQkJwuOPPy6sWrVKKCkpqfZ7Whs2bJgQEBA
|
||
|
"text/plain": [
|
||
|
"<Figure size 1000x500 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# Normalize data by setting qrs peaks to index position 0 (“X-axis normalization”)\n",
|
||
|
"indicies = wfdb.processing.xqrs_detect(butter_filtered_sig,500,0,5000)\n",
|
||
|
"print(indicies)\n",
|
||
|
"\n",
|
||
|
"# detected = [ 530 1076 1631 2174 2725 3281 3828 4378 4938]\n",
|
||
|
"cut_signal = butter_filtered_sig[indicies[0]:indicies[2]]\n",
|
||
|
"\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",
|
||
|
"plt.title('Cut Signal based on R to get one QRS complex')\n",
|
||
|
"plt.grid(True)\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 18,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAADzAElEQVR4nOydd3gUVffHv7O7yaaTQEJCCQlNEGlSRap0Y0NRUN9XBXtBUWw/LBQVQSxgL9gLqCjyolKlSO+91xBaGklI2ZTN7vz+2MzstN3s7MxmC+fzPDzszs7O3D25c+899zSGZVkWBEEQBEEQBEEQhC4Y/N0AgiAIgiAIgiCIUIKULIIgCIIgCIIgCB0hJYsgCIIgCIIgCEJHSMkiCIIgCIIgCILQEVKyCIIgCIIgCIIgdISULIIgCIIgCIIgCB0hJYsgCIIgCIIgCEJHSMkiCIIgCIIgCILQEVKyCIIgCIIgCIIgdISULIIgCB+RmZkJhmHw7bff+rspAIBvv/0WDMMgMzPTJ9dPT0/HmDFjPD73xhtv9Ek73DFmzBikp6d79d0pU6aAYRh9G0TIWLNmDRiGwZo1a/zdFK9gGAZTpkzxdzMIgvAzpGQRBBF0nDhxAo888ghatGiBiIgIxMXFoXfv3nj//fdRXl6u+nobN27ElClTUFRU5PF3/vzzT/Tv3x8NGzZEVFQUWrRogVGjRmHp0qWq7x+qHDx4EFOmTPGJUscwDBiGwYMPPqj4+csvv8yfk5+fr/v9g40NGzbg1ltvRXJyMsxmM9LT0/Hoo4/izJkzmq5bVVWF999/H1dffTXi4uIQHx+Pq666Cg8//DAOHz6sU+s9x5tn2RsWL15MihRBEG4hJYsgiKDi77//RocOHfDrr7/ipptuwocffojp06ejWbNmeP755zF+/HjV19y4cSOmTp3q8cLsnXfewc033wyGYTBx4kTMmjULI0eOxLFjx/Dzzz/z56WlpaG8vBz33HOP6jYFI0eOHMGcOXP49wcPHsTUqVN9ZjmLiIjA77//jqqqKtln8+bNQ0REhOz4nDlzcOTIEa/u98orr3ilxPubDz/8EH379sW+ffvw5JNP4pNPPsHtt9+On3/+GR07dsTmzZu9vvbIkSPx7LPPon379pgxYwamTp2Kfv36YcmSJZqu6y1qn2VvWbx4MaZOnar4WXl5OV555RWf3p8giMDH5O8GEARBeMqpU6dw5513Ii0tDatWrUKjRo34z5544gkcP34cf//9t0/bUF1djddffx1DhgzB8uXLZZ/n5ubyrxmGUVzohypms7lO7zd8+HAsWrQIS5YswS233MIf37hxI06dOoWRI0fi999/F30nLCzM6/uZTCaYTME1bW7YsAFPP/00+vTpg6VLlyIqKor/7LHHHkPv3r0xcuRIHDhwAPHx8aquvW3bNvz111+YNm0aXnrpJdFnH330kc8VnUDlcnrmCYJwDVmyCIIIGmbOnInS0lJ89dVXIgWLo1WrVrwly108lDBmYsqUKXj++ecBAM2bN+ddzFxZX/Lz81FcXIzevXsrft6wYUP+tas2zJ8/H+3atUNERATat2+PP/74QxYrxH33nXfewRdffIGWLVvCbDaje/fu2LZtm+h6e/fuxZgxY3j3yZSUFNx///24ePGiYhvdsWjRIjAMg7179/LHfv/9dzAMg9tuu0107pVXXonRo0fz74UxWd9++y3uu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Px8XHPNNQCAnTt3qv59ffv2xbp16wAAJSUl2LNnDx5++GEkJibyx9etW4f4+HhFlzxPadeuHf97AIfFoU2bNqLfVhsJCQkYPnw45s2bB8Bhkbr22mt5K4uneCJnVwwaNEhkTeIsEyNHjhT
|
||
|
"text/plain": [
|
||
|
"<Figure size 1000x500 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"[-0.03577630855309041, -0.16337948001854852]\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"plt.figure(figsize=(10, 5))\n",
|
||
|
"plt.plot(butter_filtered_sig)\n",
|
||
|
"plt.xlabel('Time')\n",
|
||
|
"plt.ylabel('Amplitude')\n",
|
||
|
"plt.title('Cut Signal with Minimas Q, S detection')\n",
|
||
|
"plt.grid(True)\n",
|
||
|
"\n",
|
||
|
"for peak in indicies:\n",
|
||
|
" start_idx = 20\n",
|
||
|
" end_idx = 25\n",
|
||
|
" signal_section = butter_filtered_sig[peak-start_idx:peak+end_idx]\n",
|
||
|
" 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",
|
||
|
" minimas_y = [butter_filtered_sig[i] for i in minimas]\n",
|
||
|
" # if minimas more than 2 take those with biggest difference in y\n",
|
||
|
" if len(minimas) > 2:\n",
|
||
|
" minimas_y = [butter_filtered_sig[i] for i in minimas]\n",
|
||
|
" 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",
|
||
|
"execution_count": 19,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAC5/0lEQVR4nOzdd3xT9foH8E9W994LKC17j7IpQxAUFRGR4WCowFVxXNTr5eoFcU/E6/yhIi5ciBNkiCBb9qaM0lIoHbTQ3Wae3x8n5zRp0zYtSdq0n/fr5Uuapsm3PW1OnvM83+dRCIIggIiIiIiIiBxC2dgLICIiIiIiak4YZBERERERETkQgywiIiIiIiIHYpBFRERERETkQAyyiIiIiIiIHIhBFhERERERkQMxyCIiIiIiInIgBllEREREREQOxCCLiIiIiIjIgRhkERG1ICNGjMCIESMc9ngrVqyAQqFAenq6wx7zWsycORPx8fFOeez09HQoFAqsWLHC7vu+8cYbTlmLszz77LNQKBTIy8tz6vOMGzcOs2fPdupzNMTUqVMxefLkxl4GETUDDLKIiK5Ramoq5s6di4SEBHh5eSEgIABDhgzB22+/jfLy8no/3s6dO/Hss8+ioKDA8Yu1k06nw9tvv43evXsjICAAQUFB6Nq1K+bMmYOUlJRGW1dTs3btWjz77LMOf9wtW7ZAoVDI/2k0GiQkJGD69Ok4d+6cw5/PlXbs2IENGzbgqaeesro9PT0ds2bNQmJiIry8vBAVFYVhw4Zh0aJFACoD+rr+k4JsKWCU/vPx8UHr1q1xyy234NNPP4VWq622tqeeego//PADDh8+7PSfAxE1b+rGXgARkTtbs2YN7rjjDnh6emL69Ono1q0bdDodtm/fjieffBLHjx/HsmXL6vWYO3fuxOLFizFz5kwEBQU5Z+F1uP322/H7779j2rRpmD17NvR6PVJSUvDbb79h8ODB6NSpEwDgnnvuwdSpU+Hp6dko63SlNm3aoLy8HBqNRr5t7dq1eO+995wSaAHAI488gn79+kGv1+PAgQNYtmwZ1qxZg6NHjyImJsYpz+lsr7/+OkaNGoV27drJt509exb9+vWDt7c37r33XsTHxyMrKwsHDhzAq6++isWLF2PYsGH44osvrB7r/vvvR//+/TFnzhz5Nj8/P6v7fPDBB/Dz84NWq0VmZibWr1+Pe++9F0uXLsVvv/2GVq1ayfft3bs3kpKS8Oabb+Lzzz930k+AiFoCBllERA2UlpaGqVOnok2bNvjzzz8RHR0tf+6hhx7C2bNnsWbNmkZcYcPs3bsXv/32G1588UX85z//sfrcu+++a5VhU6lUUKlULl5h41AoFPDy8nLpcyYnJ2PSpEkAgFmzZqFDhw545JFH8Nlnn2HBggUuXYsj5ObmYs2aNfjwww+tbn/rrbdQUlKCQ4cOoU2bNtW+BgASEhKQkJBg9bl//OMfSEhIwN13313jc06aNAlhYWHyxwsXLsRXX32F6dOn44477sDu3but7j958mQsWrQI77//frWAjYjIXiwXJCJqoNdeew0lJSX45JNPrAIsSbt27fDoo48CqH0/j0KhkDMhzz77LJ588kkAQNu2beVSJ8s9T19++SX69u0Lb29vhISEYOrUqbhw4UK1x122bBkSExPh7e2N/v37Y9u2bXZ9X6mpqQCAIUOGVPucSqVCaGio/LGtPVkmkwnPPvssYmJi4OPjg5EjR+LEiROIj4/HzJkzq33tjh07MH/+fISHh8PX1xe33XYbLl++bPW8P//8M2666SbExMTA09MTiYmJeP7552E0Gu36nizNnz8foaGhEARBvu3hhx+GQqHA//73P/m2nJwcKBQKfPDBBwCqH8OZM2fivffeAwCrsrSqpOPg6emJfv36Ye/evfVes+S6664DIAb4kt9//x3Jycnw9fWFv78/brrpJhw/ftzq644cOYKZM2fKJa1RUVG49957kZ+fX+dznj9/Hu3atUO3bt2Qk5MDADhz5gxuv/12REVFwcvLC3Fx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ztbCAwMtLrd1s/v66+/FgAIW7dulW9btGiRAEC4fPmycPLkSSEmJkbo16+f1fdw8OBBAYDw/fff1/o92DJ06FChb9++1W4/duyY4O3tLQAQevXqJTz66KPCTz/9JJSWltb6eL6+vla/U5Ysvxdbrl69KgAQbrvttmqf69Chg3DjjTfW/Q0REdWAmSwiogYoKioCAPj7+7vsOVevXg2TyYTJkycjLy9P/i8qKgrt27fH5s2bAQD79u1Dbm4u/vGPf8DDw0P++pkzZyIwMLDO51EoFFi/fj1eeOEFBAcH4+uvv8ZDDz2ENm3aYMqUKbVmKzZt2gSDwYAHH3zQ6vaHH364xq+ZM2eOVZldcnIyjEYjzp8/L9/m7e0t/7u4uBh5eXlITk5GWVlZvbsdhoeHo1OnTti6dSsAsdudSqXCk08+iZycHJw5cwaAmMkaOnSozRJAe02ZMgXBwcFW3xsAuzsE3nvvvQgPD0dMTAxuuukmlJaW4rPPPkNSUhI2btyIgoICTJs2zer3QaVSYcCAAfLvA2D986uoqEBeXh4GDhwIADhw4EC15z127BiGDx+O+Ph4/PHHH1bfg/Q7tH79epSVldXjpwHk5+dbPZaka9euOHToEO6++26kp6fj7bffxoQJExAZGYmPPvqoXs9hL2m/VXFxcbXPBQcHO72NPRE1b2x8QUTUAAEBAQBsv0FzljNnzkAQBLRv397m56Wud1JwUvV+Uhtwe3h6euLpp5/G008/jaysLPz11194++238d1330Gj0eDLL7+0+XXSc1t2jgOAkJAQm2+uAaB169ZWH0v3u3r1qnzb8ePH8cwzz+DPP/+UA1xJXfuAbElOTsbatWsBiMFUUlISkpKSEBISgm3btiEyMhKHDx/GnXfeWe/HtmTP91abhQsXIjk5GSqVCmFhYejcuTP
|
||
|
"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",
|
||
|
"plt.title('Cuted Signal with Peaks (STD)')\n",
|
||
|
"plt.legend()\n",
|
||
|
"plt.grid(True)\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 20,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"(5000, 2)\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd3gU1frHv7ubTTa9N0JI6EWaEECQKiCKiKBY8VL0AlcBxahX+V0FsYFKVRFs6BVRsctVRBAIRRAQDL1DCCW9923z+2M2Ozs7s8nuziw7m7yf5+Fh58yZ2bMnZ86c73nf8x4VwzAMCIIgCIIgCIIgCFlQe7sABEEQBEEQBEEQTQkSWQRBEARBEARBEDJCIosgCIIgCI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LA1s/o0aPRs2dPa53t2rULKpUKAwcOdOqeYjj7WxISEvDggw9a07RaLZ544glUVlZix44dbn+/XFRUVCA0NLTBPPXn6y2B9UyfPh1btmwR/OvSpYs1zyeffIJ3330XrVu3xg8//IBnnnkGnTt3xvDhw3H16lVrvhtuuAGZmZl4+OGHkZWVhRUrVmDcuHGIj4/Hhx9+6PTv+e6773hlWbdundPXOqK4uBjbtm3DfffdZ23jhYWFKCoqwqhRo3D27FnebwGAadOmQaPRSP5ugiCUDQW+IAiiydKnTx98//330Ov1OHz4MH744QcsW7YMEyZMQGZmJm/AZ8ulS5fQv39/QXq7du1E87dq1Uq
|
||
|
"text/plain": [
|
||
|
"<Figure size 1000x500 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"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": 21,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd5gUVdaHf9VxcmIiaYYkQQQkKSpBAVEU1rRi+CSo4CooimnRXYKKoIKgqGBClDVgYBWVKGGJApJzHBjS5Jw61f3+qO7qUD0zXV01dPfMeZ+Hh67q29Wn79y6dc89iWOMMRAEQRAEQRAEQRCqoAm0AARBEARBEARBEA0JUrIIgiAIgiAIgiBUhJQsgiAIgiAIgiAIFSEliyAIgiAIgiAIQkVIySIIgiAIgiAIglARUrIIgiAIgiAIgiBUhJQsgiAIgiAIgiAIFSEliyAIgiAIgiAIQkVIySIIgiAIgiAIglARUrIIopGTkZGB0aNHB1oMAMDZs2fBcRwWL15cL9cfPXo0MjIyfG4bFRVVL3KoycaNG8FxHDZu3Fgv1x8wYAAGDBjgc9vOnTvXixxE4Fm8eDE4jsPZs2cDLQrhJ9OmTQPHcbI+U9/zMkE0VEjJIogGysGDB3HfffchPT0dYWFhaNasGQYPHoz58+cHWrSgobKyEtOmTas3BaUhcunSJUybNg379u0LtChurFixAtOmTfO5/YABA8BxHIYNGyZ5z7GonD17tooS+k6oK6uOhbxGo8H58+cl75eWliI8PBwcx2HChAkBkFA9HJscjn9GoxEpKSkYMGAA3nzzTeTl5QVaRIIgAgQpWQTRANm2bRt69uyJ/fv3Y+zYsfjggw/w+OOPQ6PR4L333nNre/z4cXz66acBkvTK8umnn+L48ePicWVlJaZPn05KVi2sWbMGa9asEY8vXbqE6dOnB6WSNX36dNmf++2337B79+56kIgwGo349ttvJeeXLVsWAGnql2e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O48847YTKZ8Nprr2HOnDkYPnw4tm7dWudv82V+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": 22,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpA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Vq2wYcMG8dymTZvAcRzy8vJw6NAh8fzGjRvRo0cPt9dJSkoSF2V33HEHFi1ahEWLFuHOO+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": 23,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAA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04d+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": 24,
|
||
|
"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+fORXp6Oo4ePYp3330XR48exa5du1SJeYwdOxYcx2HLli0YMGAAAGDr1q0wGAzYtm2beF5xcTFO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NDSgpKcGoUaMAwKsQtXHjxmHr1q0AhNC3gwcP4t5770VycrJ4fOvWrUhMTES/fv1Uvz+jT58+4vcBgJSUFPTs2VP23Zrjgw8+QEpKClJTUzFy5Ehs374d8+fPxyOPPIKysjL89NNPuPnmm1FdXS2Oh9LSUkydOhWnT59GXl4eACGXjOXzWa1WlJaWIjY2Fj179lTsv8rKSkyZMgUnTpzA5s2bMWjQINnziYmJ2L17Ny5duuRlzxAEQfgWChckCIIIMEaMGOFW+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",
|
||
|
"plt.legend()\n",
|
||
|
"plt.grid(True)\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 26,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"filter_params = {\n",
|
||
|
" 'names': ['butterlowpass', 'lowess', 'non_local_means'],\n",
|
||
|
" # params for butterworth filter\n",
|
||
|
" 'order':1,\n",
|
||
|
" 'fs':500.0,\n",
|
||
|
" 'cutoff':25,\n",
|
||
|
" # params for lowess filter\n",
|
||
|
" 'filter_strength':50,\n",
|
||
|
" 'template_window_size':7,\n",
|
||
|
" 'search_window_size':21,\n",
|
||
|
" # params for nlm filter\n",
|
||
|
" 'frac':0.003,\n",
|
||
|
" 'it':1\n",
|
||
|
"}\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 27,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd3wU1drHf7Mlm04oIaEHASnSpApSFQRRERR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Ees1qtLDk5md15553isblz5zIA7NtvvxWPlZSUsJYtWzIAbP369Zdtzy233MJ69Oghvr7jjjvYHXfcwYxGI/vtt98YY4zt3LmTAWA///yzrH39+/cXX2/fvr3S30jtd1m6dKl4zGazsV69erHY2FhWWFjIGGNs/fr1Xr+bt37y9NNPMzVTnKutnv/atm3Ljh8/LjvXs9+4mDp1quKeMTExsufJxVtvvaV4fhhjLDMzkxmNRjZz5kzZ8X379jGTySQ77mrzggULvH4f6e/kq4y/++47BoAdOHCAMcbYL7/8wiwWCxs+fDgbPXq0+NmOHTuykSNHKu4r5fbbb2fXXHPNZc/57LPPZHLIyspiJpOJjRgxQnbetGnTGACZLF2fHTRoEON5Xjz+3HPPMaPRyPLz88Vjvj5/lf22nvTv3/+y3+3HH39kAMTxxp/fVa/nhjGmGNdq1arFnn766ct+R09ZuJ6zunXrsry8PPH4zz//zACw//3vf+KxDh06sMaNG7OioiL
|
||
|
"text/plain": [
|
||
|
"<Figure size 1000x500 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"butter_filtered_sig = data_helper.butterlowpass_filter(data['SB'][0], filter_params['cutoff'], filter_params['fs'], filter_params['order'])\n",
|
||
|
"# Plot the original and denoised signal\n",
|
||
|
"plt.figure(figsize=(10, 5))\n",
|
||
|
"plt.plot(data['SB'][0].p_signal[:,0], label='Original signal')\n",
|
||
|
"plt.plot(butter_filtered_sig.p_signal[:,0], label='Butterlow signal')\n",
|
||
|
"plt.xlabel('Time')\n",
|
||
|
"plt.ylabel('Amplitude')\n",
|
||
|
"plt.title('Signal with and without Butterlow signal Denoising')\n",
|
||
|
"plt.legend()\n",
|
||
|
"plt.grid(True)\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 28,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||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B+vVq9c128cYY6Wlpapzjz76KIuIiGDl5eXyucGDBzMA7N///rd8rqKigiUnJ7Px48fL5+bPn88AsG+++UY+V1JSwlq3bs0AsI0bN16zPbfccgvr27evfHznnXeyO++8k5lMJvbLL78wxhjbu3cvA8B++OEHRfsGDx4sH+/evbvS38jX7/LZZ5/J56xWK+vfvz+LjIxkhYWFjDHGNm7c6PW7eesn//jHP5gv0+7gwYNZp06dKn09MzOThYSEsFGjRin67nvvvccAsGXLljHGGHM4HCw6Opo9++yzjDHGBEFgDRo0YHfddRczmUysqKiIMcbY3LlzGc/zLC8vjzHG2NatWxkA9vnnnys+d/Xq1Yrz//3vfxkAtnv37krbOm3aNBYdHc3sdnu1v78EAPaPf/zjmvcGwA4cOMAYY2zFihWM53m2detWxXVLlixhANj27dsV9w4JCWGnT5+Wzx04cIABYAsXLpTP3X777SwkJISdOXNGPnflyhUWFRXFBg0aJJ/z7A/79u1jANi33357ze/oOcZ98sknDAAbMWIEEwRBPv/UU08xk8nE8vPzGWOMpaenM7PZzG6//XbF/V566SUGQHFPgiCuL+QuSBCEXxg5ciR27tyJcePG4cCBA3jzzTcxevRoNG7cWOEy5o3Vq1ejf//+iqQGcXFxuPfee71e37FjR4W1KCEhAe3atcPZs2flc6GhoXLgucPhQE5ODiIjI9GuXTvs3bvX5+83cOBAZGRk4MSJEwBEy8GgQYMwcOBA2Xqwbds2MMYqtWRVl7///e+qz3b/bpU
|
||
|
"text/plain": [
|
||
|
"<Figure size 1000x500 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"lowess_filtered_sig = data_helper.lowess_filter(butter_filtered_sig, filter_params['frac'], filter_params['it'])\n",
|
||
|
"# Plot the original and denoised signal\n",
|
||
|
"plt.figure(figsize=(10, 5))\n",
|
||
|
"plt.plot(data['SB'][0].p_signal[:,0], label='Original signal')\n",
|
||
|
"plt.plot(lowess_filtered_sig.p_signal[:,0], label='Lowess signal')\n",
|
||
|
"plt.xlabel('Time')\n",
|
||
|
"plt.ylabel('Amplitude')\n",
|
||
|
"plt.title('Signal with and without Lowess Denoising')\n",
|
||
|
"plt.legend()\n",
|
||
|
"plt.grid(True)\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 29,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd3wU1drHfzO7m0YSkkAKNaFX6UVQilIF5Vq4dgVU9FVRFCtXpaiIBQFFARvqxYaFa0UEKVKV3nuvaYSQni1z3j9md3ZmZ5Ps7EzYkuf7+aCZ2TMzZ8+eOec852kcY4yBIAiCIAiCIAiCMAQ+0BUgCIIgCIIgCIIIJ0jIIgiCIAiCIAiCMBASsgiCIAiCIAiCIAyEhCyCIAiCIAiCIAgDISGLIAiCIAiCIAjCQEjIIgiCIAiCIAiCMBASsgiCIAiCIAiCIAyEhCyCIAiCIAiCIAgDISGLIAiCIAiCIAjCQEjIIogaTkZGBkaPHh3oagAATpw4AY7j8Nlnn1XL/UePHo2MjAyfy8bGxlZLPYxk9erV4DgOq1evrpb79+/fH/379/e5bPv27aulHkTg+eyzz8BxHE6cOBHoqhB+MmXKFHAcp+ma6h6XCSJcISGLIMKU3bt3Y+TIkUhPT0dUVBQaNGiAQYMGYc6cOYGuWtBQUlKCKVOmVJuAEo6cO3cOU6ZMwY4dOwJdFQVLlizBlClTfC7fv39/cByHG264QfWZa1E5Y8YMA2voO6EurLoW8jzP4/Tp06rPCwoKEB0dDY7jMG7cuADU0Dh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ejSaNm2KqKgopKWl4b777sOFCxd01e/OO+/Ejh07cODAAelcZmYmVq5ciTvvvNPrNeXl5Zg8eTKaN2+OyMhINGrUCM8++6yqn3/66ae49tprkZKSgsjISLRt2xbz5s1T3c/XMcpms2Hq1Klo0aIFoqKiUKdOHVx99dVYvny539+/Y8eOmD17NvLz8/Hee+8pPjt79izuu+8+pKamIjIyEu3atcOCBQsUZbT2pe+++w5du3ZFdHQ06tati7vvvhtnz55VlPHmk7V8+XJcffXVSEhIQGxsLFq1aoX//Oc/0ufefLJcPqu+jI8XLlzAPffcg/j4eCQkJGDUqFHYuXMn+XkRYQ8JWQQRhqSnp2Pr1q3Ys2eP5mvPnj2La665Bnv37sXEiRPx5JNP4ssvv1SZGbo4cuQIRo4ciUGDBuHtt99GYmIiRo8ejb1790pljh07hh9//BHXX389Zs6ciWeeeQa7d+9Gv379cO7cOU31S0hIQPv27bFmzRrp3Lp168BxHPLy8rBv3z7p/Nq1a9GnTx+v90lOTpYWZTfddBMWLlyIhQsX4uabb5bKOBwODBkyBHXq1MGMGTPQr18/vP322/jwww+rrOdnn32G2NhYTJgwAe+88w66du2KSZMm4fnnn1eVvXjxIoYOHYqOHTvi7bffRuvWrfHcc8/h999/l8qUlpZiwIAB+OOPPzBu3Di88MILWLt2rUpL4I327dsjISFB0WZr164Fz/PYuXMnCgoKAACCIGDDhg3o27ev1/u0adMGL7/8MgDgwQcflNpMXt7X79K/f38sXLgQd911F9566y3Url0bo0ePrrCfVcZDDz2EQYMGAYBUp4ULF/p07fjx45GYmFilP1dWVhZ69+6NP/74A4888gimTZuGsrIyjBgxAv/73/9U5V9//XX873//w9NPP42JEyfi77//xl133aX5u1XElClT8Oijj6J+/fp4++23ccstt+CDDz7A4MGDYbPZpHLLly9H3759sW/fPowfPx5vv/02rrnmGvz666+KMseOHcOYMWMwZ84c3H777fjmm28wbNgwxaaFVvr27YuGDRviq6++ks4tWrQIsbGxGD58uKq8IAgYMWIEZsyYgRtuuAFz5szBjTfeiFmzZuG2225TlJ03bx7S09Pxn//8B2+//TYaNWqERx55RBK25fgyRk2ZMgVTp07FNddcg/feew8vvPACGjdu7JPwXRkjR45EdHS0wuQ2KysLV155Jf7880+MGzcO77zzDpo3b477778fs2fPVt3Dl7702Wef4dZbb4XJZML06dMxduxYLF68GFdffbVXwdvF3r17cf3116O8vBwvv/wy3n77bYwYMQLr16+v8rv5Mj4KgoAbbrgBX3/9NUaNGoVp06bh/PnzGDVqVNWNRxChDiMIIuxYtmwZM5lMzGQysV69erFnn32W/fHHH8xqtarKpqens1GjRknHjz32GOM4jm3fvl06d+HCBZaUlMQAsOPHjyuuBcDWrFkjncvOzmaRkZHsqaeeks6VlZUxh8OheO7x48dZZGQke/nllxXnALBPP/200u/36KOPstTUVOl4woQJrG/fviwlJYXNmzdPqjPHceydd96Ryo0aNYqlp6dLxzk5OQwAmzx5suoZo0aNYgAU9WOMsc6dO7OuXbtWWj/GGCspKVGde+ihh1hMTAwrKyuTzvXr148BYP/973+lc+Xl5SwtLY3dcsst0rnZs2czAOzbb7+VzhUXF7PmzZszAGzVqlWV1mf48OGsR48e0vHNN9/Mbr75ZmYymdjvv//OGGNs27ZtDAD76aefFPXr16+fdLx58+YKfyOt3+WLL76QzlmtVtarVy8WGxvLCgoKGGOMrVq1yut389ZPHn30UaZlSuvXrx9r164dY4yxqVOnMgBs69ativu/9dZbUvknnniCAWBr166VzhUWFrImTZqwjIwMqX+76tymTRtWXl4ulX3nnXcYALZ7925NdfNGdnY2i4iIYIMHD1a8V++99x4DwBYsWMAYY8xut7MmTZqw9PR0dvHiRcU9BEGQ/vbWV7/++mvVu/3pp5+qxgBvTJ48mQFgOTk57Omnn2bNmzeXPuvevTsbM2YMY4wxAOzRRx+VPlu4cCHjeV7RxowxNn/+fAaArV+/vtI6DxkyhDVt2lRxztcxqmPHjmz
|
||
|
"text/plain": [
|
||
|
"<Figure size 1000x500 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"nlm_filtered_sig = data_helper.non_local_means_filter(lowess_filtered_sig, filter_params['filter_strength'], filter_params['template_window_size'], filter_params['search_window_size'])\n",
|
||
|
"# Plot the original and denoised signal\n",
|
||
|
"plt.figure(figsize=(10, 5))\n",
|
||
|
"plt.plot(data['SB'][0].p_signal[:,0], label='Original signal')\n",
|
||
|
"plt.plot(nlm_filtered_sig.p_signal[:,0], label='NLM 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": 30,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd3wU1fr/PzO7mwYJSUgIPaEXQToIClgoioqi2K5XARX9qtiwcr0iqAiiVC+ioogiKjbUn3QRpEU60juhhPTes7tzfn9MdnZmZ5fs7syyJc/79YLX7uyZmTMnZ845z3kaxxhjIAiCIAiCIAiCIHSB93cFCIIgCIIgCIIgQgkSsgiCIAiCIAiCIHSEhCyCIAiCIAiCIAgdISGLIAiCIAiCIAhCR0jIIgiCIAiCIAiC0BESsgiCIAiCIAiCIHSEhCyCIAiCIAiCIAgdISGLIAiCIAiCIAhCR0jIIgiCIAiCIAiC0BESsgiCqHOkpKRg7Nix/q4GACAtLQ0cx2HJkiU+uf7YsWORkpLidtn69ev7pB56smnTJnAch02bNv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4jy+H0EQgQsJWQRBhAx9+vTBzz//jIKCAuzcuROTJk1CSUkJRo8e7XJRBQDnzp1D27ZtVcedHQOAli1bqo7FxcUpFmWCIEgO/uHh4UhISEBiYiIOHDiAoqIij5/NtljbsmULysrKsG/fPgwcOBCDBg1SCAwxMTHo1q2bx9e3ERERIfltuXo
|
||
|
"text/plain": [
|
||
|
"<Figure size 1000x500 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"all_filtered_signals = data_helper.filter_data(data['SB'][0], filter_params)\n",
|
||
|
"# Plot the original and denoised signal\n",
|
||
|
"plt.figure(figsize=(10, 5))\n",
|
||
|
"plt.plot(data['SB'][0].p_signal[:,0], label='Original signal')\n",
|
||
|
"plt.plot(all_filtered_signals.p_signal[:,0], label='filtered signal')\n",
|
||
|
"plt.xlabel('Time')\n",
|
||
|
"plt.ylabel('Amplitude')\n",
|
||
|
"plt.title('Signal with and without All Denoising')\n",
|
||
|
"plt.legend()\n",
|
||
|
"plt.grid(True)\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 31,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"CPU times: total: 41.5 s\n",
|
||
|
"Wall time: 55.3 s\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"%%time\n",
|
||
|
"all_filtered_signals = data_helper.filter_data(data['SB'][:10], filter_params)"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"kernelspec": {
|
||
|
"display_name": "Python 3",
|
||
|
"language": "python",
|
||
|
"name": "python3"
|
||
|
},
|
||
|
"language_info": {
|
||
|
"codemirror_mode": {
|
||
|
"name": "ipython",
|
||
|
"version": 3
|
||
|
},
|
||
|
"file_extension": ".py",
|
||
|
"mimetype": "text/x-python",
|
||
|
"name": "python",
|
||
|
"nbconvert_exporter": "python",
|
||
|
"pygments_lexer": "ipython3",
|
||
|
"version": "3.10.4"
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 2
|
||
|
}
|