Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Trialized time series faceting #232

Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 4 additions & 5 deletions nwbwidgets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def show_neurodata_base(
info.append(hbox_exp)
elif (isinstance(value, Iterable) and len(value)) or value:
neuro_data.append(
view.nwb2widget(value, neurodata_vis_spec=neurodata_vis_spec)
nwb2widget(value, neurodata_vis_spec=neurodata_vis_spec)
)
labels.append(key)
accordion = widgets.Accordion(children=neuro_data, selected_index=None)
Expand Down Expand Up @@ -240,12 +240,11 @@ def nwb2widget(node, neurodata_vis_spec: dict, **pass_kwargs) -> widgets.Widget:
if isinstance(spec, dict):
return lazy_tabs(spec, node)
elif callable(spec):
return vis2widget(
spec(node, neurodata_vis_spec=neurodata_vis_spec, **pass_kwargs)
)
visualization = spec(node, neurodata_vis_spec=neurodata_vis_spec, **pass_kwargs)
return vis2widget(visualization)
out1 = widgets.Output()
with out1:
print(node)
print(node) # Is this necessary?
return out1


Expand Down
8 changes: 1 addition & 7 deletions nwbwidgets/ophys.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,7 @@ def update_figure(index=0):


def show_df_over_f(df_over_f: DfOverF, neurodata_vis_spec: dict):
if len(df_over_f.roi_response_series) == 1:
title, data_input = list(df_over_f.roi_response_series.items())[0]
return neurodata_vis_spec[RoiResponseSeries](
data_input, neurodata_vis_spec, title=title
)
else:
return neurodata_vis_spec[NWBDataInterface](df_over_f, neurodata_vis_spec)
return neurodata_vis_spec[NWBDataInterface](df_over_f, neurodata_vis_spec)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a problem here when we make the neurodata_vis_spec[RoiResponseSeries] an OrderedDict to include the TrializedTimeSeries as an option (see the diff in the view.py module).

Because show_df_over_f is a callable the function nwb2widget expects this output to be a visualization (not an ordered dict) and a naive extension of the visualization specification generates an error. The solution I implemented was to roll back the show_df_over_f to return the visualization for the whole Container/DataInterface (see the else in the diff representing the old code) and then the visualization can be properly display as a root of the lazy_tab for that module. That is how the widget is working right now.

The other option was to modify nwb2widget to handle the case when callables return OrderedDict but that seemed like a larger modification given that nwb2widget is such a central function and this might have non-tested side effects in other visualizations. I opted for the simple solution here as that only touches the visualizations concerning the RoiExtractors and DfOverF objects.



def show_image_segmentation(img_seg: ImageSegmentation, neurodata_vis_spec: dict):
Expand Down