Skip to content

Commit

Permalink
Fix test recording for Travis (Python 3.7)
Browse files Browse the repository at this point in the history
  • Loading branch information
LegrandNico committed Aug 21, 2020
1 parent f768b64 commit 8444785
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
24 changes: 13 additions & 11 deletions systole/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ def oxi_peaks(x, sfreq=75, win=1, new_sfreq=1000, clipping=True,
References
----------
Some of the processing steps were adapted from the HeartPy toolbox [1]:
Some of the processing steps were adapted from the HeartPy toolbox:
https://python-heart-rate-analysis-toolkit.readthedocs.io/en/latest/index.html
..[1] van Gent, P., Farah, H., van Nes, N. and van Arem, B., 2019.
.. [1] van Gent, P., Farah, H., van Nes, N. and van Arem, B., 2019.
Analysing Noisy Driver Physiology Real-Time Using Off-the-Shelf Sensors:
Heart Rate Analysis Software from the Taking the Fast Lane Project. Journal
of Open Research Software, 7(1), p.32. DOI: http://doi.org/10.5334/jors.241
Expand Down Expand Up @@ -111,6 +111,8 @@ def ecg_peaks(x, sfreq=1000, new_sfreq=1000, method='pan-tompkins',
find_local=True, win_size=100):
"""A simple wrapper for many popular R peaks detectors algorithms.
This function calls methods from the py-ecg-detectors [#]_ module.
Parameters
----------
x : list or 1d array-like
Expand Down Expand Up @@ -152,10 +154,7 @@ def ecg_peaks(x, sfreq=1000, new_sfreq=1000, method='pan-tompkins',
References
----------
Some of the processing steps were adapted from the HeartPy toolbox [1]:
https://python-heart-rate-analysis-toolkit.readthedocs.io/en/latest/index.html
..[1] Howell, L., Porr, B. Popular ECG R peak detectors written in
.. [#] Howell, L., Porr, B. Popular ECG R peak detectors written in
python. DOI: 10.5281/zenodo.3353396
"""
if isinstance(x, list):
Expand Down Expand Up @@ -247,8 +246,8 @@ def rr_artefacts(rr, c1=0.13, c2=0.17, alpha=5.2):
Notes
-----
This function will use the method proposed by Lipponen & Tarvainen (2019)
to detect ectopic beats, long, shorts, missed and extra RR intervals.
This function will use the method proposed by [#]_ to detect ectopic beats,
long, shorts, missed and extra RR intervals.
Examples
--------
Expand All @@ -260,7 +259,7 @@ def rr_artefacts(rr, c1=0.13, c2=0.17, alpha=5.2):
References
----------
.. [1] Lipponen, J. A., & Tarvainen, M. P. (2019). A robust algorithm for
.. [#] Lipponen, J. A., & Tarvainen, M. P. (2019). A robust algorithm for
heart rate variability time series artefact correction using novel
beat classification. Journal of Medical Engineering & Technology,
43(3), 173–181. https://doi.org/10.1080/03091902.2019.1640306
Expand Down Expand Up @@ -369,7 +368,10 @@ def rr_artefacts(rr, c1=0.13, c2=0.17, alpha=5.2):


def interpolate_clipping(signal, threshold=255):
"""Interoplate clipping segment.
"""Interoplate clipping artefacts.
This function removes all data points equalling the provided threshold
and re-creates the missing segments using cubic spline interpolation.
Parameters
----------
Expand Down Expand Up @@ -405,7 +407,7 @@ def interpolate_clipping(signal, threshold=255):
.. Warning:: If clipping artefact is found at the edge of the signal, this
function will decrement the first/last value to allow interpolation,
which can lead to incorrect estimation.
which can result in incorrect estimation.
References
----------
Expand Down
2 changes: 1 addition & 1 deletion systole/recording.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ def read(self, duration):
self.lastBlock = -1

print("Reading TCP/IP connection (" +
str(channelCount) + "channels found). "
str(channelCount) + " channels found). "
+ str(resolutions) + " Hz. "
+ str(samplingInterval) + " samples. "
+ str(channelNames))
Expand Down
4 changes: 0 additions & 4 deletions systole/tests/test_recording.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def simulateEXG():
conn.send(data2)
conn.send(data3)
conn.send(data4)
server.close()

# Start fake server in background thread
server_thread = threading.Thread(target=simulateEXG)
Expand All @@ -87,9 +86,6 @@ def simulateEXG():
'EGG1', 'EGG2', 'EGG3', 'EGG4', 'EGG5', 'EGG6', 'RESP', 'PLETH']
assert all([data[k].shape[0] == 20 for k in list(data.keys())])

# Ensure server ends
server_thread.join()


if __name__ == '__main__':
unittest.main(argv=['first-arg-is-ignored'], exit=False)

0 comments on commit 8444785

Please sign in to comment.