Skip to main content
https://img.shields.io/badge/License-GPL%20v3-blue.svg https://zenodo.org/badge/219720901.svg
images/banner.png

Systole is an open-source Python package providing simple tools to record and analyze body signal for psychophysiology.

Installation

Systole can be installed using pip:

pip install systole

The following package will be required to use Systole:

  • Numpy (>=1.15)

  • SciPy (>=1.3.0)

  • Pandas (>=0.24)

  • Matplotlib (>=3.0.2)

  • Seaborn (>=0.9.0)

Recording

Systole supports the recording of PPG signal through the Nonin 3012LP Xpod USB pulse oximeter together with the Nonin 8000SM ‘soft-clip’ fingertip sensors. It can easily interface with PsychoPy to record PPG signal during psychological experiments.

Record and plot data with less than 6 lines of code.

import serial
from systole.recording import Oximeter
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)

Interfacing with PsychoPy

2 methods are available to record PPG signal:

  • The read() method

Will continuously record for a certain amount of time (specified by the duration parameter, in seconds). This is the easiest and most robust method, but it is not possible to run instructions in the meantime (serial mode).

# Code 1 {}
oximeter.read(duration=10)
# Code 2 {}
  • The readInWaiting() method

Will read all the available bytes (up to 10 seconds of recording). When inserted into a while loop, it allows recording PPG signal in parallel with other commands.

import time
tstart = time.time()
while time.time() - tstart < 10:
    oximeter.readInWaiting()
    # Insert code here {...}

Online detection

Online heart beat detection.

import serial
import time
from systole.recording import Oximeter

# Open serial port
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()

# Online peak detection for 10 seconds
tstart = time.time()
while time.time() - tstart < 10:
    while oxi.serial.inWaiting() >= 5:
        paquet = list(oxi.serial.read(5))
        oxi.add_paquet(paquet[2])  # Add new data point
        if oxi.peaks[-1] == 1:
          print('Heartbeat detected')

Peaks detection

Heart beat can be detected in the PPG signal either online or offline.

Methods from clipping correction and peak detection algorithm is adapted from [1].

# Plot data
oxi.plot()
images/recording.png

Artifact removal

It is possible to detect and correct outliers from RR time course following the method described in [2].

from systole import import_rr()
from systole.plotting import plot_subspaces

rr = import_rr().rr[:100]
rr[20] = 1600  # Add missed beat

plot_subspaces(rr)
images/subspaces.png

Heart rate variability

Time-domain

Extract the summary of time-domain indexes.

from systole.hrv import time_domain

stats = time_domain(rr)
stats

Frequency-domain

from systole.hrv import plot_psd

plot_psd(rr)
images/psd.png

Extract the summary of frequency-domain indexes.

from systole.hrv import frequency_domain

frequency_domain(rr)
Output

Metric

Value

Non-linear

from systole.hrv import nonlinear

nonlinear(rr)

All the results have been tested against Kubios HVR 2.2 (<https://www.kubios.com>).

Development

This module was created and is maintained by Nicolas Legrand and Micah Allen (ECG group, https://the-ecg.org/). If you want to contribute, feel free to contact one of the contributors, open an issue or submit a pull request.

This program is provided with NO WARRANTY OF ANY KIND.

Acknowledgement

This software supported by a Lundbeckfonden Fellowship (R272-2017-4345), and the AIAS-COFUND II fellowship programme that is supported by the Marie Skłodowska-Curie actions under the European Union’s Horizon 2020 (Grant agreement no 754513), and the Aarhus University Research Foundation.

Systole was largely inspired by preexisting toolboxes dedicated to heart rate variability and signal analysis.

References

Peak detection (PPG signal)

Artefact detection and correction:

Metadata

Release files for systole 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for systole 0.0.1
File Size Uploaded
systole-0.0.1.tar.gz 99.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for systole 0.0.1
File Interpreter ABI Platform
systole-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 205.1 kB

Release files / systole-0.0.1.tar.gz

Download URL systole-0.0.1.tar.gz
Size 99.8 kB
Tags Source
SHA-256 checksum
How to use checksums
526f3a168365703529a94c38b7ec1a54b1bd2ef51b3ba6c724b5428a877496ac
BLAKE2b-256 checksum
How to use checksums
ca6a5f6ca3b742852831cdeee1c6c91a749d50d630c85edbd3731b4d800f2824
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.3

Release files / systole-0.0.1-py3-none-any.whl

Download URL systole-0.0.1-py3-none-any.whl
Size 105.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
da1cdc811ed1735e5865cdb4011ca8650cf04f4d2ca932473d3409c10c33aee8
BLAKE2b-256 checksum
How to use checksums
0e62a78724a8b0ddcd0e99d4e548754e77192be4c815960bc8ff4274d0cafabf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.3

Release history Release notifications | RSS feed

0.3.1

1 release file

0.3.0

2 release files

0.2.4

1 release file

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page