Skip to content

Commit

Permalink
Merge pull request #9 from embodied-computation-group/dev
Browse files Browse the repository at this point in the history
Push v0.1.3 from dev branch
  • Loading branch information
micahgallen authored Apr 7, 2021
2 parents 235c1d2 + 871e938 commit 21b3eab
Show file tree
Hide file tree
Showing 194 changed files with 3,686 additions and 2,162 deletions.
5 changes: 5 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[flake8]
max-line-length = 88
extend-ignore = E203, E722, E501
exclude =
__init__.py
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.pyc
*-checkpoint.ipynb
mypyreports/
8 changes: 8 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[settings]
known_third_party = ecgdetectors,matplotlib,numpy,pandas,plotly,psychopy,pytest,requests,scipy,seaborn,serial,sphinx_bootstrap_theme,tqdm
multi_line_output = 3
include_trailing_comma = True
force_grid_wrap = 0
use_parentheses = True
ensure_newline_before_comments = True
line_length = 88
23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
repos:
- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.21
hooks:
- id: isort
files: ^systole/
- repo: https://github.com/ambv/black
rev: stable
hooks:
- id: black
language_version: python3
files: ^systole/
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: flake8
files: ^systole/
- repo: https://github.com/pre-commit/mirrors-mypy
rev: '' # Use the sha / tag you want to point at
hooks:
- id: mypy
files: ^systole/
args: [--ignore-missing-imports]
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ python:
- "3.6"
- "3.7"
- "3.8"
- "3.9"

install:
- pip install -r requirements-test.txt
- pip install -r requirements.txt
- pip install coverage pytest
- pip install coverage pytest black mypy flake8 isort

script:
- coverage run -m pytest
- black --check ./systole/
- isort ./systole/
- mypy ./systole/ --ignore-missing-imports --follow-imports=skip
- flake8 ./systole/

