DSA_SS24/notebooks/noise_reduction.ipynb

304 lines
761 KiB
Plaintext
Raw Permalink Normal View History

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
2024-06-11 19:04:23 +02:00
"# Noise Reduction\n",
"\n",
2024-06-11 19:04:23 +02:00
"This Notebook is used to reduce the noise in the ECG signals.\n",
"First a Butterworth filter is applied to the signals to remove the high frequency noise.\n",
"Than a loess filter is applied to the signals to remove the low frequency noise.\n",
"Last Non local means filter is applied to the signals to remove the remaining noise."
]
},
{
"cell_type": "code",
2024-06-11 19:04:23 +02:00
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from matplotlib import pyplot as plt\n",
"import wfdb.processing\n",
"import sys\n",
"import json\n",
"\n",
"sys.path.append('../scripts')\n",
"import data_helper"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Load Data"
]
},
{
"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",
2024-06-11 19:04:23 +02:00
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Reading GSVT\n",
2024-06-11 19:04:23 +02:00
"Reading AFIB\n",
"Reading SR\n",
2024-06-11 19:04:23 +02:00
"Reading SB\n",
"Number of patients per category:\n",
"GSVT: 1027\n",
"AFIB: 9787\n",
"SR: 10426\n",
"SB: 15826\n"
]
}
],
"source": [
"data = data_helper.load_data(only_demographic=False)\n",
"\n",
"print(\"Number of patients per category:\")\n",
"for cat_name in data.keys():\n",
" print(f\"{cat_name}: {len(data[cat_name])}\")"
]
},
{
"cell_type": "code",
2024-06-11 19:04:23 +02:00
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABN0AAAGJCAYAAAC+dUXNAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9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C4S+Thw8esn8DT2lpqegcgiAIgiDCCwq6EQRBEARhCI4dOyYErfbs2ePy+FdffYWxY8fi5ptvxqRJk1C/fn1YLBbMnDkTR48edTnfYrHIvo/ScY7j/Gi9A17F9uabbyIlJUX2nLi4OL/fxxNqg0Dt2rUD4Pi8+/fvr+o5Sp8fy7p16zB8+HAMGDAAH330ERo2bIiIiAh8/vnnWLJkierXlOsTT+fa7XaYTCb8/vvvsud6+/k3bNgQAHDu3DmXx86dO4fatWvLquAIgiAIgqj+UNCNIAiCIAjdY7fbMXbsWCQkJOCJJ57AjBkzcPvtt+PWW28Vzvn+++/RsmVLLFu2TKSWmjZtWkDadOTIEXAcJ3qvQ4cOAXBUN5WDT5FMSEjAkCFDNGtL8+bNcfDgQZfjBw4cEB73hZtuugkzZ87EV199pTropoYffvgB0dHRWLVqlSgg9fnnn2v2Hkq0atUKHMehRYsWgjLRHxo3box69eph27ZtLo+lpaUpBlcJgiAIgqj+kKcbQRAEQRC65+2338bGjRvx6aefYvr06ejXrx8eeeQR5OTkCOfwqiVW/bRlyxZs2rQpIG06e/asqDJoQUEBvvjiC6SkpMimlgJ
"text/plain": [
"<Figure size 1500x400 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"example_data = data['SB'][0]\n",
"#Plot specific Channel of Record\n",
"fig = wfdb.plot_items(example_data.p_signal[:,0],title=\"Example for Channel 0\",figsize=(15,4),return_fig=True)"
]
},
{
"cell_type": "code",
2024-06-11 19:04:23 +02:00
"execution_count": 4,
"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",
"\n",
"#save filter params to json file\n",
"with open('../filter_params.json', 'w') as f:\n",
" json.dump(filter_params, f)"
]
},
{
"cell_type": "code",
2024-06-11 19:04:23 +02:00
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd3wU1drHf7Mlm04oIaEHASnSpApSFQRRERRFXxtYsCFoLMj1SlMEsXEtgBdFFBQrliuIFAk1CtIRCDX0FAjpybY57x+TnZ3Z2ZCdnQlb8nw/HzQ7Oztz9tkz55znPI1jjDEQBEEQBEEQBEEQumAIdAMIgiAIgiAIgiDCCVKyCIIgCIIgCIIgdISULIIgCIIgCIIgCB0hJYsgCIIgCIIgCEJHSMkiCIIgCIIgCILQEVKyCIIgCIIgCIIgdISULIIgCIIgCIIgCB0hJYsgCIIgCIIgCEJHSMkiCIIgCIIgCILQEVKyCIKQkZKSgjFjxgS6GQCAzMxMcByHxYsXV8v1x4wZg5SUFJ/PjY2NrZZ26ElaWho4jkNaWlq1XH/AgAEYMGCAz+e2b9++WtpBXB41v1MgWbx4MTiOQ2ZmZqCbAkDdmBBKcByHadOmqfpMuMqCIK4UpGQRRA1h3759GDVqFJo1a4bIyEg0atQIgwcPxgcffBDopgUNpaWlmDZtWrUpKOHIuXPnMG3aNOzevTvQTZGxcuVKVYvKAQMGgOM48V9ERASaN2+OcePG4fTp036344033sBPP/2kOL5161ZMmzYN+fn5fl+bCBzS/mIwGBAfH4/WrVvjgQcewJo1awLdPIIgggBToBtAEET1s3XrVgwcOBBNmzbFY489huTkZJw+fRp//vkn/vOf/+CZZ54Rz83IyIDBUDP2XxYuXAie58XXpaWlmD59OgCEhBUgEKxevVr2+ty5c5g+fTpSUlLQuXPnwDTKCytXrsRHH32kStFq3L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HZZ59FSkoKLBYL6tevj8GDB2Pnzp3iOZ793PWcvf322/jvf/+LFi1awGKxoHv37ti+fbvint999x3atWuHyMhItG/fHj/++CPFeRE1CrJkEUQNoFmzZkhPT8f+/ftVJyI4e/YsBg4cCI7jMHnyZMTExOCTTz6p1OJ19OhRjBo1Co888ggeeughLFq0CGPGjEHXrl1xzTXXAACOHz+On376CXfddReaN2+O7OxsfPzxx+jfvz8OHDiAhg0b+ty+hIQEtG/fHhs3bsSECRMAAJs3bwbHccjLy8OBAwfE+27atAl9+/b1ep3ExETMnz8fTz75JEaOHCkuNDt27Cie43Q6MWTIEPTs2RNvv/021q5di3feeQctWrTAk08+edl2Ll68GLGxsUhNTUVsbCz++OMPTJkyBYWFhXjrrbdk5166dAlDhw7FHXfcgbvvvhvff/89Jk2ahA4dOuDmm28GILj/3HjjjTh16hQmTJiAhg0bYsmSJfjjjz+qlFn79u2RkJCAjRs3Yvjw4aJsDAYD9uzZg8LCQsTHx4PneWzduhXjxo3zep22bdtixowZmDJlCsaNGyfKtnfv3qq/y4ABA3D06FGMHz8ezZs3x3fffYcxY8YgPz8fEydOrPI7SXn88cdx7tw5rFmzBkuWLPH5c06nExcuXAAA2O12HDx4EFOnTkXLli1x/fXXq2oDACxZsgSPPvooevToIcqwRYsWiImJweHDh7Fs2TK89957qFevHgCISv7MmTPx6quv4u6778ajjz6K3NxcfPDBB+jXrx927dol2yy5ePEibr75Ztxzzz24//77kZSU5LUtvsq4b9++WLZsmfi5vLw8/PPPPzAYDNi0aZP4PGzatAmJiYlo27Ztpd9/4cKFmDBhAkaNGoWJEyeivLwce/fuxV9//YX/+7//q/RzkydPxpw5c3DbbbdhyJAh2LNnD4YMGYLy8nKv5z/zzDOoXbs2pk6diszMTMydOxfjx4/HN998I56j5vnTitFoxL333otXX30Vmzdvxi233AJA3e9a3c/NE088ge+//x7jx49Hu3btcPHiRWzevBkHDx5UbLR48tVXX6GoqAiPP/44OI7DnDlzcMcdd+D48eOi9WvFihUYPXo0OnTogFmzZuHSpUt45JFH0KhRI43SJYgQghEEEfasXr2aGY1GZjQaWa9evdhLL73Efv/9d2az2RTnNmvWjD300EPi62eeeYZxHMd27dolHrt48SKrU6cOA8BOnDgh+ywAtnHjRvFYTk4Os1gs7PnnnxePlZeXM6fTKbvviRMnmMViYTNmzJAdA8A+++yzy36/p59+miUlJYmvU1NTWb9+/Vj9+vXZ/PnzxTZzHMf+85//iOc99NBDrFmzZuLr3NxcBoBNnTpVcY+HHnqIAZC1jzHGrr32Wta1a9fLto8xxkpLSxXHHn/8cRYdHc3Ky8vFY/3792cA2BdffCEes1qtLDk5md15553isblz5zIA7NtvvxWPlZSUsJYtWzIAbP369Zdtzy233MJ69Oghvr7jjjvYHXfcwYxGI/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(example_data, 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(example_data.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",
2024-06-11 19:04:23 +02:00
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd3gU1frHv7M1PQFS6ITeexOUJh2FC4rtehWw4BURNHpVfldBbCCioFRFsWBDuFz1Kh3pIC2EIr2EGpKQkF62zPn9MbuzM7ubsjsTtuT9PA8PO7Ozs2ffnDnnvOdtHGOMgSAIgiAIgiAIglAFja8bQBAEQRAEQRAEEUyQkkUQBEEQBEEQBKEipGQRBEEQBEEQBEGoCClZBEEQBEEQBEEQKkJKFkEQBEEQBEEQhIqQkkUQBEEQBEEQBKEipGQRBEEQBEEQBEGoCClZBEEQBEEQBEEQKkJKFkEQBEEQBEEQhIqQkkUQhN+TmJiI8ePH+7oZAIDU1FRwHIevvvqqSu4/fvx4JCYmVvraiIiIKmmHmmzbtg0cx2Hbtm1Vcv/+/fujf//+lb62Xbt2VdIOgvC2r/vTGEcQhDqQkkUQhM84duwYxo4di0aNGiEkJAT16tXD4MGDsWDBAl83zW8oKirCm2++WWUKSjBy/fp1vPnmm0hJSfF1U2SsXbsWb775ZqWvJ4VQgOM48Z9Op0PNmjXRtWtXTJ06FSdOnPB18wiCINyi83UDCIKonuzZswcDBgxAw4YN8fTTT6N27dq4cuUK/vzzT3z88cd4/vnnxWtPnz4NjaZ67AktW7YMPM+Lx0VFRZg5cyYAVNpaU93YuHGj7Pj69euYOXMmEhMT0alTJ980yg1r167FokWLPFK0CIHBgwfj8ccfB2MMubm5OHLkCL7++mss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WmXfe/HiRWY0Gtlbb70lOweAffnll+X+vueee44lJCSIx0lJSaxv374sPj6eLVmyRGwzx3Hs448/Fq8bN24ca9SokXicmZnJALAZM2a4fMe4ceMYAFn7GGOsc+fOrGvXruW2jzHGioqKXM4988wzLCwsjJWUlIjn+vXrxwCwb775RjxXWlrKateuze6//37x3Pz58xkA9tNPP4nnCgsLWbNmzRgAtnXr1nLbc88997AePXqIx/fddx+77777mFarZevWrWOMMZacnMwAsF9++UXWvn79+onHBw4cKPNv5Olv+fbbb8VzJpOJ9erVi0VERLC8vDzGGGNbt251+9vc9ZPnnnuOeTLt9uvXj7Vt27bM9zMyMpjBYGBDhgyR9d2FCxcyAGz58uWMMcasViuLiopir7zyCmOMMZ7nWa1atdgDDzzAtFoty8/PZ4wx9tFHHzGNRsNu3brFGGNs586dDAD77rvvZN+7fv162fn//ve/DAA7cOBAmW2dOnUqi4qKYhaLpdK/3w4A9txzz5V7bwDsyJEjjDHGVqxYwTQaDdu5c6fsuqVLlzIAbPfu3bJ7GwwGdu7cOfHckSNHGAC2YMEC8dzo0aOZwWBg58+fF89dv36dRUZGsr59+4rnnPvD4cOHGQC2atWqcn+j8xj35ZdfMgBs0KBBjOd58fyLL77ItFoty8nJYYwxduPGDabT6djo0aNl93vzzTcZANk9CYK4vZC7IEEQPmHw4MHYu3cvRo0ahSNHjmDOnDkYOnQo6tWrJ3MZc8f69evRq1cvWVKDmjVr4tFHH3V7fZs2bWTWori4OLRs2RIXLlwQzxmNRjHw3Gq1IisrCxEREWjZsiWSk5M9/n19+vRBeno6Tp8+DUCwHPTt2xd9+vQRrQe7du0CY6xMS1Zl+ec//+ny3dLfVhahoaHi6/z8fNy
"text/plain": [
"<Figure size 1000x500 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"lowess_filtered_sig = data_helper.lowess_filter(example_data, filter_params['frac'], filter_params['it'])\n",
"# Plot the original and denoised signal\n",
"plt.figure(figsize=(10, 5))\n",
"plt.plot(example_data.p_signal[:,0], label='Original signal')\n",
"plt.plot(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",
2024-06-11 19:04:23 +02:00
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd5wT1drHf5PsbrYXYHfpLL1KL4LSq6BcC9d6FVDRV0VRbJer0hRBqYoCigJeVAQVlatIkSJtld57r1vYXtPmvH9MMplJ2U0yE1L2+X4+aGYymZw8e+ac85yncYwxBoIgCIIgCIIgCEIVNP5uAEEQBEEQBEEQRChBShZBEARBEARBEISKkJJFEARBEARBEAShIqRkEQRBEARBEARBqAgpWQRBEARBEARBECpCShZBEARBEARBEISKkJJFEARBEARBEAShIqRkEQRBEARBEARBqAgpWQRBEARBEARBECpCShZBVHHS0tIwatQofzcDAHDx4kVwHIdly5b55P6jRo1CWlqa29fGxsb6pB1qsnXrVnAch61bt/rk/n369EGfPn3cvrZNmzY+aQfhf5YtWwaO43Dx4kV/N4XwksmTJ4PjOI8+4+txmSBCFVKyCCJEOXLkCEaMGIEGDRogMjISderUwcCBAzF//nx/Ny1gKC0txeTJk32moIQi169fx+TJk3Hw4EF/N0XG2rVrMXnyZLev79OnDziOwz333OPwnnVROWvWLBVb6D7BrqxaF/IajQZXrlxxeL+wsBBRUVHgOA5jx471QwvVw7rJYf2n0+mQmpqKPn364P3330d2dra/m0gQhJ8gJYsgQpBdu3ahc+fOOHToEMaMGYNPPvkETz/9NDQaDT766CPZtadOncLixY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muiBEjRiAqKkrmcpuZmYnbb78df/zxB8aOHYuPPvoITZo0wVNPPYV58+Y53MOdvrRs2TI8+OCD0Gq1mD59OsaMGYPVq1fjzjvvdKp4Wzl27Bjuvvtu6PV6TJ06FbNnz8bw4cOxc+fOSn+bO+Mjz/O45557sGLFCowcORLTpk3DjRs3MHLkyMqFRxDBDiMIIuTYsGED02q1TKvVsu7du7M33niDrV+/nhkMBodrGzRowEaOHCkev/jii4zjOHbgwAHxXE5ODqtWrRoDwC5cuCD7LAC2bds28VxWVhbT6XTs1VdfFc+Vl5czs9ks+94LFy4wnU7Hpk6dKjsHgC1durTC3/fCCy+w1NRU8Xj8+PGsV69eLCUlhS1cuFBsM8dx7KOPPhKvGzlyJGvQoIF4nJ2dzQCwSZMmOXzHyJEjGQBZ+xhjrEOHDqxTp04Vto8xxkpLSx3OPfvssyw6OpqVl5eL53r37s0AsP/+97/iOb1ez2rWrMkeeOAB8dy8efMYALZq1SrxXElJCWvSpAkDwLZs2VJhe4YNG8a6du0qHt9///3s/vvvZ1qtlv3++++MMcb279/PALBffvlF1r7evXuLx3v27HH5N/L0t3z99dfiOYPBwLp3785iY2NZYWEhY4yxLVu2OP1tzvrJCy+8wDyZ0nr37s1at27NGGNsypQpDADbt2+f7P4zZ84Ur3/55ZcZALZ9+3bxXFFREWvYsCFLS0sT+7e1zS1btmR6vV689qOPPmIA2JEjRzxqmzOysrJYREQEGzRokOy5+uSTTxgAtmTJEsYYYyaTiTVs2JA1aNCA5eXlye7B87z42llfXbFihcOzvXTpUocxwBmTJk1iAFh2djZ77bXXWJMmTcT3unTpwkaPHs0YYwwAe+GFF8T3li9fzjQajUzGjDG2aNEiBoDt3LmzwjYPHjyYNWrUSHbO3TGqXbt2bNiwYRX+LmdY/97
"text/plain": [
"<Figure size 1000x500 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"nlm_filtered_sig = data_helper.non_local_means_filter(example_data, 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(example_data.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",
2024-06-11 19:04:23 +02:00
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1kAAAHWCAYAAACFeEMXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd3wU1fr/PzO7mwYJSUgIPaEXQToIClgoioqi2K5XARX9qtiwcr0iqAiiVC+ioogiKjbUn3QRpEU60juhhPTes7tzfn9MdnZmZ5fs7syyJc/79YLX7uyZmTMnZ845z3kaxxhjIAiCIAiCIAiCIHSB93cFCIIgCIIgCIIgQgkSsgiCIAiCIAiCIHSEhCyCIAiCIAiCIAgdISGLIAiCIAiCIAhCR0jIIgiCIAiCIAiC0BESsgiCIAiCIAiCIHSEhCyCIAiCIAiCIAgdISGLIAiCIAiCIAhCR0jIIgiCIAiCIAiC0BESsgiCqHOkpKRg7Nix/q4GACAtLQ0cx2HJkiU+uf7YsWORkpLidtn69ev7pB56smnTJnAch02bNvnk+tdffz2uv/56t8t26dLFJ/XwJ0uWLAHHcUhLS5OOedIuwYK3718otgVBEPpCQhZBECHDwYMHMXr0aCQnJyMiIgLNmjXD0KFD8eGHH/q7agFDeXk5pkyZ4jMBJRS5dOkSpkyZgv379/u7KgpWrVqFKVOmeHVu3759wXEcFi5cqG+lIG5icBwHjuPA8zxiY2PRtWtXPP7449ixY4fu9yMIgghEjP6uA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vGx9br31Vta3b1/p+1133cXuuusuZjAY2OrVqxljjO3du5cBYL/++quifoMHD5a+79q1y+XfyNNn+frrr6Vj1dXVrH///qx+/fqsuLiYMcbYxo0bnT6bs37y9NNPM0+n8QkTJrAWLVowQRAYY+J7A0DR9xlj7IsvvlD1fcd2cUVycjK79dZbXf4+Z84cRZtv2bKFAWDLli1TlFuzZo3quLvv3/PPP88AsC1btkjHSkpKWKtWrVhKSor0bjq2a0FBAQPA3n///cs+o2Nb2P5unTp1YlVVVdLxefPmMQDs4MGDjDGxbzRs2JD16dOHmc1mqdySJUsYALfalyCI4IA0WQRBhARDhw5FamoqRo4ciX/++QczZ87E8OHD0axZM4XJmDPWrFmD/v37K4IaxMfHq3agbXTu3FmhLUpMTESHDh1w5swZ6Vh4eLgUXMNqtSIvLw/169dHhw4dsHfvXo+fb+DAgcjKysLx48cBiFqZQYMGYeDAgdiyZQsAUbvFGHOpyXKX//u//1PdW/5sroiMjJQ+l5SUIDc3FwMHDkR5eTmOHTumKFu/fn2Fz05YWBj69u2ruM+qVavQpEkTjB49WjoWFRWFxx9/3K3nGDhwIPbu3YuysjIAYvuMGDEC3bt3l9psy5Yt4DgO1113nVvXdIa7z9K4cWM88MAD0jGTyYRnn30WpaWl+Ouvv7y+v7tYLBYsX74c9913n2RaeOONN6JRo0ZXXJsFiH0EAH744Qc0aNAAQ4cORW5urvSvV69eqF+/PjZu3Kg43533b9WqVejbt6/i71q/fn08/vjjSEtLU2jR5ERGRiIsLAybNm1SmSq6w7hx4xT+WrZ62uq2e/du5OXlYfz48TAa7W7xDz74IOLi4jy+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(example_data, filter_params)\n",
"# Plot the original and denoised signal\n",
"plt.figure(figsize=(10, 5))\n",
"plt.plot(example_data.p_signal[:,0], label='Original signal')\n",
"plt.plot(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",
2024-06-11 19:04:23 +02:00
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAksAAAHHCAYAAACvJxw8AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydZ5hURdaA385pco4wMMQhxwEEAQERE4gBUREQE67uunzqGkHUFbNixEQwIIq4KIooIChKkiA5Mznnnukc7vejmaZ7EgNM6va+z9PP9Ny+oaruvVWnzjl1jkQQBAEREREREREREZE6kbZ2AURERERERERE2jKisCQiIiIiIiIi0gCisCQiIiIiIiIi0gCisCQiIiIiIiIi0gCisCQiIiIiIiIi0gCisCQiIiIiIiIi0gCisCQiIiIiIiIi0gCisCQiIiIiIiIi0gCisCQiIiIiIiIi0gCisCQi0gjS09ORSCQsXbrUve3pp59GIpG0XqHOE18rb3PSHG3x559/MmzYMHQ6HRKJhL/++qtJz38htNRzu3nzZiQSCV9//XWTnre1qK7P5s2bW7soIm0EUVgSEQGWLl2KRCKp8/Poo482+jzPP/88q1evbr6CtgAzZsyoty3UanVrF69NYrPZuPHGGyktLeX111/n008/pX379q1drCZh8+bNTJ48mZiYGJRKJVFRUVxzzTV88803rV00EZEWQ97aBRARaUs888wzdOjQwWtbz549ad++PSaTCYVC0eDxzz//PDfccAOTJk1qxlI2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U1QqVTCM88847WtMc9tTb799lsBEF5//fVGlae6/t27dxcsFot7+8KFCwVAOHDggHtbXc/DggULBIlE4vXMVj+HnvURBEHo16+fMGDAgFp1DA8PF0pLS2vVYc2aNe5tY8aMEXr16iWYzWb3NqfTKQwbNkzo3Llzrfps2rRJEARB2Lt3b533V+Tvg2iGExHx4J133mH9+vVen4tFEARWrVrFNddcgyAIFBcXuz/jx4+noqKCPXv2eB0zffp0NBqN+/+//vqLEydOcMstt1BSUuI+3mAwMGbMGH777TecTicOh4OffvqJSZMm0a5dO/fx3bt3Z/z48Y0us1qtrtUO69ev54UXXvDa7+6772b8+PE88MADTJs2jeTkZJ5//nmvfTzrYbPZKCkpoVOnToSEhNSqN8CsWbO8lranpqYiCAKzZs1yb5PJZAwcOJDTp0/XOn7SpEnEx8e7/x88eDCpqamsXbu23vp+8803OJ1ObrrpJq/7ExMTQ+fOndm0aVMDrVU3eXl5/PXXX8yYMYOwsDD39t69ezNu3Lg6y3Pvvfc26twqlcrtw+ZwOCgpKSEgIICuXbvW2abnS7XZ93y0SgAzZ85EqVS6/x8xYgSA133yfB4MBgPFxcUMGzYMQRDYu3dvrXPWbJMRI0bUed+nTJlCaGhovdcuLS3ll19+4aabbqKystJ9j0tKShg/fjwnTpwgJyenznpVa45++uknjEZjw40g4peIZjgREQ8GDx5cr4P3hVJUVER5eTkffPABH3zwQZ37ePr9ALVW5J04cQJwCVH1UVFRgcViwWQy0blz51q/d+3atUGBwROZTMbYsWMbte/HH39McnIyJ06cYOvWrV6DIYDJZGLBggUsWbKEnJwcL/NSXf4enkIenB2oEhMTa20vKyurdXxdde/SpQtfffVVvXU4ceIEgiDUeSxwzlWQdZGRkQG42r0m3bt356effqrlxF3zvteH0+lk4cKFvPvuu6SlpXn58ISHh593WWsSFBQEQGVl5XkdV/PeVQsvnvcpMzOTuXPn8t1339W6fzWfB7VaTWR
"text/plain": [
"<Figure size 640x480 with 12 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"wfdb.plot_wfdb(all_filtered_signals,title=\"Filtered Example for all Channels\")"
]
},
{
"cell_type": "code",
2024-06-11 19:04:23 +02:00
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAkIAAAHHCAYAAABTMjf2AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd3gURRvAf3fJ3SWX3htpQOi9JPRepYoFBRQQ6ydYsIEFxIZdVFRsFBWkK02R3ov0GgIEAoH03q/u90fMcZdeLuWO/T3PPpC53dl3Zndn3nnnnXklgiAIiIiIiIiIiIjchUjrWwARERERERERkfpCVIRERERERERE7lpERUhERERERETkrkVUhERERERERETuWkRFSEREREREROSuRVSERERERERERO5aREVIRERERERE5K5FVIRERERERERE7lpERUhERERERETkrkVUhERERBosEomEt99+22z5abVaXn31VQIDA5FKpYwdO9ZsedeEKVOmEBISYpJm7rID9OvXjzZt2pg1z/qkX79+9OvXr77FELFwREVIRKQUli5dikQiMRy2trYEBAQwZcoUbt++Xd/iERMTYyJf8ePDDz+sbxEbJIsXL+aTTz7h/vvvZ9myZbz44ov1LZJZyMrKYt68ebRv3x5HR0fs7e1p06YNr732GnFxcfUtnohIg8a2vgUQEWnIvPPOO4SGhlJQUMCRI0dYunQpBw4c4Pz589jZ2dW3eDz88MPcc889JdI7duxYD9I0fHbt2kVAQABffPFFfYtiNq5du8agQYO4efMmDzzwAE8++SRyuZyzZ8/y888/88cff3D58uX6FlNEpMEiKkIiIuUwfPhwunTpAsDjjz+Op6cnH330ERs3buTBBx+sZ+mgU6dOTJo0qb7FsBiSkpJwdXU1W356vR61Wl1vSrFWq2XcuHEkJiayZ88eevXqZfL7+++/z0cffVQvsomIWAri1JiISBXo3bs3ANHR0YY0tVrNnDlz6Ny5My4uLjg4ONC7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dxPjx402spEXvb2nP3dgKWXSu8Xlr1qzBxcWFwYMHmzzjzp074+joWGJ6zhhXV1du3bpVYlpORKQ8RGdpEZFy+Oabb2jWrBmZmZksXryYffv2oVAoSpy3bNkyPvvsMy5dumRiug8NDTX838fHh7CwMPbv389TTz3F/v376d+/P3369GHGjBlcu3aNyMhI9Hp9pRWhsLAwBg0aVOF5PXv25JlnnuGbb75h6NChPPbYYyXOOXjwIHPnzuXw4cPk5eWZ/JaZmYmLi4vh7+JKVNFvgYGBpaYX9+2QSqU0btzYJK1Zs2bAnenH4iQnJ5ORkcEPP/xQYiqliKSkpFLTy+PGjRv4+/uXUCiKpiZv3Lhhkm78TCviwoULvPnmm+zatYusrCyT34orl9XB2dm5VGWjPBo1aoREIjFJc3NzM/FTg8q900UUfx+KlKLiz93Ozg4vL68S5xqfd+XKFTIzM/H29i5V/vKe8WuvvcaOHTsIDw+nadOmDBkyhAkTJtCzZ88yrxERERUhEZFyCA8PN6waGzt2LL169WLChAlERUXh6OgIwG+//caUKVMYO3Ysr7zyCt7e3tjY2DB//nwTp2qAXr16sXPnTvLz8zlx4gRz5syhTZs2uLq6sn//fiIjI3F0dDT78neVSmVwDI6OjiYvLw+lUmn4PTo6moEDB9KiRQs+//xzAgMDkcvl/PXXX3zxxRclfHxsbGxKvU9Z6UIlnKArokiGSZMmMXny5FLPadeuXY3vUxHGVp7yyMjIoG/fvjg7O/POO+/QpEkT7OzsOHnyJK+99lqJOq0OLVq04NSpU8TGxpZ
"text/plain": [
"<Figure size 640x480 with 12 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"wfdb.plot_wfdb(example_data,title=\"Raw Example for all Channels\")"
]
}
],
"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
}