Skip to content

Commit

Permalink
Added placeholder pulse_detect function to avoid error.
Browse files Browse the repository at this point in the history
  • Loading branch information
tompollard committed Jul 11, 2022
1 parent 0bf92a6 commit 16622e7
Showing 1 changed file with 80 additions and 16 deletions.
96 changes: 80 additions & 16 deletions content/tutorial/notebooks/beat-detection.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"# Beat detection\n",
"In this tutorial we will learn how to detect beats in PPG and BP signals.\n",
"\n",
"our **objectives** are to:\n",
"Our **objectives** are to:\n",
"- Call Python functions that are stored in a separate file\n",
"- Use beat detection algorithms to detect beats in PPG and BP signals\n",
"- Compare performance of the algorithms"
Expand Down Expand Up @@ -49,12 +49,48 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"id": "ce3cdfde",
"metadata": {
"id": "ce3cdfde"
"id": "ce3cdfde",
"outputId": "693c9521-0083-4ff7-edcc-907e37698176",
"colab": {
"base_uri": "https://localhost:8080/"
}
},
"outputs": [],
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n",
"Collecting wfdb==4.0.0\n",
" Downloading wfdb-4.0.0-py3-none-any.whl (161 kB)\n",
"\u001b[K |████████████████████████████████| 161 kB 2.9 MB/s \n",
"\u001b[?25hRequirement already satisfied: scipy<2.0.0,>=1.0.0 in /usr/local/lib/python3.7/dist-packages (from wfdb==4.0.0) (1.4.1)\n",
"Requirement already satisfied: requests<3.0.0,>=2.8.1 in /usr/local/lib/python3.7/dist-packages (from wfdb==4.0.0) (2.23.0)\n",
"Requirement already satisfied: matplotlib<4.0.0,>=3.2.2 in /usr/local/lib/python3.7/dist-packages (from wfdb==4.0.0) (3.2.2)\n",
"Requirement already satisfied: SoundFile<0.12.0,>=0.10.0 in /usr/local/lib/python3.7/dist-packages (from wfdb==4.0.0) (0.10.3.post1)\n",
"Requirement already satisfied: numpy<2.0.0,>=1.10.1 in /usr/local/lib/python3.7/dist-packages (from wfdb==4.0.0) (1.21.6)\n",
"Requirement already satisfied: pandas<2.0.0,>=1.0.0 in /usr/local/lib/python3.7/dist-packages (from wfdb==4.0.0) (1.3.5)\n",
"Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib<4.0.0,>=3.2.2->wfdb==4.0.0) (2.8.2)\n",
"Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib<4.0.0,>=3.2.2->wfdb==4.0.0) (3.0.9)\n",
"Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib<4.0.0,>=3.2.2->wfdb==4.0.0) (1.4.3)\n",
"Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.7/dist-packages (from matplotlib<4.0.0,>=3.2.2->wfdb==4.0.0) (0.11.0)\n",
"Requirement already satisfied: typing-extensions in /usr/local/lib/python3.7/dist-packages (from kiwisolver>=1.0.1->matplotlib<4.0.0,>=3.2.2->wfdb==4.0.0) (4.1.1)\n",
"Requirement already satisfied: pytz>=2017.3 in /usr/local/lib/python3.7/dist-packages (from pandas<2.0.0,>=1.0.0->wfdb==4.0.0) (2022.1)\n",
"Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.7/dist-packages (from python-dateutil>=2.1->matplotlib<4.0.0,>=3.2.2->wfdb==4.0.0) (1.15.0)\n",
"Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from requests<3.0.0,>=2.8.1->wfdb==4.0.0) (3.0.4)\n",
"Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests<3.0.0,>=2.8.1->wfdb==4.0.0) (2.10)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests<3.0.0,>=2.8.1->wfdb==4.0.0) (2022.6.15)\n",
"Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/dist-packages (from requests<3.0.0,>=2.8.1->wfdb==4.0.0) (1.24.3)\n",
"Requirement already satisfied: cffi>=1.0 in /usr/local/lib/python3.7/dist-packages (from SoundFile<0.12.0,>=0.10.0->wfdb==4.0.0) (1.15.0)\n",
"Requirement already satisfied: pycparser in /usr/local/lib/python3.7/dist-packages (from cffi>=1.0->SoundFile<0.12.0,>=0.10.0->wfdb==4.0.0) (2.21)\n",
"Installing collected packages: wfdb\n",
"Successfully installed wfdb-4.0.0\n"
]
}
],
"source": [
"# Packages\n",
"import sys\n",
Expand Down Expand Up @@ -112,7 +148,7 @@
"id": "60464239",
"metadata": {
"id": "60464239",
"outputId": "b69fd1bf-56dc-4532-91c7-07a06e537aa6",
"outputId": "c03e45df-1855-4eab-e60d-dd3a18d7b76a",
"colab": {
"base_uri": "https://localhost:8080/"
}
Expand Down Expand Up @@ -278,11 +314,30 @@
},
{
"cell_type": "code",
"execution_count": 12,
"source": [
"def pulse_detect(*args, **kwargs):\n",
" \"\"\"\n",
" Placeholder for a pulse detection function.\n",
" \"\"\"\n",
" msg = \"\"\"Override the pulse_detect function with the example \n",
" provided at the bottom of this notebook.\\n\"\"\"\n",
" print(msg)\n",
" return None"
],
"metadata": {
"id": "GUSfOVb0m3hD"
},
"id": "GUSfOVb0m3hD",
"execution_count": 30,
"outputs": []
},
{
"cell_type": "code",
"execution_count": 31,
"id": "8f245cd9",
"metadata": {
"id": "8f245cd9",
"outputId": "8d7ba0e0-3f77-4faf-ac2c-c841e53a4943",
"outputId": "e05d1404-a0b4-4084-97db-4a937ac1664f",
"colab": {
"base_uri": "https://localhost:8080/"
}
Expand All @@ -292,23 +347,32 @@
"output_type": "stream",
"name": "stdout",
"text": [
"Detected 15 beats in the PPG signal using the D2max algorithm\n",
"Detected 30 beats in the PPG signal using the Upslopes algorithm\n",
"Detected 15 beats in the PPG signal using the Delineator algorithm\n"
"Override the pulse_detect function with the example \n",
" provided at the bottom of this notebook.\n",
"\n",
"Override the pulse_detect function with the example \n",
" provided at the bottom of this notebook.\n",
"\n",
"Override the pulse_detect function with the example \n",
" provided at the bottom of this notebook.\n",
"\n"
]
}
],
"source": [
"temp_fs = 125\n",
"\n",
"ppg_ibis_d2max = pulse_detect(ppg_filt, temp_fs, 5, 'd2max')\n",
"print(f\"Detected {len(ppg_ibis_d2max)} beats in the PPG signal using the {'D2max'} algorithm\")\n",
"if ppg_ibis_d2max:\n",
" print(f\"Detected {len(ppg_ibis_d2max)} beats in the PPG signal using the {'D2max'} algorithm\")\n",
"\n",
"ppg_ibis_upslopes = pulse_detect(ppg_filt, temp_fs, 5,'upslopes')\n",
"print(f\"Detected {len(ppg_ibis_upslopes)} beats in the PPG signal using the {'Upslopes'} algorithm\")\n",
"if ppg_ibis_upslopes:\n",
" print(f\"Detected {len(ppg_ibis_upslopes)} beats in the PPG signal using the {'Upslopes'} algorithm\")\n",
"\n",
"ppg_ibis_delineator = pulse_detect(ppg_filt, temp_fs, 5, 'delineator')\n",
"print(f\"Detected {len(ppg_ibis_delineator)} beats in the PPG signal using the {'Delineator'} algorithm\")"
"if ppg_ibis_delineator:\n",
" print(f\"Detected {len(ppg_ibis_delineator)} beats in the PPG signal using the {'Delineator'} algorithm\")"
]
},
{
Expand All @@ -323,7 +387,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": null,
"id": "aa48073c",
"metadata": {
"id": "aa48073c",
Expand Down Expand Up @@ -426,7 +490,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": null,
"id": "36a19da3",
"metadata": {
"id": "36a19da3",
Expand Down Expand Up @@ -462,7 +526,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": null,
"id": "956b1637",
"metadata": {
"id": "956b1637",
Expand Down

0 comments on commit 16622e7

Please sign in to comment.