Пример #1
0
Файл: bar.py Проект: tbenst/glia
def save_unit_spike_trains(units, stimulus_list, c_add_unit_figures, c_add_retina_figure,
        by='angle'):
    print("Creating bar unit spike trains")
    if by == 'angle':
        get_solid = glia.compose(
            glia.f_create_experiments(stimulus_list),
            glia.f_has_stimulus_type(["BAR"]),
            partial(sorted, key=lambda e: e["stimulus"]["angle"]),
        )
        nplots = get_nplots(stimulus_list,by)
        response = glia.apply_pipeline(get_solid,units)
        result = glia.plot_units(plot_spike_trains_by_angle,response, nplots=nplots,
            ncols=3,ax_xsize=10, ax_ysize=5,
            figure_title="Unit spike train by BAR angle")
    elif by == 'width':
        get_solid = glia.compose(
            glia.f_create_experiments(stimulus_list),
            glia.f_has_stimulus_type(["BAR"]),
            partial(sorted, key=lambda e: e["stimulus"]["width"]),
        )
        nplots = get_nplots(stimulus_list,by)
        response = glia.apply_pipeline(get_solid,units)
        result = glia.plot_units(plot_spike_trains_by_trial,response, nplots=nplots,
            ncols=3,ax_xsize=10, ax_ysize=5,
            figure_title="Unit spike train by BAR angle")


    # nplots = len(speed_widths)
    c_add_unit_figures(result)
    glia.close_figs([fig for the_id,fig in result])
Пример #2
0
def save_unit_spike_trains(units, stimulus_list, c_add_unit_figures, c_add_retina_figure, prepend, append):
    print("Creating solid unit spike trains")
    
    get_solid = glia.compose(
        glia.f_create_experiments(stimulus_list,prepend_start_time=prepend,append_lifespan=append),
        glia.f_has_stimulus_type(["SOLID"]),
    )
    response = glia.apply_pipeline(get_solid,units)
    plot_function = partial(plot_spike_trains,prepend_start_time=prepend,append_lifespan=append)
    result = glia.plot_units(plot_function,response,ncols=1,ax_xsize=10, ax_ysize=5)
    c_add_unit_figures(result)
    glia.close_figs([fig for the_id,fig in result])
Пример #3
0
def save_unit_spike_trains(units, stimulus_list, c_unit_fig, c_add_retina_figure, prepend, append):
    print("Creating solid unit spike trains")

    get_solid = glia.compose(
        glia.f_create_experiments(stimulus_list,prepend_start_time=prepend,append_lifespan=append),
        glia.f_has_stimulus_type(["SOLID"]),
    )
    response = glia.apply_pipeline(get_solid,units, progress=True)
    plot_function = partial(plot_spike_trains,prepend_start_time=prepend,append_lifespan=append)
    result = glia.plot_units(plot_function,response,ncols=1,ax_xsize=10, ax_ysize=5)
    c_unit_fig(result)
    glia.close_figs([fig for the_id,fig in result])
Пример #4
0
def save_unit_psth(units, stimulus_list, c_add_unit_figures, c_add_retina_figure, prepend, append):
    print("Creating solid unit PSTH")

    get_psth = glia.compose(
        glia.f_create_experiments(stimulus_list,prepend_start_time=prepend,append_lifespan=append),
        glia.f_has_stimulus_type(["SOLID"]),
        glia.f_group_by_stimulus(),
        glia.concatenate_by_stimulus
    )
    psth = glia.apply_pipeline(get_psth,units)
    plot_function = partial(plot_psth,prepend_start_time=prepend,append_lifespan=append)
    result = glia.plot_units(partial(plot_function,bin_width=0.01),psth,ax_xsize=10, ax_ysize=5)
    c_add_unit_figures(result)
    glia.close_figs([fig for the_id,fig in result])
