Exemple #1
0
 def test_plot_hr(self):
     ax = plot_hr(oxi)
     assert isinstance(ax, matplotlib.axes.Axes)
     ax = plot_hr(oxi.peaks)
     assert isinstance(ax, matplotlib.axes.Axes)
     outliers = np.where(oxi.peaks)[0][:2]
     ax = plot_hr(np.asarray(oxi.peaks), unit='bpm', outliers=outliers)
     assert isinstance(ax, matplotlib.axes.Axes)
Exemple #2
0
    def plot_hr(self, ax=None):
        """Plot heartrate extracted from PPG recording.

        Returns
        -------
        fig, ax : Matplotlib instances.
            The figure and axe instances.
        """
        ax = plot_hr(self, ax=ax)

        return ax
# Add ectobeat (type 2)
rr[80] = 500
rr[81] = 1100

#%%
# Artefact detection
# ------------------
# You can visualize the two main subspaces and spot outliers.
# Here we can see that two intervals have been labelled as probable ectobeats
# (left pannel), and a total of 6 datapoints are considered as outliers, being
# too long or too short (right pannel).

plot_subspaces(rr)

#%%
# Plotting
# --------
# We can then plot back the labelled outliers in the RR interval time course

ectobeats, outliers = rr_outliers(rr)
plot_hr(rr.values, kind='linear', outliers=(ectobeats | outliers))

#%%
# References
# ----------
# .. [#] 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