[ PROMPT_NODE_26896 ]
Neuropixels Analysis 预处理
[ SKILL_DOCUMENTATION ]
# Neuropixels 预处理参考
针对 Neuropixels 神经记录的全面预处理技术。
## 标准预处理工作流
python
import spikeinterface.full as si
# 加载原始数据
recording = si.read_spikeglx('/path/to/data', stream_id='imec0.ap')
# 1. 相位偏移校正(针对 Neuropixels 1.0)
rec = si.phase_shift(recording)
# 2. 用于脉冲检测的带通滤波
rec = si.bandpass_filter(rec, freq_min=300, freq_max=6000)
# 3. 公共中值参考(去除相关噪声)
rec = si.common_reference(rec, reference='global', operator='median')
# 4. 移除坏通道(可选)
rec = si.remove_bad_channels(rec, bad_channel_ids=bad_channels)
## 滤波选项
### 带通滤波
python
# 标准 AP 带
rec = si.bandpass_filter(recording, freq_min=300, freq_max=6000)
# 更宽的频带(保留更多波形形状)
rec = si.bandpass_filter(recording, freq_min=150, freq_max=7500)
# 滤波参数
rec = si.bandpass_filter(
recording,
freq_min=300,
freq_max=6000,
filter_order=5,
ftype='butter', # 'butter', 'bessel', 或 'cheby1'
margin_ms=5.0 # 防止边缘伪影
)
### 仅高通滤波
python
rec = si.highpass_filter(recording, freq_min=300)
### 陷波滤波(去除工频噪声)
python
# 去除 60Hz 及其谐波
rec = si.notch_filter(recording, freq=60, q=30)
rec = si.notch_filter(rec, freq=120, q=30)
rec = si.notch_filter(rec, freq=180, q=30)
## 参考方案
### 公共中值参考(推荐)
python
# 全局中值参考
rec = si.common_reference(recording, reference='global', operator='median')
# 逐柄参考(多柄探针)
rec = si.common_reference(recording, reference='global', operator='median',
groups=recording.get_channel_groups())
### 公共平均参考
python
rec = si.common_reference(recording, reference='global', operator='average')
### 局部参考
python
# 按局部通道组进行参考
rec = si.common_reference(recording, reference='local', local_radius=(30, 100))
## 坏通道检测与移除
### 自动检测
python
# 检测坏通道
bad_channel_ids, channel_labels = si.detect_bad_channels(
recording,
method='coherence+psd',
dead_channel_threshold=-0.5,
noisy_channel_threshold=1.0,
outside_channel_threshold=-0.3,
n_neighbors=11
)
print(f"坏通道: {bad_channel_ids}")
print(f"标签: {dict(zip(b