Beispiel #1
0
def plot_unit_dsi_osi_table(fig, axis_gen, data):
    ax = next(axis_gen)
    bar_firing_rate, bar_dsi, bar_osi = data
    analytics = glia.by_speed_width_then_angle(bar_firing_rate)
    speed_widths = analytics.keys()
    speeds = sorted(list(set([speed for speed, width in speed_widths])))
    widths = sorted(list(set([width for speed, width in speed_widths])))
    color = iter(plt.cm.rainbow(np.linspace(0, 1, len(speeds))))
    w = iter(np.linspace(1, 5, len(widths)))
    speed_style = {speed: next(color) for speed in speeds}
    width_style = {width: next(w) for width in widths}

    speed_style["overall"] = "white"
    unique_speed_width = sorted(speed_widths, key=f_get_key(1))
    unique_speed_width = sorted(unique_speed_width, key=f_get_key(0))

    columns = unique_speed_width + ["overall"]
    colors = [speed_style[speed]
              for speed, width in unique_speed_width] + ['white']
    cells = [["{:1.3f}".format(bar_dsi[speed_width]) for speed_width in columns], \
             ["{:1.3f}".format(bar_osi[speed_width]) for speed_width in columns]]
    # ax.xaxis.set_visible(False)
    # ax.yaxis.set_visible(False)
    ax.axis('tight')
    ax.axis('off')
    table = ax.table(cellText=cells,
                     rowLabels=['DSI', "OSI"],
                     colLabels=columns,
                     colColours=colors,
                     loc='bottom',
                     bbox=[0, 0, 1, 0.5])
    table.auto_set_font_size(False)
    table.set_fontsize(12)
Beispiel #2
0
def plot_unit_dsi_osi_table(axis_gen,data):
    ax = next(axis_gen)
    bar_firing_rate, bar_dsi, bar_osi = data
    analytics = glia.by_speed_width_then_angle(bar_firing_rate)
    speed_widths = analytics.keys()
    speeds = sorted(list(set([speed for speed,width in speed_widths])))
    widths = sorted(list(set([width for speed,width in speed_widths])))
    color=iter(plt.cm.rainbow(np.linspace(0,1,len(speeds))))
    w = iter(np.linspace(1,5,len(widths)))
    speed_style = {speed: next(color) for speed in speeds}
    width_style = {width: next(w) for width in widths}
    
    speed_style["overall"] = "white"
    unique_speed_width = sorted(speed_widths, key=f_get_key(1))
    unique_speed_width = sorted(unique_speed_width, key=f_get_key(0))
    
    columns = unique_speed_width + ["overall"]
    colors = [speed_style[speed] for speed,width in unique_speed_width] + ['white']
    cells = [["{:1.3f}".format(bar_dsi[speed_width]) for speed_width in columns], \
             ["{:1.3f}".format(bar_osi[speed_width]) for speed_width in columns]]
    # ax.xaxis.set_visible(False) 
    # ax.yaxis.set_visible(False)
    ax.axis('tight')
    ax.axis('off')
    table = ax.table(cellText=cells,
                      rowLabels=['DSI',"OSI"],
                      colLabels=columns,
                     colColours=colors,
                        loc='bottom', bbox = [0,0,1,0.5])
    table.auto_set_font_size(False)
    table.set_fontsize(12)
Beispiel #3
0
def plot_unit_response_by_angle(axis_gen, data):
    """Plot the average for each speed and width."""
    # we will accumulate by angle in this dictionary and then divide
    bar_firing_rate, bar_dsi, bar_osi = data
    analytics = glia.by_speed_width_then_angle(bar_firing_rate)
    speed_widths = analytics.keys()
    speeds = sorted(list(set([speed for speed,width in speed_widths])))
    widths = sorted(list(set([width for speed,width in speed_widths])))
    color=iter(plt.cm.rainbow(np.linspace(0,1,len(speeds))))
    w = iter(np.linspace(1,5,len(widths)))
    speed_style = {speed: next(color) for speed in speeds}
    width_style = {width: next(w) for width in widths}
    
    for speed_width, angle_dictionary in analytics.items():
        ax = next(axis_gen)
        speed, width = speed_width
        line_angle = []
        line_radius = []
        for angle, average_number_spikes in angle_dictionary.items():
            line_angle.append(angle)
            line_radius.append(average_number_spikes)
        # connect the line
        line_angle, line_radius = glia.sort_two_arrays_by_first(line_angle,line_radius)
        line_angle.append(line_angle[0])
        line_radius.append(line_radius[0])
        ax.plot(line_angle,line_radius, linewidth=width_style[width], color=speed_style[speed])
        ax.set_title("speed: {}, width: {}".format(*speed_width), y=1.1)
        ax.set_xlabel("avg # of spikes", labelpad=12)
