{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Plot subspaces to vivualize short/long and ectopic beats\n\nThe artefact detection is based on the method described in [1]_.\n\n.. [1] Lipponen, J. A., & Tarvainen, M. P. (2019). A robust algorithm for\n heart rate variability time series artefact correction using novel beat\n classification. Journal of Medical Engineering & Technology, 43(3),\n 173\u2013181. https://doi.org/10.1080/03091902.2019.1640306\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Author: Nicolas Legrand \n# Licence: Apache-2.0" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Visualizing artefacts from RR time series\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from systole import import_rr\nfrom systole.plots import plot_subspaces\nimport matplotlib.pyplot as plt\n\n# Import PPG recording as numpy array\nrr = import_rr().rr.to_numpy()\n\n_, axs = plt.subplots(ncols=2, figsize=(12, 6))\nplot_subspaces(rr, ax=axs);" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Visualizing artefacts from the `artefact` dictionary\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from systole.detection import rr_artefacts\n\n# Use the rr_artefacts function to short/long and extra/missed intervals\nartefacts = rr_artefacts(rr)\n\n_, axs = plt.subplots(ncols=2, figsize=(12, 6))\nplot_subspaces(artefacts=artefacts, ax=axs)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Using Bokeh as plotting backend\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from bokeh.io import output_notebook\nfrom bokeh.plotting import show\nfrom systole.detection import rr_artefacts\noutput_notebook()\n\nshow(\n plot_subspaces(\n artefacts=artefacts, backend=\"bokeh\", figsize=400\n )\n)" ] } ], "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.11.16" } }, "nbformat": 4, "nbformat_minor": 0 }