Exemplo n.º 1
0
def show_position(node):

    if len(node.spatial_series.keys()) == 1:
        for value in node.spatial_series.values():
            return view.nwb2widget(value)
    else:
        return view.nwb2widget(node.spatial_series)
Exemplo n.º 2
0
def show_position(node: Position, neurodata_vis_spec: dict):

    if len(node.spatial_series.keys()) == 1:
        for value in node.spatial_series.values():
            return view.nwb2widget(value, neurodata_vis_spec=neurodata_vis_spec)
    else:
        return view.nwb2widget(node.spatial_series, neurodata_vis_spec=neurodata_vis_spec)
Exemplo n.º 3
0
def show_neurodata_base(
    node: NWBDataInterface, neurodata_vis_spec: dict
) -> widgets.Widget:
    """
    Gets a pynwb object and returns a Vertical Box containing textual info and
    an expandable Accordion with it's children.
    """
    field_lay = widgets.Layout(
        max_height="40px", max_width="500px", min_height="30px", min_width="180px"
    )
    info = []  # string data type, exposed as a Text widget
    neuro_data = []  # more complex data types, also with children
    labels = []
    for key, value in node.fields.items():
        if isinstance(value, (str, datetime)):
            lbl_key = widgets.Label(key + ":", layout=field_lay)
            lbl_val = widgets.Label(str(value), layout=field_lay)
            info.append(widgets.HBox(children=[lbl_key, lbl_val]))
        elif key == "related_publications":
            pub_list = []
            for pub in value:
                pub_list.append(
                    widgets.HTML(
                        value="<a href=http://dx.doi.org/"
                        + pub[4:]
                        + ">"
                        + pub
                        + "</a>"
                    )
                )
            lbl_key = widgets.Label(key + ":", layout=field_lay)
            pub_list.insert(0, lbl_key)
            info.append(widgets.HBox(children=pub_list))
        elif key == "experimenter":
            lbl_experimenter = widgets.Label("Experimenter:", layout=field_lay)
            if isinstance(value, (list, tuple)):
                lbl_names = widgets.Label(", ".join(value), layout=field_lay)
            else:
                lbl_names = widgets.Label(value, layout=field_lay)
            hbox_exp = widgets.HBox(children=[lbl_experimenter, lbl_names])
            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)
            )
            labels.append(key)
    accordion = widgets.Accordion(children=neuro_data, selected_index=None)
    for i, label in enumerate(labels):
        if (
            hasattr(node.fields[label], "description")
            and node.fields[label].description
        ):
            accordion.set_title(i, label + ": " + node.fields[label].description)
        else:
            accordion.set_title(i, label)
    return widgets.VBox(info + [accordion])
Exemplo n.º 4
0
def show_neurodata_base(node):
    info = []
    neuro_data = []
    labels = []
    for key, value in node.fields.items():
        if isinstance(value, str):
            info.append(
                widgets.Text(value=repr(value), description=key,
                             disabled=True))
        elif (isinstance(value, Iterable) and len(value)) or value:
            neuro_data.append(view.nwb2widget(value))
            labels.append(key)
    accordion = widgets.Accordion(children=neuro_data, selected_index=None)
    for i, label in enumerate(labels):
        if hasattr(node.fields[label],
                   'description') and node.fields[label].description:
            accordion.set_title(i,
                                label + ': ' + node.fields[label].description)
        else:
            accordion.set_title(i, label)
    return widgets.VBox(info + [accordion])