def weight(self, gid): # soma does not allow syn. weight if gid_is_mitral(gid) or \ gid_is_mtufted(gid) or \ gid_is_granule(gid): return None # init try: winit = self.initweights[gid] except KeyError: winit = 0 if gid % 2 != 0 and self.hebbian: tpre = [0] try: tpre += self.retrieve(gid) except KeyError: pass tpost = [0] try: tpost += self.retrieve(gid+1) except KeyError: pass return hebbian.weights(tpre, tpost, winit) else: return nonhebbian.weights(self.retrieve(gid), winit, gid % 2 == 0)
def soma_prefix(gid): if bulbdef.gid_is_mitral(gid): return ' MC' elif bulbdef.gid_is_mtufted(gid): return 'mTC' elif bulbdef.gid_is_granule(gid): return ' GC' elif bulbdef.gid_is_blanes(gid): return 'dSAC' return None
def printinfo(self): print '\n\nelement information' for gid in sorted(set(self.gids)): if bulbdef.gid_is_mitral(gid): print 'MC %d' % gid elif bulbdef.gid_is_mtufted(gid): print 'mTC %d' % gid elif bulbdef.gid_is_granule(gid): print 'GC %d' % gid else: ci = bulbdict.query(gid) if bulbdef.gid_is_mitral(ci[0]): s = 'MC ' else: s = 'mTC' x = (gid, s) + ci[:3] + (ci[3], ) print '%d:\t %s %d, %d, %.1g\t<-> GC %d' % x
def __init__(self, obj, spkr, dt=25.0, MinFR=0, MaxFR=200.0, MinW=0, MaxW=1): self.obj = obj def retrieve(func, gid, Tvals, tstop): try: t, y = func(gid) except KeyError: t = [0] y = [0] t.append(tstop) y.append(y[-1]) return np.interp(Tvals, t, y) def normalize(y, miny, maxy): y = np.divide(np.subtract(y, miny), maxy - miny) y = np.floor(np.multiply(y, len(self.obj.palette))) y[np.where(y < 0)] = 0 y[np.where(y > (len(self.obj.palette)-1))] = len(self.obj.palette)-1 return y from bulbvis import GC, Segment, Soma # time to visualize Tvals = np.linspace(0, spkr.tstop, int(spkr.tstop/dt)+1) if len(self.obj.gids) == 0: self.Wexc_data = [ (0, 0) ] self.Winh_data = [ (0, 0) ] self.FRdata = [ (0, 0) ] elif isinstance(self.obj, Soma): self.Wexc_data = [ (0, 0) ] self.Winh_data = [ (0, 0) ] #print normalize(retrieve(spkr.frequency, self.obj.gids[0], Tvals, spkr.tstop),MinFR, MaxFR) self.FRdata = compress(Tvals, normalize(retrieve(spkr.frequency, self.obj.gids[0], Tvals, spkr.tstop), \ MinFR, MaxFR)) else: # interpolated weight Wexc_interp = [] Winh_interp = [] # interpolated frequencies FRinterp = [] # gather all data for gid in self.obj.gids: # don't show weights for somas if bulbdef.gid_is_mitral(gid) or \ bulbdef.gid_is_mtufted(gid) or \ bulbdef.gid_is_granule(gid): continue # FR interp FRinterp.append(retrieve(spkr.frequency, gid, Tvals, spkr.tstop)) # excitatory Wexc_interp.append(retrieve(spkr.weight, gid, Tvals, spkr.tstop)) # if it is granule do not visualize WExc inverted if isinstance(self.obj, GC): Winh_interp.append(Wexc_interp[-1]) else: Winh_interp.append(retrieve(spkr.weight, gid-1, Tvals, spkr.tstop)) # get max for granule cell # avg for mitral cell segment if isinstance(self.obj, GC): Wexc_interp = np.matrix(Wexc_interp).max(0) Winh_interp = np.matrix(Winh_interp).max(0) else: Wexc_interp = np.matrix(Wexc_interp).mean(0) Winh_interp = np.matrix(Winh_interp).mean(0) # clean Wexc_interp = np.array(Wexc_interp)[0] Winh_interp = np.array(Winh_interp)[0] FRinterp = np.array(np.matrix(FRinterp).mean(0))[0] # normalizations Wexc_interp = normalize(Wexc_interp, MinW, MaxW) Winh_interp = normalize(Winh_interp, MinW, MaxW) FRinterp = normalize(FRinterp, MinFR, MaxFR) # compress self.Wexc_data = compress(Tvals, Wexc_interp) self.Winh_data = compress(Tvals, Winh_interp) self.FRdata = compress(Tvals, FRinterp)
def gid_is_soma(gid): return bulbdef.gid_is_mitral(gid) or \ bulbdef.gid_is_mtufted(gid) or \ bulbdef.gid_is_granule(gid) or \ bulbdef.gid_is_blanes(gid)