executing-plans
executing-plans
Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available
neurokitComprehensive biosignal processing for ECG/PPG/EEG/EDA/RSP/EMG/EOG; use when you need to clean, segment, and extract physiological features for HRV, event-related responses, complexity metrics, or multimodal psychophysiology pipelines.
Independent GitHub snapshot · Automated classification · Original documentation governs
Use this skill when you need to:
Reference docs (if available in this skill package): references/ecg_cardiac.md, references/hrv.md, references/eeg.md, references/eda.md, references/rsp.md, references/emg.md, references/eog.md, references/signal_processing.md, references/complexity.md, references/epochs_events.md, references/bio_module.md.
bio_process() / bio_analyze() for consistent multi-signal pipelines.neurokit2 (latest; install via pip/uv)Installation:
uv pip install neurokit2
Development version:
uv pip install https://github.com/neuropsychology/NeuroKit/zipball/dev
A complete, runnable example that simulates signals, processes them, computes features, and performs event-related epoching:
import neurokit2 as nk
import numpy as np
# -----------------------------
# 1) Simulate example signals
# -----------------------------
sampling_rate = 1000
duration = 60 # seconds
ecg = nk.ecg_simulate(duration=duration, sampling_rate=sampling_rate, heart_rate=70)
rsp = nk.rsp_simulate(duration=duration, sampling_rate=sampling_rate, respiratory_rate=15)
eda = nk.eda_simulate(duration=duration, sampling_rate=sampling_rate, scr_number=8)
# Create a simple trigger channel with 5 events
trigger = np.zeros(len(ecg))
event_times_s = [10, 20, 30, 40, 50]
for t in event_times_s:
trigger[int(t * sampling_rate)] = 1.0
# -----------------------------
# 2) ECG processing + HRV
# -----------------------------
ecg_signals, ecg_info = nk.ecg_process(ecg, sampling_rate=sampling_rate)
rpeaks = ecg_info["ECG_R_Peaks"]
hrv = nk.hrv(rpeaks, sampling_rate=sampling_rate)
# -----------------------------
# 3) Multimodal processing
# -----------------------------
bio_signals, bio_info = nk.bio_process(
ecg=ecg,
rsp=rsp,
eda=eda,
sampling_rate=sampling_rate
)
bio_results = nk.bio_analyze(bio_signals, sampling_rate=sampling_rate)
# -----------------------------
# 4) Event-related epoching
# -----------------------------
events = nk.events_find(trigger, threshold=0.5)
epochs = nk.epochs_create(
bio_signals,
events,
sampling_rate=sampling_rate,
epochs_start=-0.5,
epochs_end=2.0
)
grand_average = nk.epochs_average(epochs)
# -----------------------------
# 5) Minimal outputs
# -----------------------------
print("HRV (first columns):")
print(hrv.iloc[:, :8].round(3))
print("\nBio analysis keys:", list(bio_results.keys())[:10])
print("Grand average shape:", grand_average.shape)
Most modalities follow a consistent structure:
*_process(signal, sampling_rate=...)
Produces a cleaned signal plus intermediate channels (e.g., peaks, phases) and an info dict with indices/metadata.*_analyze(processed_signals, sampling_rate=...)
Computes summary features and automatically selects an analysis mode based on recording length.Examples:
ecg_process() → ecg_analyze() → hrv()eda_process() → eda_analyze()rsp_process() → rsp_rrv() / rsp_rvt()Many *_analyze() functions implicitly switch modes based on data duration:
If you need explicit event-related workflows, use:
events_find() to detect markersepochs_create() to segment around eventsepochs_average() (and modality-specific *_eventrelated() where applicable)HRV functions typically require R-peak indices (sample positions) and often a sampling_rate:
Common calls:
nk.hrv(peaks, sampling_rate=...) (all-in-one)nk.hrv_time(peaks), nk.hrv_frequency(peaks, sampling_rate=...), nk.hrv_nonlinear(peaks, sampling_rate=...)General utilities (see references/signal_processing.md) typically expose parameters such as:
sampling_ratelowcut, highcut)Example:
filtered = nk.signal_filter(x, sampling_rate=1000, lowcut=0.5, highcut=40)
psd = nk.signal_psd(filtered, sampling_rate=1000)
Complexity functions (see references/complexity.md) provide:
Example:
indices = nk.complexity(x, sampling_rate=1000)
apen = nk.entropy_approximate(x)
dfa = nk.fractal_dfa(x)