def test_norm_triggers(self): ppg = import_ppg('1')[0, :] # Import PPG recording signal, peaks = oxi_peaks(ppg) peaks[np.where(peaks)[0] + 1] = 1 peaks[np.where(peaks)[0] + 2] = 1 y = norm_triggers(peaks) assert sum(y) == 378 peaks = -peaks y = norm_triggers(peaks, threshold=-1, direction='lower') assert sum(y) == 378
def test_norm_triggers(self): ppg = import_ppg('1')[0, :] # Import PPG recording signal, peaks = oxi_peaks(ppg) peaks[np.where(peaks)[0] + 1] = 1 peaks[np.where(peaks)[0] + 2] = 1 peaks[-1:] = 1 y = norm_triggers(peaks) assert sum(y) == 379 peaks = -peaks.astype(int) y = norm_triggers(peaks, threshold=-1, direction='lower') assert sum(y) == 379 with pytest.raises(ValueError): norm_triggers(None) with pytest.raises(ValueError): norm_triggers(peaks, direction='invalid')
oxi.channels["Channel_1"][-1] = diastole1.status oxi.channels["Channel_2"][-1] = diastole2.status oxi.channels["Channel_3"][-1] = diastole3.status #%% # Events # -------- f, (ax1, ax2) = plt.subplots(2, 1, figsize=(12, 5), sharex=True) oxi.plot_recording(ax=ax1) oxi.plot_events(ax=ax2) plt.tight_layout() #%% # 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") angles.append(to_angles(np.where(x)[0], np.where(events)[0])) palette = itertools.cycle(sns.color_palette("deep")) ax = plt.subplot(111, polar=True) for i in angles: circular(i, color=next(palette), ax=ax)