Beispiel #4
0
def plot_unit_response_by_angle(axis_gen, data):
    """Plot the average for each speed and width."""
    # we will accumulate by angle in this dictionary and then divide
    bar_firing_rate, bar_dsi, bar_osi = data
    analytics = glia.by_speed_width_then_angle(bar_firing_rate)
    speed_widths = analytics.keys()
    speeds = sorted(list(set([speed for speed, width in speed_widths])))
    widths = sorted(list(set([width for speed, width in speed_widths])))
    color = iter(plt.cm.rainbow(np.linspace(0, 1, len(speeds))))
    w = iter(np.linspace(1, 5, len(widths)))
    speed_style = {speed: next(color) for speed in speeds}
    width_style = {width: next(w) for width in widths}

    for speed_width, angle_dictionary in analytics.items():
        ax = next(axis_gen)
        speed, width = speed_width
        line_angle = []
        line_radius = []
        for angle, average_number_spikes in angle_dictionary.items():
            line_angle.append(angle)
            line_radius.append(average_number_spikes)
        # connect the line
        line_angle, line_radius = glia.sort_two_arrays_by_first(
            line_angle, line_radius)
        line_angle.append(line_angle[0])
        line_radius.append(line_radius[0])
        ax.plot(line_angle,
                line_radius,
                linewidth=width_style[width],
                color=speed_style[speed])
        ax.set_title("speed: {}, width: {}".format(*speed_width), y=1.1)
        ax.set_xlabel("avg # of spikes", labelpad=12)
Beispiel #5
0
def save_unit_response_by_angle(units, stimulus_list, c_unit_fig,
                                c_add_retina_figure):
    print("Calculating DSI & OSI")
    bar_firing_rate, bar_dsi, bar_osi = get_fr_dsi_osi(units, stimulus_list)

    print("plotting unit response by angle")
    analytics = glia.by_speed_width_then_angle(
        glia.get_unit(bar_firing_rate)[1])
    nplots = len(list(analytics.keys()))
    del analytics

    if nplots > 1:
        ncols = 3
    else:
        ncols = 1

    result = glia.plot_units(plot_unit_response_by_angle,
                             partial(c_unit_fig, "angle"),
                             bar_firing_rate,
                             bar_dsi,
                             bar_osi,
                             nplots=nplots,
                             subplot_kw={"projection": "polar"},
                             ax_xsize=4,
                             ax_ysize=5,
                             ncols=3)
    # c_unit_fig(result)
    # glia.close_figs([fig for the_id,fig in result])

    print("plotting unit DSI/OSI table")
    result = glia.plot_units(plot_unit_dsi_osi_table,
                             partial(c_unit_fig, "selectivity_table"),
                             bar_firing_rate,
                             bar_dsi,
                             bar_osi,
                             ax_xsize=16,
                             ax_ysize=3)
    # c_unit_fig(result)
    # glia.close_figs([fig for the_id,fig in result])

    fig_population, ax = plt.subplots(2, 1)
    print("plotting population by DSI & OSI")
    plot_population_dsi_osi(fig_population, ax, (bar_dsi, bar_osi))
    c_add_retina_figure("DSI_OSI", fig_population)
    plt.close(fig_population)
Beispiel #6
0
def save_unit_response_by_angle(units, stimulus_list, c_add_unit_figures, c_add_retina_figure):
    print("Calculating DSI & OSI")
    bar_firing_rate, bar_dsi, bar_osi = get_fr_dsi_osi(units, stimulus_list)

    print("plotting unit response by angle")
    analytics = glia.by_speed_width_then_angle(glia.get_unit(bar_firing_rate)[1])
    nplots = len(list(analytics.keys()))
    del analytics

    if nplots>1:
        ncols=3
    else:
        ncols=1

    result = glia.plot_units(plot_unit_response_by_angle,
        bar_firing_rate,bar_dsi,bar_osi,
        nplots=nplots, subplot_kw={"projection": "polar"},
        ax_xsize=4, ax_ysize=5, ncols=3)
    c_add_unit_figures(result)
    glia.close_figs([fig for the_id,fig in result])


    print("plotting unit DSI/OSI table")
    result = glia.plot_units(plot_unit_dsi_osi_table,
        bar_firing_rate,bar_dsi,bar_osi,
        ax_xsize=6, ax_ysize=4)
    c_add_unit_figures(result)
    glia.close_figs([fig for the_id,fig in result])



    fig_population,ax = plt.subplots(2,1)
    print("plotting population by DSI & OSI")
    plot_population_dsi_osi(ax, (bar_dsi, bar_osi))
    c_add_retina_figure(fig_population)
    plt.close(fig_population)