{"id":24112,"library":"neurokit2","title":"NeuroKit2","description":"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.","status":"active","version":"0.2.13","language":"python","source_language":"en","source_url":"https://github.com/neuropsychology/NeuroKit","tags":["biosignal","physiology","ecg","ppg","eda","emg","hrv","signal-processing"],"install":[{"cmd":"pip install neurokit2","lang":"bash","label":"PyPI"}],"dependencies":[{"reason":"Core numerical operations","package":"numpy","optional":false},{"reason":"Data manipulation and storage","package":"pandas","optional":false},{"reason":"Signal processing and statistical functions","package":"scipy","optional":false},{"reason":"Plotting","package":"matplotlib","optional":false},{"reason":"Machine learning utilities","package":"scikit-learn","optional":false}],"imports":[{"note":"NeuroKit2 is commonly imported as nk, not as a class. Never import 'NeuroKit2' directly.","wrong":"from neurokit2 import NeuroKit2","symbol":"NeuroKit2","correct":"import neurokit2 as nk"},{"note":"All functions are accessed via the 'nk' namespace, not imported directly.","wrong":"from neurokit2 import ecg_process","symbol":"ecg_process","correct":"import neurokit2 as nk; nk.ecg_process()"}],"quickstart":{"code":"import neurokit2 as nk\nimport numpy as np\n\n# Simulate 5 seconds of ECG signal at 100 Hz\nsampling_rate = 100\necg_signal = nk.ecg_simulate(duration=5, sampling_rate=sampling_rate, noise=0.01)\n\n# Process the signal\nsignals, info = nk.ecg_process(ecg_signal, sampling_rate=sampling_rate)\n\n# Extract heart rate\nhr = nk.ecg_rate(info, sampling_rate=sampling_rate)\nprint(\"Heart rate (BPM):\", np.mean(hr))","lang":"python","description":"Simulate ECG signal, process it, and compute heart rate."},"warnings":[{"fix":"Use `nk.ecg_plot(signals, info, sampling_rate=100)` instead of passing `sampling_rate` to `ecg_plot` itself.","message":"In 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.","severity":"breaking","affected_versions":">=0.2.6"},{"fix":"If you rely on exact previous output, specify an older method or adjust post-processing.","message":"In version 0.2.5, `ecg_clean()` updated the 'biosppy' method, which may produce slightly different cleaned signals.","severity":"breaking","affected_versions":">=0.2.5"},{"fix":"Always flatten or select a single column: `ecg_signal = df['ECG'].values.flatten()`.","message":"Many 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.","severity":"gotcha","affected_versions":"all"},{"fix":"Confirm you are using the correct return: `signals` for derived time series, `info` for peak locations and parameters.","message":"The `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.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `pip install neurokit2` (note: all lowercase, no spaces).","cause":"NeuroKit2 is not installed or installed as a different package name.","error":"ModuleNotFoundError: No module named 'neurokit2'"},{"fix":"Use `nk.ecg_simulate()`. Check version: `pip show neurokit2` should be >=0.2.0.","cause":"Function name typo or outdated version; 'ecg_simulate' is correct.","error":"AttributeError: module 'neurokit2' has no attribute 'ecg_simulate'"},{"fix":"Ensure the signal length is sufficient for the method. Check that `sampling_rate` matches the actual sample rate.","cause":"Some algorithms may produce NaN values (e.g., when signal is too short).","error":"ValueError: cannot convert float NaN to integer"},{"fix":"Update to latest version: `pip install --upgrade neurokit2`.","cause":"Older version of NeuroKit2 may not support `sampling_rate` parameter in `ecg_process()`.","error":"TypeError: ecg_process() got an unexpected keyword argument 'sampling_rate'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}