MCPcopy Index your code
hub / github.com/NeurodataWithoutBorders/nwbwidgets

github.com/NeurodataWithoutBorders/nwbwidgets @v0.10.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.10.2 ↗ · + Follow
510 symbols 1,694 edges 60 files 95 documented · 19%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

NWB Widgets

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.

PyPI version codecov License Binder

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

from pynwb import NWBHDF5IO
from nwbwidgets import nwb2widget

io = NWBHDF5IO('path/to/file.nwb', mode='r')
nwb = io.read()

nwb2widget(nwb)

Demo

How it works

All visualizations are controlled by the dictionary neurodata_vis_spec. The keys of this dictionary are pynwb neurodata types, and the values are functions that take as input that neurodata_type and output a visualization. The visualizations may be of type Widget or matplotlib.Figure. When you enter a neurodata_type instance into nwb2widget, it searches the neurodata_vis_spec for that instance's neurodata_type, progressing backwards through the parent classes of the neurodata_type to find the most specific neurodata_type in neurodata_vis_spec. Some of these types are containers for other types, and create accordian UI elements for its contents, which are then passed into the neurodata_vis_spec and rendered accordingly.

Instead of supplying a function for the value of the neurodata_vis_spec 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.

Extending

To extend NWBWidgets, all you need to a function that takes as input an instance of a specific neurodata_type class, and outputs a matplotlib figure or a jupyter widget.

Used in

Core symbols most depended-on inside this repo

update
called by 27
nwbwidgets/misc.py
timeseries_time_to_ind
called by 22
nwbwidgets/utils/timeseries.py
get_timeseries_tt
called by 17
nwbwidgets/utils/timeseries.py
update
called by 14
nwbwidgets/timeseries.py
get_timeseries_in_units
called by 9
nwbwidgets/utils/timeseries.py
vis2widget
called by 8
nwbwidgets/base.py
update_value
called by 8
nwbwidgets/controllers/group_and_sort_controllers.py
get_timeseries_maxt
called by 8
nwbwidgets/utils/timeseries.py

Shape

Method 256
Function 181
Class 72
Route 1

Languages

Python100%

Modules by API surface

nwbwidgets/timeseries.py54 symbols
nwbwidgets/misc.py41 symbols
test/test_timeseries.py25 symbols
nwbwidgets/base.py25 symbols
nwbwidgets/controllers/time_window_controllers.py24 symbols
test/test_utils_units.py21 symbols
test/test_base.py20 symbols
nwbwidgets/ophys.py19 symbols
test/test_behavior.py18 symbols
nwbwidgets/controllers/group_and_sort_controllers.py18 symbols
test/test_controllers.py17 symbols
nwbwidgets/behavior.py16 symbols

For agents

$ claude mcp add nwbwidgets \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact