NWB (Neurodata Without Borders) file reading and writing for ezmsg
Project description
ezmsg-nwb
NWB (Neurodata Without Borders) file reading and writing for the ezmsg framework.
Overview
ezmsg-nwb provides streaming NWB file I/O as ezmsg Units.
Key features:
- NWB Reader - Stream data from NWB files (local or remote) as AxisArray messages
- NWB Writer - Write incoming AxisArray streams to NWB files with automatic container management
- Flexible clock handling - Support for system, monotonic, and unknown reference clocks
- Pipeline settings logging - Automatically record every component's settings into a
pipeline_settingsintervals table inside the NWB file
Installation
Install from PyPI:
pip install ezmsg-nwb
Or install the latest development version:
pip install git+https://github.com/ezmsg-org/ezmsg-nwb@main
Dependencies
ezmsgezmsg-baseprocnumpypynwbh5pyneuroconvremfilepyyaml
Usage
See the examples folder for usage examples.
import ezmsg.core as ez
from ezmsg.nwb import NWBIteratorUnit, NWBSink
For general ezmsg tutorials and guides, visit ezmsg.org.
Pipeline settings table
When NWBSink is used inside an ez.run pipeline (with ezmsg>=3.9.0), it
opens a GraphContext against the running graph server, snapshots the
settings of every component in its session, and subscribes to subsequent
settings change events. Each snapshot is flattened into dotted column names
(e.g. MY.UNIT.MyUnitSettings.endpoint.host) and appended as a row to a
pipeline_settings TimeIntervals table inside the NWB file, alongside an
updated_component column identifying which component triggered the
transition. Reading back is straightforward:
from pynwb import NWBHDF5IO
with NWBHDF5IO(path, "r") as io:
nwbfile = io.read()
df = nwbfile.intervals["pipeline_settings"].to_dataframe()
Notes:
- Settings logging is best-effort. If the writer cannot connect to the graph
server (e.g. when running the consumer outside of
ez.run), it logs a warning and continues writing data without the table. - Settings values are sanitized for NWB storage: primitives, NumPy scalars,
enums, paths, and fixed-shape sequences/arrays are stored natively;
mappings and irregular structures are JSON-encoded;
Nonebecomes the string"None". - If a settings update changes a column's shape (scalar↔array or rank
change), the writer rotates into a new file segment (
<name>_01.nwb,<name>_02.nwb, …) so each segment's table stays internally consistent.
Development
We use uv for development.
- Install
uvif not already installed. - Fork this repository and clone your fork locally.
- Open a terminal and
cdto the cloned folder. - Run
uv syncto create a.venvand install dependencies. - (Optional) Install pre-commit hooks:
uv run pre-commit install - After making changes, run the test suite:
uv run pytest tests
License
MIT License - see LICENSE for details.
Acknowledgements
This project is supported by the Wyss Center for Bio and Neuroengineering and by Blackrock Neurotech.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ezmsg_nwb-1.3.1.tar.gz.
File metadata
- Download URL: ezmsg_nwb-1.3.1.tar.gz
- Upload date:
- Size: 66.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7971d0f9b329af462601726d130a69a87498e303db584461831cda9629255a9a
|
|
| MD5 |
8484f55e50e1942d4968f1c2ad009df1
|
|
| BLAKE2b-256 |
672820ceb9f280af1f7f387dd21cc0555c5ea71dbb0f4646d1db16fbd0670840
|
File details
Details for the file ezmsg_nwb-1.3.1-py3-none-any.whl.
File metadata
- Download URL: ezmsg_nwb-1.3.1-py3-none-any.whl
- Upload date:
- Size: 40.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4227c3c77710f83a141f32c0bc9526c14b2956d9deaa7e524ebd5731264d104f
|
|
| MD5 |
f481c6d52be3100f788290becdb18ba3
|
|
| BLAKE2b-256 |
3ab714e13091ebec198d796a7774b255b53c345a9d55c89208678141043662d9
|