neurokit2 by davila7/claude-code-templates
npx skills add https://github.com/davila7/claude-code-templates --skill neurokit2NeuroKit2 是一个用于处理和分析生理信号(生物信号)的综合性 Python 工具包。使用此技能处理心血管、神经、自主神经、呼吸和肌肉信号,用于心理生理学研究、临床应用和人机交互研究。
在处理以下信号时应用此技能:
处理心电图和光电容积脉搏波信号以进行心血管分析。详细工作流程请参阅 references/ecg_cardiac.md。
主要工作流程:
关键函数:
import neurokit2 as nk
# 完整的 ECG 处理流程
signals, info = nk.ecg_process(ecg_signal, sampling_rate=1000)
# 分析 ECG 数据(事件相关或区间相关)
analysis = nk.ecg_analyze(signals, sampling_rate=1000)
# 全面的 HRV 分析
hrv = nk.hrv(peaks, sampling_rate=1000) # 时域、频域、非线性域
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
从心脏信号计算全面的 HRV 指标。所有指标和特定领域分析请参阅 references/hrv.md。
支持的领域:
关键函数:
# 一次性获取所有 HRV 指标
hrv_indices = nk.hrv(peaks, sampling_rate=1000)
# 特定领域分析
hrv_time = nk.hrv_time(peaks)
hrv_freq = nk.hrv_frequency(peaks, sampling_rate=1000)
hrv_nonlinear = nk.hrv_nonlinear(peaks, sampling_rate=1000)
hrv_rsa = nk.hrv_rsa(peaks, rsp_signal, sampling_rate=1000)
分析脑电图信号的频率功率、复杂度和微状态模式。详细工作流程和 MNE 集成请参阅 references/eeg.md。
主要能力:
关键函数:
# 跨频段功率分析
power = nk.eeg_power(eeg_data, sampling_rate=250, channels=['Fz', 'Cz', 'Pz'])
# 微状态分析
microstates = nk.microstates_segment(eeg_data, n_microstates=4, method='kmod')
static = nk.microstates_static(microstates)
dynamic = nk.microstates_dynamic(microstates)
处理皮肤电导信号以评估自主神经系统。详细工作流程请参阅 references/eda.md。
主要工作流程:
关键函数:
# 完整的 EDA 处理
signals, info = nk.eda_process(eda_signal, sampling_rate=100)
# 分析 EDA 数据
analysis = nk.eda_analyze(signals, sampling_rate=100)
# 交感神经系统活动
sympathetic = nk.eda_sympathetic(signals, sampling_rate=100)
分析呼吸模式和呼吸变异性。详细工作流程请参阅 references/rsp.md。
主要能力:
关键函数:
# 完整的 RSP 处理
signals, info = nk.rsp_process(rsp_signal, sampling_rate=100)
# 呼吸频率变异性
rrv = nk.rsp_rrv(signals, sampling_rate=100)
# 单位时间呼吸容积
rvt = nk.rsp_rvt(signals, sampling_rate=100)
处理肌肉活动信号以进行激活检测和振幅分析。工作流程请参阅 references/emg.md。
关键函数:
# 完整的 EMG 处理
signals, info = nk.emg_process(emg_signal, sampling_rate=1000)
# 肌肉激活检测
activation = nk.emg_activation(signals, sampling_rate=1000, method='threshold')
分析眼动和眨眼模式。工作流程请参阅 references/eog.md。
关键函数:
# 完整的 EOG 处理
signals, info = nk.eog_process(eog_signal, sampling_rate=500)
# 提取眨眼特征
features = nk.eog_features(signals, sampling_rate=500)
对任何信号应用滤波、分解和变换操作。全面的实用工具请参阅 references/signal_processing.md。
关键操作:
关键函数:
# 滤波
filtered = nk.signal_filter(signal, sampling_rate=1000, lowcut=0.5, highcut=40)
# 峰值检测
peaks = nk.signal_findpeaks(signal)
# 功率谱密度
psd = nk.signal_psd(signal, sampling_rate=1000)
计算非线性动力学、分形维数和信息论度量。所有可用指标请参阅 references/complexity.md。
可用度量:
关键函数:
# 一次性获取多个复杂度指标
complexity_indices = nk.complexity(signal, sampling_rate=1000)
# 特定度量
apen = nk.entropy_approximate(signal)
dfa = nk.fractal_dfa(signal)
lyap = nk.complexity_lyapunov(signal, sampling_rate=1000)
围绕刺激事件创建时段并分析生理反应。工作流程请参阅 references/epochs_events.md。
主要能力:
关键函数:
# 在信号中查找事件
events = nk.events_find(trigger_signal, threshold=0.5)
# 围绕事件创建时段
epochs = nk.epochs_create(signals, events, sampling_rate=1000,
epochs_start=-0.5, epochs_end=2.0)
# 跨时段平均
grand_average = nk.epochs_average(epochs)
同时处理多种生理信号并输出统一结果。整合工作流程请参阅 references/bio_module.md。
关键函数:
# 一次性处理多个信号
bio_signals, bio_info = nk.bio_process(
ecg=ecg_signal,
rsp=rsp_signal,
eda=eda_signal,
emg=emg_signal,
sampling_rate=1000
)
# 分析所有处理后的信号
bio_analysis = nk.bio_analyze(bio_signals, sampling_rate=1000)
NeuroKit2 根据数据时长自动选择两种分析模式之一:
事件相关分析 (< 10 秒):
区间相关分析 (≥ 10 秒):
大多数 *_analyze() 函数会自动选择适当的模式。
uv pip install neurokit2
开发版本:
uv pip install https://github.com/neuropsychology/NeuroKit/zipball/dev
import neurokit2 as nk
# 加载示例数据
ecg = nk.ecg_simulate(duration=60, sampling_rate=1000)
# 处理 ECG
signals, info = nk.ecg_process(ecg, sampling_rate=1000)
# 分析 HRV
hrv = nk.hrv(info['ECG_R_Peaks'], sampling_rate=1000)
# 可视化
nk.ecg_plot(signals, info)
# 处理多个信号
bio_signals, bio_info = nk.bio_process(
ecg=ecg_signal,
rsp=rsp_signal,
eda=eda_signal,
sampling_rate=1000
)
# 分析所有信号
results = nk.bio_analyze(bio_signals, sampling_rate=1000)
# 查找事件
events = nk.events_find(trigger_channel, threshold=0.5)
# 创建时段
epochs = nk.epochs_create(processed_signals, events,
sampling_rate=1000,
epochs_start=-0.5, epochs_end=2.0)
# 每种信号类型的事件相关分析
ecg_epochs = nk.ecg_eventrelated(epochs)
eda_epochs = nk.eda_eventrelated(epochs)
此技能包含按信号类型和分析方法组织的全面参考文档:
使用 Read 工具按需加载特定参考文件以访问详细的函数文档和参数。
每周安装量
148
仓库
GitHub 星标数
23.4K
首次出现
2026年1月21日
安全审计
安装于
claude-code127
opencode124
cursor118
gemini-cli118
antigravity107
codex106
NeuroKit2 is a comprehensive Python toolkit for processing and analyzing physiological signals (biosignals). Use this skill to process cardiovascular, neural, autonomic, respiratory, and muscular signals for psychophysiology research, clinical applications, and human-computer interaction studies.
Apply this skill when working with:
Process electrocardiogram and photoplethysmography signals for cardiovascular analysis. See references/ecg_cardiac.md for detailed workflows.
Primary workflows:
Key functions:
import neurokit2 as nk
# Complete ECG processing pipeline
signals, info = nk.ecg_process(ecg_signal, sampling_rate=1000)
# Analyze ECG data (event-related or interval-related)
analysis = nk.ecg_analyze(signals, sampling_rate=1000)
# Comprehensive HRV analysis
hrv = nk.hrv(peaks, sampling_rate=1000) # Time, frequency, nonlinear domains
Compute comprehensive HRV metrics from cardiac signals. See references/hrv.md for all indices and domain-specific analysis.
Supported domains:
Key functions:
# All HRV indices at once
hrv_indices = nk.hrv(peaks, sampling_rate=1000)
# Domain-specific analysis
hrv_time = nk.hrv_time(peaks)
hrv_freq = nk.hrv_frequency(peaks, sampling_rate=1000)
hrv_nonlinear = nk.hrv_nonlinear(peaks, sampling_rate=1000)
hrv_rsa = nk.hrv_rsa(peaks, rsp_signal, sampling_rate=1000)
Analyze electroencephalography signals for frequency power, complexity, and microstate patterns. See references/eeg.md for detailed workflows and MNE integration.
Primary capabilities:
Key functions:
# Power analysis across frequency bands
power = nk.eeg_power(eeg_data, sampling_rate=250, channels=['Fz', 'Cz', 'Pz'])
# Microstate analysis
microstates = nk.microstates_segment(eeg_data, n_microstates=4, method='kmod')
static = nk.microstates_static(microstates)
dynamic = nk.microstates_dynamic(microstates)
Process skin conductance signals for autonomic nervous system assessment. See references/eda.md for detailed workflows.
Primary workflows:
Key functions:
# Complete EDA processing
signals, info = nk.eda_process(eda_signal, sampling_rate=100)
# Analyze EDA data
analysis = nk.eda_analyze(signals, sampling_rate=100)
# Sympathetic nervous system activity
sympathetic = nk.eda_sympathetic(signals, sampling_rate=100)
Analyze breathing patterns and respiratory variability. See references/rsp.md for detailed workflows.
Primary capabilities:
Key functions:
# Complete RSP processing
signals, info = nk.rsp_process(rsp_signal, sampling_rate=100)
# Respiratory rate variability
rrv = nk.rsp_rrv(signals, sampling_rate=100)
# Respiratory volume per time
rvt = nk.rsp_rvt(signals, sampling_rate=100)
Process muscle activity signals for activation detection and amplitude analysis. See references/emg.md for workflows.
Key functions:
# Complete EMG processing
signals, info = nk.emg_process(emg_signal, sampling_rate=1000)
# Muscle activation detection
activation = nk.emg_activation(signals, sampling_rate=1000, method='threshold')
Analyze eye movement and blink patterns. See references/eog.md for workflows.
Key functions:
# Complete EOG processing
signals, info = nk.eog_process(eog_signal, sampling_rate=500)
# Extract blink features
features = nk.eog_features(signals, sampling_rate=500)
Apply filtering, decomposition, and transformation operations to any signal. See references/signal_processing.md for comprehensive utilities.
Key operations:
Key functions:
# Filtering
filtered = nk.signal_filter(signal, sampling_rate=1000, lowcut=0.5, highcut=40)
# Peak detection
peaks = nk.signal_findpeaks(signal)
# Power spectral density
psd = nk.signal_psd(signal, sampling_rate=1000)
Compute nonlinear dynamics, fractal dimensions, and information-theoretic measures. See references/complexity.md for all available metrics.
Available measures:
Key functions:
# Multiple complexity metrics at once
complexity_indices = nk.complexity(signal, sampling_rate=1000)
# Specific measures
apen = nk.entropy_approximate(signal)
dfa = nk.fractal_dfa(signal)
lyap = nk.complexity_lyapunov(signal, sampling_rate=1000)
Create epochs around stimulus events and analyze physiological responses. See references/epochs_events.md for workflows.
Primary capabilities:
Key functions:
# Find events in signal
events = nk.events_find(trigger_signal, threshold=0.5)
# Create epochs around events
epochs = nk.epochs_create(signals, events, sampling_rate=1000,
epochs_start=-0.5, epochs_end=2.0)
# Average across epochs
grand_average = nk.epochs_average(epochs)
Process multiple physiological signals simultaneously with unified output. See references/bio_module.md for integration workflows.
Key functions:
# Process multiple signals at once
bio_signals, bio_info = nk.bio_process(
ecg=ecg_signal,
rsp=rsp_signal,
eda=eda_signal,
emg=emg_signal,
sampling_rate=1000
)
# Analyze all processed signals
bio_analysis = nk.bio_analyze(bio_signals, sampling_rate=1000)
NeuroKit2 automatically selects between two analysis modes based on data duration:
Event-related analysis (< 10 seconds):
Interval-related analysis (≥ 10 seconds):
Most *_analyze() functions automatically choose the appropriate mode.
uv pip install neurokit2
For development version:
uv pip install https://github.com/neuropsychology/NeuroKit/zipball/dev
import neurokit2 as nk
# Load example data
ecg = nk.ecg_simulate(duration=60, sampling_rate=1000)
# Process ECG
signals, info = nk.ecg_process(ecg, sampling_rate=1000)
# Analyze HRV
hrv = nk.hrv(info['ECG_R_Peaks'], sampling_rate=1000)
# Visualize
nk.ecg_plot(signals, info)
# Process multiple signals
bio_signals, bio_info = nk.bio_process(
ecg=ecg_signal,
rsp=rsp_signal,
eda=eda_signal,
sampling_rate=1000
)
# Analyze all signals
results = nk.bio_analyze(bio_signals, sampling_rate=1000)
# Find events
events = nk.events_find(trigger_channel, threshold=0.5)
# Create epochs
epochs = nk.epochs_create(processed_signals, events,
sampling_rate=1000,
epochs_start=-0.5, epochs_end=2.0)
# Event-related analysis for each signal type
ecg_epochs = nk.ecg_eventrelated(epochs)
eda_epochs = nk.eda_eventrelated(epochs)
This skill includes comprehensive reference documentation organized by signal type and analysis method:
Load specific reference files as needed using the Read tool to access detailed function documentation and parameters.
Weekly Installs
148
Repository
GitHub Stars
23.4K
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
claude-code127
opencode124
cursor118
gemini-cli118
antigravity107
codex106
智能OCR文字识别工具 - 支持100+语言,高精度提取图片/PDF/手写文本
1,000 周安装