How to use the nwbwidgets.controllers.ProgressBar function in nwbwidgets

To help you get started, we’ve selected a few nwbwidgets examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NeurodataWithoutBorders / nwb-jupyter-widgets / nwbwidgets / misc.py View on Github external
progress_bar: FloatProgress, optional

    Returns
    -------

    """

    data = np.asarray(data)
    if ax is None:
        fig, ax = plt.subplots(figsize=(12, 6))
    if group_inds is not None:
        ugroup_inds = np.unique(group_inds)
        handles = []

        if progress_bar is not None:
            this_iter = ProgressBar(enumerate(ugroup_inds), desc='plotting spikes', leave=False, total=len(ugroup_inds))
            progress_bar = this_iter.container
        else:
            this_iter = enumerate(ugroup_inds)

        for i, ui in this_iter:
            color = colors[ugroup_inds[i] % len(colors)]
            lineoffsets = np.where(group_inds == ui)[0] + offset
            event_collection = ax.eventplot(data[group_inds == ui],
                                            orientation='horizontal',
                                            lineoffsets=lineoffsets,
                                            color=color)
            handles.append(event_collection[0])
        if show_legend:
            ax.legend(handles=handles[::-1], labels=list(labels[ugroup_inds][::-1]), loc='upper left',
                      bbox_to_anchor=(1.01, 1))
    else:
github NeurodataWithoutBorders / nwb-jupyter-widgets / nwbwidgets / misc.py View on Github external
-------
    matplotlib.pyplot.Figure

    """

    if time_window is None:
        time_window = [get_min_spike_time(units), get_max_spike_time(units)]

    if units_window is None:
        units_window = [0, len(units)]

    if order is None:
        order = np.arange(len(units), dtype='int')

    if progress_bar:
        this_iter = ProgressBar(order, desc='reading spike data', leave=False)
        progress_bar = this_iter.container
    else:
        this_iter = order
    data = []
    for unit in this_iter:
        data.append(get_spike_times(units, unit, time_window))

    if show_obs_intervals:
        unobserved_intervals_list = get_unobserved_intervals(units, time_window, order)
    else:
        unobserved_intervals_list = None

    ax = plot_grouped_events(data, time_window, group_inds=group_inds, labels=labels, show_legend=show_legend,
                             offset=units_window[0], unobserved_intervals_list=unobserved_intervals_list,
                             progress_bar=progress_bar)
    ax.set_ylabel('unit #')