Explore the hierarchical structure of NWB 2.0 files and visualize data with Jupyter widgets.
Explore NWB data in Jupyter
Table of Contents
About
A library of widgets for visualization NWB data in a Jupyter notebook (or lab). The widgets allow you to navigate through the hierarchical structure of the NWB file and visualize specific data elements. It is designed to work out-of-the-box with NWB 2.0 files and to be easy to extend.Installation
nwbwidgets requires Python >= 3.7.
The latest published version can be installed by running:
pip install nwbwidgets
Note that there are some optional dependencies required for some widgets. If an NWB data file contains a data type that requires additional dependencies, you will see a list of extra modules needed for that specific widget. All other widgets in the file will still work.
Usage
Using Panel
The easiest way to use NWB widgets is with the interactive Panel:
from nwbwidgets.panel import Panel
Panel()
Using nwb2widget
If you’re working directly with a NWB file object in your Jupyter notebook, you can also explore it with NWB Widgets using
from pynwb import NWBHDF5IO
from nwbwidgets import nwb2widget
io = NWBHDF5IO('path/to/file.nwb', mode='r') nwb = io.read()
nwb2widget(nwb)
Using Docker
You can also run the NWB Widgets Panel using Docker:$ docker run -p 8866:8866 ghcr.io/NeurodataWithoutBorders/nwbwidgets-panel:latest
Demo
Documentation
See our ReadTheDocs page for full documentation, including a gallery of all supported formats.How it works
All visualizations are controlled by the dictionaryneurodatavisspec. The keys of this dictionary are pynwb neurodata types, and the values are functions that take as input that neurodatatype and output a visualization. The visualizations may be of type Widget or matplotlib.Figure. When you enter a neurodatatype instance into nwb2widget, it searches the neurodatavisspec for that instance's neurodatatype, progressing backwards through the parent classes of the neurodatatype to find the most specific neurodatatype in neurodatavisspec. Some of these types are containers for other types, and create accordian UI elements for its contents, which are then passed into the neurodatavis_spec and rendered accordingly.
Instead of supplying a function for the value of the neurodatavisspec dict, you may provide a dict or OrderedDict with string keys and function values. In this case, a tab structure is rendered, with each of the key/value pairs as an individual tab. All accordian and tab structures are rendered lazily- they are only called with that tab is selected. As a result, you can provide may tabs for a single data type without a worry. They will only be run if they are selected.