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(dailymouse_b)
 stopsdata_p = extractstops(dailymouse_p)
 
 # filter stops
 stops_b = filterstops(stopsdata_b)
 stops_p = filterstops(stopsdata_p)
 
 if stops_b.size>0:
     trialids_b = np.unique(stops_b[:, 2]) # find trial numbers
     srbin_mean, srbin_std, shuffled_mean, shuffled_std= shuffle_analysis_pertrial3(stops_b,trialids_b) # calculate real and shuffled stops along the track
     shuff_beac = z_score1(srbin_mean, srbin_std, shuffled_mean, shuffled_std) # calculate zscore for each bin of the track
     start_bb_b = shuff_beac[3]; start_rz_b = shuff_beac[9] # black box bin minus the reward zone bin
     end_bb_b = shuff_beac[17]; end_rz_b = shuff_beac[11] # black box bin minus the reward zone bin
     start_score_b = start_rz_b-start_bb_b # black box bin minus the reward zone bin
     end_score_b = end_rz_b-end_bb_b # black box bin minus the reward zone bin
 if stops_p.size >0:
     trialids_p = np.unique(stops_p[:, 2]) # find trial numbers
     srbin_mean, srbin_std, shuffled_mean, shuffled_std= shuffle_analysis_pertrial3(stops_p,trialids_p) # calculate real and shuffled stops along the track
     shuff_probe = z_score1(srbin_mean, srbin_std, shuffled_mean, shuffled_std) # calculate zscore for each bin of the track
     start_bb_p = shuff_probe[3]; start_rz_p = shuff_probe[9] # black box bin minus the reward zone bin
     end_bb_p = shuff_probe[17]; end_rz_p = shuff_probe[11] # black box bin minus the reward zone bin
     start_score_p = start_rz_b-start_bb_p # black box bin minus the reward zone bin
     end_score_p = end_rz_p-end_bb_p # black box bin minus the reward zone bin
 
 # store data
 if mcount == 0 or mcount == 2 or mcount == 3 or mcount == 9: # if control mouse
Example #2
0
        stops_p = extractstops(dailymouse_p)

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

        # Shuffle stops data & get zscores
        if mcount == 3 or mcount == 5 or mcount == 6 or mcount == 7 or mcount == 8:
            if stops_b.size > 0:
                trialids_b = np.unique(
                    stops_b[:, 2])  # make array of unique trial numbers
                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
                firststopstorebeac[dcount, mcount] = score  # store data
            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
Example #3
0
        # 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
Example #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()
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()
            avg_low_stops_p = np.nanmean(low_stops_p, axis=0)
            upper_stops_p = create_srdata(upper_p, h2_trials_p)
            avg_upper_stops_p = np.nanmean(upper_stops_p, axis=0)
            lower_stops_p = create_srdata(lower_p, l2_trials_p)
            avg_lower_stops_p = np.nanmean(lower_stops_p, axis=0)
            #store average stops
            s2_con_high_probe[mcount,:,0] = avg_high_stops_p
            s2_con_low_probe[mcount,:,0] = avg_low_stops_p
            s2_con_high_probe[mcount,:,1] = avg_upper_stops_p
            s2_con_low_probe[mcount,:,1] = avg_lower_stops_p
            stops = create_srdata(datastore, trialids)
            avg_stops= np.nanmean(stops, axis=0)
            allstops[mcount,:] = avg_stops
            #calculate zscores
            srbin_mean, srbin_std, shuffled_mean, shuffled_std = shuffle_analysis_pertrial3(high_p, h_trials_p )
            zscore_p = z_score1(srbin_mean, srbin_std, shuffled_mean, shuffled_std)
            Z_high_probe[mcount,:,0] = zscore_p
            srbin_mean, srbin_std, shuffled_mean, shuffled_std = shuffle_analysis_pertrial3( low_p, l_trials_p )
            zscore_p = z_score1(srbin_mean, srbin_std, shuffled_mean, shuffled_std)
            Z_low_probe[mcount,:,0] = zscore_p
            srbin_mean, srbin_std, shuffled_mean, shuffled_std = shuffle_analysis_pertrial3( upper_p, h2_trials_p )
            zscore_p = z_score1(srbin_mean, srbin_std, shuffled_mean, shuffled_std)
            Z_high_probe[mcount,:,1] = zscore_p
            srbin_mean, srbin_std, shuffled_mean, shuffled_std = shuffle_analysis_pertrial3( lower_p, l2_trials_p )
            zscore_p = z_score1(srbin_mean, srbin_std, shuffled_mean, shuffled_std)
            Z_low_probe[mcount,:,1] = zscore_p

            # find preferred stopping location & time to RZ for each quartile
            upper = (np.argmax(avg_upper_stops_p[3:17]))+3
            high = (np.argmax(avg_high_stops_p[3:17]))+3
            low = (np.argmax(avg_low_stops_p[3:17]))+3