[ PROMPT_NODE_26894 ]
Neuropixels Analysis Motion Correction
[ SKILL_DOCUMENTATION ]
# 运动/漂移校正参考
急性探针植入过程中的机械漂移是 Neuropixels 记录面临的主要挑战。本指南涵盖了运动伪影的检测、估计和校正。
## 为什么运动校正很重要
- Neuropixels 探针在记录过程中可能会漂移 10-100+ μm
- 未经校正的漂移会导致:
- 神经元单位在记录中途出现/消失
- 波形振幅变化
- 错误的脉冲-单位分配
- 单位产出减少
## 检测:排序前检查
**在运行脉冲排序前,务必可视化漂移!**
python
import spikeinterface.full as si
from spikeinterface.sortingcomponents.peak_detection import detect_peaks
from spikeinterface.sortingcomponents.peak_localization import localize_peaks
# 先进行预处理(不要进行白化 - 会影响峰值定位)
rec = si.highpass_filter(recording, freq_min=400.)
rec = si.common_reference(rec, operator='median', reference='global')
# 检测峰值
noise_levels = si.get_noise_levels(rec, return_in_uV=False)
peaks = detect_peaks(
rec,
method='locally_exclusive',
noise_levels=noise_levels,
detect_threshold=5,
radius_um=50.,
n_jobs=8,
chunk_duration='1s',
progress_bar=True
)
# 定位峰值
peak_locations = localize_peaks(
rec, peaks,
method='center_of_mass',
n_jobs=8,
chunk_duration='1s'
)
# 可视化漂移
si.plot_drift_raster_map(
peaks=peaks,
peak_locations=peak_locations,
recording=rec,
clim=(-200, 0) # 调整颜色限制
)
### 解读漂移图
| 模式 | 解读 | 操作 |
|---------|---------------|--------|
| 水平带,稳定 | 无明显漂移 | 跳过校正 |
| 对角带(缓慢) | 逐渐沉降漂移 | 使用运动校正 |
| 快速跳跃 | 脑搏动或运动 | 使用非刚性校正 |
| 混沌模式 | 严重不稳定 | 考虑丢弃该片段 |
## 运动校正方法
### 快速校正(推荐入门)
python
# 使用预设的简单一行代码
rec_corrected = si.correct_motion(
recording=rec,
preset='nonrigid_fast_and_accurate'
)
### 可用预设
| 预设 | 速度 | 准确度 | 适用场景 |
|--------|-------|----------|----------|
| `rigid_fast` | 快 | 低 | 快速检查,小漂移 |
| `kilosort_like` | 中 | 好 | Kilosort 兼容结果 |
| `nonrigid_accurate` | 慢 | 高 | 出版级质量 |
| `nonrigid_fast_and_accurate` | 中 | 高 | **推荐默认值** |
| `dre