NWB Data Converter

Validated NWB conversion

by K-Dense-AI · MIT license · ★ 45,977 on GitHub · updated Sep 21

Validated NWB conversion cover

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…

---
name: nwb-conversion
description: 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 not perform spike sorting or claim tested support for arbitrary acquisition formats.
license: MIT
compatibility: Requires Python 3.12 with neuroconv[tiff] 0.10.2, PyNWB 4.2.0, NWB Inspector 0.7.2, roiextractors 0.10.0, tifffile 2026.9.20, zarr 2.18.7 and hdmf-zarr 0.11.3. Local HDF5 file access is required. Network is needed only for installation; no credentials.
metadata:
  version: "1.1"
  skill-author: K-Dense Inc.
  last-reviewed: "2026-10-01"
  upstream-neuroconv: "0.10.2"
  upstream-pynwb: "4.2.0"
  upstream-nwbinspector: "0.7.2"
---

# Validated NWB conversion

## Supported streams

Overview

The executable workflow covers two explicit input streams in one session:

Manual install (npx, ZIP)
Claude Codenpx skills add K-Dense-AI/scientific-agent-skills --skill nwb-conversion -g -a claude-code
Claude Code (degit)npx degit K-Dense-AI/scientific-agent-skills/skills/nwb-conversion#main ~/.claude/skills/nwb-conversion
Claude.ai / desktopZip the folder and upload it under Settings → Capabilities → Skills.
Codex, Cursor, other agentsPoint them at SKILL.md. The other files are plain text.

Connects with Agent Alley MCP · agentalley.io/mcp

Files included

  • SKILL.md7.4 KB
Read SKILL.md here
K-Dense-AI/main1 file shown
SKILL.md
Show the full text113 lines

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

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. Read the .validation.json alongside 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.
  6. 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 illustrative. The command requires a .nwb output and refuses to overwrite an existing NWB or validation report. Output contains source and converter checksums, package versions, full supplied metadata, units and clock-fit provenance in both a scratch record and the validation report. When adapting this command for large data, TIFF writes are iterative and equality checking loads one frame at a time; position CSV currently loads into memory. Round-trip checks also verify dtype, unit scaling, optical-channel links, subject metadata, position reference frame, common time origin and embedded provenance. Inspector findings requiring review appear in the CLI summary; exit zero alone does not mean the file is scientifically correct. An exception during writing or round-trip checks can leave an incomplete NWB without a report; retain the error and use a fresh output path after correcting the cause.

The real-library test converts eight non-square uint16 images with irregular frame timing plus four position samples, asserts exact pixel and timestamp round trips, and checks centimeter-to-meter conversion. A second integration test recovers a known 1000-ppm clock drift and 50-ms offset from three matched pulses. Duplicate timestamps, mismatched frame counts, absent clock evidence, nonlinear pulse disagreement and missing timezone are rejection cases. The mapping is TIFF (time,y,x) to NWB (time,x,y), explicitly checked against every transposed source page. NWB Inspector flags the short fixture with a critical orientation heuristic because width exceeds frame count; the report retains that finding and adds the exact frame/timestamp equality evidence. No transpose is performed merely to satisfy a longest-axis heuristic.

Primary references

