markersize=16,
            elinewidth=5,
            capthick=3)
ax.plot(np.hstack((1, 1, 1, 1)),
        tracks1_nb1,
        'o',
        color='k',
        alpha=0.4,
        markersize=13)
ax.plot(np.hstack((2, 2, 2, 2)),
        tracks1_p1,
        'o',
        color='k',
        alpha=0.4,
        markersize=13)
adjust_spines(ax, ['left', 'bottom'])
ax.tick_params(axis='x',
               pad=10,
               which='both',
               top='off',
               right='off',
               direction='out',
               length=14,
               width=3,
               labelsize=22)
ax.tick_params(axis='y',
               pad=10,
               which='both',
               top='off',
               right='off',
               direction='out',
                # MAKE FIGURE: 1st row: stop rasters. 2nd row: average stops. 3rd row: speed. Columns are beaconed/non-beaconed/probe
                fig = plt.figure(figsize = (12,12))
                ax = fig.add_subplot(3,3,1) #stops per trial
                ax.set_title('Beaconed trials', fontsize = 22,verticalalignment = 'bottom', style = 'italic')
                ax.axvspan(8.8, 8.8+2.2, facecolor='DarkGreen', alpha=0.25, hatch = '/', linewidth =0) # green box spanning the rewardzone to mark reward zone
                ax.axvspan(0, 3, facecolor='k', hatch = '/', linewidth =0, alpha=0.15) # black box
                ax.axvspan(20-3, 20, facecolor='k', hatch = '/', linewidth =0, alpha=0.15)# black box
                ax.axvline(0, linewidth = 3, color = 'black') # bold line on the y axis
                ax.axhline(0, linewidth = 3, color = 'black') # bold line on the x axis
                ax.plot(stopsdata_b[:,0],stopsdata_b[:,2], 'o', color = 'Black', markersize =4.5, label = 'Stop') #plot becaoned trials
                ax.plot(reward_beac[:,0],reward_beac[:,2], '>', color = 'Red', markersize = 6, label = 'Reward') #plot becaoned trials
                ax.tick_params(axis='x', pad = 10, top='off', right = 'off', direction = 'out',width = 2, length = 8,labelsize =18)
                ax.tick_params(axis='y', pad = 10, top='off', right = 'off', direction = 'out',width = 2, length = 8, labelsize =18)
                ax.set_xlim(0,20)
                ax.set_ylim(0,trialno+0.5)
                adjust_spines(ax, ['left','bottom']) # removes top and right spines
                makelegend(fig,ax) # make legend
                ax.locator_params(axis = 'x', nbins=3) # set number of ticks on x axis
                ax.locator_params(axis = 'y', nbins=4) # set number of ticks on y axis
                ax.set_xticklabels(['', '', ''])
                ax.set_ylabel('Trial number', fontsize=18, labelpad = 20)

                ax = fig.add_subplot(3,3,2) #stops per trial
                ax.set_title('Non-beaconed trials', fontsize = 22, style = 'italic',verticalalignment = 'bottom')
                ax.axvspan(8.8, 8.8+2.2, facecolor='DarkGreen', alpha=0.25, hatch = '/', linewidth =0) # green box spanning the rewardzone to mark reward zone
                ax.axvspan(0, 3, facecolor='k', alpha=0.15, hatch = '/', linewidth =0) # black box
                ax.axvspan(20-3, 20, facecolor='k', alpha=0.15, hatch = '/', linewidth =0)# black box
                ax.axvline(0, linewidth = 3, color = 'black') # bold line on the y axis
                ax.axhline(0, linewidth = 3, color = 'black') # bold line on the x axis
                ax.plot(stopsdata_nb[:,0],stopsdata_nb[:,2], 'o',color = 'Black', markersize = 4.5) #plot becaoned trials
                ax.plot(reward_nbeac[:,0],reward_nbeac[:,2], '>', color = 'Red', markersize = 6, label = 'Reward') #plot becaoned trials
               right='off',
               direction='out',
               width=2,
               length=7,
               labelsize=15)  # tick parameters: pad is tick label relative to
ax.tick_params(axis='y',
               pad=10,
               top='off',
               right='off',
               direction='out',
               width=2,
               length=7,
               labelsize=15)
ax.set_xlim(0, 22)
ax.set_ylim(30, 100)
adjust_spines(ax, ['left', 'bottom'])  # remove right and top axis
plt.locator_params(nbins=7, axis='y')  # set tick number on y axis
plt.locator_params(nbins=3, axis='x')  # set tick number on x axis
plt.xticks(rotation=70)  # rotate x ticks 70 degrees
ax = plt.ylabel('Location (cm)', fontsize=16, labelpad=18)

ax = fig.add_subplot(1, 3, 2)
ax.axvline(0, linewidth=3, color='black')  # bold line on the x axis
ax.axhline(30, linewidth=3, color='black')  # bold line on the y axis
ax.axhspan(88, 100, linewidth=0, facecolor='g', alpha=0.15,
           hatch='/')  # mark reward zone
