Skip to content

garrettmflynn/webnwb

Repository files navigation

WebNWB

Neurodata without Borders — directly on the browser.

Npm package version Npm package monthly downloads License: AGPL v3 Discord

webnwb is a library for reading and writing Neurodata without Borders (NWB) files on the web.

Features

  • 🔬 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, and createAcquisition 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.

Documentation

Visit nwb.brainsatplay.com for documentation and examples.

Contributing

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):

  1. Validate writing a dataset using best practices and the schema
  2. Allow writing a dataset in place using the File Access API (Chrome)
  3. Support Zarr as a backend file format

Derivative Packages

  • 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

Known Issues

  1. .specloc is not rewritten as an object reference
  2. 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.
  3. Links, references, and tables (with references) are not yet supported.
  4. Cannot save multidimensional arrays like the data property in a SpatialSeries.
  5. Timestamp arrays can't be written (e.g. timestamps in a TimeSeries) because they are trying to convert to a BigInt by h5wasm.
  6. 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']
    }
})

Acknowledgments

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.

About

A JavaScript API for working with neurodata stored in the NWB Format

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published