Пример #5
0
def save_unit_psth(units, stimulus_list, c_unit_fig, c_add_retina_figure, prepend, append):
    print("Creating solid unit PSTH")

    get_psth = glia.compose(
        glia.f_create_experiments(stimulus_list,prepend_start_time=prepend,append_lifespan=append),
        glia.f_has_stimulus_type(["SOLID"]),
        glia.f_group_by_stimulus(),
        glia.concatenate_by_stimulus
    )
    psth = glia.apply_pipeline(get_psth,units, progress=True)
    plot_function = partial(plot_psth,prepend_start_time=prepend,append_lifespan=append)
    result = glia.plot_units(partial(plot_function,bin_width=0.01),psth,ax_xsize=10, ax_ysize=5)
    c_unit_fig(result)
    glia.close_figs([fig for the_id,fig in result])
Пример #6
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,
                             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,
                             bar_firing_rate,
                             bar_dsi,
                             bar_osi,
                             ax_xsize=6,
                             ax_ysize=4)
    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(ax, (bar_dsi, bar_osi))
    c_add_retina_figure(fig_population)
    plt.close(fig_population)
Пример #7
0
def save_unit_spike_trains(units,
                           stimulus_list,
                           c_add_unit_figures,
                           c_add_retina_figure,
                           by='angle'):
    print("Creating bar unit spike trains")
    if by == 'angle':
        get_solid = glia.compose(
            glia.f_create_experiments(stimulus_list),
            glia.f_has_stimulus_type(["BAR"]),
            partial(sorted, key=lambda e: e["stimulus"]["angle"]),
        )
        nplots = get_nplots(stimulus_list, by)
        response = glia.apply_pipeline(get_solid, units, progress=True)
        result = glia.plot_units(plot_spike_trains_by_angle,
                                 response,
                                 nplots=nplots,
                                 ncols=3,
                                 ax_xsize=10,
                                 ax_ysize=5,
                                 figure_title="Unit spike train by BAR angle")
    elif by == 'width':
        get_solid = glia.compose(
            glia.f_create_experiments(stimulus_list),
            glia.f_has_stimulus_type(["BAR"]),
            partial(sorted, key=lambda e: e["stimulus"]["width"]),
        )
        nplots = get_nplots(stimulus_list, by)
        response = glia.apply_pipeline(get_solid, units, progress=True)
        result = glia.plot_units(plot_spike_trains_by_trial,
                                 response,
                                 nplots=nplots,
                                 ncols=3,
                                 ax_xsize=10,
                                 ax_ysize=5,
                                 figure_title="Unit spike train by BAR angle")

    # nplots = len(speed_widths)
    c_add_unit_figures(result)
    glia.close_figs([fig for the_id, fig in result])
Пример #8
0
Файл: bar.py Проект: tbenst/glia
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)
Пример #9
0
def save_unit_spike_trains(units,
                           stimulus_list,
                           c_unit_fig,
                           c_add_retina_figure,
                           width=None,
                           height=None):
    print("Creating grating unit spike trains")

    get_solid = glia.compose(glia.f_create_experiments(stimulus_list),
                             glia.f_has_stimulus_type(["GRATING"]),
                             glia.f_split_by_wavelength())
    response = glia.apply_pipeline(get_solid, units, progress=True)

    nplots = len(glia.get_unit(response)[1])
    result = glia.plot_units(
        plot_spike_trains,
        response,
        nplots=nplots,
        ncols=3,
        ax_xsize=10,
        ax_ysize=5,
        figure_title="Unit spike train by GRATING waveperiod")
    c_unit_fig(result)
    glia.close_figs([fig for the_id, fig in result])
Пример #10
0
def cover(units, stimulus_list, metadata, c_unit_fig, c_retina_fig):
    "Add cover page."
    data = {k: v.name for k, v in units.items()}
    result = glia.plot_units(create_cover_page, data, ax_xsize=10, ax_ysize=5)
    c_unit_fig(result)
    glia.close_figs([fig for the_id, fig in result])
Пример #11
0
def cover(units, stimulus_list, c_add_unit_figures, c_add_retina_figureand):
    "Add cover page."
    data = {k:v.name for k,v in units.items()}
    result = glia.plot_units(create_cover_page,data,ax_xsize=10, ax_ysize=5)
    c_add_unit_figures(result)
    glia.close_figs([fig for the_id,fig in result])