Skip to content

About

brainstem nwb extension

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

Repository files navigation

ndx-brainstem

An NWB extension that stores BrainSTEM experimental metadata inside an NWB file: the BrainSTEM records the file was made from, with every field, and the links between them.

Files are written by brainstem-nwb (brainstem-nwb export --extension brainstem). Core NWB fields (Subject, Devices, electrode groups, epochs and the text fields) describe the experiment for every NWB reader. This extension adds the structured detail behind them, so nothing BrainSTEM records is lost.

Status: pre-release (0.2.0). The schema may change before 1.0.

Installation

pip install ndx-brainstem

What a file contains

/general/brainstem (BrainstemMetadata, a LabMetaData) holds:

  • Provenance attributes: export format version and scope, export time, the checksum of the source export (source_sha256) and of the file's content (content_sha256), the BrainSTEM project, session, subject and unit ids, and the exporter and mapping versions.
  • One BrainstemTable per kind of record, for example procedures, materials, interfaces, acquisitions, manipulations, behaviors, specimen_sets, specimens, logs, log_entries, regions, catalog, lab_resources and people. Each row is one BrainSTEM record. The spec fixes no table names; the writer's current list is in brainstem-nwb's extensions documentation.
  • schemas (BrainstemSchemaTable): every BrainSTEM JSON schema the tables name, with its stable URL (published versions never change) and, when embedded, the schema itself.

BrainstemTable columns

Column Type Contents
brainstem_id, brainstem_model required text The record's BrainSTEM id and model label (e.g. modules.procedure)
one per BrainSTEM field text Strings as stored. Other values (numbers, booleans, JSON objects such as type_json) are JSON text. An empty string means no value
one per link field ragged DynamicTableRegion Rows of another BrainstemTable, or of /intervals/epochs
details_schema, coordinates_schema text <Family>/<Type>@<version> of the record's typed details or coordinates, e.g. Procedure/VirusInjection@3.0.0
unresolved_links text JSON {field: [ids]} of links to records not in the file
writer-defined text or DynamicTableRegion Columns the writer adds beyond the fields, such as nwb_device (the NWB device a row became), nwb_epochs (rows of /intervals/epochs), log and catalog_entry (links to the parent log or catalog entry). A field whose name a DynamicTable reserves is written as record_<field>; a *_time field also gets an ISO 8601 copy named <field>_iso

The table attribute brainstem_models lists the model labels of the table's rows.

Reading

from pynwb import NWBHDF5IO

with NWBHDF5IO("sub-X_ses-Y.nwb", "r") as io:
    nwbfile = io.read()
    brainstem = nwbfile.lab_meta_data["brainstem"]
    procedures = brainstem.brainstem_tables["procedures"].to_dataframe()

NWB stores the extension's schema in every file, so pynwb (and MatNWB) can read these files without installing this package.

Installation (development)

pip install -e . --group dev   # pip 25.1 or newer; or: pip install -e . && pip install pytest
python src/spec/create_extension_spec.py   # regenerate spec/*.yaml after changing the spec
pytest

This extension was created with ndx-template.

About

brainstem nwb extension

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages