duration = min(durations) windowSize = 60 velWindow = np.arange(600, duration, windowSize) startshock = 15 * 60 endshock = 30 * 60 + 30 * 2 eVelocity = np.zeros((len(e_shock), len(velWindow) - 1)) cVelocity = np.zeros((len(c_shock), len(velWindow) - 1)) for i in range(len(velWindow) - 1): startT = velWindow[i] endT = velWindow[i + 1] for exp in range(len(e_shock)): [expVel, et] = aba.getVelRaw(e_shock[exp], tRange=(startT, endT), smoothWinLen=sm) eVelocity[exp, i] = np.median(expVel) for cnt in range(len(c_shock)): [cntVel, ct] = aba.getVelRaw(c_shock[cnt], tRange=(startT, endT), smoothWinLen=sm) cVelocity[cnt, i] = np.median(cntVel) fig = pylab.figure(100, figsize=(6.5, 6)) pylab.clf() pylab.suptitle("Fish velocity traces during shocking") ax = pylab.subplot(111) for i in range(len(eVelocity)): xax = velWindow[1:] pylab.plot(xax, eVelocity[i], "k", alpha=0.3) # pylab.plot(xax,eVelocity[i]) pylab.plot(xax, eVelocity[1], "g", lw=3) pylab.plot(xax, eVelocity[2], "b", lw=3)
frametime = tracking[:,0] mintime = max(frametime)-min(frametime) return mintime #velocity analysis for shock periods, last n min, covering different acclimation times n=5 minutes = n * 60 e_maxtimes = [] for n in range(len(e_shockR)): mtime = getmintime(e_shockR[n]) e_maxtimes.append(mtime) e_mintimes = [x - minutes for x in e_maxtimes] eBaseVelEnd = [] for n in range(len(e_shockR)): velocity = aba.getVelRaw(e_shockR[n], (e_mintimes[n], e_maxtimes[n])) eBaseVelEnd.append(np.median(velocity)) c_maxtimes = [] for n in range(len(c_shockR)): mtime = getmintime(c_shockR[n]) c_maxtimes.append(mtime) c_mintimes = [x - minutes for x in c_maxtimes] cBaseVelEnd = [] for n in range(len(c_shockR)): cvelocity = aba.getVelRaw(c_shockR[n], (c_mintimes[n], c_maxtimes[n])) cBaseVelEnd.append(np.median(cvelocity)) #velocity locomation analysis eBaseVelStart1 = aba.getVelMulti(e_shockR, (0,450))
mintime = max(frametime)-min(frametime) return mintime #velocity analysis for shock periods, last n min, covering different acclimation times n=15 minutes = n * 60 sm = 15; #smooth over 15 frames e_maxtimes = [] for n in range(len(e_shock)): mtime = getmintime(e_shock[n]) e_maxtimes.append(mtime) e_mintimes = [x - minutes for x in e_maxtimes] eShockVel = [] for n in range(len(e_shock)): velocity = aba.getVelRaw(e_shock[n], tRange=(e_mintimes[n], e_maxtimes[n]),smoothWinLen=sm) eShockVel.append(np.median(velocity)) c_maxtimes = [] for n in range(len(c_shock)): mtime = getmintime(c_shock[n]) c_maxtimes.append(mtime) c_mintimes = [x - minutes for x in c_maxtimes] cShockVel = [] for n in range(len(c_shock)): cvelocity = aba.getVelRaw(c_shock[n], tRange=(c_mintimes[n], c_maxtimes[n]),smoothWinLen=sm) cShockVel.append(np.median(cvelocity)) #velocity analysis for starting shock periods, last m min, covering different acclimation times m=15