# NeuroKit2

> Process neurophysiological signals and extract biomarkers in Python

- Category: Science & Biomedical AI / Biosignals & Time-Series ML
- Language: Python
- Repository: https://github.com/neuropsychology/NeuroKit
- Website: https://neuropsychology.github.io/NeuroKit
- Canonical page: https://ai-tldr.dev/tools/neurokit2/

## In short

NeuroKit2 is a Python toolbox for processing neurophysiological signals. It handles many common recording types, including ECG (cardiac activity), PPG (blood volume pulse), EDA (skin conductance), EMG (muscle activity), RSP (respiration), EOG (eye movements), and EEG (brain activity). It sits in the Biosignals & Time-Series ML category of the Science & Biomedical AI tools and is open-source, written in Python.

## Overview

NeuroKit2 is a Python toolbox for processing neurophysiological signals. It handles many common recording types, including ECG (cardiac activity), PPG (blood volume pulse), EDA (skin conductance), EMG (muscle activity), RSP (respiration), EOG (eye movements), and EEG (brain activity).

The library turns raw signals into cleaned data and extracted features with a small amount of code. It covers filtering and detrending, peak detection, ECG waveform delineation, heart rate variability indices in the time, frequency, and nonlinear domains, complexity and entropy measures, and both event-related and interval-related analysis.

Because it produces structured numeric features from raw recordings, NeuroKit2 is a practical front end for digital-biomarker and machine-learning pipelines: you use it to compute the physiological measures, then feed those features into your own models or statistics.

## What it does

- Processes ECG, PPG, EDA, EMG, RSP, EOG, and EEG signals from one package
- Computes heart rate variability indices across time-domain, frequency-domain, and nonlinear measures
- Delineates the ECG waveform, identifying P, Q, S, and T waves and the QRS complex
- Provides filtering, detrending, and peak-detection routines for cleaning raw signals
- Includes complexity analysis such as entropy calculations and fractal dimensions
- Supports both event-related analysis (stimulus-locked epochs) and interval-related analysis of longer recordings

## Getting started

Install NeuroKit2 with pip, then process a batch of signals and extract features in a couple of lines.

1. Install NeuroKit2

   Install the package from PyPI with pip.

```bash
pip install neurokit2
```

2. Process biosignals

   Import NeuroKit2 and run several signals through the processing pipeline at once, passing the sampling rate of your recording.

```python
import neurokit2 as nk

processed_data, info = nk.bio_process(
    ecg=data["ECG"],
    rsp=data["RSP"],
    eda=data["EDA"],
    sampling_rate=100,
)
```

3. Extract features

   Analyze the processed data to compute the extracted features and biomarkers, ready to feed into your own models or statistics.

```python
results = nk.bio_analyze(processed_data, sampling_rate=100)
```

## When to use it

- Compute heart rate variability and other cardiac biomarkers from ECG or PPG recordings
- Extract physiological features to feed into digital-biomarker or machine-learning pipelines
- Clean and delineate raw biosignals before downstream time-series modelling
- Run event-related or interval-related analysis for physiological research studies
