# 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(dailymouse_b) stops_nb = extractstops(dailymouse_nb) stops_p = extractstops(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
except KeyError: # if there is no datafile, skip that mouse & day print ('Error, no file') continue trialno = np.max(saraharray[:,9]) # total number of trials for that day and mouse (used later for defining y axis max) # make array of trial number for each row in dataset trialarray = maketrialarray(saraharray) saraharray[:,9] = trialarray[:,0] # replace trial column in dataset *see README for why this is done* # Extract data for beaconed, non-beaconed, probe 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_nb = extractstops(dailymouse_nb) stopsdata_p = extractstops(dailymouse_p) #get location and trial number of rewards 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])
trialno = np.amax( stopsdata[:, 9]) # find max trial number of current session stopsdata[:, 9] += max_trialno max_trialno += trialno stopsdata_p = np.vstack((stopsdata_p, stopsdata)) dcount += 1 if stopsdata_p.size > 0: if mcount == 3 or mcount == 5 or mcount == 7 or mcount == 8: # get trials trialids = np.unique(stopsdata_p[:, 9]) # for plotting stops against time timedata = timetostop( stopsdata_p, trialids) # add time from bb (replaces apsolute time) timedata = extractstops(timedata) # extract stops timedata = filterstops(timedata) # filter stops timestore = np.vstack( (timestore, timedata)) # store data for all mice if mcount == 3: time1 = timedata if mcount == 5: time2 = timedata if mcount == 6: time3 = timedata if mcount == 7: time4 = timedata if mcount == 8: time5 = timedata # for splitting data based on time to RZ trialids = np.unique(stopsdata_p[:,