def model(self, p, t, x, y): """Sum of two Gaussians in time, modulated by a 2D spatial Gaussian returns a vector of voltage values v of same length as t. x and y are vectors of x and y coordinates of each channel's spatial location. Output of this should be an (nchans, nt) matrix of modelled voltage values v""" return np.outer(g2(p[6], p[7], p[8], p[8], x, y), p[0]*g(p[1], p[2], t) + p[3]*g(p[4], p[5], t))
def __init__(self, p0, t, v, min1=50, min2=50, dmurange=(100, 500)): self.p0 = p0 self.t = t self.v = v self.min1 = min1 self.min2 = min2 self.dmurange = dmurange #cons = (self.con1, self.con2, self.con3, self.con4) self.cons = self.con0 self.calc() figure() plot(t, v, 'k.-') p = self.p plot(t, p[0]*g(p[1], p[2], t) + p[3]*g(p[4], p[5], t), 'r-')
def plot(self): t = self.t p = self.p for (V, x, y) in zip(self.V, self.x, self.y): figure() title('x, y = %r um' % ((x, y), )) plot(t, V, 'k.-') plot(t, g2(p[6], p[7], p[8], p[8], x, y) * p[0] * g(p[1], p[2], t), 'r-') plot(t, g2(p[6], p[7], p[8], p[8], x, y) * p[3] * g(p[4], p[5], t), 'g-') plot( t, g2(p[6], p[7], p[8], p[8], x, y) * (p[0] * g(p[1], p[2], t) + p[3] * g(p[4], p[5], t)), 'b-') gca().autoscale_view(tight=True, scalex=True, scaley=False) # tight fit to timepoints gca().set_ylim(-100, 100) figure() title('x, y = %r (model origin in space)' % ((p[6], p[7]), )) plot(t, p[0] * g(p[1], p[2], t) + p[3] * g(p[4], p[5], t), 'm-') gca().autoscale_view(tight=True, scalex=True, scaley=False) # tight fit to timepoints gca().set_ylim(-100, 100)
def plot(self): t = self.t p = self.p for (V, x, y) in zip(self.V, self.x, self.y): figure() title('x, y = %r um' % ((x, y),)) plot(t, V, 'k.-') plot(t, g2(p[6], p[7], p[8], p[8], x, y) * p[0]*g(p[1], p[2], t), 'r-') plot(t, g2(p[6], p[7], p[8], p[8], x, y) * p[3]*g(p[4], p[5], t), 'g-') plot(t, g2(p[6], p[7], p[8], p[8], x, y) * (p[0]*g(p[1], p[2], t) + p[3]*g(p[4], p[5], t)), 'b-') gca().autoscale_view(tight=True, scalex=True, scaley=False) # tight fit to timepoints gca().set_ylim(-100, 100) figure() title('x, y = %r (model origin in space)' % ((p[6], p[7]),)) plot(t, p[0]*g(p[1], p[2], t) + p[3]*g(p[4], p[5], t), 'm-') gca().autoscale_view(tight=True, scalex=True, scaley=False) # tight fit to timepoints gca().set_ylim(-100, 100)
def model(self, p, t): """Sum of two Gaussians, returns a vector of v values""" return p[0]*g(p[1], p[2], t) + p[3]*g(p[4], p[5], t)