cleaned code, updated Readme plots

main
Felix Jan Michael Mucha 2024-06-11 19:04:23 +02:00
parent 2bc9cebfe1
commit c22da6d352
10 changed files with 235 additions and 1689 deletions

View File

@ -15,17 +15,10 @@
"metadata": {},
"outputs": [],
"source": [
"import pickle"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"path = \"C:/Studium/dsa/data\"\n",
"#path = \"C:/Users/Nils/Documents/HS-Mannheim/0000_MASTER/DSA/EKG_Prog/data\""
"import sys\n",
"\n",
"sys.path.append('../scripts')\n",
"import data_helper"
]
},
{
@ -37,50 +30,31 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Reading SB\n",
"Length of SB: 50\n",
"Reading AFIB\n",
"Length of AFIB: 27\n",
"Reading GSVT\n",
"Length of GSVT: 0\n",
"Reading AFIB\n",
"Reading SR\n",
"Length of SR: 13\n"
"Reading SB\n",
"Number of patients per category:\n",
"GSVT: 1027\n",
"AFIB: 9787\n",
"SR: 10426\n",
"SB: 15826\n"
]
}
],
"source": [
"import pickle\n",
"from matplotlib import pyplot as plt\n",
"import wfdb\n",
"# read pickle files and check len and print first record and first record keys\n",
"data = data_helper.load_data(only_demographic=False)\n",
"\n",
"#path = \"C:/Studium/dsa/data\"\n",
"#path = \"C:/Users/Nils/Documents/HS-Mannheim/0000_MASTER/DSA/EKG_Prog/data\"\n",
"path = \"C:/Users/klara/projects/DSA/data\"\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)}\")"
"print(\"Number of patients per category:\")\n",
"for cat_name in data.keys():\n",
" print(f\"{cat_name}: {len(data[cat_name])}\")"
]
},
{
@ -92,7 +66,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 5,
"metadata": {},
"outputs": [
{
@ -146,7 +120,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
"version": "3.10.4"
}
},
"nbformat": 4,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -4,14 +4,17 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Signal Processing\n",
"# Noise Reduction\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."
"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",
"execution_count": 40,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
@ -40,21 +43,22 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Reading SB\n",
"Reading AFIB\n",
"Reading GSVT\n",
"Reading AFIB\n",
"Reading SR\n",
"SB: 16559\n",
"AFIB: 9839\n",
"GSVT: 948\n",
"SR: 9720\n"
"Reading SB\n",
"Number of patients per category:\n",
"GSVT: 1027\n",
"AFIB: 9787\n",
"SR: 10426\n",
"SB: 15826\n"
]
}
],
@ -68,7 +72,7 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 3,
"metadata": {},
"outputs": [
{
@ -90,7 +94,7 @@
},
{
"cell_type": "code",
"execution_count": 41,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
@ -116,7 +120,7 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 5,
"metadata": {},
"outputs": [
{
@ -146,7 +150,7 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 6,
"metadata": {},
"outputs": [
{
@ -176,7 +180,7 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": 7,
"metadata": {},
"outputs": [
{
@ -206,7 +210,7 @@
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": 8,
"metadata": {},
"outputs": [
{
@ -236,7 +240,7 @@
},
{
"cell_type": "code",
"execution_count": 36,
"execution_count": 9,
"metadata": {},
"outputs": [
{
@ -256,7 +260,7 @@
},
{
"cell_type": "code",
"execution_count": 38,
"execution_count": 10,
"metadata": {},
"outputs": [
{

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 51 KiB