// $Id: parnqsnet.hoc,v 1.2 2006/02/11 13:34:17 hines Exp $ // load_file("nqsnet.hoc") objref sp[5],nq[5] datestr="06feb04" scale=1 // redefined in network.hoc double pmat[CTYPi][CTYPi][STYPi],numc[CTYPi],ix[CTYPi],wmat[CTYPi][CTYPi][STYPi] obfunc cobj(){} // return cell given gid (defined in network.hoc) //* routines //** styp() sets synapse type based on presynaptic cell func styp () { local pr,po pr=$1 po=$2 if (pr==IN && po==IN) { return GA } else if (pr==IN) { return IH } else if (pr==SU) { return EX } else if (pr==SM) { return AM } else printf("styp ERR %s->%s not classified",CTYP.object(pr).s,CTYP.object(po).s) } for ii=0,2 {sp[ii]=new NQS("PR","PO","SID","WT","DEL") sp[ii].clear(1e5*scale)} batch_flag=1 for ii=0,2 sp[ii].mo(1) batch_flag=0 // mkspmat() uses sp and sp[1], returns sp proc mkspmat () { local a,sn,ii,jj,n,x,y,z,z1 localobj vr,vo x=$1 y=$2 z=$3 rdm.ACG(903342) a=allocvecs(vr,vo) sn=pmat[x][y][z]*numc[x]*numc[y] // number of synapses for ii=0,1 sp[ii].clear sp.mo(2) sp.pad(1.5*sn) // leave room rdm.discunif(ix[x],ix[x]+numc[x]-1) // randomly chosen presynaptic cells PRv.setrand(rdm) rdm.discunif(ix[y],ix[y]+numc[y]-1) // randomly chosen postsynaptic cells POv.setrand(rdm) if (z==EX) z1=AM else z1=z sytyp(c[y],z1,vr) // will want to replace this since got rid of c[] SIDv.vfill(vr) rdm.normal(wmat[x][y][z1],(0.5*wmat[x][y][z1])^2) // calc random weights WTv.setrand(rdm) // set the weight column rdm.normal(2.2,0.1) // random delays DELv.setrand(rdm) sp.elimrepeats("PR","PO","SID") // so don't have 2 connections between same cells sp.shuffle() // randomize again sp.pad(sn) // reduce the length down to desired if (z==EX) { // now have to repeat everything, also will need for IX z1=NM sp[1].mo(2) // reset the PRv,POv,... pointers sp[1].cp(sp) // this will be the same as prior rdm.normal(wmat[x][y][z1],(0.5*wmat[x][y][z1])^2) WTv.setrand(rdm) sytyp(c[y],z1,vo) // vo and vr represent list indices for cell synlists vo.sub(vr) // difference between the NMDA synnums and AMPA synnums if (! vo.ismono(0)){ printf("mkspmat ERRA\n") return } SIDv.add(vo.x[0]) sp.grow(sp[1]) } sp.mo(2) // reset the PRv,POv,... pointers WTv.negwrap() // take any neg weights and make them positive dealloc(a) } // mkpomat() only make the array for a single postsynaptic cell proc mkpomat () { local a,sn,ii,jj,n,x,y,yid,z,z1 localobj vr,vo x=$1 y=$2 z=$3 yid=$4 // rdm.ACG(903342) // We want to have a postsynaptic gid specific stream but streams from // different gids should be statistically independent. // A stream is random but we want to be able to reproduce it at will // Assume this is the only place where this is required mcell_ran4_init(yid) // for independent sims add offset > i*allcells rdm.MCellRan4(1) //avoid 0 want to always start at known seed a=allocvecs(vr,vo) sn=pmat[x][y][z]*numc[x]*1 // number of synapses if (sn<1) { // treat sn<1 as a prob of connecting rather than a density if (rdm.uniform(0,1).add(idtp)") sp.delect() sp.select("POID",TP) sp.spr(".add(idtp)") sp.delect() sp.select("PRID",B5) sp.spr(".add(idb5)") sp.delect() sp.select("POID",B5) sp.spr(".add(idb5)") sp.delect() sp.select("PRID",SM) sp.spr(".add(idstim)") sp.delect() }