-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from rzlim08/rvt
Add RVT algorithm (Birn et al. 2006)
- Loading branch information
Showing
4 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import peakdet | ||
from phys2denoise.metrics.chest_belt import rvt | ||
|
||
|
||
def test_peakdet(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) | ||
assert phys.troughs is not None | ||
assert phys.peaks is not None | ||
|
||
|
||
def test_rvt(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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,7 @@ test = | |
%(style)s | ||
pytest >=5.3 | ||
pytest-cov | ||
peakdet | ||
coverage | ||
devtools = | ||
pre-commit | ||
|