The Python Toolbox for Neurophysiological Signal Processing.
Project description
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
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)
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)
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)
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)
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)
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_resample(): Up- or down-sample a signal.
signal_interpolate(): Interpolate (fills the values between data points) a signal using different methods.
signal_merge(): Arbitrary addition of two signals with different time ranges.
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)
events_find(): Find and select events in a continuous signal (e.g., from a photosensor).
events_plot(): Plot events in signal.
events_to_mne(): Create MNE compatible events for integration with M/EEG.
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
No citation yet :’(
Alternatives
Here’s a list of great alternative packages that you should check-out:
General
ECG
EDA
BreatheEasyEDA (matlab)
EDA (matlab)
EEG
Eye-Tracking
News
0.0.1 (2019-10-29)
First release on PyPI.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file neurokit2-0.0.9.tar.gz
.
File metadata
- Download URL: neurokit2-0.0.9.tar.gz
- Upload date:
- Size: 8.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.8.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0299344be14ac16fe9f9a50385c4f7a36343d0ab9a00ca41625843653bff5889 |
|
MD5 | abfdedc9dd0bf2458b93b68013ff87cd |
|
BLAKE2b-256 | 77cc10233ba753e6abfda3ffa4328698da33abbb9897308452d48205b01e95ff |