1---
2name: nwb-conversion
3description: 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 not perform spike sorting or claim tested support for arbitrary acquisition formats.
4license: MIT
5compatibility: Requires Python 3.12 with neuroconv[tiff] 0.10.2, PyNWB 4.2.0, NWB Inspector 0.7.2, roiextractors 0.10.0, tifffile 2026.9.20, zarr 2.18.7 and hdmf-zarr 0.11.3. Local HDF5 file access is required. Network is needed only for installation; no credentials.
6metadata:
7 version: "1.1"
8 skill-author: K-Dense Inc.
9 last-reviewed: "2026-10-01"
10 upstream-neuroconv: "0.10.2"
11 upstream-pynwb: "4.2.0"
12 upstream-nwbinspector: "0.7.2"
13---
14 
15# Validated NWB conversion
16 
17## Supported streams
18 
19The executable workflow covers two explicit input streams in one session:
20 
21| Input | NWB representation | Tested constraints |
22| --- | --- | --- |
23| 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 |
24| Calibrated position CSV (`time_s,x,y`) | Behavior `Position` / `SpatialSeries` through PyNWB | Coordinates in m, cm or mm; converted to meters without temporal resampling |
25 
26Other acquisition readers require their own format-specific tests. In particular, this helper does
27not decode SpikeGLX, Open Ephys, multichannel TIFF, volumetric TIFF, compressed video, or pixel-to-world
28calibration. Do not rename an arbitrary numeric table to a supported stream.
29 
30## Install the tested environment
31 
32```bash
33uv venv --python 3.12 nwb-env
34uv pip install --python nwb-env/bin/python 'neuroconv[tiff]==0.10.2' pynwb==4.2.0 \
35 nwbinspector==0.7.2 roiextractors==0.10.0 tifffile==2026.9.20 \
36 zarr==2.18.7 hdmf-zarr==0.11.3
37```
38 
39Keep both Zarr pins even for an HDF5-only conversion: NeuroConv 0.10.2 imports its backend
40configuration modules at startup, and the tested unconstrained Zarr 3.4.0 installation failed on
41`zarr.codec_registry`. The pinned environment ran the real conversion, PyNWB validation and
42Inspector successfully on macOS ARM64. The dependency resolver supplies NumPy and HDF5 support.
43These are compatibility pins, not claims that Zarr 2 and hdmf-zarr 0.11.3 are the latest releases.
44Current interface checks and the tested dependency exception are recorded in
45[references/upstream-review.md](references/upstream-review.md).
46 
47## Workflow
48 
491. Inventory the actual inputs and acquisition metadata. Identify image plane/channel, optical
50 settings, subject/session identifiers, timezone, behavior coordinate system, units and the
51 timestamp clock for every stream. Preserve originals. Do not replace missing metadata with
52 plausible defaults from a sample config.
532. Copy [assets/session-template.json](assets/session-template.json) beside the raw data and
54 replace the explicitly synthetic values. Paths resolve from that JSON file. Read
55 [references/input-contract.md](references/input-contract.md) for the exact CSV and metadata
56 contract and the pulse-pair variant. TIFF pixels are retained as acquired; a raw arbitrary-unit
57 intensity does not become a photon count merely by changing its unit label.
583. Establish the common timebase from acquisition evidence. Frame timestamps must already be
59 reference-clock seconds since the timezone-aware session start. For position, provide either
60 a documented shared clock or matched synchronization pulses. The helper fits one affine clock
61 transform, checks its residual against a specified tolerance, and refuses extrapolation beyond
62 the pulse range. It never estimates synchronization from coincident-looking neural/behavioral
63 signals. Clock resets or nonlinear drift require an explicitly validated piecewise mapping.
644. Execute the converter. Inputs must have finite, strictly increasing timestamps and matching
65 image/timestamp counts. Explicitly declare one channel and one plane; known TIFF channel/plane
66 metadata must agree. Grayscale pages alone cannot exclude undocumented interleaving.
67 The acquisition samples stay intact; only coordinate units and, when
68 evidenced, behavior timestamps are transformed.
695. Read the `.validation.json` alongside the NWB file. Schema compliance, Inspector findings and
70 data equality answer different questions. The script exits with an error for schema failures
71 and flags critical Inspector findings for review in the report. Review all findings in context;
72 successful validation cannot establish that anatomical labels, pulse pairing or calibration
73 supplied by the user are correct.
746. Deliver the NWB, validation JSON, original conversion config and an explanation of remaining
75 metadata gaps or Inspector findings. No upload or archive submission is part of this workflow.
76 
77## Execute
78 
79Run the following from the skill directory, with paths to the actual analysis files:
80 
81```bash
82nwb-env/bin/python scripts/convert_session.py /path/to/session.json --output /path/to/session.nwb
83```
84 
85`nwb-env` must point to the environment created above; the absolute example input paths are
86illustrative. The command requires a `.nwb` output and refuses to overwrite an existing NWB or
87validation report. Output contains source and converter checksums,
88package versions, full supplied metadata, units and clock-fit provenance in both a scratch record
89and the validation report. When adapting this command for large data, TIFF writes are iterative
90and equality checking loads one frame at a time; position CSV currently loads into memory.
91Round-trip checks also verify dtype, unit scaling, optical-channel links, subject metadata,
92position reference frame, common time origin and embedded provenance. Inspector findings requiring
93review appear in the CLI summary; exit zero alone does not mean the file is scientifically correct.
94An exception during writing or round-trip checks can leave an incomplete NWB without a report;
95retain the error and use a fresh output path after correcting the cause.
96 
97The real-library test converts eight non-square uint16 images with irregular frame timing plus
98four position samples, asserts exact pixel and timestamp round trips, and checks centimeter-to-meter
99conversion. A second integration test recovers a known 1000-ppm clock drift and 50-ms offset from
100three matched pulses. Duplicate timestamps, mismatched frame counts, absent clock evidence,
101nonlinear pulse disagreement and missing timezone are rejection cases. The mapping is
102TIFF `(time,y,x)` to NWB `(time,x,y)`, explicitly checked against every transposed source page. NWB Inspector flags the short fixture
103with a critical orientation heuristic because width exceeds frame count; the report retains that
104finding and adds the exact frame/timestamp equality evidence. No transpose is performed merely to
105satisfy a longest-axis heuristic.
106 
107## Primary references
108 
109- [NeuroConv TIFF conversion](https://neuroconv.readthedocs.io/en/stable/conversion_examples_gallery/imaging/tiff.html)
110- [NeuroConv temporal alignment](https://neuroconv.readthedocs.io/en/stable/user_guide/temporal_alignment.html)
111- [PyNWB](https://github.com/NeurodataWithoutBorders/pynwb)
112- [NWB Inspector and its relation to schema validation](https://github.com/NeurodataWithoutBorders/nwbinspector)
113 
View all files on GitHub →

Details

Updated
Sep 21, 2026
License
MIT
Stars on the repo
★ 45,977
Checked
Source
K-Dense-AI/scientific-agent-skills ↗
Creator
K-Dense-AI · 168 listings
View creator

Similar skills

See all →

More from K-Dense-AI

SkillAdaptyv Bio Foundry APIK-Dense-AI/scientific-agent-skills · by K-Dense-AIHow to use the Adaptyv Bio Foundry API and Python SDK for protein experiment design, submission, and results retrieval. Use this skill whenever the user mentions Adaptyv, Foundry API, protein binding assays, protein screening experiments, BLI/SPR assays, thermostability assays, or wants to submit protein sequences for experimental characterization. Also trigger when code imports `adaptyv`, `adaptyv_sdk`, or `FoundryClient`, or references `foundry-api-public.adaptyvbio.com`.★ 46k GitHub starsSkillTime Series MLK-Dense-AI/scientific-agent-skills · by K-Dense-AIThis skill should be used for time series machine learning tasks including classification, regression, clustering, forecasting, anomaly detection, segmentation, and similarity search. Use when working with temporal data, sequential patterns, or time-indexed observations requiring specialized algorithms beyond standard ML approaches. Particularly suited for univariate and multivariate time series analysis with scikit-learn compatible APIs.★ 46k GitHub starsSkillAnalytical Method ValidatorK-Dense-AI/scientific-agent-skills · by K-Dense-AIPlan, execute, and document validation, verification, and transfer of analytical procedures under the governing framework - ICH Q2(R2) and Q14, USP <1220>/<1225>/<1226>, ICH M10 bioanalytical, CLSI EP, or ISO/IEC 17025. Use for HPLC, LC-MS/MS, GC, CE, ICP-MS, dissolution, qNMR, qPCR, NIR, and ligand binding or cell-based assays whenever the question is whether a procedure is fit for its intended purpose. Triggers include "method validation", "analytical method validation", "AMV", "validation protocol", "acceptance criteria", "linearity", "reportable range", "accuracy and precision", "repeatability", "intermediate precision", "recovery", "LOD", "LOQ", "detection limit", "quantitation limit", "specificity", "robustness", "method transfer", "method comparison", "Deming", "Passing-Bablok", "Bland-Altman", "equivalence testing", "OOS investigation", "ICH Q2", "Q2(R2)", "Q14", "USP 1225", "ICH M10", "incurred sample reanalysis", "ISR", "CLSI EP", and any request to show that an assay works.★ 46k GitHub starsSkillSingle-Cell Data StructureK-Dense-AI/scientific-agent-skills · by K-Dense-AIData structure for annotated matrices in single-cell analysis. Use when working with .h5ad files or integrating with the scverse ecosystem. This is the data format skill—for analysis workflows use scanpy; for probabilistic models use scvi-tools; for population-scale queries use cellxgene-census.★ 46k GitHub starsSkillAutonomous Artifact OptimizerK-Dense-AI/scientific-agent-skills · by K-Dense-AIAutonomously improve a real artifact (code, training recipe, agent harness, data pipeline, prompt) against an objective and an evaluator, using Hypothesis Tree Refinement (HTR) from the Arbor paper. Use this whenever someone wants to iteratively optimize something over many experiments without overfitting — e.g. "get my model's eval score up", "improve this agent/harness", "tune this pipeline", "beat the baseline on this benchmark", "run a search over approaches and keep the best", "do an MLE-bench / Kaggle-style optimization", or any long-horizon "make this artifact better and don't just memorize the dev set" task. Trigger it even when the user doesn't say "Arbor" or "hypothesis tree" but describes repeated experiment-and-evaluate loops, branching exploration of competing ideas, or worries about a dev/test gap. Runs Claude itself as the coordinator with subagent executors in isolated git worktrees; for the standalone `arbor` CLI tool see references/arbor-upstream.md.★ 46k GitHub starsSkillGene Regulatory Network InferrerK-Dense-AI/scientific-agent-skills · by K-Dense-AIInfer gene regulatory networks (GRNs) from gene expression data using scalable algorithms (GRNBoost2, GENIE3). Use when analyzing transcriptomics data (bulk RNA-seq, single-cell RNA-seq) to identify transcription factor-target gene relationships and regulatory interactions. Supports distributed computation for large-scale datasets.★ 46k GitHub stars