Skip to content

[Bug]: Acquisition traces fails to show if the rois table is of type FibersTable #293

@luiztauffer

Description

@luiztauffer

What happened?

Acquisition traces fails to show if the rois table is of type FibersTable

Steps to Reproduce

from pynwb import NWBHDF5IO
from nwbwidgets import nwb2widget

io = NWBHDF5IO('file_with_fiber_photometry.nwb', mode='r')
nwbfile = io.read()

nwb2widget(nwbfile)

Traceback

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
File /media/luiz/storage2/conda_environments/env_shuler/lib/python3.8/site-packages/ipywidgets/widgets/widget.py:773, in Widget._handle_msg(self, msg)
    771         if 'buffer_paths' in data:
    772             _put_buffers(state, data['buffer_paths'], msg['buffers'])
--> 773         self.set_state(state)
    775 # Handle a state request.
    776 elif method == 'request_state':

File /media/luiz/storage2/conda_environments/env_shuler/lib/python3.8/site-packages/ipywidgets/widgets/widget.py:655, in Widget.set_state(self, sync_data)
    652 if name in self.keys:
    653     from_json = self.trait_metadata(name, 'from_json',
    654                                     self._trait_from_json)
--> 655     self.set_trait(name, from_json(sync_data[name], self))

File /media/luiz/storage2/conda_environments/env_shuler/lib/python3.8/contextlib.py:120, in _GeneratorContextManager.__exit__(self, type, value, traceback)
    118 if type is None:
    119     try:
--> 120         next(self.gen)
    121     except StopIteration:
    122         return False

File /media/luiz/storage2/conda_environments/env_shuler/lib/python3.8/site-packages/traitlets/traitlets.py:1371, in HasTraits.hold_trait_notifications(self)
   1369 for changes in cache.values():
   1370     for change in changes:
-> 1371         self.notify_change(change)

File /media/luiz/storage2/conda_environments/env_shuler/lib/python3.8/site-packages/ipywidgets/widgets/widget.py:701, in Widget.notify_change(self, change)
    698     if name in self.keys and self._should_send_property(name, getattr(self, name)):
    699         # Send new state to front-end
    700         self.send_state(key=name)
--> 701 super().notify_change(change)

File /media/luiz/storage2/conda_environments/env_shuler/lib/python3.8/site-packages/traitlets/traitlets.py:1386, in HasTraits.notify_change(self, change)
   1384 def notify_change(self, change):
   1385     """Notify observers of a change event"""
-> 1386     return self._notify_observers(change)

File /media/luiz/storage2/conda_environments/env_shuler/lib/python3.8/site-packages/traitlets/traitlets.py:1431, in HasTraits._notify_observers(self, event)
   1428 elif isinstance(c, EventHandler) and c.name is not None:
   1429     c = getattr(self, c.name)
-> 1431 c(event)

File /media/luiz/storage2/Github/nwb-jupyter-widgets/nwbwidgets/base.py:130, in lazy_tabs..on_selected_index(change)
    128 def on_selected_index(change):
    129     if isinstance(change.owner.children[change.new], widgets.HTML):
--> 130         children[change.new] = vis2widget(tabs_spec[change.new][1](node))
    131         change.owner.children = children

File /media/luiz/storage2/Github/nwb-jupyter-widgets/nwbwidgets/ophys.py:325, in RoiResponseSeriesWidget.__init__(self, roi_response_series, neurodata_vis_spec, **kwargs)
    324 def __init__(self, roi_response_series: RoiResponseSeries, neurodata_vis_spec=None, **kwargs):
--> 325     super().__init__(roi_response_series, "rois", **kwargs)

File /media/luiz/storage2/Github/nwb-jupyter-widgets/nwbwidgets/timeseries.py:594, in BaseGroupedTraceWidget.__init__(self, time_series, dynamic_table_region_name, foreign_time_window_controller, foreign_group_and_sort_controller, mpl_plotter, **kwargs)
    592     table = dynamic_table_region.table
    593     referenced_rows = np.array(dynamic_table_region.data)
--> 594     self.gas = GroupAndSortController(
    595         dynamic_table=table,
    596         keep_rows=referenced_rows,
    597     )
    598     self.controls.update(gas=self.gas)
    599 else:

File /media/luiz/storage2/Github/nwb-jupyter-widgets/nwbwidgets/controllers/group_and_sort_controllers.py:141, in GroupAndSortController.__init__(self, dynamic_table, group_by, window, keep_rows, control_order, control_limit, groups)
    133 range_controller_max = min(30, self.nitems)
    134 dt_desc_map = {
    135     "DynamicTable": "traces",
    136     "TimeIntervals": "trials",
   (...)
    139     # "FibersTable": "traces",
    140 }
--> 141 desc = dt_desc_map[dynamic_table.neurodata_type] if dynamic_table is not None else "traces"
    142 self.range_controller = RangeController(
    143     0,
    144     self.nitems,
   (...)
    148     orientation="vertical",
    149 )
    150 self.range_controller.layout = Layout(min_width="75px")

KeyError: 'FibersTable'

Operating System

Linux

Python Version

3.9

Package Versions

No response

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions