Example #1
0
    def test_oximeter(self):

        serial = serialSim()
        oxi = Oximeter(serial=serial, add_channels=1)
        oxi.setup()
        oxi.read(10)
        oxi.find_peaks()

        # Simulate events in recording
        for idx in np.random.choice(len(oxi.recording), 5):
            oxi.channels['Channel_0'][idx] = 1
        ax = oxi.plot_events()
        assert isinstance(ax, matplotlib.axes.Axes)

        ax = oxi.plot_hr()
        assert isinstance(ax, matplotlib.axes.Axes)

        ax = oxi.plot_recording()
        assert isinstance(ax, matplotlib.axes.Axes)

        oxi.readInWaiting()
        oxi.waitBeat()
        oxi.find_peaks()

        oxi.peaks = []
        oxi.instant_rr = []
        oxi.times = []
        oxi.threshold = []

        oxi.save('test')
        assert os.path.exists("test.npy")
        os.remove("test.npy")
Example #2
0
    def test_oximeter(self):

        serial = serialSim()
        oxi = Oximeter(serial=serial, add_channels=1)
        oxi.setup()
        serial.ppg = serial.ppg[-2:]  # To the end of recording
        oxi.read(10)
        oxi.find_peaks()
        # Simulate events in recording
        for idx in np.random.choice(len(oxi.recording), 5):
            oxi.channels['Channel_0'][idx] = 1
        ax = oxi.plot_events()
        assert isinstance(ax, matplotlib.axes.Axes)

        ax = oxi.plot_hr()
        assert isinstance(ax, matplotlib.axes.Axes)

        ax = oxi.plot_recording()
        assert isinstance(ax, matplotlib.axes.Axes)

        oxi.serial.ppg = [1000]  # Insert error in recording
        with self.assertRaises(ValueError):
            oxi.readInWaiting(stop=True)

        serial = serialSim()
        oxi.serial.ppg = [1000, -1, 1000, -1, -1]  # Insert error in recording
        oxi.readInWaiting(stop=False)

        oxi.serial.ppg = [1000, -1, 1000, -1, -1]  # Insert error in recording
        oxi.waitBeat()
        oxi.find_peaks()

        oxi.peaks = []
        oxi.instant_rr = []
        oxi.times = []
        oxi.threshold = []

        oxi.save('test')
        assert os.path.exists("test.npy")
        os.remove("test.npy")
        oxi = Oximeter(serial=serial)
Example #3
0
import numpy as np
import seaborn as sns
from psychopy.sound import Sound

from systole import serialSim
from systole.plotting import circular
from systole.recording import Oximeter
from systole.utils import norm_triggers, to_angles

#%%
# Recording
# ---------
# For the purpose of demonstration, here we simulate data acquisition through
# the pulse oximeter using pre-recorded signal.

ser = serialSim()

#%%
# If you want to allow online data acquisition, you should uncomment the
# following lines and provide the reference of the COM port where the pulse
# oximeter is plugged in.

###############################################################################
# .. code-block:: python
#
#   import serial
#   ser = serial.Serial('COM4')  # Change this value according to your setup

#%%
# Create an Oximeter instance, initialize recording and record for 10 seconds
Example #4
0
# Author: Nicolas Legrand <*****@*****.**>

import numpy as np
import pandas as pd
import unittest
import matplotlib
from unittest import TestCase

from systole.plotting import plot_hr, plot_events, plot_oximeter,\
    plot_subspaces, circular, plot_circular, plot_psd
from systole import import_ppg, import_rr, serialSim
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))