Exemplo n.º 1
0
def create_figure(xmin, xmax):
    ncols = 7
    nrows = 6

    f, axarr = plt.subplots(figsize=(25, 12),
                            ncols=ncols,
                            nrows=nrows,
                            sharey='row')

    titles = [
        "Aligned to stim onset",
        "Aligned to escape onset",
        "Aligned to speed peak",
        "Aligned to at shelter",
        "Aligned to spont homing",
        "Aligned to spont homing max speed",
        "Aligned to spont runs",
    ]
    ylables = [
        'Shelter dist, px',
        'Speed, px/frame',
        'Ang vel, def/frame',
        'Raw ROI sig',
        'Mean ROI sig',
    ]
    all_axes = []
    for i, title in enumerate(titles):
        axes = []
        for n, ylabel in enumerate(ylables):
            ax = axarr[n, i]

            if n == 0:
                ax.set(title=title)
            if i == 0:
                ax.set(ylabel=ylabel)
            if n == nrows - 1:
                ax.set(xlabel="Time (s)")
            if "Ang vel" in ylabel:
                ax.set(ylim=[-20, 20])

            ax.set(xlim=[xmin, xmax])
            axes.append(ax)
        all_axes.append(axes)

    set_figure_subplots_aspect(left=0.06,
                               right=0.97,
                               bottom=0.05,
                               top=0.93,
                               wspace=0.17,
                               hspace=0.4)
    clean_axes(f)

    return f, all_axes
Exemplo n.º 2
0
        if longest == 0: continue
        x = np.arange(60, longest + 30, 30)
        axarr[1, 0].set(title='Signal',
                        ylabel=f'{roi}\nDFF',
                        xlim=[x.min(), x.max()],
                        xticks=x,
                        xticklabels=((x - n_frames_pre) / 30).astype(np.int32),
                        xlabel='s')
        axarr[0, 0].set(
            ylim=[0, 80],
            ylabel='X position\n$cm$',
            xticks=[],
            xlim=[x.min(), x.max()],
        )
        clean_axes(f)

        axes, titles = tag_axes, ('stim', 'start', 'run', 'shelter', 'stop')
        for ax, ttl in zip(tag_axes, titles):
            ax.set(title=ttl)
            ax.set(xticks=[0, 30, 60],
                   xticklabels=[-1, 0, 1],
                   xlabel='s',
                   yticks=[],
                   ylim=axarr[1, 0].get_ylim())

            ax.spines['left'].set_visible(False)
            ax.axvline(30, color=[.2, .2, .2], lw=3)

        save_figure(
            f,
Exemplo n.º 3
0
'''
liftoff_th = 6  # paw < 6% of boy weight is liftoff

xkwargs = dict(
    xticks=[-1.5, -1, -0.5, -0.25, 0, 0.25, 0.5, 1, 1.5],
    xticklabels=[-1.5, -1, -.5, -0.25, 0, 0.25, 0.5, 1, 1.5],
)

cog_fig, cog_ax = plt.subplots(figsize=(12, 12))
main_fig, main_axes = plt.subplots(figsize=(18, 12),
                                   ncols=2,
                                   nrows=2,
                                   sharex=True,
                                   sharey=True)
main_axes = main_axes.flatten()
clean_axes(main_fig)

# style main figure
for ch, ax in zip(sensors, main_axes):
    ax.set(title=ch,
           ylabel='weight %',
           xlabel='time wrt RF take off (s)',
           xlim=[-.5, .5],
           **xkwargs)
    ax.axvline(0, lw=4, ls='--', color=[.2, .2, .2], zorder=-1)
    ax.axhline(0, lw=2, color='k', zorder=-1)

step_start_frames, all_sigs = [], []
for i, trial in track(data.iterrows(), total=len(data)):
    start = np.where(trial.fr_on_sensor == 0)[0][0]
    step_start_frames.append(start)