def setlayervq (sts,time=10,perc=100,wt=1e9,inputseed=32343,vq0=False): # Set up a netstim>ncl>intf shock in particular layers or cell type global grpshockNetStim a,vr1,vr2,sel=allocvecs(3) vq=h.NQS("ind","time","wt","sy") nqce=col.cellsnq;nqce.verbose=layers.verbose=0 if layers.select("name",h.SEQ,sts)>0: top=layers.fetch("name",h.SEQ,sts,"top") bot=layers.fetch("name",h.SEQ,sts,"bot") nqce.select("zloc","[]",bot,top) sel.copy(nqce.getcol("id")) selsz=sel.size() if h.verbose: print "\nLayer %s(%d,%g):"%(sts,selsz,perc/100.) elif (cellsnq.select("ty",h.iex(sts))>0): # need to pull out number for that string ident to use with this nq sel=nqce.getcol("id") selsz=sel.size() else: print sts," not found in layers or cellsnq" if perc<100: vr1.resize(perc*(selsz+1)/100.) vr1.setrnd(6,0,selsz-1,inputseed) vr2=sel.ind(vr1) else: vr2.copy(sel) # if h.verbose: print "#%d->"%(vr1.size()) #xo = h.NetCon(grpshockNetStim,col.ce[int(sel[int(x)])]) # connections when using netcons -- see params.hoc:setlayershock() #ncl.append(xo);xo.delay=time;xo.weight[AM] = wt # weight into AM or AM2? vq.v[0].append(vr2) # postsyn NQS("ind","time","wt","sy") vq.pad() vq.v[1].fill(time);vq.v[2].fill(wt);vq.v[3].fill(AM) nqce.verbose=layers.verbose=1 h.dealloc(a) if vq0: vq0.append(vq) else : vq0=vq vq.sort("time");vq.sort("ind") return vq0 # skrewtdel() reset time and wts for a shock def skrewtdel (ncl,perc=100,wt=30,dl=1,seed=34342):#Reset shock put in using netstim>ncls>intf from "reset %, time or wts for shock" sz=ncl.count(); a=-1 if perc<100: a,v1r=allocvecs(1) setn=round(perc*(sz+1)/100.) v1r.resize(setn) v1r.setrnd(6,0,sz-1,seed) for nc in ncl: nc.weight[AM]=0. for x in v1r: i=int(x) ncl[i].weight[AM]=wt ncl[i].delay=dl else: for (i,nc) in enumerate(ncl): nc.weight[AM]=wt nc.delay=dl if a>-1: h.dealloc(a) def skrewtdel (vq=None,perc=100,wt=30,dl=1,seed=34342): # reset shock put in intf.initvspks(id,time,wt,syn) "reset %, time or wts for shock" sz=ncl.count(); a=-1 if perc<100: a,v1r=allocvecs(1) setn=round(perc*(sz+1)/100.) v1r.resize(setn) v1r.setrnd(6,0,sz-1,seed) for nc in ncl: nc.weight[AM]=0. for x in v1r: i=int(x) ncl[i].weight[AM]=wt ncl[i].delay=dl else: for (i,nc) in enumerate(ncl): nc.weight[AM]=wt nc.delay=dl if a>-1: h.dealloc(a)