def getBoutDur(mice, eventType, behType, trials): """ DEPRICATED: Needs major revision! """ print "DEPRICATED: Needs major revision!" # Load the data dataList = loadData(mice) # Load the events fileList = loopMice(mice, behType) eventList = getBeh(mice, fileList['Behaviour'], behType) durationData = pd.DataFrame() for mus, sess in mice: # Find the events boutDur = np.array([]) startList = eventList[mus][eventType[0]].dropna().values endList = eventList[mus][eventType[1]].dropna().values for i in range(trials[0] - 1, trials[1]): ind, start = find_nearest(dataList[mus].index.values, startList[i]) ind, end = find_nearest(dataList[mus].index.values, endList[i]) boutDur = np.append(boutDur, end - start) durationData[mus] = boutDur durationData.set_index(np.arange(trials[0], trials[1] + 1), inplace=True) return durationData
import matplotlib.patches as mpatches from imagingIO import loopMice from trials import markTrials from analysis import dffCalc, filtData, smoothData, normData # Start running the analysis mice = [(8404, 6), (8857, 3), (8864, 1)] behType = 'FR1' fs = 0.05 base = -5.0 duration = 30 trials=[1,12] # Locate the files fileList = loopMice(mice, behType) # Load the events eventList = getBeh(mice, fileList['Behaviour'], behType) # Load the data dataList = loadData(mice, behType) # dFF and plot again filtList = filtData(mice, dffCalc(mice, dataList, lowest=False), cutoff=5.0, order=6) dFFList = smoothData(mice, filtList, window=4) eventType = 'Eat_Start' eventsData = markTrials(mice, dataList, base=base, duration=duration, eventType=eventType, behType=behType, trials=trials, baselining=True) sem=eventsData.pivot_table(index=['Event', 'Cell'], columns='New_Time').sem() time = np.arange(base,duration,fs) print len(sem), len(time)