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://img.shields.io/travis/neuropsychology/NeuroKit.svg 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:

Examples

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})
data.plot(subplots=True)
https://raw.github.com/neuropsychology/NeuroKit/master/docs/img/README_simulation.png

Cardiac activity (ECG) processing

# Generate 20 seconds of ECG signal
ecg = nk.ecg_simulate(duration=20, heart_rate=70)

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

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

Respiration (RSP) processing

# Generate one minute of respiratory (RSP) signal
rsp = nk.rsp_simulate(duration=60, respiratory_rate=15)

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

# Visualise the processing
nk.rsp_plot(signals)
https://raw.github.com/neuropsychology/NeuroKit/master/docs/img/README_respiration.png

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 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, and 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.

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.6.tar.gz (1.1 MB view details)

Uploaded Source

File details

Details for the file neurokit2-0.0.6.tar.gz.

File metadata

  • Download URL: neurokit2-0.0.6.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for neurokit2-0.0.6.tar.gz
Algorithm Hash digest
SHA256 bc5dfe6c3c3de272c2cf90174ac6d24c9ec9a983b2e1533a0cc2b0a6b06bdf74
MD5 186cab5de573b8cc66a828fcb4364920
BLAKE2b-256 24aada639042ab813f960966b986d28e8ec4c8159c3378c47719b59f88fd3f25

See more details on using hashes here.

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