Registry / data / neurokit2

neurokit2

JSON →
library0.2.13pypypi✓ verified 84d ago

NeuroKit2 is a Python toolbox for neurophysiological signal processing (ECG, PPG, EDA, EMG, RSP, etc.). It provides end-to-end pipelines for cleaning, processing, and analyzing biosignals. The current version is 0.2.13, released in early 2025. The project is actively maintained with frequent releases.

pip install neurokit2
INSTALL
IMPORT
SIG · NEUROKIT2
N
neurokit2
datapythonv0.2.13
Install
19.4s avg
Import
8020ms
Disk
469MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.2.13 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
build_error
glibc
py 3.103.95 runs
installs and imports cleanly · install 19.4s · import 6.416s · 442MB
469MB installed
● package 469MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

NeuroKit2
import neurokit2 as nk
from neurokit2 import NeuroKit2
NeuroKit2 is commonly imported as nk, not as a class. Never import 'NeuroKit2' directly.
ecg_process
import neurokit2 as nk; nk.ecg_process()
from neurokit2 import ecg_process
All functions are accessed via the 'nk' namespace, not imported directly.

Simulate ECG signal, process it, and compute heart rate.

import neurokit2 as nk import numpy as np # Simulate 5 seconds of ECG signal at 100 Hz sampling_rate = 100 ecg_signal = nk.ecg_simulate(duration=5, sampling_rate=sampling_rate, noise=0.01) # Process the signal signals, info = nk.ecg_process(ecg_signal, sampling_rate=sampling_rate) # Extract heart rate hr = nk.ecg_rate(info, sampling_rate=sampling_rate) print("Heart rate (BPM):", np.mean(hr))
Debug
Known issues
breakingIn version 0.2.6, the `*_plot()` methods no longer accept `sampling_rate` as a separate argument; it must be provided via the plotting function's parameters.
fix
Use `nk.ecg_plot(signals, info, sampling_rate=100)` instead of passing `sampling_rate` to `ecg_plot` itself.
affects: >=0.2.6
breakingIn version 0.2.5, `ecg_clean()` updated the 'biosppy' method, which may produce slightly different cleaned signals.
fix
If you rely on exact previous output, specify an older method or adjust post-processing.
affects: >=0.2.5
gotchaMany functions expect the signal to be a 1D array. Passing a 2D array (e.g., from pandas DataFrame) can cause silent errors or wrong results.
fix
Always flatten or select a single column: `ecg_signal = df['ECG'].values.flatten()`.
affects: all
gotchaThe `ecg_process()` function returns a tuple (signals, info). The `signals` DataFrame includes multiple channels (ECG_Clean, ECG_Rate, etc.). The `info` dict contains peak indices and other metadata. Confusing these two can lead to incorrect analysis.
fix
Confirm you are using the correct return: `signals` for derived time series, `info` for peak locations and parameters.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'neurokit2'
NeuroKit2 is not installed or installed as a different package name.
fix
Run `pip install neurokit2` (note: all lowercase, no spaces).
AttributeError: module 'neurokit2' has no attribute 'ecg_simulate'
Function name typo or outdated version; 'ecg_simulate' is correct.
fix
Use `nk.ecg_simulate()`. Check version: `pip show neurokit2` should be >=0.2.0.
ValueError: cannot convert float NaN to integer
Some algorithms may produce NaN values (e.g., when signal is too short).
fix
Ensure the signal length is sufficient for the method. Check that `sampling_rate` matches the actual sample rate.
TypeError: ecg_process() got an unexpected keyword argument 'sampling_rate'
Older version of NeuroKit2 may not support `sampling_rate` parameter in `ecg_process()`.
fix
Update to latest version: `pip install --upgrade neurokit2`.
Upgrade
Version history
0.2.13latest on PyPI · released Mar 2, 2026
Audit
Dependencies
numpyrequiredCore numerical operations
pandasrequiredData manipulation and storage
scipyrequiredSignal processing and statistical functions
matplotlibrequiredPlotting
scikit-learnrequiredMachine learning utilities
Agent activity
2 hits · last 30 days
node
2
Resources
neurokit2 — pip install neurokit2 · libregistry