How to use the nwbwidgets.utils.units.align_by_time_intervals 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
ucol_vals = [None]
    ncols = len(ucol_vals)

    fig, axs = plt.subplots(nrows, ncols, sharex=True, sharey=True, squeeze=False, figsize=(10, 10))
    big_ax = create_big_ax(fig)
    for i, row in enumerate(urow_vals):
        for j, col in enumerate(ucol_vals):
            ax = axs[i, j]
            ax_trials_select = trials_select.copy()
            if row is not None:
                ax_trials_select &= row_vals == row
            if col is not None:
                ax_trials_select &= col_vals == col
            ax_trials_select = np.where(ax_trials_select)[0]
            if len(ax_trials_select):
                data = align_by_time_intervals(units, index, time_intervals, align_by, align_by,
                                               before, after, ax_trials_select)
                show_psth_raster(data, before, after, ax=ax)
                ax.set_xlabel('')
                ax.set_ylabel('')
                if ax.is_first_col():
                    ax.set_ylabel(row)
                if ax.is_last_row():
                    ax.set_xlabel(col)

    big_ax.set_xlabel(cols_label, labelpad=50)
    big_ax.set_ylabel(rows_label, labelpad=60)

    return fig
github NeurodataWithoutBorders / nwb-jupyter-widgets / nwbwidgets / misc.py View on Github external
group_inds
    labels
    sigma_in_secs: float, optional
        standard deviation of gaussian kernel
    ntt:
        Number of time points to use for smooth curve

    Returns
    -------
    matplotlib.Figure

    """
    if trials is None:
        trials = units.get_ancestor('NWBFile').trials

    data = align_by_time_intervals(units, index, trials, start_label, start_label, before, after, order,
                                   progress_bar=progress_bar)
    # expanded data so that gaussian smoother uses larger window than is viewed
    expanded_data = align_by_time_intervals(units, index, trials, start_label, start_label,
                                            before + sigma_in_secs * 4,
                                            after + sigma_in_secs * 4,
                                            order,
                                            progress_bar=progress_bar)

    fig, axs = plt.subplots(2, 1, figsize=(10, 10))

    show_psth_raster(data, before, after, group_inds, labels, ax=axs[0], progress_bar=progress_bar)

    axs[0].set_title('PSTH for unit {}'.format(index))
    axs[0].set_xticks([])
    axs[0].set_xlabel('')
github NeurodataWithoutBorders / nwb-jupyter-widgets / nwbwidgets / misc.py View on Github external
standard deviation of gaussian kernel
    ntt:
        Number of time points to use for smooth curve

    Returns
    -------
    matplotlib.Figure

    """
    if trials is None:
        trials = units.get_ancestor('NWBFile').trials

    data = align_by_time_intervals(units, index, trials, start_label, start_label, before, after, order,
                                   progress_bar=progress_bar)
    # expanded data so that gaussian smoother uses larger window than is viewed
    expanded_data = align_by_time_intervals(units, index, trials, start_label, start_label,
                                            before + sigma_in_secs * 4,
                                            after + sigma_in_secs * 4,
                                            order,
                                            progress_bar=progress_bar)

    fig, axs = plt.subplots(2, 1, figsize=(10, 10))

    show_psth_raster(data, before, after, group_inds, labels, ax=axs[0], progress_bar=progress_bar)

    axs[0].set_title('PSTH for unit {}'.format(index))
    axs[0].set_xticks([])
    axs[0].set_xlabel('')

    show_psth_smoothed(expanded_data, axs[1], before, after, group_inds,
                       sigma_in_secs=sigma_in_secs, ntt=ntt)
    return fig