Skip to content

Commit

Permalink
extracted fake phys
Browse files Browse the repository at this point in the history
  • Loading branch information
rzlim08 committed Feb 25, 2021
1 parent 7a7bc2f commit d4fd563
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
14 changes: 14 additions & 0 deletions phys2denoise/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import numpy as np
import pytest


@pytest.fixture(scope="module")
def fake_phys():
f = 0.3
fs = 62.5 # sampling rate
t = 300
samples = np.arange(t * fs) / fs
noise = np.random.normal(0, 0.5, len(samples))
fake_phys = 10 * np.sin(2 * np.pi * f * samples) + noise
return fake_phys

21 changes: 5 additions & 16 deletions phys2denoise/tests/test_rvt.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,19 @@
import peakdet
import numpy as np
import pytest
from phys2denoise.metrics.chest_belt import rvt


@pytest.fixture
def fake_phys():
f = 0.3
fs = 62.5 # sampling rate
t = 300
samples = np.arange(t * fs) / fs
noise = np.random.normal(0, 0.5, len(samples))
fake_phys = 10 * np.sin(2 * np.pi * f * samples) + noise
def test_peakdet(fake_phys):
phys = peakdet.Physio(fake_phys, fs=62.5)
phys = peakdet.operations.filter_physio(phys, cutoffs=3, method="lowpass")
return phys


def test_peakdet(fake_phys):
phys = peakdet.operations.peakfind_physio(fake_phys)
phys = peakdet.operations.peakfind_physio(phys)
assert phys.troughs is not None
assert phys.peaks is not None


def test_rvt(fake_phys):
phys = peakdet.operations.peakfind_physio(fake_phys)
phys = peakdet.Physio(fake_phys, fs=62.5)
phys = peakdet.operations.filter_physio(phys, cutoffs=3, method="lowpass")
phys = peakdet.operations.peakfind_physio(phys)
r = rvt(phys.data, phys.peaks, phys.troughs, samplerate=phys.fs)
assert r is not None
assert len(r) == 18750

0 comments on commit d4fd563

Please sign in to comment.