Neurodata without Borders — directly on the browser.
webnwb
is a library for reading and writing Neurodata without Borders (NWB) files on the web.
- 🔬 Read data from NWB files based on the included specification.
- ⚡ Lazy-load large files (e.g. from the NIH Brain Initiative’s Distributed Archives for Neurophysiology Data Integration (DANDI)).
- 📦 Create NWB files from scratch.
- ⚒️ Use helper functions like
addAcquisition
,getAcquisition
, andcreateAcquisition
to quickly write data to new and existing NWB files.
Note: While tools like neurosift are extraordinarily useful for rapid visualization of NWB files, WebNWB is intended to provide a robust interface for modifying NWB files—a task that requires significantly more preprocessing to accomplish strictly in accordance with the NWB Schema. If you prefer I/O speed, you may wish to look at hdf5-io, h5wasm, or other minimal HDF5 readers.
Visit nwb.brainsatplay.com for documentation and examples.
The essential features of the WebNWB API are aggregated in the api.ts file, which configures hdf5-io to process the underlying HDF5 file in a way that conforms with the NWB Schema.
Anyone who would like to contribute to the acceptance of webnwb
as an official NWB API is welcome to message Garrett Flynn to coordinate work on the following areas (or anything else you think will be useful):
- Validate writing a dataset using best practices and the schema
- Allow writing a dataset in place using the File Access API (Chrome)
- Support Zarr as a backend file format
- hdf5-io: Load HDF5 files as JavaScript objects using h5wasm.
- apify: A way to generate APIs from simple specification languages (e.g. the NWB Schema)
- esconform: A generic library for enforcing schema properties
- dandi: A basic API for making calls to the DANDI REST API.
- nwb-inspector: A port of the original NWB Inspector for the browser
.specloc
is not rewritten as an object reference- Sometimes we get a memory overload error before the file is completely written. This leads to partial rewrites...
- Some of these issues might be resolved by moving to the WorkerFS filesystem and uniformly making the API asynchronous.
- Links, references, and tables (with references) are not yet supported.
- Cannot save multidimensional arrays like the data property in a SpatialSeries.
- Timestamp arrays can't be written (e.g.
timestamps
in a TimeSeries) because they are trying to convert to a BigInt byh5wasm
. - Using this library again with Vite will require you to specify
hdf5-io
as excluded from the optimized dependencies:
// vite.config.js
export default defineConfig({
optimizeDeps: {
exclude: ['hdf5-io']
}
})
From January to August 2023, the development of WebNWB was generously supported by a contract from the Kavli Foundation. The basic API was originally prototyped as part of the 2022 NWB-DANDI Remote Developer Hackathon and refined during the 2022 NWB User Days event by Garrett Flynn from Brains@Play.