ax.axhline(x, ls='--', color='black', linewidth=1.5)  # mark black box
ax.plot(n_groups,
        con_nbeac,
        'o',
        color='0.3',
Esempio n. 4
0
def plot_fig1F(session_paths, save_path):


    # specify mouse/mice and day/s to analyse
    days = [1]
    n_bins = 20
    # specify mouse/mice and day/s to analyse
    days = ['Day' + str(int(x)) for x in np.arange(1)]

    # empty arrays for storing data
    firststopstorebeac = np.zeros((len(days), len(session_paths), n_bins, 2))
    firststopstorenbeac = np.zeros((len(days), len(session_paths), n_bins, 2))
    firststopstoreprobe = np.zeros((len(days), len(session_paths), n_bins, 2))
    firststopstorebeac[:,:,:] = np.nan
    firststopstorenbeac[:,:,:] = np.nan
    firststopstoreprobe[:,:,:] = np.nan

    #loop days and mice to collect data
    for dcount,day in enumerate(days):
        session_count = 0
        for session_path in session_paths:
            saraharray, track_start, track_end = translate_to_legacy_format(session_path)

            rz_start = saraharray[0, 11]
            rz_end = saraharray[0, 12]

            trialarray = maketrialarray(saraharray) # make array of trial number same size as saraharray
            saraharray[:,9] = trialarray[:,0] # replace trial number because of increment error (see README.py)

            # split data by trial type
            dailymouse_b = np.delete(saraharray, np.where(saraharray[:, 8] > 0), 0) # delete all data not on beaconed tracks
            dailymouse_nb = np.delete(saraharray, np.where(saraharray[:, 8] != 10), 0)# delete all data not on non beaconed tracks
            dailymouse_p = np.delete(saraharray, np.where(saraharray[:, 8] != 20), 0)# delete all data not on probe tracks

            #extract stops
            stopsdata_b = extractstops_HUMAN(dailymouse_b)
            stopsdata_nb = extractstops_HUMAN(dailymouse_nb)
            stopsdata_p = extractstops_HUMAN(dailymouse_p)

            # filter stops
            stopsdata_b = filterstops(stopsdata_b)
            stopsdata_nb = filterstops(stopsdata_nb)
            stopsdata_p = filterstops(stopsdata_p)

            trialids_b = np.unique(stopsdata_b[:, 2])  # make array of unique trial numbers
            srbin_mean, srbin_std, shuffled_mean, shuffled_std = shuffle_analysis_pertrial3(stopsdata_b,trialids_b)  # get average real stops & shuffled stops per lcoation bin
            zscore_b = z_score1(srbin_mean, srbin_std, shuffled_mean, shuffled_std)  # calculate z-scores
            firststopstorebeac[dcount, session_count,:,1] = zscore_b  # store zscores
            if stopsdata_nb.size > 0:  # if there is non-beaconed data
                trialids_nb = np.unique(stopsdata_nb[:, 2])  # make array of unique trial numbers
                srbin_mean, srbin_std, shuffled_mean, shuffled_std = shuffle_analysis_pertrial3(stopsdata_nb, trialids_nb)  # get average real stops & shuffled stops per lcoation bin
                zscore_nb = z_score1(srbin_mean, srbin_std, shuffled_mean, shuffled_std)  # calculate z-scores
                firststopstorenbeac[dcount, session_count,:,1] = zscore_nb  # store zscores
            if stopsdata_p.size > 0:  # if there is probe data
                trialids_p = np.unique(stopsdata_p[:, 2])  # make array of unique trial numbers
                srbin_mean, srbin_std, shuffled_mean, shuffled_std = shuffle_analysis_pertrial3(stopsdata_p, trialids_p)  # get average real stops & shuffled stops per lcoation bin
                zscore_p = z_score1(srbin_mean, srbin_std, shuffled_mean, shuffled_std)  # calculate z-scores
                firststopstoreprobe[dcount, session_count,:,1] = zscore_p  # store zscores
                session_count += 1


    # AVERAGE DATA FOR PLOTS
    # stack experiments then average over days then mice
    con_b1 = np.nanmean(((firststopstorebeac[0, :, :,1])), axis=0)
    con_nb1 = np.nanmean(((firststopstorenbeac[0, :, :,1])), axis=0)
    con_p1 = np.nanmean(((firststopstoreprobe[0,:, :, 1])), axis=0)
    sdcon_b1 = np.nanstd(((firststopstorebeac[0, :, :,1])), axis=0)/math.sqrt(session_count)
    sdcon_nb1 = np.nanstd(((firststopstorenbeac[0, :, :,1])), axis=0)/ math.sqrt(session_count)
    sdcon_p1 = np.nanstd(((firststopstoreprobe[0, :, :,1])), axis=0)/ math.sqrt(session_count)


    # PLOT GRAPHS

    bins = np.arange(0.5,n_bins+0.5,1) # track bins

    fig = plt.figure(figsize = (12,4))
    ax = fig.add_subplot(1,3,1)
    ax.set_title('Beaconed', fontsize=20, verticalalignment='bottom', style='italic')  # title
    ax.axvspan(rz_start, rz_end, facecolor='g', alpha=0.25, hatch = '/', linewidth =0) # green box spanning the rewardzone - to mark reward zone
    ax.axvspan(0, track_start, facecolor='k', alpha=0.15, hatch = '/', linewidth =0) # black box
    ax.axvspan(track_end, 20, facecolor='k', alpha=0.15, hatch = '/', linewidth =0)# black box
    ax.axvline(0, linewidth = 3, color = 'black') # bold line on the y axis
    ax.axhline(-10, linewidth = 3, color = 'black') # bold line on the x axis
    ax.axhline(0, linewidth = 1,ls='--', color = 'black') # bold line on the x axis
    #ax.plot(bins*5,con_b,color = 'red',label = 'AAV-fl-GFP', linewidth = 2) #plot becaoned trials
    #ax.fill_between(bins*5,con_b-sdcon_b,con_b+sdcon_b, facecolor = 'red', alpha = 0.3)
    ax.plot(bins,con_b1,'',color = 'blue',label = 'AAV-fl-GFP', linewidth = 2) #plot becaoned trials
    ax.fill_between(bins,con_b1-sdcon_b1,con_b1+sdcon_b1, facecolor = 'blue', alpha = 0.3)
    ax.tick_params(axis='x', pad = 10, top='off', right = 'off', direction = 'out',width = 2, length = 7,labelsize =16)
    ax.tick_params(axis='y', pad = 10, top='off', right = 'off', direction = 'out',width = 2, length = 7,labelsize =16)
    ax.set_xlim(0,20)
    ax.set_ylim(-10,35)
    adjust_spines(ax, ['left','bottom']) # removes top and right spines
    ax.locator_params(axis = 'x', nbins=3) # set number of ticks on x axis
    ax.locator_params(axis = 'y', nbins=5) # set number of ticks on y axis
    ax.set_xticklabels(['0', '10', '20'])
    ax.set_yticklabels(['-10','0','10','20', '30'])
    ax = plt.ylabel('Stops (Zscore)', fontsize=16, labelpad = 18)

    ax = fig.add_subplot(1,3,2) #stops per trial
    ax.set_title('Non-Beaconed', fontsize=20, verticalalignment='bottom', style='italic')  # title
    ax.axvspan(rz_start, rz_end, facecolor='g', alpha=0.25, hatch = '/', linewidth =0) # green box spanning the rewardzone - to mark reward zone
    ax.axvspan(0, track_start, facecolor='k', alpha=0.15, hatch = '/', linewidth =0) # black box
    ax.axvspan(track_end, 20, facecolor='k', alpha=0.15, hatch = '/', linewidth =0)# black box
    ax.axvline(0, linewidth = 3, color = 'black') # bold line on the y axis
    ax.axhline(-10, linewidth = 3, color = 'black') # bold line on the x axis
    ax.axhline(0, linewidth = 1,ls='--', color = 'black') # bold line on the x axis
    #ax.plot(bins*5,con_nb,color = 'red', linewidth = 2) #plot becaoned trials
    #ax.fill_between(bins*5,con_nb-sdcon_nb,con_nb+sdcon_nb, facecolor = 'red', alpha = 0.3)
    ax.plot(bins,con_nb1,color = 'blue', linewidth = 2) #plot becaoned trials
    ax.fill_between(bins,con_nb1-sdcon_nb1,con_nb1+sdcon_nb1, facecolor = 'blue', alpha = 0.3)
    ax.tick_params(axis='x', pad = 10, top='off', right = 'off', direction = 'out',width = 2, length = 7,labelsize =16)
    ax.tick_params(axis='y', pad = 10, top='off', right = 'off', direction = 'out',width = 2, length = 7,labelsize =16)
    ax.set_xlim(0,20)
    ax.set_ylim(-10,35)
    adjust_spines(ax, ['left','bottom']) # re;moves top and right spines
    ax.locator_params(axis = 'x', nbins=3) # set number of ticks on x axis
    ax.locator_params(axis = 'y', nbins=5) # set number of ticks on y axis
    ax.set_xticklabels(['0', '10', '20'])
    ax.set_yticklabels(['','','','', ''])
    ax = plt.xlabel('Location (VU)', fontsize=16, labelpad = 18)

    ax = fig.add_subplot(1,3,3) #stops per trial
    ax.set_title('Probe', fontsize=20, verticalalignment='bottom', style='italic')  # title
    ax.axvspan(rz_start, rz_end, facecolor='g', alpha=0.25, hatch = '/', linewidth =0) # green box spanning the rewardzone - to mark reward zone
    ax.axvspan(0, track_start, facecolor='k', alpha=0.15, hatch = '/', linewidth =0) # black box
    ax.axvspan(track_end, 20, facecolor='k', alpha=0.15, hatch = '/', linewidth =0)# black box
    ax.axhline(0, linewidth = 1,ls='--', color = 'black') # bold line on the x axis
    ax.axvline(0, linewidth = 3, color = 'black') # bold line on the y axis
    ax.axhline(-10, linewidth = 3, color = 'black') # bold line on the x axis
    #ax.plot(bins*5,con_p,color = 'red', label = 'Beaconed', linewidth = 2) #plot becaoned trials
    #ax.fill_between(bins*5,con_p-sdcon_p,con_p+sdcon_p, facecolor = 'red', alpha = 0.3)
    ax.plot(bins,con_p1,color = 'blue', label = 'Beaconed', linewidth = 2) #plot becaoned trials
    ax.fill_between(bins,con_p1-sdcon_p1,con_p1+sdcon_p1, facecolor = 'blue', alpha = 0.3)
    ax.tick_params(axis='x', pad = 10, top='off', right = 'off', direction = 'out',width = 2, length = 7,labelsize =16)
    ax.tick_params(axis='y', pad = 10, top='off', right = 'off', direction = 'out',width = 2, length = 7,labelsize =16)
    ax.set_xlim(0,20)
    ax.set_ylim(-10,35)
    adjust_spines(ax, ['left','bottom']) # removes top and right spines
    ax.locator_params(axis = 'x', nbins=3) # set number of ticks on x axis
    ax.locator_params(axis = 'y', nbins=5) # set number of ticks on y axis
    ax.set_xticklabels(['0', '10', '20'])
    ax.set_yticklabels(['','','','', ''])

    plt.subplots_adjust(hspace = .35, wspace = .35,  bottom = 0.25, left = 0.15, right = 0.82, top = 0.85)


    fig.savefig(save_path, dpi=200)
    plt.close()
Esempio n. 5
0
def plot_fig1E(session_paths, save_path):


    days = [1]
    # specify mouse/mice and day/s to analyse
     # choose specific day/s
    number_of_trials = 1000 # arbitrarily large amount of trials so we can catch all the trials

    # Arrays for storing data (output)
    firststopstorebeac = np.zeros(((number_of_trials), len(session_paths)))
    firststopstorenbeac = np.zeros(((number_of_trials), len(session_paths)))
    firststopstoreprobe = np.zeros(((number_of_trials), len(session_paths)))
    firststopstorebeac[:,:] = np.nan
    firststopstorenbeac[:,:] = np.nan
    firststopstoreprobe[:,:] = np.nan

    sd_con_FirstStopsstorebeac = np.zeros(((number_of_trials), len(session_paths)))
    sd_con_FirstStopsstorenbeac = np.zeros(((number_of_trials), len(session_paths)))
    sd_con_FirstStopsstoreprobe = np.zeros(((number_of_trials), len(session_paths)))
    sd_con_FirstStopsstorebeac[:, :] = np.nan
    sd_con_FirstStopsstorenbeac[:, :] = np.nan
    sd_con_FirstStopsstoreprobe[:, :] = np.nan

    # For each day and mouse, pull raw data, calculate first stops and store data
    for dcount,day in enumerate(days):
        session_count = 0
        for session_path in session_paths:
            saraharray, track_start, track_end = translate_to_legacy_format(session_path)

            rz_start = saraharray[0, 11]
            rz_end = saraharray[0, 12]

            # make array of trial number for each row in dataset
            trialarray = maketrialarray(saraharray) # write array of trial per row in datafile
            saraharray[:,9] = trialarray[:,0] # replace trial column in dataset *see README for why this is done*

            # split data by trial type
            dailymouse_b = np.delete(saraharray, np.where(saraharray[:, 8] > 0), 0)
            dailymouse_nb = np.delete(saraharray, np.where(saraharray[:, 8] != 10), 0)
            dailymouse_p = np.delete(saraharray, np.where(saraharray[:, 8] != 20), 0)

            # get stops
            stops_b = extractstops_HUMAN(dailymouse_b)
            stops_nb = extractstops_HUMAN(dailymouse_nb)
            stops_p= extractstops_HUMAN(dailymouse_p)

            #filterstops
            stops_b = filterstops(stops_b)
            stops_nb = filterstops(stops_nb)
            stops_p = filterstops(stops_p)

            # get first stop for each trial

            trarray = np.unique(trialarray[:, 0])  # get unique trial numbers

            stops_f_b = FirstStops_humans(trarray, stops_b, track_start, track_end)  # get locations of first stop for each trial
            #beac = np.nanmean(stops_f_b, axis=0)  # find average first stop location
            #sdbeac = np.nanstd(stops_f_b, axis=0)  # get sd of first stop location

            if stops_nb.size > 0:
                stops_f_nb = FirstStops_humans(trarray, stops_nb, track_start, track_end)  # get locations of first stop for each trial
                #nbeac = np.nanmean(stops_f_nb, axis=0)  # find average first stop location
                #sdnbeac = np.nanstd(stops_f_nb, axis=0)  # get sd of first stop location
            if stops_p.size > 0:
                stops_f_p = FirstStops_humans(trarray, stops_p, track_start, track_end)  # get locations of first stop for each trial
                #probe = np.nanmean(stops_f_p, axis=0)  # find average first stop location
                #sdprobe = np.nanstd(stops_f_p, axis=0)  # get sd of first stop location

            for i in range(len(stops_f_b)):
                firststopstorebeac[i, session_count] = stops_f_b[i][0]
                #sd_con_FirstStopsstorebeac[dcount, session_count] = beac[0]

            if stops_nb.size > 0:
                for i in range(len(stops_f_nb)):
                    firststopstorenbeac[i, session_count] = stops_f_nb[i][0]
                    #sd_con_FirstStopsstorenbeac[dcount, session_count] = nbeac[0]

            if stops_p.size > 0:
                for i in range(len(stops_f_p)):
                    firststopstoreprobe[i, session_count] = stops_f_p[i][0]
                    #sd_con_FirstStopsstoreprobe[dcount, session_count] = probe[0]

            session_count += 1


            # Average over days for all mice

    con_beac = np.nanmean(((firststopstorebeac)), axis=1)
    con_beac = con_beac[~np.isnan(con_beac)]
    con_nbeac = np.nanmean(((firststopstorenbeac)), axis=1)
    con_nbeac = con_nbeac[~np.isnan(con_nbeac)]
    con_probe = np.nanmean(((firststopstoreprobe)), axis=1)
    con_probe = con_probe[~np.isnan(con_probe)]
    sd_con_beac = np.nanstd(((firststopstorebeac)), axis=1) / math.sqrt(session_count)
    sd_con_beac = sd_con_beac[~np.isnan(sd_con_beac)]
    sd_con_nbeac = np.nanstd(((firststopstorenbeac)), axis=1) / math.sqrt(session_count)
    sd_con_nbeac = sd_con_nbeac[~np.isnan(sd_con_nbeac)]
    sd_con_probe = np.nanstd(((firststopstoreprobe)), axis=1) / math.sqrt(session_count)
    sd_con_probe = sd_con_probe[~np.isnan(sd_con_probe)]

    # PLOT GRAPHS

    b_trial_max = np.arange(0,len(con_beac),1)
    nb_trial_max = np.arange(0,len(con_nbeac),1)
    p_trial_max = np.arange(0,len(sd_con_probe),1)

    # array of days
    #x = con_beac[0]

    # plot average first stop over days for all mice
    fig = plt.figure(figsize = (12,4))  # make figure, this shape (width, height)
    ax = fig.add_subplot(1,3,1)
    ax.set_title('Beaconed', fontsize=20, verticalalignment='bottom', style='italic') #title
    ax.axhspan(rz_start, rz_end, facecolor='g', alpha=0.15, hatch='/',linewidth=0)  # green box of reward zone
    ax.axhspan(0, 4, facecolor='k', alpha=0.15, hatch='/', linewidth=0)  # black box (4 is used for appearance)
    ax.axhline(4, linewidth=1, ls='--', color='black')  # mark black box border
    ax.axvline(0, linewidth=3, color='black')  # bold line on the y axis
    ax.axhline(2, linewidth=3, color='black')  # bold line on the x axis

    ax.plot(b_trial_max, con_beac, 'o',color = '0.3', label = 'Non reward zone score', linewidth = 2, markersize = 6, markeredgecolor = 'black')
    ax.errorbar(b_trial_max,con_beac,sd_con_beac, fmt = 'o', color = '0.3', capsize = 1.5, markersize = 2, elinewidth = 1.5)
    ax.tick_params(axis='x', pad = 10, top='off', right = 'off', direction = 'out',width = 2, length = 7,labelsize =15) # tick parameters: pad is tick label relative to
    ax.tick_params(axis='y', pad = 10, top='off', right = 'off', direction = 'out',width = 2, length = 7,labelsize =15)
    ax.set_xlim(0,len(b_trial_max))
    ax.set_ylim(2,rz_end+2)
    adjust_spines(ax, ['left','bottom']) # remove right and top axis
    plt.locator_params(nbins=7, axis ='y') # set tick number on y axis
    plt.locator_params(nbins=3, axis ='x') # set tick number on x axis
    ax = plt.ylabel('Location (VU)', fontsize=16, labelpad = 18)

    ax = fig.add_subplot(1,3,2)
    ax.set_title('Non-Beaconed', fontsize=20, verticalalignment='bottom', style='italic')
    ax.axhspan(rz_start, rz_end, facecolor='g', alpha=0.15, hatch='/', linewidth=0)  # green box spanning the rewardzone - to mark reward zone
    ax.axhspan(0, 4, facecolor='k', alpha=0.15, hatch='/', linewidth=0)  # black box
    ax.axhline(4, linewidth=1, ls='--', color='black')  # mark black box border
    ax.axvline(0, linewidth = 3, color = 'black')# bold line on the y axis
    ax.axhline(2, linewidth = 3, color = 'black')# bold line on the x axis

    ax.plot(nb_trial_max, con_nbeac, 'o', color = '0.3', label = 'Non reward zone score', linewidth = 2, markersize = 6, markeredgecolor = 'black')
    ax.errorbar(nb_trial_max,con_nbeac,sd_con_nbeac, fmt = 'o', color = '0.3', capsize = 1.5, markersize = 2, elinewidth = 1.5)
    ax.tick_params(axis='x', pad = 10, top='off', right = 'off', direction = 'out',width = 2, length = 7,labelsize =15)
    ax.tick_params(axis='y', pad = 10, top='off', right = 'off', direction = 'out',width = 2, length = 7,labelsize =15)
    ax.set_xlim(0,len(nb_trial_max))
    ax.set_ylim(2,rz_end+2)
    adjust_spines(ax, ['left','bottom']) # remove right and top axis
    plt.locator_params(nbins=7, axis ='y') # set tick number on y axis
    plt.locator_params(nbins=3, axis ='x') # set tick number on x axis
    ax = plt.xlabel('Number of trials', fontsize=16,labelpad=18)

    ax = fig.add_subplot(1,3,3)
    ax.set_title('Probe', fontsize=20, verticalalignment='bottom', style='italic')  # title
    ax.axhspan(rz_start, rz_end, facecolor='g', alpha=0.15, hatch='/', linewidth=0)  # green box of reward zone
    ax.axhspan(0, 4, facecolor='k', alpha=0.15, hatch='/', linewidth=0)  # black box (4 is used for appearance)
    ax.axhline(4, linewidth=1, ls='--', color='black')  # mark black box border
    ax.axvline(0, linewidth=3, color='black')  # bold line on the y axis
    ax.axhline(2, linewidth=3, color='black')  # bold line on the x axis

    ax.plot(p_trial_max, con_probe, 'o', color = '0.3', label = 'Non reward zone score', linewidth = 2, markersize = 6, markeredgecolor = 'black')
    ax.errorbar(p_trial_max,con_probe,sd_con_probe, fmt = 'o', color = '0.3', capsize = 1.5, markersize = 2, elinewidth = 1.5)
    ax.tick_params(axis='x', pad = 10, top='off', right = 'off', direction = 'out',width = 2, length = 7,labelsize =15)
    ax.tick_params(axis='y', pad = 10, top='off', right = 'off', direction = 'out',width = 2, length = 7,labelsize =15)
    ax.set_xlim(0,len(p_trial_max))
    ax.set_ylim(2,rz_end+2)
    adjust_spines(ax, ['left','bottom']) # remove right and top axis
    plt.locator_params(nbins=7, axis ='y') # set tick number on y axis
    plt.locator_params(nbins=3, axis ='x') # set tick number on x axis

    plt.subplots_adjust(hspace = .35, wspace = .35,  bottom = 0.25, left = 0.15, right = 0.82, top = 0.85)

    fig.savefig(save_path, dpi=200)
    plt.close()
Esempio n. 6
0
def plot_fig1D(session_paths, save_path):

    days = [1]
    n_bins = 20
    # specify mouse/mice and day/s to analyse
    days = ['Day' + str(int(x)) for x in np.arange(1)]

    # Arrays for storing data (output)
    firststopstorebeac = np.zeros((len(days), len(session_paths), n_bins, 2))
    firststopstorenbeac = np.zeros((len(days), len(session_paths), n_bins, 2))
    firststopstoreprobe = np.zeros((len(days), len(session_paths), n_bins, 2))
    firststopstorebeac[:, :, :, :] = np.nan
    firststopstorenbeac[:, :, :, :] = np.nan
    firststopstoreprobe[:, :, :, :] = np.nan

    # For each day and mouse, pull raw data, calculate first stops and store data
    for dcount, day in enumerate(days):
        session_count = 0
        for session_path in session_paths:
            saraharray, track_start, track_end = translate_to_legacy_format(
                session_path)

            rz_start = saraharray[0, 11]
            rz_end = saraharray[0, 12]

            # make array of trial number for each row in dataset
            trialarray = maketrialarray(
                saraharray)  # write array of trial per row in datafile
            saraharray[:,
                       9] = trialarray[:,
                                       0]  # replace trial column in dataset *see README for why this is done*

            # split data by trial type
            dailymouse_b = np.delete(saraharray,
                                     np.where(saraharray[:, 8] > 0), 0)
            dailymouse_nb = np.delete(saraharray,
                                      np.where(saraharray[:, 8] != 10), 0)
            dailymouse_p = np.delete(saraharray,
                                     np.where(saraharray[:, 8] != 20), 0)

            # get stops
            stops_b = extractstops_HUMAN(dailymouse_b)
            stops_nb = extractstops_HUMAN(dailymouse_nb)
            stops_p = extractstops_HUMAN(dailymouse_p)

            #filterstops
            stops_b = filterstops(stops_b)
            stops_nb = filterstops(stops_nb)
            stops_p = filterstops(stops_p)

            # get first stop for each trial

            trarray = np.arange(np.min(saraharray[:, 9]),
                                np.max(saraharray[:, 9] + 0.1),
                                1)  # array of trial numbers
            beac = []
            nbeac = []
            probe = []  # make empty arrays to store data
            trialids_b = np.unique(stops_b[:, 2])  # find unique trial numbers
            stops_f_b = FirstStops_humans(
                trarray, stops_b, track_start,
                track_end)  # get locations of first stop for each trial
            stops_f_b = create_srdata(stops_f_b,
                                      trialids_b)  # bin first stop data
            beac = np.nanmean(
                stops_f_b,
                axis=0)  # average times mouse stops first in each bin
            if stops_nb.size > 0:
                trialids_nb = np.unique(stops_nb[:, 2])
                stops_f_nb = FirstStops_humans(
                    trarray, stops_nb, track_start,
                    track_end)  # get locations of first stop for each trial
                stops_f_nb = create_srdata(stops_f_nb,
                                           trialids_nb)  # bin first stop data
                nbeac = np.nanmean(
                    stops_f_nb,
                    axis=0)  # average times mouse stops first in each bin
            if stops_p.size > 0:
                trialids_p = np.unique(stops_p[:, 2])
                stops_f_p = FirstStops_humans(
                    trarray, stops_p, track_start,
                    track_end)  # get locations of first stop for each trial
                stops_f_p = create_srdata(stops_f_p,
                                          trialids_p)  # bin first stop data
                probe = np.nanmean(
                    stops_f_p,
                    axis=0)  # average times mouse stops first in each bin

            # store data
            #if mcount == 3 or mcount == 5 or mcount == 6 or mcount == 7 or mcount == 8:
            firststopstorebeac[dcount, session_count, :,
                               0] = beac  # store first stop data
            srbin_mean, srbin_std, shuffled_mean, shuffled_std = shuffle_analysis_pertrial3(
                stops_b, trialids_b)  # get average stops per location bin
            firststopstorebeac[dcount, session_count, :,
                               1] = srbin_mean  # store stops data
            if stops_nb.size > 0:
                firststopstorenbeac[dcount, session_count, :,
                                    0] = nbeac  # store first stop data
                srbin_mean, srbin_std, shuffled_mean, shuffled_std = shuffle_analysis_pertrial3(
                    stops_nb,
                    trialids_nb)  # get average stops per location bin
                firststopstorenbeac[dcount, session_count, :,
                                    1] = srbin_mean  # store stops data
            if stops_p.size > 0:
                firststopstoreprobe[dcount, session_count, :,
                                    0] = probe  # store first stop data
                srbin_mean, srbin_std, shuffled_mean, shuffled_std = shuffle_analysis_pertrial3(
                    stops_p, trialids_p)  # get average stops per location bin
                firststopstoreprobe[dcount, session_count, :,
                                    1] = srbin_mean  # store stops data
            session_count += 1

    # Average over days for all mice

    # week 1 (first stop)
    con_beac_w1 = np.nanmean(((firststopstorebeac[0, :, :, 0])), axis=0)
    con_nbeac_w1 = np.nanmean(((firststopstorenbeac[0, :, :, 0])), axis=0)
    con_probe_w1 = np.nanmean(((firststopstoreprobe[0, :, :, 0])), axis=0)
    sd_con_beac_w1 = np.nanstd(
        ((firststopstorebeac[0, :, :, 0])), axis=0) / math.sqrt(session_count)
    sd_con_nbeac_w1 = np.nanstd(
        ((firststopstorenbeac[0, :, :, 0])), axis=0) / math.sqrt(session_count)
    sd_con_probe_w1 = np.nanstd(
        ((firststopstoreprobe[0, :, :, 0])), axis=0) / math.sqrt(session_count)
    # week 1 (all stops)
    con_beac1_w1 = np.nanmean(((firststopstorebeac[0, :, :, 1])), axis=0)
    con_nbeac1_w1 = np.nanmean(((firststopstorenbeac[0, :, :, 1])), axis=0)
    con_probe1_w1 = np.nanmean(((firststopstoreprobe[0, :, :, 1])), axis=0)
    sd_con_beac1_w1 = np.nanstd(
        ((firststopstorebeac[0, :, :, 1])), axis=0) / math.sqrt(session_count)
    sd_con_nbeac1_w1 = np.nanstd(
        ((firststopstorenbeac[0, :, :, 1])), axis=0) / math.sqrt(session_count)
    sd_con_probe1_w1 = np.nanstd(
        ((firststopstoreprobe[0, :, :, 1])), axis=0) / math.sqrt(session_count)
    '''
    # week 4 (first stop)
    con_beac_w4 = np.nanmean(np.nanmean(((firststopstorebeac[18:22,:,:,0])), axis = 0), axis = 0)
    con_nbeac_w4 = np.nanmean(np.nanmean(((firststopstorenbeac[18:22,:,:,0])), axis =0), axis = 0)
    con_probe_w4 = np.nanmean(np.nanmean(((firststopstoreprobe[18:22,:,:,0])), axis = 0), axis = 0)
    sd_con_beac_w4 = np.nanstd(np.nanmean(((firststopstorebeac[18:22,:,:,0])), axis = 0), axis = 0)/math.sqrt(8)
    sd_con_nbeac_w4 = np.nanstd(np.nanmean(((firststopstorenbeac[18:22,:,:,0])), axis =0), axis = 0)/math.sqrt(8)
    sd_con_probe_w4 = np.nanstd(np.nanmean(((firststopstoreprobe[18:22,:,:,0])), axis = 0), axis = 0)/math.sqrt(8)
    # week 4 (all stops)
    con_beac1_w4 = np.nanmean(np.nanmean(((firststopstorebeac[18:22,:,:,1])), axis = 0), axis = 0)
    con_nbeac1_w4 = np.nanmean(np.nanmean(((firststopstorenbeac[18:22,:,:,1])), axis =0), axis = 0)
    con_probe1_w4 = np.nanmean(np.nanmean(((firststopstoreprobe[18:22,:,:,1])), axis = 0), axis = 0)
    sd_con_beac1_w4 = np.nanstd(np.nanmean(((firststopstorebeac[18:22,:,:,1])), axis = 0), axis = 0)/math.sqrt(8)
    sd_con_nbeac1_w4 = np.nanstd(np.nanmean(((firststopstorenbeac[18:22,:,:,1])), axis =0), axis = 0)/math.sqrt(8)
    sd_con_probe1_w4 = np.nanstd(np.nanmean(((firststopstoreprobe[18:22,:,:,1])), axis = 0), axis = 0)/math.sqrt(8)
    '''

    # PLOT GRAPHS

    bins = np.arange(0.5, n_bins + 0.5, 1)

    # first stop histogram
    fig = plt.figure(figsize=(12, 4))
    ax = fig.add_subplot(1, 3, 1)  #stops per trial
    ax.set_title('Beaconed',
                 fontsize=20,
                 verticalalignment='bottom',
                 style='italic')  # title
    ax.axvspan(
        rz_start, rz_end, facecolor='g', alpha=0.25, hatch='/',
        linewidth=0)  # green box spanning the rewardzone - to mark reward zone
    ax.axvspan(0,
               track_start,
               facecolor='k',
               alpha=0.15,
               hatch='/',
               linewidth=0)  # black box
    ax.axvspan(track_end,
               20,
               facecolor='k',
               alpha=0.15,
               hatch='/',
               linewidth=0)  # black box
    ax.axvline(0, linewidth=3, color='black')  # bold line on the y axis
    ax.axhline(0, linewidth=3, color='black')  # bold line on the x axis
    ax.plot(bins, con_beac_w1, color='blue', label='Beaconed',
            linewidth=2)  #plot becaoned trials
    ax.fill_between(bins,
                    con_beac_w1 - sd_con_beac_w1,
                    con_beac_w1 + sd_con_beac_w1,
                    facecolor='blue',
                    alpha=0.3)
    #ax.plot(bins,con_beac_w4,color = 'red',label = 'Beaconed', linewidth = 2) #plot becaoned trials
    #ax.fill_between(bins,con_beac_w4-sd_con_beac_w4,con_beac_w4+sd_con_beac_w4, facecolor = 'red', alpha = 0.3)
    ax.tick_params(axis='x',
                   pad=10,
                   top='off',
                   right='off',
                   direction='out',
                   width=2,
                   length=7,
                   labelsize=16)
    ax.tick_params(axis='y',
                   pad=10,
                   top='off',
                   right='off',
                   direction='out',
                   width=2,
                   length=7,
                   labelsize=16)
    ax.set_xlim(0, 20)
    ax.set_ylim(0, 0.95)
    adjust_spines(ax, ['left', 'bottom'])  # removes top and right spines
    ax.locator_params(axis='x', nbins=3)  # set number of ticks on x axis
    ax.locator_params(axis='y', nbins=4)  # set number of ticks on y axis
    ax.set_xticklabels(['0', '10', '20'])
    ax.set_yticklabels(['0', '0.3', '0.6', '0.9'])
    ax.set_ylabel('1st stop probability', fontsize=16, labelpad=18)

    ax = fig.add_subplot(1, 3, 2)  #stops per trial
    ax.set_title('Non-Beaconed',
                 fontsize=20,
                 verticalalignment='bottom',
                 style='italic')  # title
    ax.axvspan(
        rz_start, rz_end, facecolor='g', alpha=0.25, hatch='/',
        linewidth=0)  # green box spanning the rewardzone - to mark reward zone
    ax.axvspan(0,
               track_start,
               facecolor='k',
               alpha=0.15,
               hatch='/',
               linewidth=0)  # black box
    ax.axvspan(track_end,
               20,
               facecolor='k',
               alpha=0.15,
               hatch='/',
               linewidth=0)  # black box
    ax.axvline(0, linewidth=3, color='black')  # bold line on the y axis
    ax.axhline(0, linewidth=3, color='black')  # bold line on the x axis
    ax.plot(bins, con_nbeac_w1, color='blue',
            linewidth=2)  #plot becaoned trials
    ax.fill_between(bins,
                    con_nbeac_w1 - sd_con_nbeac_w1,
                    con_nbeac_w1 + sd_con_nbeac_w1,
                    facecolor='blue',
                    alpha=0.3)
    #ax.plot(bins,con_nbeac_w4,color = 'red', linewidth = 2) #plot becaoned trials
    #ax.fill_between(bins,con_nbeac_w4-sd_con_nbeac_w4,con_nbeac_w4+sd_con_nbeac_w4, facecolor = 'red', alpha = 0.3)
    ax.tick_params(axis='x',
                   pad=10,
                   top='off',
                   right='off',
                   direction='out',
                   width=2,
                   length=7,
                   labelsize=16)
    ax.tick_params(axis='y',
                   pad=10,
                   top='off',
                   right='off',
                   direction='out',
                   width=2,
                   length=7,
                   labelsize=16)
    ax.set_xlim(0, 20)
    ax.set_ylim(0, 0.95)
    adjust_spines(ax, ['left', 'bottom'])  # re;moves top and right spines
    ax.locator_params(axis='x', nbins=3)  # set number of ticks on x axis
    ax.locator_params(axis='y', nbins=4)  # set number of ticks on y axis
    ax.set_xticklabels(['0', '10', '20'])
    ax.set_yticklabels(['', '', '', ''])
    ax.set_xlabel('Distance (VU)', fontsize=16, labelpad=18)

    ax = fig.add_subplot(1, 3, 3)  #stops per trial
    ax.set_title('Probe',
                 fontsize=20,
                 verticalalignment='bottom',
                 style='italic')  # title
    ax.axvspan(
        rz_start, rz_end, facecolor='g', alpha=0.25, hatch='/',
        linewidth=0)  # green box spanning the rewardzone - to mark reward zone
    ax.axvspan(0,
               track_start,
               facecolor='k',
               alpha=0.15,
               hatch='/',
               linewidth=0)  # black box
    ax.axvspan(track_end,
               20,
               facecolor='k',
               alpha=0.15,
               hatch='/',
               linewidth=0)  # black box
    ax.axvline(0, linewidth=3, color='black')  # bold line on the y axis
    ax.axhline(0, linewidth=3, color='black')  # bold line on the x axis
    ax.plot(bins, con_probe_w1, color='blue', label='Beaconed',
            linewidth=2)  #plot becaoned trials
    ax.fill_between(bins,
                    con_probe_w1 - sd_con_probe_w1,
                    con_probe_w1 + sd_con_probe_w1,
                    facecolor='blue',
                    alpha=0.3)
    #ax.plot(bins,con_probe_w4,color = 'red', label = 'Beaconed', linewidth = 2) #plot becaoned trials
    #ax.fill_between(bins,con_probe_w4-sd_con_probe_w4,con_probe_w4+sd_con_probe_w4, facecolor = 'red', alpha = 0.3)
    ax.tick_params(axis='x',
                   pad=10,
                   top='off',
                   right='off',
                   direction='out',
                   width=2,
                   length=7,
                   labelsize=16)
    ax.tick_params(axis='y',
                   pad=10,
                   top='off',
                   right='off',
                   direction='out',
                   width=2,
                   length=7,
                   labelsize=16)
    ax.set_xlim(0, 20)
    ax.set_ylim(0, 0.95)
    adjust_spines(ax, ['left', 'bottom'])  # removes top and right spines
    ax.locator_params(axis='x', nbins=3)  # set number of ticks on x axis
    ax.locator_params(axis='y', nbins=4)  # set number of ticks on y axis
    ax.set_yticklabels(['', '', '', ''])
    ax.set_xticklabels(['0', '10', '20'])

    plt.subplots_adjust(hspace=.35,
                        wspace=.35,
                        bottom=0.25,
                        left=0.15,
                        right=0.82,
                        top=0.85)

    fig.savefig(save_path, dpi=200)
    plt.close()
def plot_fig1G (session_paths, save_path):

    days = [1] #
    number_of_trials = 1000 # arbitrarily large amount of trials so we can catch all the trials

    # Arrays for storing data (output)
    firststopstorebeac = np.zeros(((number_of_trials), len(session_paths)))
    firststopstorenbeac = np.zeros(((number_of_trials), len(session_paths)))
    firststopstoreprobe = np.zeros(((number_of_trials), len(session_paths)))
    firststopstorebeac[:,:] = np.nan
    firststopstorenbeac[:,:] = np.nan
    firststopstoreprobe[:,:] = np.nan

    sd_con_firststopstorebeac = np.zeros(((number_of_trials), len(session_paths)))
    sd_con_firststopstorenbeac = np.zeros(((number_of_trials), len(session_paths)))
    sd_con_firststopstoreprobe = np.zeros(((number_of_trials), len(session_paths)))
    sd_con_firststopstorebeac[:,:] = np.nan
    sd_con_firststopstorenbeac[:,:] = np.nan
    sd_con_firststopstoreprobe[:,:] = np.nan

    # For each day and mouse, pull raw data, calculate first stops and store data
    for dcount, day in enumerate(days):
        session_count = 0
        for session_path in session_paths:
            saraharray, track_start, track_end = translate_to_legacy_format(session_path)

            rz_start = saraharray[0, 11]
            rz_end = saraharray[0, 12]

            # make array of trial number for each row in dataset
            trialarray = maketrialarray(saraharray) # write array of trial per row in datafile
            saraharray[:,9] = trialarray[:,0] # replace trial column in dataset *see README for why this is done*

            # get stops and trial arrays
            dailymouse_b = np.delete(saraharray, np.where(saraharray[:, 8] > 0), 0) # delete all data not on beaconed tracks
            dailymouse_nb = np.delete(saraharray, np.where(saraharray[:, 8] != 10), 0)# delete all data not on non beaconed tracks
            dailymouse_p = np.delete(saraharray, np.where(saraharray[:, 8] != 20), 0)# delete all data not on

            # get stops
            stops_b = extractstops_HUMAN(dailymouse_b)
            stops_nb = extractstops_HUMAN(dailymouse_nb)
            stops_p= extractstops_HUMAN(dailymouse_p)

            # filter stops
            stops_b = filterstops(stops_b)
            stops_nb = filterstops(stops_nb)
            stops_p = filterstops(stops_p)

            if stops_b.size > 0:
                trialids_b = np.unique(stops_b[:, 2])  # make array of unique trial numbers

                for i in range(len(stops_b)):
                    srbin_mean, srbin_std, shuffled_mean, shuffled_std = shuffle_analysis_pertrial3(stops_b,trialids_b)  # get average real stops & shuffled stops per lcoation bin
                shuff_beac = z_score1(srbin_mean, srbin_std, shuffled_mean, shuffled_std)  # calculate z-scores
                bb = shuff_beac[3]; rz = shuff_beac[9]  # black box - reward zone zscore
                score = rz - bb


            if stops_nb.size > 0:
                trialids_nb = np.unique(stops_nb[:, 2])  # make array of unique trial numbers
                srbin_mean, srbin_std, shuffled_mean, shuffled_std = shuffle_analysis_pertrial3(stops_nb,trialids_nb)  # get average real stops & shuffled stops per lcoation bin
                shuff_nbeac = z_score1(srbin_mean, srbin_std, shuffled_mean, shuffled_std)  # calculate z-scores
                bb = shuff_nbeac[3];
                rz = shuff_nbeac[9]  # black box - reward zone zscore
                score = rz - bb
            for i in range(len(stops_nb)):
                firststopstorebeac[i, session_count] = score[i][0]

            if stops_p.size > 0:
                trialids_p = np.unique(stops_p[:, 2])  # make array of unique trial numbers
                srbin_mean, srbin_std, shuffled_mean, shuffled_std = shuffle_analysis_pertrial3(stops_p,trialids_p)  # get average real stops & shuffled stops per lcoation bin
                shuff_probe = z_score1(srbin_mean, srbin_std, shuffled_mean, shuffled_std)  # calculate z-scores
                bb = shuff_probe[3];
                rz = shuff_probe[9]  # black box - reward zone zscore
                score = rz - bb
                firststopstoreprobe[dcount, mcount] = score  # store data

                mcount += 1

         # get average real stops & shuffled stops per location bin
                zscore_b = z_score1(srbin_mean, srbin_std, shuffled_mean, shuffled_std)
            for i in range(len(stops_b)):
                firststopstorebeac[i, session_count] = zscore_b[i][0]

            if stops_nb.size>0:
                trialids_nb = np.unique(stops_nb[:, 2])
                srbin_mean, srbin_std, shuffled_mean, shuffled_std = shuffle_analysis_pertrial3(stops_nb,trialids_nb)  # get average real stops & shuffled stops per location bin
                zscore_nb = z_score1(srbin_mean, srbin_std, shuffled_mean, shuffled_std)
            for i in range(len(stops_nb)):
                firststopstorebeac[i, session_count] = zscore_nb[i][0]

            if stops_p.nb.size>0:
                trialids_p = np.unique(stops_p[:, 2])
                srbin_mean, srbin_std, shuffled_mean, shuffled_std = shuffle_analysis_pertrial3(stops_p,trialids_p)  # get average real stops & shuffled stops per location bin
                zscore_p = z_score1(srbin_mean, srbin_std, shuffled_mean, shuffled_std)
            for i in range(len(stops_p)):
                firststopstorebeac[i, session_count] = zscore_p[i][0]

                session_count +=1


    # stack experiments then average over days for each mouse
    con_b = np.nanmean(((firststopstorebeac)), axis = 1)
    con_b = con_b[~np.isnan(con_b)]
    con_nb = np.nanmean(((firststopstorenbeac)), axis =1)
    con_nb = con_nb[~np.isnan(con_nb)]
    con_p = np.nanmean(((firststopstoreprobe)), axis = 1)
    con_p = con_p[~np.isnan(con_nb)]
    sd_con_b = np.nanstd(((firststopstorebeac)), axis=1)/math.sqrt(session_count)
    sd_con_b = sd_con_b[~np.isnan(sd_con_b)]
    sd_con_nb = np.nanstd(((firststopstorenbeac)), axis=1)/math.sqrt(session_count)
    sd_con_nb = sd_con_nb[~np.isnan(sd_con_nb)]
    sd_con_p = np.nanstd(((firststopstoreprobe)), axis=1)/math.sqrt(session_count)
    sd_con_p = sd_con_p[~np.isnan(sd_con_p)]


    # PLOT GRAPHS

    bins = np.arange(0.5,21.5+1e-6,1) # track bins

    fig = plt.figure(figsize = (12,3))
    ax = fig.add_subplot(1,3,1)
    ax.axvline(0, linewidth = 3, color = 'black') # bold line on the y axis
    ax.axhline(-10, linewidth = 3, color = 'black') # bold line on the x axis
    ax.axhline(0, linewidth = 1,ls='--', color = 'black') # bold line on the x axis
    ax.plot(bins,con_b,'o',color = 'Black',label = 'AAV-fl-GFP', linewidth = 2, markersize = 6, markeredgecolor = 'black') #plot becaoned trials
    ax.errorbar(bins,con_b,sd_con_b, fmt = 'o', color = 'black', capsize = 2, capthick = 1, markersize = 4, elinewidth = 1.5)
    ax.tick_params(axis='x', pad = 10, top='off', right = 'off', direction = 'out',width = 2, length = 7,labelsize =16)
    ax.tick_params(axis='y', pad = 10, top='off', right = 'off', direction = 'out',width = 2, length = 7,labelsize =16)
    ax.set_xlim(0,22)
    ax.set_ylim(-10,20)
    adjust_spines(ax, ['left','bottom']) # removes top and right spines
    ax.locator_params(axis = 'x', nbins=3) # set number of ticks on x axis
    ax.locator_params(axis = 'y', nbins=4) # set number of ticks on y axis
    ax = plt.ylabel('Training day)', fontsize=16, labelpad = 18)

    ax = fig.add_subplot(1,3,2) #stops per trial
    ax.axvline(0, linewidth = 3, color = 'black') # bold line on the y axis
    ax.axhline(-10, linewidth = 3, color = 'black') # bold line on the x axis
    ax.axhline(0, linewidth = 1,ls='--', color = 'black') # bold line on the x axis
    ax.plot(bins,con_nb,'o', color = 'Black', linewidth = 2, markersize = 6, markeredgecolor = 'black') #plot becaoned trials
    ax.errorbar(bins,con_nb,sd_con_nb, fmt = 'o', color = 'black',  capsize = 2, capthick = 1, markersize = 4, elinewidth = 1.5)
    ax.tick_params(axis='x', pad = 10, top='off', right = 'off', direction = 'out',width = 2, length = 7,labelsize =16)
    ax.tick_params(axis='y', pad = 10, top='off', right = 'off', direction = 'out',width = 2, length = 7,labelsize =16)
    ax.set_xlim(0,22)
    ax.set_ylim(-10,20)
    adjust_spines(ax, ['left','bottom']) # re;moves top and right spines
    ax.locator_params(axis = 'x', nbins=3) # set number of ticks on x axis
    ax.locator_params(axis = 'y', nbins=4) # set number of ticks on y axis
    ax = plt.xlabel('Training day', fontsize=16, labelpad = 18)

    ax = fig.add_subplot(1,3,3) #stops per trial
    ax.axhline(0, linewidth = 1,ls='--', color = 'black') # bold line on the x axis
    ax.axvline(0, linewidth = 3, color = 'black') # bold line on the y axis
    ax.axhline(-10, linewidth = 3, color = 'black') # bold line on the x axis
    ax.plot(bins,con_p, 'o', color = 'Black',label = 'Beaconed', linewidth = 2, markersize = 6, markeredgecolor = 'black') #plot becaoned trials
    ax.errorbar(bins,con_p,sd_con_p, fmt = 'o', color = 'black',  capsize = 2, capthick = 1, markersize = 4, elinewidth = 1.5)
    ax.tick_params(axis='x', pad = 10, top='off', right = 'off', direction = 'out',width = 2, length = 7,labelsize =16)
    ax.tick_params(axis='y', pad = 10, top='off', right = 'off', direction = 'out',width = 2, length = 7,labelsize =16)
    ax.set_xlim(0,22)
    ax.set_ylim(-10,20)
    adjust_spines(ax, ['left','bottom']) # removes top and right spines
    ax.locator_params(axis = 'x', nbins=3) # set number of ticks on x axis
    ax.locator_params(axis = 'y', nbins=4) # set number of ticks on y axis
    ax = plt.xlabel('Training day', fontsize=16, labelpad = 18)

    plt.subplots_adjust(hspace = .35, wspace = .35,  bottom = 0.25, left = 0.15, right = 0.82, top = 0.85)

    fig.savefig(save_path, dpi=200)
    plt.close()