+
+.. only:: html
+
+ .. figure:: /auto_examples/images/thumb/sphx_glr_Tutorial_recording_thumb.png
+ :alt: Recording PPG signal
+
+ :ref:`sphx_glr_auto_examples_Tutorial_recording.py`
+
+.. raw:: html
+
+
+
+
+.. toctree::
+ :hidden:
+
+ /auto_examples/Tutorial_recording
+
.. raw:: html
@@ -136,13 +157,13 @@ If you want to see the tutorials in action, you can also click on the link below
.. container:: sphx-glr-download sphx-glr-download-python
- :download:`Download all examples in Python source code: auto_examples_python.zip `
+ :download:`Download all examples in Python source code: auto_examples_python.zip `
.. container:: sphx-glr-download sphx-glr-download-jupyter
- :download:`Download all examples in Jupyter notebooks: auto_examples_jupyter.zip `
+ :download:`Download all examples in Jupyter notebooks: auto_examples_jupyter.zip `
.. only:: html
diff --git a/source/auto_examples/plot_ArtefactsCorrection.ipynb b/source/auto_examples/plot_ArtefactsCorrection.ipynb
index c238176b..ac2c3ed4 100644
--- a/source/auto_examples/plot_ArtefactsCorrection.ipynb
+++ b/source/auto_examples/plot_ArtefactsCorrection.ipynb
@@ -15,7 +15,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "\nOutliers and ectobeats correction\n=================================\n\nHere, we describe two method for artefacts and outliers correction, after\ndetection using the method proposed by Lipponen & Tarvainen (2019) [#]_.\n"
+ "\n# Outliers and ectobeats correction\n\nHere, we describe two method for artefacts and outliers correction, after\ndetection using the method proposed by Lipponen & Tarvainen (2019) [#]_.\n"
]
},
{
@@ -26,7 +26,7 @@
},
"outputs": [],
"source": [
- "# Author: Nicolas Legrand
\n# Licence: GPL v3\n\n# Two approaches for artefacts correction are proposed:\n# * `correct_peaks()` will find and correct artefacts in a boolean peaks\n# vector, thus ensuring the length of recording remain constant and corrected\n# peaks fit the signal sampling rate. This method is more adapted to\n# event-related cardiac activity designs.\n\n# * `correct_rr()` will find and correct artefacts in the RR time series. The\n# signal length will possibly change after the interpolation of long, short or\n# ectopic beats. This method is more relevant for HRV analyse of long recording\n# where the timing of experimental events is not important."
+ "# Author: Nicolas Legrand \n# Licence: GPL v3\n\n# Two approaches for artefacts correction are proposed:\n# * `correct_peaks()` will find and correct artefacts in a boolean peaks\n# vector, thus ensuring the length of recording remain constant and corrected\n# peaks fit the signal sampling rate. This method is more adapted to\n# event-related cardiac activity designs.\n\n# * `correct_rr()` will find and correct artefacts in the RR time series. The\n# signal length will possibly change after the interpolation of long, short or\n# ectopic beats. This method is more relevant for HRV analyse of long recording\n# where the timing of experimental events is not important.\n\nimport matplotlib.pyplot as plt"
]
},
{
@@ -37,7 +37,7 @@
},
"outputs": [],
"source": [
- "import numpy as np\nimport matplotlib.pyplot as plt\nfrom systole import simulate_rr\nfrom systole.plotting import plot_subspaces\nfrom systole.correction import correct_peaks, correct_rr"
+ "import numpy as np\n\nfrom systole import simulate_rr\nfrom systole.correction import correct_peaks, correct_rr\nfrom systole.plotting import plot_subspaces"
]
},
{
@@ -80,7 +80,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "References\n----------\n.. [#] Lipponen, J. A., & Tarvainen, M. P. (2019). A robust algorithm for\n heart rate variability time series artefact correction using novel\n beat classification. Journal of Medical Engineering & Technology,\n 43(3), 173\u2013181. https://doi.org/10.1080/03091902.2019.1640306\n\n"
+ "## References\n.. [#] Lipponen, J. A., & Tarvainen, M. P. (2019). A robust algorithm for\n heart rate variability time series artefact correction using novel\n beat classification. Journal of Medical Engineering & Technology,\n 43(3), 173\u2013181. https://doi.org/10.1080/03091902.2019.1640306\n\n"
]
}
],
@@ -100,7 +100,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.7.6"
+ "version": "3.7.9"
}
},
"nbformat": 4,
diff --git a/source/auto_examples/plot_ArtefactsCorrection.py b/source/auto_examples/plot_ArtefactsCorrection.py
index 23081216..86fe1b80 100644
--- a/source/auto_examples/plot_ArtefactsCorrection.py
+++ b/source/auto_examples/plot_ArtefactsCorrection.py
@@ -20,13 +20,13 @@
# ectopic beats. This method is more relevant for HRV analyse of long recording
# where the timing of experimental events is not important.
+import matplotlib.pyplot as plt
#%%
import numpy as np
-import matplotlib.pyplot as plt
+
from systole import simulate_rr
-from systole.plotting import plot_subspaces
from systole.correction import correct_peaks, correct_rr
-
+from systole.plotting import plot_subspaces
#%% Method 1 - Peaks correction
# #############################
diff --git a/source/auto_examples/plot_ArtefactsCorrection.py.md5 b/source/auto_examples/plot_ArtefactsCorrection.py.md5
index 6d0f4c05..48fd0b2b 100644
--- a/source/auto_examples/plot_ArtefactsCorrection.py.md5
+++ b/source/auto_examples/plot_ArtefactsCorrection.py.md5
@@ -1 +1 @@
-b249ea1af60fe433eb0565a2693898a6
\ No newline at end of file
+3aef4defe652fe63c7a1eda1c7f030b5
\ No newline at end of file
diff --git a/source/auto_examples/plot_ArtefactsCorrection.rst b/source/auto_examples/plot_ArtefactsCorrection.rst
index e22c6f93..e5831943 100644
--- a/source/auto_examples/plot_ArtefactsCorrection.rst
+++ b/source/auto_examples/plot_ArtefactsCorrection.rst
@@ -1,12 +1,21 @@
+
+.. DO NOT EDIT.
+.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
+.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
+.. "auto_examples\plot_ArtefactsCorrection.py"
+.. LINE NUMBERS ARE GIVEN BELOW.
+
.. only:: html
.. note::
:class: sphx-glr-download-link-note
- Click :ref:`here ` to download the full example code
- .. rst-class:: sphx-glr-example-title
+ Click :ref:`here `
+ to download the full example code
+
+.. rst-class:: sphx-glr-example-title
- .. _sphx_glr_auto_examples_plot_ArtefactsCorrection.py:
+.. _sphx_glr_auto_examples_plot_ArtefactsCorrection.py:
Outliers and ectobeats correction
@@ -15,6 +24,7 @@ Outliers and ectobeats correction
Here, we describe two method for artefacts and outliers correction, after
detection using the method proposed by Lipponen & Tarvainen (2019) [#]_.
+.. GENERATED FROM PYTHON SOURCE LINES 8-24
.. code-block:: default
@@ -33,6 +43,7 @@ detection using the method proposed by Lipponen & Tarvainen (2019) [#]_.
# ectopic beats. This method is more relevant for HRV analyse of long recording
# where the timing of experimental events is not important.
+ import matplotlib.pyplot as plt
@@ -40,14 +51,15 @@ detection using the method proposed by Lipponen & Tarvainen (2019) [#]_.
+.. GENERATED FROM PYTHON SOURCE LINES 25-31
.. code-block:: default
import numpy as np
- import matplotlib.pyplot as plt
+
from systole import simulate_rr
- from systole.plotting import plot_subspaces
from systole.correction import correct_peaks, correct_rr
+ from systole.plotting import plot_subspaces
@@ -56,9 +68,11 @@ detection using the method proposed by Lipponen & Tarvainen (2019) [#]_.
+.. GENERATED FROM PYTHON SOURCE LINES 32-33
#############################
+.. GENERATED FROM PYTHON SOURCE LINES 33-38
.. code-block:: default
@@ -82,8 +96,11 @@ detection using the method proposed by Lipponen & Tarvainen (2019) [#]_.
+.. GENERATED FROM PYTHON SOURCE LINES 39-40
+
#############################
+.. GENERATED FROM PYTHON SOURCE LINES 40-43
.. code-block:: default
@@ -97,6 +114,8 @@ detection using the method proposed by Lipponen & Tarvainen (2019) [#]_.
+.. GENERATED FROM PYTHON SOURCE LINES 44-50
+
References
----------
.. [#] Lipponen, J. A., & Tarvainen, M. P. (2019). A robust algorithm for
@@ -107,7 +126,7 @@ References
.. rst-class:: sphx-glr-timing
- **Total running time of the script:** ( 0 minutes 0.493 seconds)
+ **Total running time of the script:** ( 0 minutes 0.132 seconds)
.. _sphx_glr_download_auto_examples_plot_ArtefactsCorrection.py:
diff --git a/source/auto_examples/plot_ArtefactsCorrection_codeobj.pickle b/source/auto_examples/plot_ArtefactsCorrection_codeobj.pickle
index 3c030986..c60e91a0 100644
Binary files a/source/auto_examples/plot_ArtefactsCorrection_codeobj.pickle and b/source/auto_examples/plot_ArtefactsCorrection_codeobj.pickle differ
diff --git a/source/auto_examples/plot_ArtefactsDetection.ipynb b/source/auto_examples/plot_ArtefactsDetection.ipynb
index 61b9538e..5b08500f 100644
--- a/source/auto_examples/plot_ArtefactsDetection.ipynb
+++ b/source/auto_examples/plot_ArtefactsDetection.ipynb
@@ -15,7 +15,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "\nOutliers and artefacts detection\n================================\n\nThis example shows how to detect ectopic, missed, extra, slow and long long\nfrom RR or pulse rate interval time series using the method proposed by\nLipponen & Tarvainen (2019) [#]_.\n"
+ "\n# Outliers and artefacts detection\n\nThis example shows how to detect ectopic, missed, extra, slow and long long\nfrom RR or pulse rate interval time series using the method proposed by\nLipponen & Tarvainen (2019) [#]_.\n"
]
},
{
@@ -37,21 +37,21 @@
},
"outputs": [],
"source": [
- "from systole.detection import rr_artefacts\nfrom systole.utils import simulate_rr\nfrom systole.plotting import plot_subspaces"
+ "from systole.detection import rr_artefacts\nfrom systole.plotting import plot_subspaces\nfrom systole.utils import simulate_rr"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "RR artefacts\n------------\nThe proposed method will detect 4 kinds of artefacts in an RR time series:\nMissed R peaks, when an existing R component was erroneously NOT detected by\nthe algorithm.\n* Extra R peaks, when an R peak was detected but does not exist in the\nsignal.\n* Long or short interval intervals, when R peaks are correctly detected but\nthe resulting interval has extreme value in the overall time-series.\n* Ectopic beats, due to disturbance of the cardiac rhythm when the heart\neither skip or add an extra beat.\n* The category in which the artefact belongs will have an influence on the\ncorrection procedure (see Artefact correction).\n\n"
+ "## RR artefacts\nThe proposed method will detect 4 kinds of artefacts in an RR time series:\nMissed R peaks, when an existing R component was erroneously NOT detected by\nthe algorithm.\n* Extra R peaks, when an R peak was detected but does not exist in the\nsignal.\n* Long or short interval intervals, when R peaks are correctly detected but\nthe resulting interval has extreme value in the overall time-series.\n* Ectopic beats, due to disturbance of the cardiac rhythm when the heart\neither skip or add an extra beat.\n* The category in which the artefact belongs will have an influence on the\ncorrection procedure (see Artefact correction).\n\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "Simulate RR time series\n-----------------------\nThis function will simulate RR time series containing ectopic, extra, missed,\nlong and short artefacts.\n\n"
+ "## Simulate RR time series\nThis function will simulate RR time series containing ectopic, extra, missed,\nlong and short artefacts.\n\n"
]
},
{
@@ -69,7 +69,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "Artefact detection\n------------------\n\n"
+ "## Artefact detection\n\n"
]
},
{
@@ -87,7 +87,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "Subspaces visualization\n-----------------------\nYou can visualize the two main subspaces and spot outliers. The left pamel\nplot subspaces that are more sensitive to ectopic beats detection. The right\npanel plot subspaces that will be more sensitive to long or short beats,\ncomprizing the extra and missed beats.\n\n"
+ "## Subspaces visualization\nYou can visualize the two main subspaces and spot outliers. The left pamel\nplot subspaces that are more sensitive to ectopic beats detection. The right\npanel plot subspaces that will be more sensitive to long or short beats,\ncomprizing the extra and missed beats.\n\n"
]
},
{
@@ -105,7 +105,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "References\n----------\n.. [#] Lipponen, J. A., & Tarvainen, M. P. (2019). A robust algorithm for\n heart rate variability time series artefact correction using novel\n beat classification. Journal of Medical Engineering & Technology,\n 43(3), 173\u2013181. https://doi.org/10.1080/03091902.2019.1640306\n\n"
+ "## References\n.. [#] Lipponen, J. A., & Tarvainen, M. P. (2019). A robust algorithm for\n heart rate variability time series artefact correction using novel\n beat classification. Journal of Medical Engineering & Technology,\n 43(3), 173\u2013181. https://doi.org/10.1080/03091902.2019.1640306\n\n"
]
}
],
@@ -125,7 +125,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.7.6"
+ "version": "3.7.9"
}
},
"nbformat": 4,
diff --git a/source/auto_examples/plot_ArtefactsDetection.py b/source/auto_examples/plot_ArtefactsDetection.py
index 71f6e97b..0f955bcd 100644
--- a/source/auto_examples/plot_ArtefactsDetection.py
+++ b/source/auto_examples/plot_ArtefactsDetection.py
@@ -12,8 +12,8 @@
#%%
from systole.detection import rr_artefacts
-from systole.utils import simulate_rr
from systole.plotting import plot_subspaces
+from systole.utils import simulate_rr
#%%
# RR artefacts
diff --git a/source/auto_examples/plot_ArtefactsDetection.py.md5 b/source/auto_examples/plot_ArtefactsDetection.py.md5
index f88ec5d6..07e2582d 100644
--- a/source/auto_examples/plot_ArtefactsDetection.py.md5
+++ b/source/auto_examples/plot_ArtefactsDetection.py.md5
@@ -1 +1 @@
-a2452a9bf97fecafbff193fcb02361fa
\ No newline at end of file
+4e7dc2a699048ce938dac18e50c4acef
\ No newline at end of file
diff --git a/source/auto_examples/plot_ArtefactsDetection.rst b/source/auto_examples/plot_ArtefactsDetection.rst
index 62e233e3..87661ff2 100644
--- a/source/auto_examples/plot_ArtefactsDetection.rst
+++ b/source/auto_examples/plot_ArtefactsDetection.rst
@@ -1,12 +1,21 @@
+
+.. DO NOT EDIT.
+.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
+.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
+.. "auto_examples\plot_ArtefactsDetection.py"
+.. LINE NUMBERS ARE GIVEN BELOW.
+
.. only:: html
.. note::
:class: sphx-glr-download-link-note
- Click :ref:`here ` to download the full example code
- .. rst-class:: sphx-glr-example-title
+ Click :ref:`here `
+ to download the full example code
+
+.. rst-class:: sphx-glr-example-title
- .. _sphx_glr_auto_examples_plot_ArtefactsDetection.py:
+.. _sphx_glr_auto_examples_plot_ArtefactsDetection.py:
Outliers and artefacts detection
@@ -16,6 +25,7 @@ This example shows how to detect ectopic, missed, extra, slow and long long
from RR or pulse rate interval time series using the method proposed by
Lipponen & Tarvainen (2019) [#]_.
+.. GENERATED FROM PYTHON SOURCE LINES 9-13
.. code-block:: default
@@ -30,12 +40,13 @@ Lipponen & Tarvainen (2019) [#]_.
+.. GENERATED FROM PYTHON SOURCE LINES 14-18
.. code-block:: default
from systole.detection import rr_artefacts
- from systole.utils import simulate_rr
from systole.plotting import plot_subspaces
+ from systole.utils import simulate_rr
@@ -44,6 +55,8 @@ Lipponen & Tarvainen (2019) [#]_.
+.. GENERATED FROM PYTHON SOURCE LINES 19-32
+
RR artefacts
------------
The proposed method will detect 4 kinds of artefacts in an RR time series:
@@ -58,11 +71,14 @@ either skip or add an extra beat.
* The category in which the artefact belongs will have an influence on the
correction procedure (see Artefact correction).
+.. GENERATED FROM PYTHON SOURCE LINES 34-38
+
Simulate RR time series
-----------------------
This function will simulate RR time series containing ectopic, extra, missed,
long and short artefacts.
+.. GENERATED FROM PYTHON SOURCE LINES 38-41
.. code-block:: default
@@ -76,9 +92,12 @@ long and short artefacts.
+.. GENERATED FROM PYTHON SOURCE LINES 42-44
+
Artefact detection
------------------
+.. GENERATED FROM PYTHON SOURCE LINES 44-47
.. code-block:: default
@@ -92,6 +111,8 @@ Artefact detection
+.. GENERATED FROM PYTHON SOURCE LINES 48-54
+
Subspaces visualization
-----------------------
You can visualize the two main subspaces and spot outliers. The left pamel
@@ -99,6 +120,7 @@ plot subspaces that are more sensitive to ectopic beats detection. The right
panel plot subspaces that will be more sensitive to long or short beats,
comprizing the extra and missed beats.
+.. GENERATED FROM PYTHON SOURCE LINES 54-57
.. code-block:: default
@@ -120,12 +142,14 @@ comprizing the extra and missed beats.
.. code-block:: none
- array([,
- ],
+ array([,
+ ],
dtype=object)
+.. GENERATED FROM PYTHON SOURCE LINES 58-64
+
References
----------
.. [#] Lipponen, J. A., & Tarvainen, M. P. (2019). A robust algorithm for
@@ -136,7 +160,7 @@ References
.. rst-class:: sphx-glr-timing
- **Total running time of the script:** ( 0 minutes 0.901 seconds)
+ **Total running time of the script:** ( 0 minutes 1.520 seconds)
.. _sphx_glr_download_auto_examples_plot_ArtefactsDetection.py:
diff --git a/source/auto_examples/plot_ArtefactsDetection_codeobj.pickle b/source/auto_examples/plot_ArtefactsDetection_codeobj.pickle
index bac4dda8..ca140d90 100644
Binary files a/source/auto_examples/plot_ArtefactsDetection_codeobj.pickle and b/source/auto_examples/plot_ArtefactsDetection_codeobj.pickle differ
diff --git a/source/auto_examples/plot_HeartBeatEvokedArpeggios.ipynb b/source/auto_examples/plot_HeartBeatEvokedArpeggios.ipynb
index 5a824167..2cb1fc7b 100644
--- a/source/auto_examples/plot_HeartBeatEvokedArpeggios.ipynb
+++ b/source/auto_examples/plot_HeartBeatEvokedArpeggios.ipynb
@@ -15,7 +15,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "\nHeartbeat Evoked Arpeggios\n============================\n\nThis tutorial illustrates how to use the ``Oximeter`` class to trigger stimuli\nat different phases of the cardiac cycle using the [Psychopy](https://www.psychopy.org/)\ntoolbox. The PPG signal is recorded for 30 seconds and peaks are detected\nonline. Four notes ('C', 'E', 'G', 'Bfl') are played in synch with peak\ndetection with various delays: no delay, 1/4, 2/4 or 3/4 of the previous\ncardiac cycle length. While R-R intervals are prone to large changes over longer\ntimescales, such changes are physiologically limited from one heartbeat to the next,\nlimiting variance in the onset synchrony between the tones and the cardiac cycle.\nOn this basis, each presentation time is calibrated based on the previous RR-interval.\nThis procedure can easily be adapted to create a standard interoception task, e.g. by either presenting\ntones at no delay (systole, s+) or at a fixed offset (diastole, s-).\n"
+ "\n# Heartbeat Evoked Arpeggios\n\nThis tutorial illustrates how to use the ``Oximeter`` class to trigger stimuli\nat different phases of the cardiac cycle using the [Psychopy](https://www.psychopy.org/)\ntoolbox. The PPG signal is recorded for 30 seconds and peaks are detected\nonline. Four notes ('C', 'E', 'G', 'Bfl') are played in synch with peak\ndetection with various delays: no delay, 1/4, 2/4 or 3/4 of the previous\ncardiac cycle length. While R-R intervals are prone to large changes over longer\ntimescales, such changes are physiologically limited from one heartbeat to the next,\nlimiting variance in the onset synchrony between the tones and the cardiac cycle.\nOn this basis, each presentation time is calibrated based on the previous RR-interval.\nThis procedure can easily be adapted to create a standard interoception task, e.g. by either presenting\ntones at no delay (systole, s+) or at a fixed offset (diastole, s-).\n"
]
},
{
@@ -26,14 +26,14 @@
},
"outputs": [],
"source": [
- "# Author: Nicolas Legrand \n# Licence: GPL v3\n\nimport time\nimport numpy as np\nimport itertools\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nfrom psychopy.sound import Sound\n\nfrom systole.utils import norm_triggers\nfrom systole import serialSim\nfrom systole.utils import to_angles\nfrom systole.plotting import circular\nfrom systole.recording import Oximeter"
+ "# Author: Nicolas Legrand \n# Licence: GPL v3\n\nimport itertools\nimport time\n\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport seaborn as sns\nfrom psychopy.sound import Sound\n\nfrom systole import serialSim\nfrom systole.plotting import circular\nfrom systole.recording import Oximeter\nfrom systole.utils import norm_triggers, to_angles"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "Recording\n---------\nFor the purpose of demonstration, here we simulate data acquisition through\nthe pulse oximeter using pre-recorded signal.\n\n"
+ "## Recording\nFor the purpose of demonstration, here we simulate data acquisition through\nthe pulse oximeter using pre-recorded signal.\n\n"
]
},
{
@@ -94,14 +94,14 @@
},
"outputs": [],
"source": [
- "beat = Sound('C', secs=0.1)\ndiastole1 = Sound('E', secs=0.1)\ndiastole2 = Sound('G', secs=0.1)\ndiastole3 = Sound('Bfl', secs=0.1)\n\nsystoleTime1, systoleTime2, systoleTime3 = None, None, None\ntstart = time.time()\nwhile time.time() - tstart < 30:\n\n # Check if there are new data to read\n while oxi.serial.inWaiting() >= 5:\n\n # Convert bytes into list of int\n paquet = list(oxi.serial.read(5))\n\n if oxi.check(paquet): # Data consistency\n oxi.add_paquet(paquet[2]) # Add new data point\n\n # T + 0\n if oxi.peaks[-1] == 1:\n beat = Sound('C', secs=0.1)\n beat.play()\n systoleTime1 = time.time()\n systoleTime2 = time.time()\n systoleTime3 = time.time()\n\n # T + 1/4\n if systoleTime1 is not None:\n if time.time() - systoleTime1 >= ((oxi.instant_rr[-1]/4)/1000):\n diastole1 = Sound('E', secs=0.1)\n diastole1.play()\n systoleTime1 = None\n\n # T + 2/4\n if systoleTime2 is not None:\n if time.time() - systoleTime2 >= (\n ((oxi.instant_rr[-1]/4) * 2)/1000):\n diastole2 = Sound('G', secs=0.1)\n diastole2.play()\n systoleTime2 = None\n\n # T + 3/4\n if systoleTime3 is not None:\n if time.time() - systoleTime3 >= (\n ((oxi.instant_rr[-1]/4) * 3)/1000):\n diastole3 = Sound('A', secs=0.1)\n diastole3.play()\n systoleTime3 = None\n\n # Track the note status\n oxi.channels['Channel_0'][-1] = beat.status\n oxi.channels['Channel_1'][-1] = diastole1.status\n oxi.channels['Channel_2'][-1] = diastole2.status\n oxi.channels['Channel_3'][-1] = diastole3.status"
+ "beat = Sound(\"C\", secs=0.1)\ndiastole1 = Sound(\"E\", secs=0.1)\ndiastole2 = Sound(\"G\", secs=0.1)\ndiastole3 = Sound(\"Bfl\", secs=0.1)\n\nsystoleTime1, systoleTime2, systoleTime3 = None, None, None\ntstart = time.time()\nwhile time.time() - tstart < 30:\n\n # Check if there are new data to read\n while oxi.serial.inWaiting() >= 5:\n\n # Convert bytes into list of int\n paquet = list(oxi.serial.read(5))\n\n if oxi.check(paquet): # Data consistency\n oxi.add_paquet(paquet[2]) # Add new data point\n\n # T + 0\n if oxi.peaks[-1] == 1:\n beat = Sound(\"C\", secs=0.1)\n beat.play()\n systoleTime1 = time.time()\n systoleTime2 = time.time()\n systoleTime3 = time.time()\n\n # T + 1/4\n if systoleTime1 is not None:\n if time.time() - systoleTime1 >= ((oxi.instant_rr[-1] / 4) / 1000):\n diastole1 = Sound(\"E\", secs=0.1)\n diastole1.play()\n systoleTime1 = None\n\n # T + 2/4\n if systoleTime2 is not None:\n if time.time() - systoleTime2 >= (((oxi.instant_rr[-1] / 4) * 2) / 1000):\n diastole2 = Sound(\"G\", secs=0.1)\n diastole2.play()\n systoleTime2 = None\n\n # T + 3/4\n if systoleTime3 is not None:\n if time.time() - systoleTime3 >= (((oxi.instant_rr[-1] / 4) * 3) / 1000):\n diastole3 = Sound(\"A\", secs=0.1)\n diastole3.play()\n systoleTime3 = None\n\n # Track the note status\n oxi.channels[\"Channel_0\"][-1] = beat.status\n oxi.channels[\"Channel_1\"][-1] = diastole1.status\n oxi.channels[\"Channel_2\"][-1] = diastole2.status\n oxi.channels[\"Channel_3\"][-1] = diastole3.status"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "Events\n--------\n\n"
+ "## Events\n\n"
]
},
{
@@ -119,7 +119,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "Cardiac cycle\n-------------\n\n"
+ "## Cardiac cycle\n\n"
]
},
{
@@ -130,7 +130,7 @@
},
"outputs": [],
"source": [
- "angles = []\nx = np.asarray(oxi.peaks)\nfor ev in oxi.channels:\n events = norm_triggers(np.asarray(oxi.channels[ev]), threshold=1, n=40,\n direction='higher')\n angles.append(to_angles(np.where(x)[0], np.where(events)[0]))\n\npalette = itertools.cycle(sns.color_palette('deep'))\nax = plt.subplot(111, polar=True)\nfor i in angles:\n circular(i, color=next(palette), ax=ax)"
+ "angles = []\nx = np.asarray(oxi.peaks)\nfor ev in oxi.channels:\n events = norm_triggers(\n np.asarray(oxi.channels[ev]), threshold=1, n=40, direction=\"higher\"\n )\n angles.append(to_angles(np.where(x)[0], np.where(events)[0]))\n\npalette = itertools.cycle(sns.color_palette(\"deep\"))\nax = plt.subplot(111, polar=True)\nfor i in angles:\n circular(i, color=next(palette), ax=ax)"
]
}
],
@@ -150,7 +150,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.7.6"
+ "version": "3.7.9"
}
},
"nbformat": 4,
diff --git a/source/auto_examples/plot_HeartBeatEvokedArpeggios.py b/source/auto_examples/plot_HeartBeatEvokedArpeggios.py
index 7121a50e..af7981e1 100644
--- a/source/auto_examples/plot_HeartBeatEvokedArpeggios.py
+++ b/source/auto_examples/plot_HeartBeatEvokedArpeggios.py
@@ -18,18 +18,18 @@
# Author: Nicolas Legrand
# Licence: GPL v3
+import itertools
import time
+
+import matplotlib.pyplot as plt
import numpy as np
-import itertools
import seaborn as sns
-import matplotlib.pyplot as plt
from psychopy.sound import Sound
-from systole.utils import norm_triggers
from systole import serialSim
-from systole.utils import to_angles
from systole.plotting import circular
from systole.recording import Oximeter
+from systole.utils import norm_triggers, to_angles
#%%
# Recording
@@ -58,10 +58,10 @@
#%%
# Create an Oxymeter instance, initialize recording and record for 10 seconds
-beat = Sound('C', secs=0.1)
-diastole1 = Sound('E', secs=0.1)
-diastole2 = Sound('G', secs=0.1)
-diastole3 = Sound('Bfl', secs=0.1)
+beat = Sound("C", secs=0.1)
+diastole1 = Sound("E", secs=0.1)
+diastole2 = Sound("G", secs=0.1)
+diastole3 = Sound("Bfl", secs=0.1)
systoleTime1, systoleTime2, systoleTime3 = None, None, None
tstart = time.time()
@@ -78,7 +78,7 @@
# T + 0
if oxi.peaks[-1] == 1:
- beat = Sound('C', secs=0.1)
+ beat = Sound("C", secs=0.1)
beat.play()
systoleTime1 = time.time()
systoleTime2 = time.time()
@@ -86,32 +86,30 @@
# T + 1/4
if systoleTime1 is not None:
- if time.time() - systoleTime1 >= ((oxi.instant_rr[-1]/4)/1000):
- diastole1 = Sound('E', secs=0.1)
+ if time.time() - systoleTime1 >= ((oxi.instant_rr[-1] / 4) / 1000):
+ diastole1 = Sound("E", secs=0.1)
diastole1.play()
systoleTime1 = None
# T + 2/4
if systoleTime2 is not None:
- if time.time() - systoleTime2 >= (
- ((oxi.instant_rr[-1]/4) * 2)/1000):
- diastole2 = Sound('G', secs=0.1)
+ if time.time() - systoleTime2 >= (((oxi.instant_rr[-1] / 4) * 2) / 1000):
+ diastole2 = Sound("G", secs=0.1)
diastole2.play()
systoleTime2 = None
# T + 3/4
if systoleTime3 is not None:
- if time.time() - systoleTime3 >= (
- ((oxi.instant_rr[-1]/4) * 3)/1000):
- diastole3 = Sound('A', secs=0.1)
+ if time.time() - systoleTime3 >= (((oxi.instant_rr[-1] / 4) * 3) / 1000):
+ diastole3 = Sound("A", secs=0.1)
diastole3.play()
systoleTime3 = None
# Track the note status
- oxi.channels['Channel_0'][-1] = beat.status
- oxi.channels['Channel_1'][-1] = diastole1.status
- oxi.channels['Channel_2'][-1] = diastole2.status
- oxi.channels['Channel_3'][-1] = diastole3.status
+ oxi.channels["Channel_0"][-1] = beat.status
+ oxi.channels["Channel_1"][-1] = diastole1.status
+ oxi.channels["Channel_2"][-1] = diastole2.status
+ oxi.channels["Channel_3"][-1] = diastole3.status
#%%
# Events
@@ -129,11 +127,12 @@
angles = []
x = np.asarray(oxi.peaks)
for ev in oxi.channels:
- events = norm_triggers(np.asarray(oxi.channels[ev]), threshold=1, n=40,
- direction='higher')
+ events = norm_triggers(
+ np.asarray(oxi.channels[ev]), threshold=1, n=40, direction="higher"
+ )
angles.append(to_angles(np.where(x)[0], np.where(events)[0]))
-palette = itertools.cycle(sns.color_palette('deep'))
+palette = itertools.cycle(sns.color_palette("deep"))
ax = plt.subplot(111, polar=True)
for i in angles:
circular(i, color=next(palette), ax=ax)
diff --git a/source/auto_examples/plot_HeartBeatEvokedArpeggios.py.md5 b/source/auto_examples/plot_HeartBeatEvokedArpeggios.py.md5
index e8f830d2..5e585e14 100644
--- a/source/auto_examples/plot_HeartBeatEvokedArpeggios.py.md5
+++ b/source/auto_examples/plot_HeartBeatEvokedArpeggios.py.md5
@@ -1 +1 @@
-029c9e4a34b72dc4b6002dd306d71f25
\ No newline at end of file
+b3a99b467f1d4d705f9233756f6a06d8
\ No newline at end of file
diff --git a/source/auto_examples/plot_HeartBeatEvokedArpeggios.rst b/source/auto_examples/plot_HeartBeatEvokedArpeggios.rst
index b2eac1a0..f681d86d 100644
--- a/source/auto_examples/plot_HeartBeatEvokedArpeggios.rst
+++ b/source/auto_examples/plot_HeartBeatEvokedArpeggios.rst
@@ -1,12 +1,21 @@
+
+.. DO NOT EDIT.
+.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
+.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
+.. "auto_examples\plot_HeartBeatEvokedArpeggios.py"
+.. LINE NUMBERS ARE GIVEN BELOW.
+
.. only:: html
.. note::
:class: sphx-glr-download-link-note
- Click :ref:`here ` to download the full example code
- .. rst-class:: sphx-glr-example-title
+ Click :ref:`here `
+ to download the full example code
- .. _sphx_glr_auto_examples_plot_HeartBeatEvokedArpeggios.py:
+.. rst-class:: sphx-glr-example-title
+
+.. _sphx_glr_auto_examples_plot_HeartBeatEvokedArpeggios.py:
Heartbeat Evoked Arpeggios
@@ -24,6 +33,7 @@ On this basis, each presentation time is calibrated based on the previous RR-int
This procedure can easily be adapted to create a standard interoception task, e.g. by either presenting
tones at no delay (systole, s+) or at a fixed offset (diastole, s-).
+.. GENERATED FROM PYTHON SOURCE LINES 17-34
.. code-block:: default
@@ -31,31 +41,89 @@ tones at no delay (systole, s+) or at a fixed offset (diastole, s-).
# Author: Nicolas Legrand
# Licence: GPL v3
+ import itertools
import time
+
+ import matplotlib.pyplot as plt
import numpy as np
- import itertools
import seaborn as sns
- import matplotlib.pyplot as plt
from psychopy.sound import Sound
- from systole.utils import norm_triggers
from systole import serialSim
- from systole.utils import to_angles
from systole.plotting import circular
from systole.recording import Oximeter
+ from systole.utils import norm_triggers, to_angles
+
+
+
+
+
+.. rst-class:: sphx-glr-script-out
+
+ Out:
+
+ .. code-block:: none
+
+ c:\programdata\anaconda3\lib\site-packages\seaborn\cm.py:1582: UserWarning:
+
+ Trying to register the cmap 'rocket' which already exists.
+
+ c:\programdata\anaconda3\lib\site-packages\seaborn\cm.py:1583: UserWarning:
+
+ Trying to register the cmap 'rocket_r' which already exists.
+
+ c:\programdata\anaconda3\lib\site-packages\seaborn\cm.py:1582: UserWarning:
+
+ Trying to register the cmap 'mako' which already exists.
+
+ c:\programdata\anaconda3\lib\site-packages\seaborn\cm.py:1583: UserWarning:
+
+ Trying to register the cmap 'mako_r' which already exists.
+
+ c:\programdata\anaconda3\lib\site-packages\seaborn\cm.py:1582: UserWarning:
+
+ Trying to register the cmap 'icefire' which already exists.
+ c:\programdata\anaconda3\lib\site-packages\seaborn\cm.py:1583: UserWarning:
+ Trying to register the cmap 'icefire_r' which already exists.
+ c:\programdata\anaconda3\lib\site-packages\seaborn\cm.py:1582: UserWarning:
+ Trying to register the cmap 'vlag' which already exists.
+ c:\programdata\anaconda3\lib\site-packages\seaborn\cm.py:1583: UserWarning:
+ Trying to register the cmap 'vlag_r' which already exists.
+ c:\programdata\anaconda3\lib\site-packages\seaborn\cm.py:1582: UserWarning:
+
+ Trying to register the cmap 'flare' which already exists.
+
+ c:\programdata\anaconda3\lib\site-packages\seaborn\cm.py:1583: UserWarning:
+
+ Trying to register the cmap 'flare_r' which already exists.
+
+ c:\programdata\anaconda3\lib\site-packages\seaborn\cm.py:1582: UserWarning:
+
+ Trying to register the cmap 'crest' which already exists.
+
+ c:\programdata\anaconda3\lib\site-packages\seaborn\cm.py:1583: UserWarning:
+
+ Trying to register the cmap 'crest_r' which already exists.
+
+
+
+
+
+.. GENERATED FROM PYTHON SOURCE LINES 35-39
Recording
---------
For the purpose of demonstration, here we simulate data acquisition through
the pulse oximeter using pre-recorded signal.
+.. GENERATED FROM PYTHON SOURCE LINES 39-42
.. code-block:: default
@@ -69,17 +137,24 @@ the pulse oximeter using pre-recorded signal.
+.. GENERATED FROM PYTHON SOURCE LINES 43-46
+
If you want to allow online data acquisition, you should uncomment the
following lines and provide the reference of the COM port where the pulse
oximeter is plugged in.
+.. GENERATED FROM PYTHON SOURCE LINES 48-52
+
.. code-block:: python
import serial
ser = serial.Serial('COM4') # Change this value according to your setup
+.. GENERATED FROM PYTHON SOURCE LINES 54-55
+
Create an Oximeter instance, initialize recording and record for 10 seconds
+.. GENERATED FROM PYTHON SOURCE LINES 55-58
.. code-block:: default
@@ -101,16 +176,19 @@ Create an Oximeter instance, initialize recording and record for 10 seconds
+.. GENERATED FROM PYTHON SOURCE LINES 59-60
+
Create an Oxymeter instance, initialize recording and record for 10 seconds
+.. GENERATED FROM PYTHON SOURCE LINES 60-114
.. code-block:: default
- beat = Sound('C', secs=0.1)
- diastole1 = Sound('E', secs=0.1)
- diastole2 = Sound('G', secs=0.1)
- diastole3 = Sound('Bfl', secs=0.1)
+ beat = Sound("C", secs=0.1)
+ diastole1 = Sound("E", secs=0.1)
+ diastole2 = Sound("G", secs=0.1)
+ diastole3 = Sound("Bfl", secs=0.1)
systoleTime1, systoleTime2, systoleTime3 = None, None, None
tstart = time.time()
@@ -127,7 +205,7 @@ Create an Oxymeter instance, initialize recording and record for 10 seconds
# T + 0
if oxi.peaks[-1] == 1:
- beat = Sound('C', secs=0.1)
+ beat = Sound("C", secs=0.1)
beat.play()
systoleTime1 = time.time()
systoleTime2 = time.time()
@@ -135,32 +213,30 @@ Create an Oxymeter instance, initialize recording and record for 10 seconds
# T + 1/4
if systoleTime1 is not None:
- if time.time() - systoleTime1 >= ((oxi.instant_rr[-1]/4)/1000):
- diastole1 = Sound('E', secs=0.1)
+ if time.time() - systoleTime1 >= ((oxi.instant_rr[-1] / 4) / 1000):
+ diastole1 = Sound("E", secs=0.1)
diastole1.play()
systoleTime1 = None
# T + 2/4
if systoleTime2 is not None:
- if time.time() - systoleTime2 >= (
- ((oxi.instant_rr[-1]/4) * 2)/1000):
- diastole2 = Sound('G', secs=0.1)
+ if time.time() - systoleTime2 >= (((oxi.instant_rr[-1] / 4) * 2) / 1000):
+ diastole2 = Sound("G", secs=0.1)
diastole2.play()
systoleTime2 = None
# T + 3/4
if systoleTime3 is not None:
- if time.time() - systoleTime3 >= (
- ((oxi.instant_rr[-1]/4) * 3)/1000):
- diastole3 = Sound('A', secs=0.1)
+ if time.time() - systoleTime3 >= (((oxi.instant_rr[-1] / 4) * 3) / 1000):
+ diastole3 = Sound("A", secs=0.1)
diastole3.play()
systoleTime3 = None
# Track the note status
- oxi.channels['Channel_0'][-1] = beat.status
- oxi.channels['Channel_1'][-1] = diastole1.status
- oxi.channels['Channel_2'][-1] = diastole2.status
- oxi.channels['Channel_3'][-1] = diastole3.status
+ oxi.channels["Channel_0"][-1] = beat.status
+ oxi.channels["Channel_1"][-1] = diastole1.status
+ oxi.channels["Channel_2"][-1] = diastole2.status
+ oxi.channels["Channel_3"][-1] = diastole3.status
@@ -169,9 +245,12 @@ Create an Oxymeter instance, initialize recording and record for 10 seconds
+.. GENERATED FROM PYTHON SOURCE LINES 115-117
+
Events
--------
+.. GENERATED FROM PYTHON SOURCE LINES 117-123
.. code-block:: default
@@ -192,9 +271,12 @@ Events
+.. GENERATED FROM PYTHON SOURCE LINES 124-126
+
Cardiac cycle
-------------
+.. GENERATED FROM PYTHON SOURCE LINES 126-139
.. code-block:: default
@@ -202,11 +284,12 @@ Cardiac cycle
angles = []
x = np.asarray(oxi.peaks)
for ev in oxi.channels:
- events = norm_triggers(np.asarray(oxi.channels[ev]), threshold=1, n=40,
- direction='higher')
+ events = norm_triggers(
+ np.asarray(oxi.channels[ev]), threshold=1, n=40, direction="higher"
+ )
angles.append(to_angles(np.where(x)[0], np.where(events)[0]))
- palette = itertools.cycle(sns.color_palette('deep'))
+ palette = itertools.cycle(sns.color_palette("deep"))
ax = plt.subplot(111, polar=True)
for i in angles:
circular(i, color=next(palette), ax=ax)
@@ -218,13 +301,24 @@ Cardiac cycle
:class: sphx-glr-single-img
+.. rst-class:: sphx-glr-script-out
+
+ Out:
+
+ .. code-block:: none
+
+ c:\programdata\anaconda3\lib\site-packages\systole\plotting.py:697: UserWarning:
+
+ FixedFormatter should only be used together with FixedLocator
+
+
.. rst-class:: sphx-glr-timing
- **Total running time of the script:** ( 0 minutes 36.528 seconds)
+ **Total running time of the script:** ( 0 minutes 41.321 seconds)
.. _sphx_glr_download_auto_examples_plot_HeartBeatEvokedArpeggios.py:
diff --git a/source/auto_examples/plot_HeartBeatEvokedArpeggios_codeobj.pickle b/source/auto_examples/plot_HeartBeatEvokedArpeggios_codeobj.pickle
index 5335154a..ea881b4e 100644
Binary files a/source/auto_examples/plot_HeartBeatEvokedArpeggios_codeobj.pickle and b/source/auto_examples/plot_HeartBeatEvokedArpeggios_codeobj.pickle differ
diff --git a/source/auto_examples/plot_InstantaneousHeartRate.ipynb b/source/auto_examples/plot_InstantaneousHeartRate.ipynb
index 419dadc4..c685875a 100644
--- a/source/auto_examples/plot_InstantaneousHeartRate.ipynb
+++ b/source/auto_examples/plot_InstantaneousHeartRate.ipynb
@@ -15,7 +15,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "\nInstantaneous Heart Rate\n========================\n\nThis example show how to record PPG signals using the `Nonin 3012LP\nXpod USB pulse oximeter `_ and the `Nonin\n8000SM 'soft-clip' fingertip sensors `_.\nPeaks are automatically labelled online and the instantaneous heart rate is\nplotted.\n"
+ "\n# Instantaneous Heart Rate\n\nThis example show how to record PPG signals using the `Nonin 3012LP\nXpod USB pulse oximeter `_ and the `Nonin\n8000SM 'soft-clip' fingertip sensors `_.\nPeaks are automatically labelled online and the instantaneous heart rate is\nplotted.\n"
]
},
{
@@ -26,14 +26,14 @@
},
"outputs": [],
"source": [
- "# Author: Nicolas Legrand \n# Licence: GPL v3\n\nfrom systole import serialSim\nfrom systole.utils import heart_rate\nfrom systole.recording import Oximeter\nimport matplotlib.pyplot as plt\nimport numpy as np"
+ "# Author: Nicolas Legrand \n# Licence: GPL v3\n\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nfrom systole import serialSim\nfrom systole.recording import Oximeter\nfrom systole.utils import heart_rate"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "Recording\n---------\nFor the demonstration purpose, here we simulate data acquisition through\nthe pulse oximeter using pre-recorded signal.\n\n"
+ "## Recording\nFor the demonstration purpose, here we simulate data acquisition through\nthe pulse oximeter using pre-recorded signal.\n\n"
]
},
{
@@ -76,7 +76,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "Plotting\n--------\n\n"
+ "## Plotting\n\n"
]
},
{
@@ -87,7 +87,7 @@
},
"outputs": [],
"source": [
- "fig, ax = plt.subplots(3, 1, figsize=(13, 8), sharex=True)\noxi.plot_recording(ax=ax[0])\n\nax[1].plot(oxi.times, oxi.peaks, 'k')\nax[1].set_title('Peaks vector', fontweight='bold')\nax[1].set_xlabel('Time (s)')\nax[1].set_ylabel('Peak\\n detection')\n\n\nhr, time = heart_rate(oxi.peaks, sfreq=75, unit='rr', kind='cubic')\nax[2].plot(time, hr, label='Interpolated HR', linestyle='--', color='gray')\nax[2].plot(np.array(oxi.times)[np.where(oxi.peaks)[0]],\n hr[np.where(oxi.peaks)[0]], 'ro', label='Instantaneous HR')\nax[2].set_xlabel('Time (s)')\nax[2].set_title('Instantaneous Heart Rate', fontweight='bold')\nax[2].set_ylabel('RR intervals (ms)')\n\nplt.tight_layout()"
+ "fig, ax = plt.subplots(3, 1, figsize=(13, 8), sharex=True)\noxi.plot_recording(ax=ax[0])\n\nax[1].plot(oxi.times, oxi.peaks, \"k\")\nax[1].set_title(\"Peaks vector\", fontweight=\"bold\")\nax[1].set_xlabel(\"Time (s)\")\nax[1].set_ylabel(\"Peak\\n detection\")\n\n\nhr, time = heart_rate(oxi.peaks, sfreq=75, unit=\"rr\", kind=\"cubic\")\nax[2].plot(time, hr, label=\"Interpolated HR\", linestyle=\"--\", color=\"gray\")\nax[2].plot(\n np.array(oxi.times)[np.where(oxi.peaks)[0]],\n hr[np.where(oxi.peaks)[0]],\n \"ro\",\n label=\"Instantaneous HR\",\n)\nax[2].set_xlabel(\"Time (s)\")\nax[2].set_title(\"Instantaneous Heart Rate\", fontweight=\"bold\")\nax[2].set_ylabel(\"RR intervals (ms)\")\n\nplt.tight_layout()"
]
}
],
@@ -107,7 +107,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.7.3"
+ "version": "3.7.9"
}
},
"nbformat": 4,
diff --git a/source/auto_examples/plot_InstantaneousHeartRate.py b/source/auto_examples/plot_InstantaneousHeartRate.py
index 664ed6a0..985e0c81 100644
--- a/source/auto_examples/plot_InstantaneousHeartRate.py
+++ b/source/auto_examples/plot_InstantaneousHeartRate.py
@@ -12,12 +12,13 @@
# Author: Nicolas Legrand
# Licence: GPL v3
-from systole import serialSim
-from systole.utils import heart_rate
-from systole.recording import Oximeter
import matplotlib.pyplot as plt
import numpy as np
+from systole import serialSim
+from systole.recording import Oximeter
+from systole.utils import heart_rate
+
#%%
# Recording
# ---------
@@ -47,18 +48,22 @@
fig, ax = plt.subplots(3, 1, figsize=(13, 8), sharex=True)
oxi.plot_recording(ax=ax[0])
-ax[1].plot(oxi.times, oxi.peaks, 'k')
-ax[1].set_title('Peaks vector', fontweight='bold')
-ax[1].set_xlabel('Time (s)')
-ax[1].set_ylabel('Peak\n detection')
+ax[1].plot(oxi.times, oxi.peaks, "k")
+ax[1].set_title("Peaks vector", fontweight="bold")
+ax[1].set_xlabel("Time (s)")
+ax[1].set_ylabel("Peak\n detection")
-hr, time = heart_rate(oxi.peaks, sfreq=75, unit='rr', kind='cubic')
-ax[2].plot(time, hr, label='Interpolated HR', linestyle='--', color='gray')
-ax[2].plot(np.array(oxi.times)[np.where(oxi.peaks)[0]],
- hr[np.where(oxi.peaks)[0]], 'ro', label='Instantaneous HR')
-ax[2].set_xlabel('Time (s)')
-ax[2].set_title('Instantaneous Heart Rate', fontweight='bold')
-ax[2].set_ylabel('RR intervals (ms)')
+hr, time = heart_rate(oxi.peaks, sfreq=75, unit="rr", kind="cubic")
+ax[2].plot(time, hr, label="Interpolated HR", linestyle="--", color="gray")
+ax[2].plot(
+ np.array(oxi.times)[np.where(oxi.peaks)[0]],
+ hr[np.where(oxi.peaks)[0]],
+ "ro",
+ label="Instantaneous HR",
+)
+ax[2].set_xlabel("Time (s)")
+ax[2].set_title("Instantaneous Heart Rate", fontweight="bold")
+ax[2].set_ylabel("RR intervals (ms)")
plt.tight_layout()
diff --git a/source/auto_examples/plot_InstantaneousHeartRate.py.md5 b/source/auto_examples/plot_InstantaneousHeartRate.py.md5
index 8dd58a8b..ffacad5c 100644
--- a/source/auto_examples/plot_InstantaneousHeartRate.py.md5
+++ b/source/auto_examples/plot_InstantaneousHeartRate.py.md5
@@ -1 +1 @@
-2e5f5defbd94632a635de74bc150aaa1
\ No newline at end of file
+bab8f131b47340be7647609e2fbff9e0
\ No newline at end of file
diff --git a/source/auto_examples/plot_InstantaneousHeartRate.rst b/source/auto_examples/plot_InstantaneousHeartRate.rst
index 515d3f07..d83201d9 100644
--- a/source/auto_examples/plot_InstantaneousHeartRate.rst
+++ b/source/auto_examples/plot_InstantaneousHeartRate.rst
@@ -1,7 +1,18 @@
-.. note::
- :class: sphx-glr-download-link-note
- Click :ref:`here ` to download the full example code
+.. DO NOT EDIT.
+.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
+.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
+.. "auto_examples\plot_InstantaneousHeartRate.py"
+.. LINE NUMBERS ARE GIVEN BELOW.
+
+.. only:: html
+
+ .. note::
+ :class: sphx-glr-download-link-note
+
+ Click :ref:`here `
+ to download the full example code
+
.. rst-class:: sphx-glr-example-title
.. _sphx_glr_auto_examples_plot_InstantaneousHeartRate.py:
@@ -16,6 +27,7 @@ Xpod USB pulse oximeter `_ and the `Nonin
Peaks are automatically labelled online and the instantaneous heart rate is
plotted.
+.. GENERATED FROM PYTHON SOURCE LINES 11-22
.. code-block:: default
@@ -23,12 +35,13 @@ plotted.
# Author: Nicolas Legrand
# Licence: GPL v3
- from systole import serialSim
- from systole.utils import heart_rate
- from systole.recording import Oximeter
import matplotlib.pyplot as plt
import numpy as np
+ from systole import serialSim
+ from systole.recording import Oximeter
+ from systole.utils import heart_rate
+
@@ -36,11 +49,14 @@ plotted.
+.. GENERATED FROM PYTHON SOURCE LINES 23-27
+
Recording
---------
For the demonstration purpose, here we simulate data acquisition through
the pulse oximeter using pre-recorded signal.
+.. GENERATED FROM PYTHON SOURCE LINES 27-30
.. code-block:: default
@@ -54,15 +70,20 @@ the pulse oximeter using pre-recorded signal.
+.. GENERATED FROM PYTHON SOURCE LINES 31-34
+
If you want to enable online data acquisition, you should uncomment the
following lines and provide the reference of the COM port where the pulse
oximeter is plugged in.
+.. GENERATED FROM PYTHON SOURCE LINES 36-40
+
.. code-block:: python
import serial
ser = serial.Serial('COM4') # Change this value according to your setup
+.. GENERATED FROM PYTHON SOURCE LINES 40-45
.. code-block:: default
@@ -83,38 +104,46 @@ oximeter is plugged in.
Reset input buffer
-
+
+
+.. GENERATED FROM PYTHON SOURCE LINES 46-48
Plotting
--------
+.. GENERATED FROM PYTHON SOURCE LINES 48-70
.. code-block:: default
fig, ax = plt.subplots(3, 1, figsize=(13, 8), sharex=True)
oxi.plot_recording(ax=ax[0])
- ax[1].plot(oxi.times, oxi.peaks, 'k')
- ax[1].set_title('Peaks vector', fontweight='bold')
- ax[1].set_xlabel('Time (s)')
- ax[1].set_ylabel('Peak\n detection')
+ ax[1].plot(oxi.times, oxi.peaks, "k")
+ ax[1].set_title("Peaks vector", fontweight="bold")
+ ax[1].set_xlabel("Time (s)")
+ ax[1].set_ylabel("Peak\n detection")
- hr, time = heart_rate(oxi.peaks, sfreq=75, unit='rr', kind='cubic')
- ax[2].plot(time, hr, label='Interpolated HR', linestyle='--', color='gray')
- ax[2].plot(np.array(oxi.times)[np.where(oxi.peaks)[0]],
- hr[np.where(oxi.peaks)[0]], 'ro', label='Instantaneous HR')
- ax[2].set_xlabel('Time (s)')
- ax[2].set_title('Instantaneous Heart Rate', fontweight='bold')
- ax[2].set_ylabel('RR intervals (ms)')
+ hr, time = heart_rate(oxi.peaks, sfreq=75, unit="rr", kind="cubic")
+ ax[2].plot(time, hr, label="Interpolated HR", linestyle="--", color="gray")
+ ax[2].plot(
+ np.array(oxi.times)[np.where(oxi.peaks)[0]],
+ hr[np.where(oxi.peaks)[0]],
+ "ro",
+ label="Instantaneous HR",
+ )
+ ax[2].set_xlabel("Time (s)")
+ ax[2].set_title("Instantaneous Heart Rate", fontweight="bold")
+ ax[2].set_ylabel("RR intervals (ms)")
plt.tight_layout()
.. image:: /auto_examples/images/sphx_glr_plot_InstantaneousHeartRate_001.png
+ :alt: Oximeter recording, Peaks vector, Instantaneous Heart Rate
:class: sphx-glr-single-img
@@ -124,7 +153,7 @@ Plotting
.. rst-class:: sphx-glr-timing
- **Total running time of the script:** ( 0 minutes 31.257 seconds)
+ **Total running time of the script:** ( 0 minutes 32.270 seconds)
.. _sphx_glr_download_auto_examples_plot_InstantaneousHeartRate.py:
@@ -137,13 +166,13 @@ Plotting
- .. container:: sphx-glr-download
+ .. container:: sphx-glr-download sphx-glr-download-python
:download:`Download Python source code: plot_InstantaneousHeartRate.py `
- .. container:: sphx-glr-download
+ .. container:: sphx-glr-download sphx-glr-download-jupyter
:download:`Download Jupyter notebook: plot_InstantaneousHeartRate.ipynb `
diff --git a/source/auto_examples/plot_InstantaneousHeartRate_codeobj.pickle b/source/auto_examples/plot_InstantaneousHeartRate_codeobj.pickle
index 9f809667..7b461f2f 100644
Binary files a/source/auto_examples/plot_InstantaneousHeartRate_codeobj.pickle and b/source/auto_examples/plot_InstantaneousHeartRate_codeobj.pickle differ
diff --git a/source/auto_examples/plot_InteractiveVisualizations.ipynb b/source/auto_examples/plot_InteractiveVisualizations.ipynb
index 4d50f0b9..720e98e7 100644
--- a/source/auto_examples/plot_InteractiveVisualizations.ipynb
+++ b/source/auto_examples/plot_InteractiveVisualizations.ipynb
@@ -15,7 +15,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "\nInteractive visualization\n=========================\n\nThe pipeline of physiological recording can often benefiit from\ninteractive data visualization and exploration to guide data analysis. Systole\ninclude functions build on the top of Plotly (https://plotly.com/) for\ninteractive data visualization and dashboard integration\n(https://plotly.com/dash/).\n"
+ "\n# Interactive visualization\n\nThe pipeline of physiological recording can often benefiit from\ninteractive data visualization and exploration to guide data analysis. Systole\ninclude functions build on the top of Plotly (https://plotly.com/) for\ninteractive data visualization and dashboard integration\n(https://plotly.com/dash/).\n"
]
},
{
@@ -37,14 +37,14 @@
},
"outputs": [],
"source": [
- "import plotly\nfrom systole.detection import rr_artefacts\nfrom systole import import_rr, import_ppg\nfrom systole.plotly import plot_subspaces, plot_frequency, plot_raw,\\\n plot_timedomain, plot_nonlinear"
+ "import plotly\n\nfrom systole import import_ppg, import_rr\nfrom systole.detection import rr_artefacts\nfrom systole.plotly import (\n plot_frequency,\n plot_nonlinear,\n plot_raw,\n plot_subspaces,\n plot_timedomain,\n)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "Raw data\n--------\n\n\n"
+ "## Raw data\n\n\n"
]
},
{
@@ -55,14 +55,14 @@
},
"outputs": [],
"source": [
- "ppg = import_ppg()[0]\nplot_raw(ppg)"
+ "ppg = import_ppg()\nplot_raw(ppg)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "HRV analyses\n------------\n\n"
+ "## HRV analyses\n\n"
]
},
{
@@ -80,7 +80,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "Frequency domain\n----------------\n\n"
+ "## Frequency domain\n\n"
]
},
{
@@ -98,7 +98,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "Frequency domain\n----------------\n\n"
+ "## Frequency domain\n\n"
]
},
{
@@ -116,7 +116,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "Nonlinear domain\n----------------\n\n"
+ "## Nonlinear domain\n\n"
]
},
{
@@ -134,7 +134,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "Artefact detection\n------------------\n\n"
+ "## Artefact detection\n\n"
]
},
{
@@ -152,7 +152,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "Subspaces visualization\n-----------------------\nYou can visualize the two main subspaces and spot outliers. The left pamel\nplot subspaces that are more sensitive to ectopic beats detection. The right\npanel plot subspaces that will be more sensitive to long or short beats,\ncomprizing the extra and missed beats.\n\n"
+ "## Subspaces visualization\nYou can visualize the two main subspaces and spot outliers. The left pamel\nplot subspaces that are more sensitive to ectopic beats detection. The right\npanel plot subspaces that will be more sensitive to long or short beats,\ncomprizing the extra and missed beats.\n\n"
]
},
{
@@ -183,7 +183,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.7.6"
+ "version": "3.7.9"
}
},
"nbformat": 4,
diff --git a/source/auto_examples/plot_InteractiveVisualizations.py b/source/auto_examples/plot_InteractiveVisualizations.py
index b16cb2ce..7d82a967 100644
--- a/source/auto_examples/plot_InteractiveVisualizations.py
+++ b/source/auto_examples/plot_InteractiveVisualizations.py
@@ -14,16 +14,22 @@
#%%
import plotly
+
+from systole import import_ppg, import_rr
from systole.detection import rr_artefacts
-from systole import import_rr, import_ppg
-from systole.plotly import plot_subspaces, plot_frequency, plot_raw,\
- plot_timedomain, plot_nonlinear
+from systole.plotly import (
+ plot_frequency,
+ plot_nonlinear,
+ plot_raw,
+ plot_subspaces,
+ plot_timedomain,
+)
#%%
# Raw data
# --------
#
-ppg = import_ppg()[0]
+ppg = import_ppg()
plot_raw(ppg)
#%%
diff --git a/source/auto_examples/plot_InteractiveVisualizations.py.md5 b/source/auto_examples/plot_InteractiveVisualizations.py.md5
index 823aa025..88d2919e 100644
--- a/source/auto_examples/plot_InteractiveVisualizations.py.md5
+++ b/source/auto_examples/plot_InteractiveVisualizations.py.md5
@@ -1 +1 @@
-cfae274584268d9e92e0554406ece01f
\ No newline at end of file
+de495e58aace86865c15275ef84c8cc7
\ No newline at end of file
diff --git a/source/auto_examples/plot_InteractiveVisualizations.rst b/source/auto_examples/plot_InteractiveVisualizations.rst
index 760572dd..3e355857 100644
--- a/source/auto_examples/plot_InteractiveVisualizations.rst
+++ b/source/auto_examples/plot_InteractiveVisualizations.rst
@@ -1,12 +1,21 @@
+
+.. DO NOT EDIT.
+.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
+.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
+.. "auto_examples\plot_InteractiveVisualizations.py"
+.. LINE NUMBERS ARE GIVEN BELOW.
+
.. only:: html
.. note::
:class: sphx-glr-download-link-note
- Click :ref:`here ` to download the full example code
- .. rst-class:: sphx-glr-example-title
+ Click :ref:`here `
+ to download the full example code
- .. _sphx_glr_auto_examples_plot_InteractiveVisualizations.py:
+.. rst-class:: sphx-glr-example-title
+
+.. _sphx_glr_auto_examples_plot_InteractiveVisualizations.py:
Interactive visualization
@@ -18,6 +27,7 @@ include functions build on the top of Plotly (https://plotly.com/) for
interactive data visualization and dashboard integration
(https://plotly.com/dash/).
+.. GENERATED FROM PYTHON SOURCE LINES 11-15
.. code-block:: default
@@ -32,14 +42,21 @@ interactive data visualization and dashboard integration
+.. GENERATED FROM PYTHON SOURCE LINES 16-28
.. code-block:: default
import plotly
+
+ from systole import import_ppg, import_rr
from systole.detection import rr_artefacts
- from systole import import_rr, import_ppg
- from systole.plotly import plot_subspaces, plot_frequency, plot_raw,\
- plot_timedomain, plot_nonlinear
+ from systole.plotly import (
+ plot_frequency,
+ plot_nonlinear,
+ plot_raw,
+ plot_subspaces,
+ plot_timedomain,
+ )
@@ -48,14 +65,17 @@ interactive data visualization and dashboard integration
+.. GENERATED FROM PYTHON SOURCE LINES 29-32
+
Raw data
--------
+.. GENERATED FROM PYTHON SOURCE LINES 32-35
.. code-block:: default
- ppg = import_ppg()[0]
+ ppg = import_ppg()
plot_raw(ppg)
@@ -63,36 +83,21 @@ Raw data
-.. only:: builder_html
+.. raw:: html
- .. raw:: html
+