nwb-conversion
它能做什么
这个工具可以把神经科学实验数据转换成一种标准格式,叫做 NWB。它能确保时间和测量等重要信息被正确保存,特别适用于显微镜图像和运动数据。
适用场景
- ✓当你有显微镜图像(TIFF)和行为位置数据(CSV)需要转换时。
- ✓当你需要确保图像和运动数据的时间同步时。
- ✓当你想整理和验证实验数据,以便分享或后续分析时。
技能链接
https://github.com/K-Dense-AI/scientific-agent-skills/blob/main/skills/nwb-conversion/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请把我的 TIFF 图像和 CSV 位置数据转换为 NWB 格式。”
每周 5 个新技能,1 分钟读完。
工作原理
工具会使用 NeuroConv 和 PyNWB 这两个程序,读取你的图像和行为文件。它会对齐两类数据的时间,并在保存为 NWB 格式前检查一切是否正确。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Validated NWB conversion
Supported streams
The executable workflow covers two explicit input streams in one session:
| Input | NWB representation | Tested constraints |
|---|---|---|
| Two-photon grayscale multi-page TIFF + frame timestamps CSV | Acquisition TwoPhotonSeries named Imaging through NeuroConv |
One channel, one plane, one 2D image per page, fixed shape and dtype |
Calibrated position CSV (time_s,x,y) |
Behavior Position / SpatialSeries through PyNWB |
Coordinates in m, cm or mm; converted to meters without temporal resampling |
Other acquisition readers require their own format-specific tests. In particular, this helper does not decode SpikeGLX, Open Ephys, multichannel TIFF, volumetric TIFF, compressed video, or pixel-to-world calibration. Do not rename an arbitrary numeric table to a supported stream.
Install the tested environment
uv venv --python 3.12 nwb-env
uv pip install --python nwb-env/bin/python 'neuroconv[tiff]==0.10.2' pynwb==4.2.0 \
nwbinspector==0.7.2 roiextractors==0.10.0 tifffile==2026.9.20 \
zarr==2.18.7 hdmf-zarr==0.11.3
Keep both Zarr pins even for an HDF5-only conversion: NeuroConv 0.10.2 imports its backend
configuration modules at startup, and the tested unconstrained Zarr 3.4.0 installation failed on
zarr.codec_registry. The pinned environment ran the real conversion, PyNWB validation and
Inspector successfully on macOS ARM64. The dependency resolver supplies NumPy and HDF5 support.
These are compatibility pins, not claims that Zarr 2 and hdmf-zarr 0.11.3 are the latest releases.
Current interface checks and the tested dependency exception are recorded in
references/upstream-review.md.
Workflow
- Inventory the actual inputs and acquisition metadata. Identify image plane/channel, optical settings, subject/session identifiers, timezone, behavior coordinate system, units and the timestamp clock for every stream. Preserve originals. Do not replace missing metadata with plausible defaults from a sample config.
- Copy assets/session-template.json beside the raw data and replace the explicitly synthetic values. Paths resolve from that JSON file. Read references/input-contract.md for the exact CSV and metadata contract and the pulse-pair variant. TIFF pixels are retained as acquired; a raw arbitrary-unit intensity does not become a photon count merely by changing its unit label.
- Establish the common timebase from acquisition evidence. Frame timestamps must already be reference-clock seconds since the timezone-aware session start. For position, provide either a documented shared clock or matched synchronization pulses. The helper fits one affine clock transform, checks its residual against a specified tolerance, and refuses extrapolation beyond the pulse range. It never estimates synchronization from coincident-looking neural/behavioral signals. Clock resets or nonlinear drift require an explicitly validated piecewise mapping.
- Execute the converter. Inputs must have finite, strictly increasing timestamps and matching image/timestamp counts. Explicitly declare one channel and one plane; known TIFF channel/plane metadata must agree. Grayscale pages alone cannot exclude undocumented interleaving. The acquisition samples stay intact; only coordinate units and, when evidenced, behavior timestamps are transformed.
- Read the
.validation.jsonalongside the NWB file. Schema compliance, Inspector findings and data equality answer different questions. The script exits with an error for schema failures and flags critical Inspector findings for review in the report. Review all findings in context; successful validation cannot establish that anatomical labels, pulse pairing or calibration supplied by the user are correct. - Deliver the NWB, validation JSON, original conversion config and an explanation of remaining metadata gaps or Inspector findings. No upload or archive submission is part of this workflow.
Execute
Run the following from the skill directory, with paths to the actual analysis files:
nwb-env/bin/python scripts/convert_session.py /path/to/session.json --output /path/to/session.nwb
nwb-env must point to the environment created above; the absolute example input paths are
…
常见问题
它支持哪些数据类型?
它支持单页 TIFF 格式的灰度双光子显微镜图像及其帧时间戳,以及带时间戳的 CSV 行为位置数据。
它能转换其他文件格式吗?
不能,这个工具只针对上述 TIFF 和 CSV 格式。它不支持 SpikeGLX、Open Ephys 或视频等格式。
如果时间对不上怎么办?
工具会尝试对齐时间,并检查误差是否在可接受范围内。如果存在严重问题或信息缺失,它可能会失败,或提示你需要手动修正。
详情
作者的原始描述
Converts neuroscience acquisition data to Neurodata Without Borders files with NeuroConv and PyNWB, preserves metadata and timebases, checks evidence-based clock alignment, and produces schema validation, NWB Inspector findings and round-trip checks. Use for NWB conversion and synchronization of planar single-channel two-photon TIFF imaging plus timestamped behavioral position CSV; this skill does
热度
- GitHub 星标
- 51k
- 排名
- #3508
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …