科研 Skill

远程NWB文件流式读取

reading-remote-nwb

Explores and reads NWB files on the DANDI Archive without downloading them, using range requests for time series and tables. Use when inspecting a large NWB file remotely.

发布者 Codar安全审核通过v0.1.0更新于 2026-11-18

SKILL.md

Reading NWB files remotely

NWB files are HDF5 underneath and often several gigabytes. Reading only the bytes a question needs makes looking inside a 10 GB file cost about a megabyte.

Prerequisites

list_files, nwb_summary, nwb_tree, nwb_read and nwb_table below are tools from the upstream "brainhound" agent harness this skill was written for. They are not bundled with this skill and will not exist as callable tools in a generic Codex/Claude Code environment. If they are unavailable, use the "When you need full analysis in Python" section below, which only needs pip install pynwb remfile h5py dandi and works anywhere with network access to the DANDI Archive.

Steps (when brainhound-style tools are available)

  1. Find the file. list_files with a DANDI id gives paths. Refer to a file as dandi:<dandiset>/<path>, for example dandi:000003/sub-YutaMouse20/sub-YutaMouse20_ses-YutaMouse20-140327_behavior+ecephys.nwb.
  2. Get the overview with nwb_summary: session, subject, devices, electrodes, units, and every acquisition, stimulus, interval and processing entry with its NWB type and shape.
  3. Drill down with nwb_tree, giving a path like /processing/ecephys and a depth. It shows each dataset's shape, dtype and its unit, rate and conversion attributes.
  4. Read numbers with nwb_read: give the dataset path, plus start and count per dimension. Without them it reads a small corner. The stats line covers the whole slice, even when only part of it is printed.
  5. Read tables with nwb_table: /units, /intervals/trials, /general/extracellular_ephys/electrodes, or any DynamicTable. Pick columns, and page with start and count.

NWB conventions you need

  • Units. A TimeSeries stores raw numbers. The value in its unit is data * conversion + offset. For example, int16 data with conversion=1.95e-7 and unit=volts means each step is 0.195 µV.
  • Time. A TimeSeries has either a timestamps dataset (one time per sample, in seconds) or starting_time with a rate attribute (Hz). Sample i is at starting_time + i / rate.
  • Axes. The first dimension of data is time. For extracellular recordings the second is channels, in the order of the electrodes region (data/../electrodes, a list of row numbers into the electrodes table).
  • Ragged columns. A column x with a sibling x_index is ragged: row i holds x[x_index[i-1]:x_index[i]] (from 0 for the first row). /units/spike_times works this way. nwb_table follows this for you, and summarizes long cells as a count plus the first values.
  • References. Columns like electrodes/group point at other objects. brainhound shows them as paths, such as </general/extracellular_ephys/shank0>.
  • Containers. Types like LFP, Position and BehavioralEvents hold one or more series inside them. Look one level down for the data.

Sizing reads

  • Ask for what the question needs: a few seconds of one channel, not the whole recording. At 30 kHz, one second is 30000 rows.
  • One brainhound call reads at most 128 MB of raw data. For more, read in pieces or use Python (below).
  • Reading a narrow column across many rows of a big uncompressed array touches most of the file between them. Prefer contiguous blocks of rows.

When you need full analysis in Python (no special tools required)

This is the general-purpose path when the brainhound tools above are not available, and the recommended path for any heavy analysis in any environment:

# pip install pynwb remfile h5py dandi
import h5py, remfile, pynwb
from dandi.dandiapi import DandiAPIClient

with DandiAPIClient() as client:
    asset = client.get_dandiset("000003").get_asset_by_path("sub-YutaMouse20/sub-YutaMouse20_ses-YutaMouse20-140327_behavior+ecephys.nwb")
    url = asset.get_content_url(follow_redirects=1, strip_query=True)

io = pynwb.NWBHDF5IO(file=h5py.File(remfile.File(url), "r"), load_namespaces=True)
nwb = io.read()
spikes = nwb.units["spike_times"][0]  # one unit's spike times, in seconds

Limitations

  • Remote range-reads depend on the DANDI Archive's S3-backed URLs supporting HTTP range requests; some mirrors or re-hosted copies may not.
  • Zarr-backed NWB assets need a different reader (zarr/pynwb with the Zarr backend) than the HDF5 path shown here.

Always give the dandiset's license and citation (from DANDI's metadata, or dataset_info when using brainhound) with any result built on its data.

示例提示词

我想不下载整个文件,直接从DANDI上按需读取这份NWB数据的spike时间。

所属插件

神经科学面向神经科学研究:EEG/MEG、fMRI、BIDS、spike sorting、连接组、脑机接口解码评估、神经刺激安全与公开神经数据检索。

安装该插件会一并获得同领域的 45 个 Skill / MCP。

同插件的其他科研 Skill

常见问题

远程NWB文件流式读取能做什么?

Explores and reads NWB files on the DANDI Archive without downloading them, using range requests for time series and tables. Use when inspecting a large NWB file remotely。

如何安装远程NWB文件流式读取?

在科搭 Codar 左侧点击「插件」,在「组件」页签搜索「远程NWB文件流式读取」并安装;在 Claude Code 或 Codex 中可以发送本页的安装提示词,或下载 Skill 包后解压到 ~/.claude/skills 或 ~/.codex/skills。

远程NWB文件流式读取需要哪些权限?

该科研 Skill没有声明额外权限;执行具体操作时仍由 Agent 按自身规则请求确认。

远程NWB文件流式读取经过官方审核吗?

是。SpeedSkills 收录的每个版本都会记录内容摘要与权限声明,当前版本已通过安全审核。