Beispiel #1
0
from systole.recording import Oximeter
from systole.detection import hrv_subspaces

serial = serialSim()
oxi = Oximeter(serial=serial, add_channels=1).setup().read(10)
oxi.channels['Channel_0'][100] = 1

# Simulate oximeter instance from recorded signal
ppg = import_ppg()
oxi = Oximeter(serial=None, add_channels=1)
oxi.threshold = [0] * 75
oxi.peaks = [0] * 75
oxi.instant_rr = [0] * 75
oxi.recording = list(ppg[0, :75])
for i in range(len(ppg[0, 75:750])):
    oxi.add_paquet(ppg[0, 75 + i])
oxi.channels['Channel_0'] = np.zeros(750, dtype=int)
oxi.channels['Channel_0'][np.random.choice(np.arange(0, 750), 5)] = 1
oxi.times = list(np.arange(0, 10, 1 / 75))

# Create angular data
x = np.random.normal(np.pi, 0.5, 100)
y = np.random.uniform(0, np.pi * 2, 100)
z = np.concatenate([
    np.random.normal(np.pi / 2, 0.5, 50),
    np.random.normal(np.pi + np.pi / 2, 0.5, 50)
])


class TestPlotting(TestCase):
    def test_plot_hr(self):
Beispiel #2
0
diastole1 = Sound("E", secs=0.1)
diastole2 = Sound("G", secs=0.1)
diastole3 = Sound("Bfl", secs=0.1)

systoleTime1, systoleTime2, systoleTime3 = None, None, None
tstart = time.time()
while time.time() - tstart < 30:

    # Check if there are new data to read
    while oxi.serial.inWaiting() >= 5:

        # Convert bytes into list of int
        paquet = list(oxi.serial.read(5))

        if oxi.check(paquet):  # Data consistency
            oxi.add_paquet(paquet[2])  # Add new data point

        # T + 0
        if oxi.peaks[-1] == 1:
            beat = Sound("C", secs=0.1)
            beat.play()
            systoleTime1 = time.time()
            systoleTime2 = time.time()
            systoleTime3 = time.time()

        # T + 1/4
        if systoleTime1 is not None:
            if time.time() - systoleTime1 >= ((oxi.instant_rr[-1] / 4) / 1000):
                diastole1 = Sound("E", secs=0.1)
                diastole1.play()
                systoleTime1 = None
Beispiel #3
0
from systole import import_ppg, import_rr, serialSim
from systole.recording import Oximeter

serial = serialSim()
oxi = Oximeter(serial=serial, add_channels=1).setup().read(10)
oxi.channels['Channel_0'][100] = 1

# Simulate oximeter instance from recorded signal
ppg = import_ppg().ppg.to_numpy()
oxi = Oximeter(serial=None, add_channels=1)
oxi.threshold = [0] * 75
oxi.peaks = [0] * 75
oxi.instant_rr = [0] * 75
oxi.recording = list(ppg[:75])
for i in range(len(ppg[75:750])):
    oxi.add_paquet(ppg[75 + i])
oxi.channels['Channel_0'] = np.zeros(750, dtype=int)
oxi.channels['Channel_0'][np.random.choice(np.arange(0, 750), 5)] = 1
oxi.times = list(np.arange(0, 10, 1 / 75))

# Create angular data
x = np.random.normal(np.pi, 0.5, 100)
y = np.random.uniform(0, np.pi * 2, 100)
z = np.concatenate([
    np.random.normal(np.pi / 2, 0.5, 50),
    np.random.normal(np.pi + np.pi / 2, 0.5, 50)
])


class TestPlotting(TestCase):
    def test_plot_hr(self):