reward_beac = extractrewards(dailymouse_b)
 reward_nbeac = extractrewards(dailymouse_nb)
 
 # filter stops (removes stops 0.5 cm after a stop)
 stopsdata_b = filterstops(stopsdata_b)
 stopsdata_nb = filterstops(stopsdata_nb)
 stopsdata_p = filterstops(stopsdata_p)
 
 # extract trial numbers from data (only unique ones)
 trialids_b = np.unique(stopsdata_b[:, 2])
 trialids_nb = np.unique(stopsdata_nb[:, 2])
 if stopsdata_p.size > 0: # if there are probe trials
     trialids_p = np.unique(stopsdata_p[:, 2])
         
 # get mean stops per bin for real and shuffled data
 srbin_mean_b, srbin_std_b,shuffled_mean_b, shuffled_std_b = shuffle_analysis_pertrial3(stopsdata_b, trialids_b)
 srbin_mean_nb, srbin_std_nb, shuffled_mean_nb, shuffled_std_nb = shuffle_analysis_pertrial3(stopsdata_nb, trialids_nb)
 if stopsdata_p.size > 0:
     srbin_mean_p, srbin_std_p, shuffled_mean_p, shuffled_std_p = shuffle_analysis_pertrial3(stopsdata_p, trialids_p)
 
 # calculate average speed
 speed_beaconed = speed_per_trial(bins,saraharray,trialids_b)
 speed_nbeaconed = speed_per_trial(bins,saraharray,trialids_nb)
 if stopsdata_p.size>0: # if there are probe trials
     speed_probe = speed_per_trial(bins,saraharray,trialids_p)
     sd_speed_probe = np.nanstd(speed_probe,axis = 1)
 sd_speed_beaconed = np.nanstd(speed_beaconed,axis = 1)
 sd_speed_nbeaconed = np.nanstd(speed_nbeaconed,axis = 1)
 speed_beaconed = np.nanmean(speed_beaconed,axis = 1)
 speed_nbeaconed = np.nanmean(speed_nbeaconed,axis = 1)
 if stopsdata_p.size>0: # if there are probe trials
                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(
                trarray, stops_p)  # 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, mcount, :,
                               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, mcount, :,
                               1] = srbin_mean  # store stops data
            if stops_nb.size > 0:
                firststopstorenbeac[dcount, mcount, :,
                                    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, mcount, :,
                                    1] = srbin_mean  # store stops data
            if stops_p.size > 0:
                firststopstoreprobe[dcount, mcount, :,
                                    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
 # 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(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
        #extract stops
        stopsdata_b = extractstops(dailymouse_b)
        stopsdata_nb = extractstops(dailymouse_nb)
        stopsdata_p = extractstops(dailymouse_p)

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

        # Shuffle stops data & store data
        if mcount == 0 or mcount == 3 or mcount == 5 or mcount == 6 or mcount == 7:
            if stopsdata_b.size > 0:
                trialids_b = np.unique(
                    stopsdata_b[:, 2])  # get unique trial numbers
                srbin_mean, srbin_std, shuffled_mean, shuffled_std = shuffle_analysis_pertrial3(
                    stopsdata_b, trialids_b)  # get real and shuffled stops
                zscore_b = z_score1(srbin_mean, srbin_std, shuffled_mean,
                                    shuffled_std)  # calculate z-score
                firststopstorebeac[dcount, mcount, :] = zscore_b  # store data
            if stopsdata_nb.size > 0:
                trialids_nb = np.unique(
                    stopsdata_nb[:, 2])  # get unique trial numbers
                srbin_mean, srbin_std, shuffled_mean, shuffled_std = shuffle_analysis_pertrial3(
                    stopsdata_nb, trialids_nb)  # get real and shuffled stops
                zscore_nb = z_score1(srbin_mean, srbin_std, shuffled_mean,
                                     shuffled_std)  # calculate z-score
                firststopstorenbeac[dcount,
                                    mcount, :] = zscore_nb  # store data
            if stopsdata_p.size > 0:
                trialids_p = np.unique(
                    stopsdata_p[:, 2])  # get unique trial numbers
Esempio n. 5
0
                                 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, :,
Esempio n. 6
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. 7
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()
Esempio n. 8
0
        # filter stops
        stopsdata_b = filterstops(stopsdata_b)
        stopsdata_nb = filterstops(stopsdata_nb)
        stopsdata_p = filterstops(stopsdata_p)

        # get array of trial numbers
        trialids_b = np.unique(stopsdata_b[:, 2])
        trialids_nb = np.unique(stopsdata_nb[:, 2])
        trialids_p = np.unique(stopsdata_p[:, 2])

        #get location and trial number of rewards
        reward_beac = extractrewards(dailymouse_b)
        reward_nbeac = extractrewards(dailymouse_nb)

        # real and shuffled stop average
        srbin_mean_b, srbin_std_b, shuffled_mean_b, shuffled_std_b = shuffle_analysis_pertrial3(
            stopsdata_b, trialids_b)  # get average real and shuffled stops
        srbin_mean_nb, srbin_std_nb, shuffled_mean_nb, shuffled_std_nb = shuffle_analysis_pertrial3(
            stopsdata_nb, trialids_nb)  # get average real and shuffled stops
        if stopsdata_p.size > 0:
            srbin_mean_p, srbin_std_p, shuffled_mean_p, shuffled_std_p = shuffle_analysis_pertrial_tracks(
                stopsdata_p, trialids_p,
                tracklength / 10)  # get average real and shuffled stops

        # calculate average speed
        speed_beaconed = speed_per_trial(bins, saraharray, trialids_b)
        speed_nbeaconed = speed_per_trial(bins, saraharray, trialids_nb)
        if stopsdata_p.size > 0:
            speed_probe = speed_per_trial(bins, saraharray, trialids_p)
            sd_speed_probe = np.nanstd(speed_probe, axis=1)
        sd_speed_beaconed = np.nanstd(speed_beaconed, axis=1)
        sd_speed_nbeaconed = np.nanstd(speed_nbeaconed, axis=1)
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()
            low_stops_p = create_srdata(low_p, l_trials_p)
            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