Skip to main content

The Python Toolbox for Neurophysiological Signal Processing.

Project description

https://raw.github.com/neuropsychology/NeuroKit/master/docs/img/banner.png https://img.shields.io/pypi/pyversions/neurokit2.svg https://img.shields.io/pypi/v/neurokit2.svg https://travis-ci.org/neuropsychology/NeuroKit.svg?branch=master https://codecov.io/gh/neuropsychology/NeuroKit/branch/master/graph/badge.svg https://img.shields.io/pypi/dm/neurokit2 Maintainability

The Python Toolbox for Neurophysiological Signal Processing (EDA, ECG, PPG, EMG, EEG…)

This is a work in progress project meant as a continuation of NeuroKit.py. We are looking to build a community of people around this collaborative project. If you’re interested by getting involved, do let us know!

Installation

To install NeuroKit2, run this command in your terminal:

pip install https://github.com/neuropsychology/neurokit/zipball/master

Contribution

NeuroKit2 is meant to be a all-level-friendly collaborative project. Additionally, it tries to credit all contributors, so that your involvement pays off on your CV. Thus, if you have some ideas for improvement, new features, or just wanna learn Python and do something useful at the same time, do not hesitate and check-out the CONTRIBUTION guide.

Documentation

Documentation Status API Tutorials

Click on the links above and check out our tutorials:

Tutorials

Examples

Overview

Simulate physiological signals

import numpy as np
import pandas as pd
import neurokit2 as nk

# Generate synthetic signals
ecg = nk.ecg_simulate(duration=10, heart_rate=70)
rsp = nk.rsp_simulate(duration=10, respiratory_rate=15)
eda = nk.eda_simulate(duration=10, n_scr=3)
emg = nk.emg_simulate(duration=10, n_bursts=2)

# Visualise biosignals
data = pd.DataFrame({"ECG": ecg,
                     "RSP": rsp,
                     "EDA": eda,
                     "EMG": emg})
nk.signal_plot(data, subplots=True)
https://raw.github.com/neuropsychology/NeuroKit/master/docs/img/README_simulation.png

Electrodermal Activity (EDA)

# Generate 10 seconds of EDA signal (recorded at 250 samples / second) with 2 SCR peaks
eda = nk.eda_simulate(duration=10, sampling_rate=250, n_scr=2 drift=0.01)

# Process it
signals, info = nk.eda_process(eda, sampling_rate=250)

# Visualise the processing
nk.eda_plot(signals, sampling_rate=250)
https://raw.github.com/neuropsychology/NeuroKit/master/docs/img/README_eda.png

Cardiac activity (ECG)

# Generate 15 seconds of ECG signal (recorded at 250 samples / second)
ecg = nk.ecg_simulate(duration=15, sampling_rate=250, heart_rate=70)

# Process it
signals, info = nk.ecg_process(ecg, sampling_rate=250)

# Visualise the processing
nk.ecg_plot(signals, sampling_rate=250)
https://raw.github.com/neuropsychology/NeuroKit/master/docs/img/README_ecg.png

Respiration (RSP)

# Generate one minute of respiratory (RSP) signal (recorded at 250 samples / second)
rsp = nk.rsp_simulate(duration=60, sampling_rate=250, respiratory_rate=15)

# Process it
signals, info = nk.rsp_process(rsp, sampling_rate=250)

# Visualise the processing
nk.rsp_plot(signals, sampling_rate=250)
https://raw.github.com/neuropsychology/NeuroKit/master/docs/img/README_rsp.png

Electromyography (EMG)

# Generate 10 seconds of EMG signal (recorded at 250 samples / second)
    emg = nk.emg_simulate(duration=10, sampling_rate=250, n_bursts=3)

# Process it
signals = nk.emg_process(emg, sampling_rate=250)

# Visualise the processing
nk.emg_plot(signals, sampling_rate=250)
https://raw.github.com/neuropsychology/NeuroKit/master/docs/img/README_emg.png

PPG, BVP, EGG, …

Consider helping us developing it!

Signal processing

Signal cleaning

  • signal_distord(): Add noise of a given frequency, amplitude and shape to a signal.

  • signal_binarize(): Convert a continuous signal into zeros and ones depending on a given threshold.

  • signal_filter(): Filter a signal using ‘butterworth’, ‘fir’ or ‘savgol’ filters.

  • signal_detrend(): Apply a baseline (order = 0), linear (order = 1), or polynomial (order > 1) detrending to the signal (i.e., removing a general trend).

  • signal_smooth(): Signal smoothing using the convolution of a filter kernel.

  • signal_psd(): Compute the Power Spectral Density (PSD).

Signal preprocessing

Signal processing

  • signal_zerocrossings(): Locate the indices where the signal crosses zero.

  • signal_findpeaks(): Locate peaks (local maxima) in a signal and their related characteristics, such as height (prominence), width and distance with other peaks.

  • signal_plot(): Plot signal with events as vertical lines.

Other Utilities

Read data

  • read_acqknowledge(): Read and format a BIOPAC’s AcqKnowledge file into a pandas’ dataframe.

Events (stimuli triggers and markers)

Design

NeuroKit2 is designed to provide a consistent, accessible yet powerful and flexible API.

  • Consistency: For each type of signals (ECG, RSP, EDA, EMG…), the same function names are called (in the form signaltype_functiongoal()) to achieve equivalent goals, such as *_clean(), *_findpeaks(), *_process(), *_plot() (replace the star with the signal type, e.g., ecg_clean()).

  • Accessibility: Using NeuroKit2 is made very easy for beginners through the existence powerful high-level “master” functions, such as *_process(), that performs cleaning, preprocessing and processing with sensible defaults.

  • Flexibility: However, advanced users can very easily build their own custom analysis pipeline by using the mid-level functions (such as *_clean(), *_rate()), offering more control and flexibility over their parameters.

Citation

https://zenodo.org/badge/218212111.svg

No citation yet :’(

Alternatives

Here’s a list of great alternative packages that you should check-out:

General

ECG

EDA

EEG

Eye-Tracking

News

0.0.1 (2019-10-29)

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

neurokit2-0.0.10.tar.gz (8.9 MB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page