Skip to main content

brainstem-nwb

Export experimental metadata from BrainSTEM to Neurodata Without Borders (NWB) files.

brainstem-nwb reads a BrainSTEM project export and writes one NWB file per session and subject, following NWB and DANDI conventions. Each file holds what BrainSTEM knows about the experiment:

  • session and subject
  • surgeries, viruses and drugs
  • devices, electrode groups and optogenetic sites
  • acquisitions, behaviors, manipulations and epochs

Alongside the files it writes a versioned conversion manifest and a validation report.

This release exports metadata only. Measured data (recordings, video, imaging) is not converted yet; the files describe it and point to it. Raw-data conversion with NeuroConv, starting with flat binary extracellular recordings, is designed and planned (see docs/design/phase4-raw-data.md).

Install

pip install brainstem-nwb
# the development version:
pip install git+https://github.com/brainstem-org/brainstem-nwb

Python 3.10 or newer. brainstem-nwb reads the BrainSTEM data model from the server at run time, so the first export needs network access to www.brainstem.org (or your --url); the model is then cached (see installation). Installing also installs pynwb, NWB Inspector and the BrainSTEM Python API tools.

Quick start

From a project export downloaded in BrainSTEM (Project → Download → JSON):

brainstem-nwb export --export-file brainstem-export.json.gz --output ./nwb/

Or fetch the export directly (needs read access to the project):

brainstem login                     # once, from the BrainSTEM API tools
brainstem-nwb export --project PROJECT_UUID --output ./nwb/
brainstem-nwb export --session SESSION_UUID --output ./nwb/   # one session's export

From Python:

from brainstem_nwb import export_project

result = export_project(project_id="PROJECT_UUID", output_dir="./nwb")
# or: export_project(export_file="brainstem-export.json.gz", output_dir="./nwb")
print(result.exit_code, result.manifest.summary)

The output directory then contains:

nwb/
  sub-<subject>/sub-<subject>_ses-<session>.nwb
  brainstem-nwb-manifest.json      what was exported, from which records, with every warning
  validation-report.json / .txt    pynwb, NWB Inspector (DANDI configuration) and BrainSTEM checks
  source/brainstem-export-….json.gz   the export the files were built from (when fetched)

Other commands:

  • Dry run: brainstem-nwb manifest --export-file … -o manifest.json writes only the manifest, so you can inspect what would be written.
  • One session: brainstem-nwb export … --session NAME.
  • Validate existing files: brainstem-nwb validate ./nwb/.

Some NWB fields are not in a BrainSTEM export, so they are never guessed: experimenter, lab and institution. Supply them in a configuration file:

# brainstem-nwb.toml  (use with --config brainstem-nwb.toml)
[nwbfile]
experimenter = ["Last, First"]
lab = "My Lab"
institution = "My University"

A fully reproducible example is in examples/synthetic-ephys.

Principles

  • Nothing is invented. No time series, electrode positions or other observations are generated from metadata. Fields BrainSTEM does not have stay empty, and the manifest records why. Each value is marked present, missing, unknown, not applicable or not exported.

  • Nothing is silently dropped. Every field of every exported record is accounted for:

    • mapped to NWB,
    • used to link records,
    • or kept in the manifest, with the reason.

    The mapping specification is generated from the code.

  • Traceable. Every file carries a provenance block naming its BrainSTEM records, the exporter and mapping versions, and the checksum of the source export. Its NWB identifier is derived from the content, so re-exporting unchanged records gives the same identifier.

  • Core NWB by default. With --extension brainstem, every BrainSTEM record is also stored losslessly in the file as ndx-brainstem tables. See extensions.

Documentation

License

The code is released under the MIT License.

The BrainSTEM data model and its JSON schemas are not part of this package and are not covered by that license: they are © BrainSTEM, all rights reserved (terms). brainstem-nwb reads them from the BrainSTEM server as an API client. --embed-schemas embeds the schemas of a file's records unchanged, as a BrainSTEM export does, with BrainSTEM's notice next to them.

Metadata

Release files for brainstem-nwb 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for brainstem-nwb 0.1.1
File Size Uploaded Provenance Actions
brainstem_nwb-0.1.1.tar.gz 206.7 kB With provenance Details for brainstem_nwb-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for brainstem-nwb 0.1.1
File Interpreter ABI Platform Actions
brainstem_nwb-0.1.1-py3-none-any.whl Python 3 none any Details for brainstem_nwb-0.1.1-py3-none-any.whl

Total release size: 330.0 kB

Release files / brainstem_nwb-0.1.1.tar.gz

Download URL brainstem_nwb-0.1.1.tar.gz
Size 206.7 kB
Tags Source
SHA-256 checksum
How to use checksums
5873e094675109356d0fc3b89974bb043353ae06ffe69488d1a174735e312dbe
BLAKE2b-256 checksum
How to use checksums
9961def3dc059ecdb01b1807ee169941c425bad6bd8a07a5f60241e3e4028378
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / brainstem_nwb-0.1.1-py3-none-any.whl

Download URL brainstem_nwb-0.1.1-py3-none-any.whl
Size 123.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
919c3a323e1c91fe4029346e79143677d212fe99d1f6fd64a1439ab05e1f1b79
BLAKE2b-256 checksum
How to use checksums
28f00a62c6d78da3116feec1fbb3a08922e27111173d3f19c794fcfa78fff5f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Security for brainstem-nwb 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for brainstem_nwb-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page