after_success:
- bash <(curl -s https://codecov.io/bash)
Binary file removed Images/recording.png
Binary file not shown.
8 changes: 0 additions & 8 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,3 @@
include README.rst
include LICENSE
include requirements.txt

# Add datasets files
include systole/datasets/ppg.npy
include systole/datasets/rr.txt
include systole/datasets/Task1_ECG.npy
include systole/datasets/Task1_EDA.npy
include systole/datasets/Task1_Respiration.npy
include systole/datasets/Task1_Stim.npy
45 changes: 33 additions & 12 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@
.. image:: https://codecov.io/gh/embodied-computation-group/systole/branch/master/graph/badge.svg
:target: https://codecov.io/gh/embodied-computation-group/systole

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black

.. image:: https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336
:target: https://pycqa.github.io/isort/

.. image:: http://www.mypy-lang.org/static/mypy_badge.svg
:target: http://mypy-lang.org/

.. image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white
:target: https://github.com/pre-commit/pre-commit

================

.. figure:: https://github.com/embodied-computation-group/systole/raw/master/source/images/banner.png
Expand All @@ -38,35 +50,44 @@ Systole can be installed using pip:
The following packages are required to use Systole:

* Numpy (>=1.15)
* SciPy (>=1.3.0)
* Pandas (>=0.24)
* Matplotlib (>=3.0.2)
* Seaborn (>=0.9.0)
* py-ecg-detectors (>=1.0.2)
* `Numpy <https://numpy.org/>`_ (>=1.15)
* `SciPy <https://www.scipy.org/>`_ (>=1.3.0)
* `Pandas <https://pandas.pydata.org/>`_ (>=0.24)
* `Matplotlib <https://matplotlib.org/>`_ (>=3.0.2)
* `Seaborn <https://seaborn.pydata.org/>`_ (>=0.9.0)
* `py-ecg-detectors <https://github.com/berndporr/py-ecg-detectors>`_ (>=1.0.2)

Interactive plotting functions and reports generation will also require the following packages to be installed:

* plotly (>=4.8.0)
* plotly_express (>=0.4.1)
* `Plotly <https://plotly.com/>`_ (>=4.8.0)

For an overview of all the recording functionalities, you can refer to the following tutorials:
Tutorial
========

For an overview of all the recording functionalities, you can refer to the following examples:

* Recording
* Artefacts detection and artefacts correction
* Heart rate variability

For an introduction to Systole and cardiac signal analysis, you can refer to the following tutorial:

* Introduction to cardiac signal analysis - |Colab badge| - `Jupyter Book <https://legrandnico.github.io/Notebooks/IntroductionCardiacSignalAnalysis.html>`_

.. |Colab badge| image:: https://colab.research.google.com/assets/colab-badge.svg
:target: https://colab.research.google.com/github/LegrandNico/Notebooks/blob/main/IntroductionCardiacSignalAnalysis.ipynb

Recording
=========

Systole natively supports recording of physiological signals from the following setups:
* `Nonin 3012LP Xpod USB pulse oximeter <https://www.nonin.com/products/xpod/>`_ together with the `Nonin 8000SM 'soft-clip' fingertip sensors <https://www.nonin.com/products/8000s/>`_ (USB).
* Remote Data Access (RDA) via BrainVision Recorder together with Brain product ExG amplifier `<https://www.brainproducts.com/>`_ (Ethernet).
* Remote Data Access (RDA) via BrainVision Recorder together with `Brain product ExG amplifier <https://www.brainproducts.com/>`_ (Ethernet).

Artefact correction
===================

Systole implements the artefact rejection method recently proposed by Lipponen & Tarvainen (2019) [#]_.
Systole implements systolic peak detection inspired by van Gent et al. (2019) [#]_ and the artefact rejection method recently proposed by Lipponen & Tarvainen (2019) [#]_.

.. code-block:: python
Expand Down Expand Up @@ -137,7 +158,7 @@ References

**Peak detection (PPG signal)**

.. [#] van Gent, P., Farah, H., van Nes, N., & van Arem, B. (2019). HeartPy: A novel heart rate algorithm for the analysis of noisy signals. Transportation Research Part F: Traffic Psychology and Behaviour, 66, 368–378. https://doi.org/10.1016/j.trf.2019.09.015
.. [#] van Gent, P., Farah, H., van Nes, N., & van Arem, B. (2019). HeartPy: A novel heart rate algorithm for the analysis of noisy signals. *Transportation Research Part F: Traffic Psychology and Behaviour, 66, 368–378*. https://doi.org/10.1016/j.trf.2019.09.015
**Artefact detection and correction:**

Expand Down
54 changes: 0 additions & 54 deletions examples/Tutorial_HRV.py

This file was deleted.

15 changes: 8 additions & 7 deletions examples/Tutorial_recording.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@
# Recording and plotting your first time-series will only require 5 lines
# of code:

import time

import serial

from systole.recording import Oximeter
ser = serial.Serial('COM4') # Add your USB port here

ser = serial.Serial("COM4") # Add your USB port here

# Open serial port, initialize and plot recording for Oximeter
oxi = Oximeter(serial=ser).setup().read(duration=10)
Expand Down Expand Up @@ -56,7 +60,7 @@
# seconds for a continuous recording). When inserted into a while loop, it can
# record PPG signal in parallel with other commands.

import time

tstart = time.time()
while time.time() - tstart < 10:
oximeter.readInWaiting()
Expand All @@ -67,12 +71,9 @@
# ----------------
# Online heart beat detection, for cardiac-stimulus synchrony

import serial
import time
from systole.recording import Oximeter

# Open serial port
ser = serial.Serial('COM4') # Change this value according to your setup
ser = serial.Serial("COM4") # Change this value according to your setup

# Create an Oxymeter instance and initialize recording
oxi = Oximeter(serial=ser, sfreq=75, add_channels=4).setup()
Expand All @@ -84,4 +85,4 @@
paquet = list(oxi.serial.read(5))
oxi.add_paquet(paquet[2]) # Add new data point
if oxi.peaks[-1] == 1:
print('Heartbeat detected')
print("Heartbeat detected")
6 changes: 3 additions & 3 deletions examples/plot_ArtefactsCorrection.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
# ectopic beats. This method is more relevant for HRV analyse of long recording
# where the timing of experimental events is not important.

import matplotlib.pyplot as plt
#%%
import numpy as np
import matplotlib.pyplot as plt

from systole import simulate_rr
from systole.plotting import plot_subspaces
from systole.correction import correct_peaks, correct_rr

from systole.plotting import plot_subspaces

#%% Method 1 - Peaks correction
# #############################
Expand Down
2 changes: 1 addition & 1 deletion examples/plot_ArtefactsDetection.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

#%%
from systole.detection import rr_artefacts
from systole.utils import simulate_rr
from systole.plotting import plot_subspaces
from systole.utils import simulate_rr

#%%
# RR artefacts
Expand Down
86 changes: 0 additions & 86 deletions examples/plot_ECGProcessing.py

This file was deleted.

Loading

0 comments on commit 21b3eab

Please sign in to comment.