systole.plots.plot_shortlong#

systole.plots.plot_shortlong(rr: None, artefacts: Dict[str, ndarray], input_type: str = 'rr_ms') figure | Axes[source]#
systole.plots.plot_shortlong(rr: List[float] | ndarray, artefacts: None, input_type: str = 'rr_ms') figure | Axes
systole.plots.plot_shortlong(rr: List[float] | ndarray, artefacts: Dict[str, ndarray], input_type: str = 'rr_ms') figure | Axes

Visualization of short, long, extra and missed intervals detection.

The artefact detection is based on the method described in [1].

Parameters:
rr

Interval time-series (R-R, beat-to-beat…), in seconds or in miliseconds.

artefacts

The artefacts detected using systole.detection.rr_artefacts().

input_type

The type of input vector. Default is “peaks” (a boolean vector where 1 represents the occurrence of R waves or systolic peaks). Can also be “rr_s” or “rr_ms” for vectors of RR intervals, or interbeat intervals (IBI), expressed in seconds or milliseconds (respectively).

ax

Where to draw the plot. Default is None (create a new figure). Only applies when backend=”matplotlib”.

backend

Select plotting backend {“matplotlib”, “bokeh”}. Defaults to “matplotlib”.

figsize

Figure size. Default is (6, 6) for matplotlib backend, and the height is 600 when using bokeh backend.

Returns:
plot

The matplotlib axes, or the boken figure containing the plot.

Notes

If both rr and artefacts are provided, the function will drop artefacts and re-evaluate given the current RR time-series.

References

[1]

Lipponen, J. A., & Tarvainen, M. P. (2019). A robust algorithm for heart rate variability time series artefact correction using novel beat classification. Journal of Medical Engineering & Technology, 43(3), 173–181. https://doi.org/10.1080/03091902.2019.1640306

Examples

Visualizing short/long and missed/extra intervals from a RR time series.

from systole import import_rr
from systole.plots import plot_shortlong

# Import PPG recording as numpy array
rr = import_rr().rr.to_numpy()

plot_shortlong(rr)
<Axes: title={'center': 'Subspace 2 \n (long and short beats detection)'}, xlabel='Subspace $S_{21}$', ylabel='Subspace $S_{22}$'>
../../_images/systole.plots.plot_shortlong_0_1.png

Visualizing ectopic subspace from the artefact dictionary.

from systole.detection import rr_artefacts

# Use the rr_artefacts function to short/long and extra/missed intervals
artefacts = rr_artefacts(rr)

plot_shortlong(artefacts=artefacts)
<Axes: title={'center': 'Subspace 2 \n (long and short beats detection)'}, xlabel='Subspace $S_{21}$', ylabel='Subspace $S_{22}$'>
../../_images/systole.plots.plot_shortlong_1_1.png

Using Bokeh as plotting backend.

from bokeh.io import output_notebook
from bokeh.plotting import show
from systole.detection import rr_artefacts
output_notebook()

show(
   plot_shortlong(artefacts=artefacts, backend="bokeh")
)
Loading BokehJS ...