def test_to_angle(self): """Test to_angles function""" rr = import_rr().rr.values # Create event vector events = rr + np.random.normal(500, 100, len(rr)) ang = to_angles(np.cumsum(rr), np.cumsum(events)) assert ~np.any(np.asarray(ang) < 0) assert ~np.any(np.asarray(ang) > np.pi * 2)
def test_plot_psd(self): """Test plot_psd function""" rr = import_rr().rr.values ax = plot_psd(rr) assert isinstance(ax, matplotlib.axes.Axes) freq, psd = plot_psd(rr, show=False) assert freq.mean() == 1.25 assert psd.mean().round(4) == 0.003
def test_plot_subspaces(self): rr = import_rr().rr s1, s2, s3 = hrv_subspaces(rr) ax = plot_subspaces(s1, s2, s3) ax = plot_subspaces(rr, kind='bar') ax = plot_subspaces(rr, kind='hex') assert isinstance(ax[0], matplotlib.axes.Axes) assert isinstance(ax[1], matplotlib.axes.Axes)
def test_to_angle(self): """Test to_angles function""" rr = import_rr().rr.values # Create event vector events = rr + np.random.normal(500, 100, len(rr)) ang = to_angles(list(np.cumsum(rr)), list(np.cumsum(events))) assert ~np.any(np.asarray(ang) < 0) assert ~np.any(np.asarray(ang) > np.pi * 2) ppg = import_ppg('1')[0, :] # Import PPG recording signal, peaks = oxi_peaks(ppg) ang = to_angles(peaks, peaks)
def test_rr_outliers(self): rr = import_rr().rr # Import PPG recording ectobeats, outliers = rr_outliers(rr) assert np.where(ectobeats)[0][0] == 122 assert np.where(outliers)[0][0] == 120
def test_hrv_subspaces(self): rr = import_rr().rr # Import PPG recording s1, s2, s3 = hrv_subspaces(rr) assert round(np.mean(s1), 3) == -0.004 assert round(np.mean(s2), 3) == 0.076 assert round(np.mean(s3), 3) == -0.082
from systole import import_rr, import_ppg from systole.plotly import plot_subspaces, plot_frequency, plot_raw,\ plot_timedomain, plot_nonlinear #%% # Raw data # -------- # ppg = import_ppg()[0] plot_raw(ppg) #%% # HRV analyses # ------------ rr = import_rr().rr.values #%% # Frequency domain # ---------------- plot1 = plot_timedomain(rr) plotly.io.show(plot1) #%% # Frequency domain # ---------------- plot2 = plot_frequency(rr) plotly.io.show(plot2) #%% # Nonlinear domain
from systole import import_rr from systole.plotly import plot_nonlinear # Import PPG recording as numpy array rr = import_rr().rr.to_numpy() plot_nonlinear(rr)
time series using the method proposed by Lipponen & Tarvainen (2019) [#]_. """ # Author: Nicolas Legrand <*****@*****.**> # Licence: GPL v3 #%% from systole.detection import rr_outliers from systole.plotting import plot_subspaces, plot_hr from systole import import_rr #%% # Simulate RR time series # ----------------------- rr = import_rr().rr[:100] #%% # Add artefacts # ------------- # Add missed beat rr[20] = 1600 # Add extra beat rr[40] = 400 # Add ectobeat (type 1) rr[60] = 1100 rr[61] = 500
def test_plot_subspaces(self): rr = import_rr().rr ax = plot_subspaces(rr) assert isinstance(ax[0], matplotlib.axes.Axes) assert isinstance(ax[1], matplotlib.axes.Axes)