Emergence of physiological oscillation frequencies in neocortex simulations (Neymotin et al. 2011)

 Download zip file   Auto-launch 
Help downloading and running models
"Coordination of neocortical oscillations has been hypothesized to underlie the "binding" essential to cognitive function. However, the mechanisms that generate neocortical oscillations in physiological frequency bands remain unknown. We hypothesized that interlaminar relations in neocortex would provide multiple intermediate loops that would play particular roles in generating oscillations, adding different dynamics to the network. We simulated networks from sensory neocortex using 9 columns of event-driven rule-based neurons wired according to anatomical data and driven with random white-noise synaptic inputs. ..."
1 . Neymotin SA, Lee H, Park E, Fenton AA, Lytton WW (2011) Emergence of physiological oscillation frequencies in a computer model of neocortex. Front Comput Neurosci 5:19-75 [PubMed]
Model Information (Click on a link to find other models with that property)
Model Type: Realistic Network;
Brain Region(s)/Organism: Neocortex;
Cell Type(s): Neocortex V1 pyramidal corticothalamic L6 cell; Neocortex V1 pyramidal intratelencephalic L2-5 cell; Neocortex V1 interneuron basket PV cell; Neocortex fast spiking (FS) interneuron; Neocortex spiny stellate cell;
Gap Junctions:
Receptor(s): GabaA; AMPA; NMDA; Gaba;
Transmitter(s): Gaba; Glutamate;
Simulation Environment: NEURON;
Model Concept(s): Activity Patterns; Oscillations; Synchronization; Laminar Connectivity;
Implementer(s): Lytton, William [billl at neurosim.downstate.edu]; Neymotin, Sam [samn at neurosim.downstate.edu];
Search NeuronDB for information about:  Neocortex V1 pyramidal corticothalamic L6 cell; Neocortex V1 pyramidal intratelencephalic L2-5 cell; Neocortex V1 interneuron basket PV cell; GabaA; AMPA; NMDA; Gaba; Gaba; Glutamate;
misc.mod *
nstim.mod *
stats.mod *
declist.hoc *
decmat.hoc *
decnqs.hoc *
decvec.hoc *
default.hoc *
drline.hoc *
grvec.hoc *
init.hoc *
labels.hoc *
local.hoc *
nqs.hoc *
nqsnet.hoc *
nrnoc.hoc *
python.hoc *
pywrap.hoc *
simctrl.hoc *
spkts.hoc *
stats.hoc *
syncode.hoc *
xgetargs.hoc *
// $Id: decvec.hoc,v 1.424 2010/12/13 13:52:10 billl Exp $

proc decvec() {}

//* Declarations
objref ind, tvec, vec, vec0, vec1, tmpvec, vrtmp, veclist, veccollect, pwm
objref tmpobj, XO, YO, rdm, dir
strdef filename,dblform,tabform,xtmp
{dblform="%.4g" tabform=" "}

dir = new List()
tmpfile = new File()
if (! name_declared("datestr")) load_file("setup.hoc")
load_file("declist.hoc")  // declare list iterators
print "Loading decvec"

{symnum = 7 colnum = 10}
func cg () { return $1%(colnum-1)+1 } // skip white color
objref clrsym[colnum+1]
for ii=0,colnum { clrsym[ii]=new Union() clrsym[ii].x=ii%colnum }
// black->red->blue->green->orange->brown->violet->yellow->grey
{clrsym[0].s="white" clrsym[1].s="black" clrsym[2].s="red" clrsym[3].s="blue"
clrsym[4].s="green" clrsym[5].s="orange" clrsym[6].s="brown" clrsym[7].s="violet" 
clrsym[8].s="yellow" clrsym[9].s="grey"} 
clrsym[0].o=new List()
{symmax=20 symmin=2}
obfunc sg () { local ii localobj o
  o.x[1]=(3-ii)%4+1 // descending line types
  o.x[4]=(int((ii+1)/5)%2+1)*4-(ii+1)%4+1 // another line type sequence
  return o

{ MSONUM=100 MSOSIZ=100 msomax=0 msoptr=0 objref mso[MSONUM] }
double x[4],y[4]
xx=0 // declare a scalar 
ind = new Vector(100)
tvec = new Vector(100)
vec = new Vector(100)
vec0 = new Vector(10)
vec1 = new Vector(10)
vrtmp = new Vector(10)
veclist = new List()
veccollect = new List()
rdm = new Random()

if (!(xwindows && name_declared("xwindows"))) {
  objref graphItem
  strdef temp_string_, temp_string2_

//* stuff that doesn't belong here
//** dired([list,]file) - put together list of files matching 'file', calls 'ls -1 file'
//   dired([list,]file,1) file name to read for list of files
//   dired([list,]file,2) clear dir first; if list isn't present assume 'dir'
//   dired([list,]file,3) do recursive search
func dired () { local f,i,f1 localobj st,o
  st=new String2()
  if (numarg()==0) { print "dired([list,]filename[,flag])\t\
    adds the filename to list (use wildcards) (flag:1 read file;flag:2 clear list)"
    return 0 }
  if (argtype(1)==2) {o=dir st.s=$s1 i=2} else {o=$o1 st.s=$s2 i=3}
  while (i<=numarg()) { 
    if (argtype(i)==2) st.t=$si else f=$i
  if (f==2 || f==3) o.remove_all
  if (f==1) {
  } else { // f!=1
    if (f==3) {
      printf("Search starting in ") system("pwd")
      sprint(st.t,"sh -fc \"find . -name %s > %s\"",st.s,xtmp)
    } else {
      if (strm(st.s,"[*?]")) f1=0 else f1=1 // is this a wildcard or a directory
      if (f1) {  
        if (sfunc.len(st.t)>0) {
          sprint(st.t,"find %s -name %s >> %s",st.s,st.t,xtmp)
        } else  sprint(st.t,"find %s >> %s",st.s,xtmp)
      } else     sprint(st.t,"ls -1R %s >> %s",st.s,xtmp)
  while (tmpfile.scanstr(st.t) != -1) {
    if (f1) { // a directory
      if ((x=ftype(st.t))!=2) {print "Ignoring ",st.t,x  continue}
    o.append(new String(st.t))
    tmpfile.gets(st.t)  // get rid of the rest of the line
  printf("%d files in dir\n",o.count)
  return o.count

// lsdir([dir])
proc lsdir () { 
  if (numarg()==1) {
    for ltr($o1) {sprint(tstr,"ls -l %s",XO.s) system(tstr)}
  } else for ltr(dir) {sprint(tstr,"ls -l %s",XO.s) system(tstr)}

//** lbrw(list,action) is used to put up a browser
// note action given without '()'
proc lbrw () {

//** l2v(S1,S2) makes a list(S1) and puts all the XO.S2 into vec
// eg l2v("IClamp","amp")
proc l2v () {
  tmpobj=new List($s1)
  if (numarg()==3) YO=$o3 else YO=vec
  YO.resize(tmpobj.count) YO.resize(0)
  for ltr(tmpobj) {

//* vector iterator vtr
// for vtr(vec) { print x }
// for vtr(&x, vec) { print x }
// for vtr(&x, vec, &y) { print x,y }
// for vtr(&x, vec, max_ind) { print x }
// for vtr(&x, vec, min_ind, max_ind) { print x }
// for vtr(&x, vec, &y, min_ind, max_ind) { print x,y }
iterator vtr () { local i,j,pf,cf,b,e localobj o
  if (argtype(1)==1) { // 1st arg a vector or the pointer
    o=$o1 i=2
  } else if (argtype(1)==3) {
    pf=1 o=$o2 i=3 // pointer alway in position 1
  b=0 e=o.size-1 // default: do whole vec
  // now can take counter or limits
  if (argtype(i)==3) {cf=i i+=1} // cf gives counter location
  if (argtype(i)==0) {
    if (argtype(i+1)==0) {b=$i i+=1 e=$i} else e=$i
  if (!cf) i1=0 else {i=cf $&i=0} // default counter
  for j=b,e {
    if (pf) $&1=o.x[j] else x=o.x[j]  
    if (cf) $&i+=1 else i1+=1

//* vector iterator vtr2, treat two vectors as pairs
// usage 'for vtr2(&x, &y, vec1, vec2) { print x,y }'
iterator vtr2 () { local i,pairwise,noi1
  if (numarg()==3) { pairwise=1 i1=0 }
  if (numarg()==4) if (argtype(4)==3) { pairwise=1 $&4=0 noi1=1}
  if (pairwise) if ($o3.size%2!=0) { print "vtr2 ERROR: vec not even sized." return }
  if (! pairwise) {
    if ($o3.size != $o4.size) { print "vtr2 ERROR: sizes differ." return }
    if (numarg()==5) {$&5=0 noi1=1} else {i1 = 0}
  for i = 0,$o3.size()-1 {
    $&1 = $o3.x[i]
    if (pairwise) $&2=$o3.x[i+=1] else $&2=$o4.x[i]
    if (noi1) { if (pairwise) $&4+=1 else $&5+=1 } else i1+=1

proc viconv () { local a,b
  if (numarg()==0) { printf("viconv(TARG,OLD_INDS,NEW_INDS)\n") return }
  a=b=allocvecs(2) b+=1
  if ($o2.size!=$o3.size) {printf("OLD_INDS %d != NEW_INDS %d\n",$o2.size,$o3.size) return}
  for vtr2(&x,&y,$o2,$o3) { // x -> y

//* iterator lvtr, step through a list and a vector together
// usage 'for lvtr(XO, &x, list, vec) { print XO,x }'
iterator lvtr () { local i
  if ($o3.count <  $o4.size) { printf("lvtr ERROR: vecsize > listsize: list %d,vec %d.\n",$o3.count,$o4.size) return }
  if ($o3.count != $o4.size) { printf("lvtr WARNING: sizes differ: list %d,vec %d.\n",$o3.count,$o4.size) }
  if (numarg()==5) {$&5=0} else {i1 = 0}
  for i = 0, $o4.size()-1 {
    $o1 = $o3.object(i)
    $&2 = $o4.x[i]
    if (numarg()==5) { $&5+=1 } else { i1+=1 }

//* other iterators: case, scase, ocase
iterator case () { local i,j,max,flag
  if (argtype(numarg())==3) {flag=1 max=numarg()-1} else {flag=0 max=numarg()}
  if (flag) {i=max+1 $&i=0} else i1 = 0
  for i = 2, max {
    $&1 = $i
    if (flag) {j=i i=max+1 $&i+=1 i=j} else i1+=1

iterator scase () { local i,j,min,max,flag
  if (argtype(numarg())==3) {flag=1 max=numarg()-1} else {flag=0 max=numarg()}
  if (flag) {i=max+1 $&i=0} else i1=0
  if (argtype(1)==1) {
    if (! isobj($o1,"String")) $o1=new String() // will accept String or String2
  } else min=1
  for i = min,max {
    if (min==1) temp_string_=$si else $o1.s=$si
    if (flag) {j=i i=max+1 $&i+=1 i=j} else i1+=1

// eg for scase2("a","b","c","d","e","f") print tmpobj.s,tmpobj.t
iterator scase2 () { local i,min,flag,na,newstr localobj o
  flag=i1=0 newstr=min=1 
  if (argtype(na)==0) {i=na newstr=$i na-=1}
  if (argtype(1)==1) {flag=1 min=2}
  for i=min,na {
    if (i==min || newstr) o=new String2()
    o.s=$si i+=1  o.t=$si
    if (flag) $o1=o else tmpobj=o

iterator ocase () { local i
  i1 = 0
  if (isassigned($o1)) {
    for i = 1, numarg() {
      XO = $oi
 } else {
    for i = 2, numarg() {
      $o1 = $oi

//* strm(STR,REGEXP) == regexp string match 
func strm () { return sfunc.head($s1,$s2,"")!=-1 }
func strc () { return strcmp($s1,$s2)==0 }

//** count_substr(str,sub): count occurences of substring in str
func count_substr () { local cnt
  cnt = 0
  while (sfunc.tail($s1,$s2,$s1) != -1) { cnt += 1}
  return cnt

//* nind(targ,data,ind) fill the target vector with data NOT index by ind (opposite of v.index)
proc nind () { 
  if (! eqobj($o1,$o2)) $o1.copy($o2)

//* vlk(vec)
// vlk(vec,max)
// vlk(vec,min,max)
// vlk(vec,min,max,"INDEX") -- give index of each entry
// prints out a segment of a vector
proc vlkomitoff () { execute1("func vlkomit () {return NOP}") }
proc vlkomit0(){execute1("func vlkomit(){if(vcnt($o1,0)==$o1.size) return 1 else return 0}")}
proc vlk () { local ii,i,j,ami,min,max,wdh,nl,na,width,tablen,omfl,ixfl localobj st,v1,vi
  st=new String2()  v1=new Vector(numarg()) vi=new Vector()
  nl=1 wdh=vlk_width j=0 omfl=ixfl=0 ami=2
  na=numarg() min=0 max=$o1.size-1
  if (vlkomit(v1)!=NOP) omfl=1 // omfl to omit printing some
  if (argtype(na)==2) {i=na 
    if (strm($si,"I")) {ixfl=1 vrsz($o1,vi) vi.indgen ami=1}
  if (argtype(na)==0) {i=na 
    if ($i<0) min=$i else max=$i 
  if (argtype(na)==0) {i=na min=$i na-=1}
  if (max<0) max+=$o1.size
  if (min<0) min+=$o1.size
  if (max>$o1.size-1) { max=$o1.size-1 printf("vlk: max beyond $o1 size\n") }
  if (strm(tabform,"\t")) tablen=6 else if (strm(tabform,"\n")) tablen=-1e5 else {
    tablen=sfunc.len(tabform) }
  for ii=min,max { 
    if (omfl) { v1.resize(0)
      for i=1,na v1.append($oi.x[ii])
      if (vlkomit(v1)) continue
    if (ixfl) sprint(st.s,dblform,vi.x[ii]) else sprint(st.s,dblform,$o1.x[ii])
    for i=ami,na sprint(st.s,st.t,st.s,$oi.x[ii]) 
    if (width>vlk_width && nl) {printf("\n") width=0}
  if (nl) print ""

// vpr2(v1,v2) to print out 2 vecs in parallel
proc vpr2 () { local i,fl2,max,min,newline localobj v1,v2
  v1=$o1 v2=$o2 min=0 max=v1.size if (v2.size!=max) {print "vpr2 diff szs" return}
  for ({i=min fl2=0}; i<max; i+=1) {
    if (v1.x[i]==BVBASE || v2.x[i]==BVBASE) {
      if (!fl2) printf(" ")  
    } else { 
      printf("\n%5.1g %5.1g [%d]",v1.x[i],v2.x[i],i)
  print ""

//** vlkp(SRC,PVEC) uses indices in PVEC to print out values in SRC
proc vlkp () { local i,j,wdh
  j=0 nl=1 wdh=vlk_width
  if (numarg()==2) {
    for vtr(&x,$o1) {
      if ((j=j+1)%vlk_width==0 && nl && strcmp(tabform," ")==0) { print "" }
  } else {
    for vtr(&x,$o1) { for i=2,numarg() printf("%g%s",$oi.x[x],tabform) 
      print "" }
  if (nl) print ""

//* vprf() prints 1,2 or 3 vectors in parallel to output file
proc vprf () { local x2
  if (! tmpfile.isopen()) {
    print "Writing to temp file 'temp'"
  if (numarg()==1) { 
    for vtr(&x,$o1) { tmpfile.printf("%g\n",x) }
  } else if (numarg()==2) { 
    for vtr2(&x,&y,$o1,$o2) { tmpfile.printf("%g %g\n",x,y) }
  } else if (numarg()==3) { 
    for vtr2(&x,&y,$o1,$o2,&ii) { x2=$o3.x[ii] tmpfile.printf("%g %g %g\n",x,y,x2) }

//* vpr() prints 1,2 or 3 vectors in parallel to STDOUT
proc vpr () { local x2
  if (numarg()==1) { 
    for vtr(&x,$o1) { printf("%g",x) }
  } else if (numarg()==2) { 
    for vtr2(&x,&y,$o1,$o2) { printf("%g:%g ",x,y) }
  } else if (numarg()==3) { 
    for vtr2(&x,&y,$o1,$o2,&ii) { x2=$o3.x[ii] printf("%g:%g:%g ",x,y,x2) }
  print ""

//* readvec(vec) read from line
proc readvec () { 
  while (read(xx)) $o1.append(xx)
//* popvec(), savenums, readnums, vecsprint, savevec, savestr
//  vrsz(), vcp(), zvec(), resize, copy, empty
proc pushvec () { local i // same as .append, retained for compatability
  for i=2, numarg() $o1.append($i)

//** insvec(VEC,IND,VAL1[,VAL2,...]) insert values into the vector
proc insvec () { local ix,i,a // insert values into a vector
  a=allocvecs(1)  ix=$2
  for i=3, numarg() mso[a].append($i)

//** revec() clear vector then append
proc revec () { local i,x localobj o,st // clear vector then append
  if (! isobj($o1,"Vector")) $o1=new Vector(100)
  if (argtype(2)==2) {
    o=$o1 o.resize(0)
    st=new String2($s2)
    if (strm(st.s,",")) { // use split
    } else if (strm(st.s," ")) {
      split(st.s,o," ")
    } else while (sfunc.len(st.s)>0) { // assume binary vector, could generalize for hex and base64
      sfunc.tail(st.s, ".", st.t)
  } else for (i=1;i<=numarg();i+=1) { 
    if (ty==1) {        o=$oi o.resize(0)
    } else if (ty==0) { o.append($i)
    } else if (ty==3) { o.append($&i) }

//** unvec(VEC,&a,&b,...) put values from vector back into doubles (via pointers)
proc unvec () { local i
  if ($o1.size!=numarg()-1) { printf("unvec WARNING resizing %s to %d\n",$o1,numarg()-1) 
    $o1.resize(numarg()-1) }
  for i=2,numarg() $&i=$o1.x[i-2] 

//** wevec(VEC,wt0,wt1,...) returned weighted sum
func wevec () { local i,sum
  if ($o1.size!=numarg()-1) { printf("wevec SIZE ERR %d %d\n",$o1.size,numarg()-1) return }
  for i=2,numarg() sum+=$o1.x[i-2]*$i
  return sum

//** vrsz(VEC or NUM,VEC1,VEC2...,VECn or NUM)  -- vector resize -- to size of first arg
//   vrsz(VEC or NUM,VEC1,NUM,VEC2,etc)  -- vector resize -- to size of first arg (vec or num)
// or prior NUM
// optional final number is fill
func vrsz () { local i,sz,max,fill,flag,rsz0
  if (argtype(1)==1) { 
    if (isobj($o1,"Vector")) sz=$o1.size else if (isobj($o1,"List")) sz=$o1.count
    if (argtype(2)==0) {printf("vrsz(vec,num) backwards ERR\n") return -1}
  } else sz=$1
  if (argtype(max)==0) {i=max max-=1 fill=$i flag=1}
  if (argtype(max)==2) {max-=1 rsz0=1} // string means resize(0)
  if (sz<0) sz+=$o2.size // reduce size
  if (sz<0) {printf("vrsz ERR: can't resize %s to %d\n",$o2,sz) return sz}
  for i=2, max { 
    if (argtype(i)==0) sz=$i else {
      if (rsz0) $oi.resize(0) else if (flag) $oi.fill(fill) 
  return sz

//** vcp() -- copy vector segment with resizing
proc vcp () { local i,sz
  $o1.resize($4-$3+1) $o1.copy($o2,$3,$4)

//** veccut(VEC,min,max) just keep a piece of the vector
// veccut(VEC,min,max,tstep) generate indices from times using tstep
proc veccut () { local a localobj v1
  if (numarg()==4) { min=round($2/$4) max=round($3/$4)
  } else { min=$2 max=$3 }

//** zvec()
proc zvec () { local i // make vectors zero size
  for i=1, numarg() $oi.resize(0)

//* save and read series
//** savenums(x[,y,...]) save numbers to tmpfile via a vector
proc savenums () { local i,vv
  if (argtype(1)==3) {
  } else for i=1, numarg() mso[vv].append($i)

//** readnums(&x[,&y...]) recover nums from tmpfile via a vector
func readnums () { local a,i,cnt localobj v1
  if (numarg()==1 && v1.size>1) {
    if (verbose) printf("readnums WARNING: reading %d vals into presumed double array\n",cnt)
  } else {
    if (numarg()>v1.size && verbose) {
      printf("readnums() WARNING: too many args %d>%d\n",numarg(),v1.size) }
    for (i=1; i<=numarg() && i<=v1.size; i+=1) $&i = v1.x[i-1]
  return cnt

//** wrvstr(str) save string to a file by converting to ascii
proc wrvstr () { local vv,i

//** rdvstr(str) read string from a file via vread and conversion
func rdvstr () { local vv,i,flag
  if (mso[vv].vread(tmpfile)) {
    if (numarg()==1) v2str(mso[vv],$s1) else v2str(mso[vv],tstr)
  } else flag=0
  return flag

//** str2v()
proc str2v () { localobj lo
  lo=new String()
  while (sfunc.len(lo.s)>0) {
//** v2str() translates from vector to string
proc v2str () { local ii,x
  for ii=0,$o1.size-1 { x=$o1.x[ii] sprint($s2,"%s%c",$s2,x) }

//* popvec() remove last entry
func popvec () { local sz, ret
  sz = $o1.size-1
  if (sz<0) return 1e9
  ret = $o1.x[sz]
  return ret

//* chkvec (look at last entry)
func chkvec () { if ($o1.size>0) return $o1.x[$o1.size-1] else return -1e10 }

// vecsprint(strdef,vec)
proc vecsprint () { local ii
  if ($o2.size>100) { return }
  for ii=0,$o2.size-1 { sprint($s1,"%s %g ",$s1,$o2.x[ii]) }

// savevec([list,]vec1[,vec2,...]) add vector onto veclist or other list if given as 1st arg
// don't throw out vectors
func savevec () { local i,flag,beg localobj v1
  if (numarg()==0) { savevec(hoc_obj_[0],hoc_obj_[1]) return }
  if (isobj($o1,"List")) beg=2 else beg=1
  for i=beg, numarg() { 
    if (veccollect.count>0) { // grab a vector from garbage collection
    } else v1 = new Vector($oi.size)
    if (beg==2) $o1.append(v1) else veclist.append(v1)
  if (beg==2) return $o1.count-1 else return veclist.count-1

// prveclist(filename[,list])
proc prveclist () { localobj xo
  if (!batch_flag && tmpfile.ropen($s1)) {
    printf("%s exists; save anyway? (y/n) ",$s1)
    getstr(temp_string_) chop(temp_string_)
    if (strcmp(temp_string_,"y")!=0) return
  if (! tmpfile.wopen($s1)) { print "Can't open ",$s1  return }
  if (numarg()==2) {
    for ltr(xo,$o2) xo.vwrite(tmpfile)
  } else {
    for ltr(xo,veclist) xo.vwrite(tmpfile)

// prvl2(filename[,list]) --- save using a more standard fwrite
proc prvl2 () { localobj xo,o
  if (!batch_flag && tmpfile.ropen($s1)) {
    printf("%s exists; save anyway? (y/n) ",$s1)
    getstr(temp_string_) chop(temp_string_)
    if (strcmp(temp_string_,"y")!=0) return
  if (! tmpfile.wopen($s1)) { print "Can't open ",$s1  return }
  if (numarg()==2) o=$o2 else o=veclist
  for ltr(xo,o) {tmpfile.printf("%d\n",xo.size) xo.fwrite(tmpfile)}

// rdveclist("FILENAME"[,list])
// rdveclist("FILENAME"[,NOERASE])
proc rdveclist () { local flag,a
  if (numarg()==1) { flag=1 clrveclist() } else if (argtype(2)==1) $o2.remove_all else flag=1
  if (! tmpfile.ropen($s1)) { print "Can't open ",$s1  return }
  while (mso[a].vread(tmpfile)) {
    if (flag) savevec(mso[a]) else savevec($o2,mso[a])
// rdvecs("FILENAME",vec1,vec2,...)
proc rdvecs () { local i
  if (! tmpfile.ropen($s1)) { print "Can't open ",$s1  return }
  for i=2,numarg() {
    if ($oi==nil) $oi=new Vector()
    if ($oi.vread(tmpfile)==0) printf("WARNING nothing to read into %s\n",$oi)
// svvecs("FILENAME",vec1,vec2,...)
proc svvecs () { local i
  for i=2,numarg() savevec($oi)
// vpad(vec,howmany,val[,right])
proc vpad () { local a
  mso[a].resize($2) mso[a].fill($3)
  if (numarg()==4) $o1.append(mso[a]) else {
    mso[a].append($o1) $o1.copy(mso[a])     }

// vtrunc(vec,howmany[,right])
proc vtrunc () { local a
  if (numarg()==3) $o1.resize($o1.size-$2) else {
    $o1.reverse $o1.resize($o1.size-$2) $o1.reverse

proc rdxy () { local a,flag
  a = allocvecs(1)
  if (numarg()>=1) tmpfile.ropen($s1) else tmpfile.ropen("aa")
  if (numarg()>=2) flag=$2 else flag=2
  if (flag==2) {
    for vtr2(&x,&y,mso[a]) {ind.append(x) vec.append(y)}
  } else {
  print ind.size," points read"

// closest(vec,num) -- return ind for vec member closest to num
func closest () { local a,ret
  mso[a].copy($o1) mso[a].sub($2) mso[a].abs
  return ret

// memb(TEST#,#1,#2,...) -- true if the TEST# is in the list
func memb () { local na,i
  for i=2,numarg() if ($1==$i) return 1
  return 0

proc clrveclist () { localobj o,xo
  if (numarg()==1) o=$o1 else o=veclist
  for ltr(xo,o) { xo.resize(0) veccollect.append(xo) }

// savestr(str1...) add string obj onto tmplist
proc savestr () { local i
  if (argtype(1)==1) for i=2, numarg() $o1.append(new String($si)) else {
    for i=1, numarg() tmplist.append(new String($si))

// redund with v.count in vecst.mod
func vcount () { local val,sum
  val=$2 sum=0
  for vtr(&x,$o1) if (x==val) sum+=1
  return sum

// tvecl(inlist[,outlist]) -- transpose veclist
obfunc tvecl () { local x,cnt,sz,err,ii,p localobj xo,il,ol
  if (numarg()>1) ol=$o2
  if (!isassigned(ol)) {ol=veclist clrveclist()} else ol.remove_all
  err=0   cnt=il.count sz=il.o(0).size
  for ltr(xo,il,&x) if (xo.size!=sz) err=x
  if (err) { print "Wrong size vector is #",x return ol }
  p = allocvecs(1,cnt)  mso[p].resize(cnt)
  for ii=0,sz-1 {
    for jj=0,cnt-1 mso[p].x[jj] = il.o(jj).x[ii]
  return ol

//* vinsect(v1,v2,v3) -- v1 gets intersection (common members) of v2,v3
//  replaced by v.insct() in vecst.mod
proc vinsect () {
  for vtr(&x,$o2) for vtr(&y,$o3) if (x==y) $o1.append(x)

//* vecsplit(vec,vec1,vec2[,vec3,...])
// splits vec into other vecs given
proc vecsplit () { local num,ii,i
  num = numarg()-1 // how many
  for i=2,numarg() $oi.resize(0)
  for (ii=0;ii<$o1.size;ii+=num) {
    for i=2,numarg() if (ii+i-2<$o1.size) $oi.append($o1.x[ii+i-2])

//* vecsort(vec,vec1,vec2[,vec3,...])
// sorts n vecs including first vec by first one
proc vecsort () { local i,inv,scr,narg
  if (narg<2 || narg>10) {print "Wrong #args in decvec.hoc:vecsort" return}
  scr=inv=allocvecs(2) scr+=1
  for i=3,narg sprint(temp_string_,"%s,%s",temp_string_,$oi)

//** order(&x,&y,...) put values in order
proc order () { local a,i,na
  for i=1,na mso[a].append($&i)
  for i=1,na $&i=mso[a].x[i-1]

//** vdelind()  -- delete a single index
proc vdelind () { local i,iin
  iin = $2
  if (iin<0) iin=$o1.size+iin
  if (iin>$o1.size-1 || iin<0) {
    printf("vdelind Error: index %d doesn't exist.\n",iin) return }
  if (iin<$o1.size-1) $o1.copy($o1,iin,iin+1,$o1.size-1)

//* mkveclist(num[,sz]) recreate veclist to have NUM vecs each of size SZ (or MSOSIZ)
proc mkveclist () { local ii,num,sz,diff localobj xo
  diff = num-veclist.count
  if (numarg()==2) { sz=$2 } else { sz = MSOSIZ }
  if (diff>0) {
    for ii=0,diff-1 {
    tmpvec = new Vector(sz)
  } else if (diff<0) {
    for (ii=veclist.count-1;ii>=num;ii=ii-1) { veclist.remove(ii) }
  for ltr(xo,veclist) { xo.resize(sz) }

//* allocvecs
// create temp set of vectors on mso
// returns starting point on mso 
// eg p = allocvecs(3)
// p = allocvecs(v1,v2,v3) // where v1..v3 are localobj or objref
// p = allocvecs(v1,v2,v3,...,size) // set all to size
// p = allocvecs(num,list) // append num vecs to list
// p = allocvecs(num,size) // num vecs of size size
// p = allocvecs(num,size,list) // append num vecs of size to list
// p = allocvecs(num,list,size) // allow args to be given in reverse order
// access these vectors by mso[p+0] ... [p+2]
func allocvecs () { local i,ii,llen,sz,newv,aflg,lflg,na localobj o
  if (numarg()==0) { 
    print "p=allocvecs(#) or p=allocvecs(v1,v2,...), access with mso[p], mso[p+1]..." return 0 }
  sz=MSOSIZ  na=numarg()
  if (argtype(1)==0) {
    aflg=0 newv=$1
    if (na>=2) if (argtype(2)==0) sz=$2 else {lflg=1 o=$o2} // append to list in arg2
    if (na>=3) if (argtype(3)==0) sz=$3 else {lflg=1 o=$o3} 
    if (lflg) o.remove_all
  } else {
    if (argtype(na)==0) {
      i=na sz=$i newv=i-1
    } else newv=na 
  llen = msoptr
  for ii=msomax,msoptr+newv-1 { // may need new vectors
    if (ii>=MSONUM) { print "alloc ERROR: MSONUM exceeded." return 0 }
    mso[ii] = new Vector(sz)
  for ii=0,newv-1 {
    msoptr = msoptr+1
  if (msomax<msoptr) msomax = msoptr
  if (aflg) for i=1,newv $oi=mso[i-1+llen]
  if (lflg) for i=0,newv-1 o.append(mso[i+llen])
  return llen

//** dealloc(start)
// remove temp set of vectors from mso
proc dealloc () { local ii,min
  if (numarg()==0) { min = 0 } else { min = $1 }
  msoptr = min

//* indvwhere family
//** vwh(VEC,VAL) returns index where VEC.x[i]==VAL
func vwh () { 
  if (argtype(2)==0) return $o1.indwhere("==",$2) 
  if (numarg()==3) return $o1.indwhere($s2,$3)
  return $o1.indwhere($s2,$3,$4)

//** vval(VEC,STR,NUM) uses indwhere to return first value that qualifies
func vval () {
  if (argtype(2)==0) return $o1.x[$o1.indwhere("==",$2)]
  if (numarg()==3) return $o1.x[$o1.indwhere($s2,$3)] 
  return $o1.x[$o1.indwhere($s2,$3,$4)] 

//** vcnt(VEC,STR,x[,y]) uses indvwhere and returns # of values that qualify
func vcnt () { local a,ret
  if (numarg()==2) mso[a].indvwhere($o1,"==",$2)
  if (numarg()==3) mso[a].indvwhere($o1,$s2,$3)
  if (numarg()==4) mso[a].indvwhere($o1,$s2,$3,$4)
  ret = mso[a].size
  // if ($o1.size>0) printf("%d/%d (%g)\n",ret,$o1.size,ret/$o1.size*100)
  return ret
//** civw(DEST,SRC1,STR1,x1[,y1]...) does compound indvwhere
// overwrites tstr; DEST should be size 0 unless to be compounded
// civw(DEST,0,...) will resize DEST to 0
func civw () { local i,a,b,c,f2,x,y,sz,min
  a=b=c=allocvecs(3) b+=1 c+=2
  // if ($o1.size>0) print "Starting with previously set index vector"
  if (argtype(2)==0) {
    if ($2==0) { $o1.resize(0) min=3
      if (argtype(3)==1) sz=$o3.size else {
        printf("ERR0: arg 3 should be obj when $2==0\n",i) return -1 }
    } else {
      printf("ERR0a: arg 2 should be 0 if a number -- zero sizes ind vector\n") 
      return -1
  } else if (argtype(2)==1) sz=$o2.size else {
    printf("ERR0b: arg 2 should be obj\n",i) return -1 }
  for (i=min;i<=numarg();) {
    if (argtype(i)!=1) { printf("ERR1: arg %d should be obj\n",i) return -1}
    if ($oi.size!=sz)  { printf("ERR1a: all vecs should be size %d\n",sz) return -1}
    mso[a].copy($oi)  i+=1   // look in a
    if (argtype(i)!=2) { printf("ERR2: arg %d should be str\n",i) return -1}
    tstr=$si          i+=1
    if (strm(tstr,"[[(]")) f2=1 else f2=0 // opstring2 needs 2 args
    if (argtype(i)!=0) { printf("ERR3: arg %d should be dbl\n",i) return -1}
    x=$i              i+=1 
    if (f2) {
      if (argtype(i)!=0) { printf("ERR4: arg %d should be dbl\n",i) return -1}
      y=$i            i+=1
    if (f2) mso[b].indvwhere(mso[a],tstr,x,y) else { // the engine
            mso[b].indvwhere(mso[a],tstr,x)   }
    $o1.resize(sz) // make sure it's big enough for insct -- shouldn't need
    if (mso[c].size>0) $o1.insct(mso[b],mso[c]) else $o1.copy(mso[b])
    if ($o1.size==0) break
  return $o1.size

//* vecconcat(vec1,vec2,...)
// vecconcat(vec1,list) puts concat all vecs from list
// destructive: concatenates all vecs onto vec1
// performs a list2vec() functionality
proc vecconcat () { local i,max localobj xo
  if (numarg()<2) { 
    print "vecconcat(v1,v2,...) puts all into v1" return 
  if (argtype(max)==0) {max-=1 $o1.resize(0)}
  if (isobj($o2,"List")) {
    for ltr(xo,$o2) $o1.append(xo)
  } else for i=2,max $o1.append($oi)
//** vecelim(v1,v2)  eliminates items in v1 given by index vec v2
proc vecelim () {
  for vtr(&x,$o2) { $o1.x[x]= -1e20 }

//** redundout(vec) eliminates sequential redundent entries
// destructive
func redundout () { local x,ii,p1
  return $o1.size

//** uniq(src,dest[,cnt]) uses redundout to return random values of a vector
// like redundout except nondestructive
obfunc uniq () { local a localobj v1,vret
  v1.copy($o1) v1.sort 
  if (numarg()==3) {          $o2.redundout(v1,0,$o3) 
  } else if (numarg()==2) {   $o2.redundout(v1) 
  } else {
    vret=new Vector(v1.size) vret.redundout(v1)
  if (numarg()==1) return vret else return $o2

//** complement(ind,max) for indices -- return values from 0..max that are not in ind
proc complement () { local a,b,max
  a=b=allocvecs(2) b+=1

//** albetname() generate sequential 3 char alphabetical file names (make filenames)
obfunc albetname () { local na,sret localobj st
  na=numarg() sret=0
  st=new String2()
  if (na==0) { fnum+=1 st.t=".id"
  } else if (na>=1) {
    if (argtype(1)==2) {st.t=$s1 fnum+=1} else fnum=$1
  if (na==2) st.t=$s2  // partially back compatible, doesn't handle albetname(tstr,".id")
  if (na==3) {st.t=$s3 sret=1}
  if (fnum>17575) printf("albetname WARN: out of names: %d > %d\n",fnum,26^3-1)
  sprint(st.s,"%c%c%c",  fnum/26/26%26+97,fnum/26%26+97,fnum%26+97)
  if (sfunc.len(st.t)>0) sprint(st.s,"%s%s",st.s,st.t)
  if (sret) $s2=st.s 
  return st

// save_idraw([filename,save_all,PS]) -- save idraw to file
// default is to generate albetname, save selected to idraw
proc save_idraw () { local sv,ps localobj st,li
  st=new String()
  if (argtype(1)==2) {
    if (argtype(2)==0) sv=$2
    if (argtype(3)==0) ps=$3
  } else if (argtype(1)==0) {
    if (argtype(2)==0) ps=$2  
  if (sfunc.len(st.s)==0) st.s=albetname().s
  if (verbose) printf("Saving to %s\n",st.s)
  pwm.printfile(st.s, ps, sv)

proc find_pwm () { localobj li
  if (isassigned(pwm)) return
  li=new List("PWManager")
  if (li.count==0) pwm=new PWManager() else pwm=li.o(0)

// vecconv() convert $o1 by replacing instances in $o2 by corresponding instances in $o3
proc vecconv () { local a,x,y localobj v1,v2,v3,v4
  if (argtype(2)==0) v2.append($2) else v2=$o2
  if (argtype(3)==0) v3.append($3) else v3=$o3
  for vtr2(&x,&y,v2,v3) { // x -> y

//** veceq()  like vec.eq but don't have to be same size and shows discrepency
func veceq () { local sz1,sz2,eq,beg,ii,jj,kk
  sz1=$o1.size sz2=$o2.size
  if (numarg()==3) beg=$3 else beg=0
  if (sz1!=sz2) printf("%s %d; %s %d\n",$o1,sz1,$o2,sz2)
  ii=0 jj=beg
  while (ii<sz1 && jj<sz2) {
    if ($o1.x[ii]!=$o2.x[jj]) { 
      printf("Differ at %d %d\n",ii,jj) 
      for kk=-10,10 if ((ii+kk)>=0 && (ii+kk)<sz1 && (jj+kk)>=0 && (jj+kk)<sz2) {
        printf("(%d)%g:(%d)%g ",(ii+kk),$o1.x[ii+kk],(jj+kk),$o2.x[jj+kk])  }
      print ""
    } else eq=1
    ii+=1 jj=ii+beg
  return eq

//* isstring() determine if object $o1 is of type string, if so return the string in [$s2]
func isstring () {
  if (sfunc.substr(tstr,"String")==0) {
    if (numarg()==2) sprint($s2,"%s",$o1.s)
    return 1
  } else {
    if (numarg()==2) sprint($s2,"%s",$o1)
    return 0

//** isassigned() checks whether an object is Null
if (name_declared("VECST_INSTALLED")) {
  sprint(tstr,"func isassigned () { return !isojt($o1,nil) }")
} else {
  sprint(tstr,"func isassigned () { return !isobt($o1,nil) }")

//** declare goes through a list of scalars and assigns them if they don't already exist
// eg declare("adj",nil,"vd",nil,"vc",nil,"allcells",0,"div","d[1][1]")
func declare () { local i,nd,min,verbose,ty,tye,ret localobj st,ut
  if (argtype(1)==0) {verbose=0 min=2} else {min=verbose=1}
  if (numarg()==0) {
    printf("eg declare(\"obj\",new Vector(),\"num\",0,\"arr\",\"d[2][2]\",\"vec\",\"o[5]\",\"str\",\"\")\nfirst arg num means quiet")
    return 0 }
  st=new String2() ut=new String2() ret=0
  ut.s="^[do]\\["  ut.t="^[A-Z][A-Za-z]+[(][^)]*[)]$" // for declaring arrays and objects
  for i=min,numarg() {
    st.s=$si     i=i+1
    if (nd==1) { nd=0
      if (verbose) {
        printf("declare WARN defining '%s' despite prior existence in symbol table\n",st.s) }}
    if ((nd==5 && ty==0) || (nd==4 && ty==2) || (nd==2 && ty==1)) { // OK -- DO NOTHING
      if (i==min+1) ret=1
      if (verbose) printf("'%s' predeclared\n",st.s)
    } else if (nd != 0) { // different type codes from name_declared() bzw argtype()
      if ((nd==5 && ty==2) || (nd==2 && ty==2)) {
        if (strm($si,ut.s)) { // name_declared gives 2 for either objref and objarray
          if (nd==5) st.t="DOUBLE" else st.t="OBJ"
          if (verbose) {
            printf("'%s' predeclared as %s array: WARN: no check on type or dims\n",st.s,st.t)}
          continue  // declaration for a double or obj array 
        } else  if (strm($si,ut.t)) { 
          if (verbose) printf("'%s' predeclared\n",st.s)
          continue  // declaration for an object
      if (nd==5) tye=0 else if (nd==4) tye=2 else if (nd==2) tye=1 
      if (verbose) printf("Declared ERR %s predeclared as a %d statt %d\n",st.s,tye,ty)
    } else { // declare it
      if (ty==0) { 
      } else if (ty==1) { 
        if ($oi==nil) {  sprint(st.t,"objref %s\n%s=nil",st.s,st.s)
        } else           sprint(st.t,"objref %s\n%s=%s", st.s,st.s,$oi)
      } else if (ty==2) { // key strings are eg d[5][5] or o[5][5] for double or obj array
        if (strm($si,ut.s)) {
          if (strm($si,"^d")) ty=0 else ty=1
          if (ty==0) sprint(st.t,"double %s%s",st.s,st.t) else \
                     sprint(st.t,"objref %s%s",st.s,st.t) 
        } else if (strm($si,ut.t)) {
          sprint(st.t,"objref %s\n%s = new %s",st.s,st.s,$si) 
        } else sprint(st.t,"strdef %s\n%s=\"%s\"",st.s,st.s,$si)
  return ret

//** declared goes through a list of function names and makes sure they exist
// useful to check a bunch of names before entering a template that calls them as external
proc declared () { local i,nd,min,flag
  if (argtype(1)==0) {flag=$1 min=2} else {flag=0 min=1}
  for i=min,numarg() {
    if (nd==0 || (flag==1 && nd==1)) { // declare it or clear it
      // sprint(tstr,"func %s () {printf(\"\\tEMPTY FUNCTION %s()\\n\") return 0}",$si,$si)
      sprint(tstr,"func %s () {return 0}",$si)
    } else if (nd!=1) { // 2=obj,3=sec,4=str,5=dbl
      printf("NAME CONFLICT: %s can't be a func since was declared as a %d\n",$si,nd)

//** isit() like isassigned() but can take a string instead
obfunc isit () { local ret localobj sv,o,st
  o=new Union()  st=new String()
  if (argtype(1)==2) {
    execute(st.s) // XO points to the thing
    return o
  } else return isassigned($o1)

//** isob(s1,s2) like isobj but takes string statt obj
func isob () { localobj st
  st=new String()
  execute(st.s) // XO points to the thing
  if (sfunc.substr(st.s,$s2)==0) {
    return 1
  } else {
    return 0

//** eqobj(o1,o2) checks whether 2 objects are the same
func eqobj () {	return object_id($o1) == object_id($o2) }
//** ocnt(STR) counts number of objects named string
func ocnt () { local ret
  tmpobj=new List($s1) ret=tmpobj.count
  return ret

//** isobj(o1,s2) checks whether object $o1 is of type $s2
func isobj () { localobj st
  st=new String()
  if (sfunc.substr(st.s,$s2)==0) {
    return 1
  } else {
    return 0

//** isobt(o1,o2) checks whether object $o1 is of type $o2
func isobt () { localobj s
  s=new String2()
  sprint(s.s,"%s",$o1)  sprint(s.t,"%s",$o2)
  sfunc.head(s.s,"\\[",s.s) sfunc.head(s.t,"\\[",s.t)
  if (strc(s.s,s.t)) return 1 else return 0

// destructive of $s1
func str2num () { local x localobj o,st
  if (sscanf($s1,"%d",&x)!=1) {
    o=new Union() st=new String()
    sprint(st.s,"%s.x=%s",o,$s1)  // o has temp existance in global namespace
    if (!execute1(st.s,0)) printf("Can't find '%s'\n",$s1)
  return x

func isnum () { return strm($s1,"^[-+0-9.][-+0-9.eE]*$") }

// fln(num,STR_OBJ) move forward line n lines, chop string at end, remove quotes if present
// fln("rxp",STR_OBJ) move forward to regexp rxp; with arg3 use exact search
// fln("rxp OR n",STR_OBJ,obj) return union in obj with more data
// uses tmpfile; assumes that file is open for reading
fln_lnum=0 // use to count lines; must be rest by calling routine
func fln () { local n,nn,x,y localobj o,st,un
  n=nn=0 y=OK o=$o2
  if (argtype(1)==0) nn=$1 // if need to back up
  if (argtype(3)==1 || argtype(4)==1) { un=new Union(tmpfile.tell())
    if (argtype(3)==1) $o3=un else $o4=un 
  if (nn) {
    while(n<nn) { tmpfile.gets(o.s) n+=1 }
  } else { // look for a string
    st=new String2()
    if (argtype(3)!=0) { // default regexp search
      if (strc(o.s,"A")) o.s="B" else o.s="A" // start with something different
      while (! strm(o.s,$s1)) {tmpfile.gets(o.s) n+=1}
    } else {  // exact string search
      sprint(st.s,"%s\n",$s1) // look for this string
      o.s=$s1 // make sure not somehow starting with exactly the same thing
      while (strcmp(o.s,st.s)!=0) {tmpfile.gets(o.s) n+=1} // might want to return line cnt
  sfunc.left(o.s,sfunc.len(o.s)-1) // get rid of newline
  if (sfunc.head(o.s,"\"","")==0) { // find quote at beginning
    sfunc.left(o.s,sfunc.len(o.s)-1) // assume quote at end
  } else if (sscanf(o.s,"%g,%g",&x,&y)==2) { // specifically used by NQS.rddif
  } else if (sscanf(o.s,"%g",&y)==1) { }
  if (un!=nil) {un.x[1]=tmpfile.tell() un.x[2]=n un.x[3]=x un.x[4]=y un.s=o.s}
  return y

// like perl chop -- removes the last character
// chop(STR[,TERM]); TERM chop only TERM
// note that no + means must repeat char eg "))*" statt ")+"
func chop () { local ln1,match localobj st
  ln1=sfunc.len($s1)  st=new String()
  if (numarg()==2) { 
    if (!strc($s2,"\n")) sprint($s2,"%s$",$s2) // just look for terminal character
    if ((match=sfunc.head($s1,$s2,st.s))==-1) {
      return 0 
    } else {
      return match
  } else if (sfunc.len($s1)>=1) {
    return 1
  } else {
    print "ERR: chop called on empty string" }
    return 0

// lchop(STR[,BEGIN]) -- chop from the left
func lchop () { local ln1,match localobj st
  ln1=sfunc.len($s1)  st=new String()
  if (numarg()==2) { 
    sprint($s2,"^%s",$s2) // just look for initial chars
    if ((match=sfunc.tail($s1,$s2,st.s))==-1) {
      return 0 
    } else {
      return match
  } else if (sfunc.len($s1)>=1) {
    return 1
  } else {
    print "ERR: chop called on empty string" }
    return 0

// strcat(tstr,"stra","strb",...) tstr=stra+strb+...
// 1st arg can be a strdef or String obj
// other args can be strdef, String obj, literal string, or number handled as %g
// returns String obj
obfunc strcat () { local i,na localobj out
  if (argtype(1)==0) { out=new String() 
  } else if (argtype(1)==1) { 
    if (isassigned($o1)) out=$o1 else { out=new String() $o1=out }
  } else { out=new String() out.s=$s1 } // print "AA:",$s1," ",sfunc.len($s1)
  if (argtype(na)==0) { out.s="" na-=1 } // clear string
  for i=2,na {
    if (argtype(i)==1) {        sprint(out.s,"%s%s",out.s,$oi.s) 
    } else if (argtype(i)==2) { sprint(out.s,"%s%s",out.s,$si) 
    } else                      sprint(out.s,"%s%g",out.s,$i) 
  if (argtype(1)==2) $s1=out.s
  return out

// split(string,vec) // split comma sep string into numbers
// split(string,list) // split comma sep string into list of strings
// split(string,list,regexp) // split regexp sep string into list of strings
// split(string,vec,regexp,1) // split but don't interpret: eg "5*3"->15 or "x"->val
// split(string,list,num) // split every num chars
// eg split("534,  43 , 2, 1.4, 34",vec[,"/"])
// split("13, 3*PI/2*tau/2, 32+7, 6, 9.2, 42/3",vec) 
//    optional 3rd str is what to split on; default is comma
func split () { local i,vf,x,done,num localobj s,st,o
  if (numarg()==0) {
    printf("eg split(\"534 43 2 1.4 34\",vec,\" \") split(\"a,b,c,d,e\",tmplist)")
    return -1 }
  s=new String2() st=new String2()
  if (argtype(2)!=1) {
    o=new Vector() vf=2 i=2
  } else { 
    o=$o2 i=3
    if (isobj(o,"Vector")) {
    } else {
      if (!isassigned(o)) { o=new List() $o2=o }
  if (vf) revec(o) else o.remove_all
  if (argtype(i)==2) {       st.s=$si   i+=1
  } else if (argtype(i)==1) {st.s=$oi.s i+=1
  } else                     st.s="[, ]+"
  if (argtype(i)==0) { // length split into a list eg c2 c2 c2 etc
    if (vf) {printf("Split err: attempting to do length split into vector: %s",o) return 0}
    sprint(st.s,"%%*%ds%%s",num) // eg "%2*s%s" to get all but first 2 chars
    sprint(st.t,"%%%ds",num)     // eg "%2s"    to get first 2 chars
    if (num>sfunc.len(s.t)){
      printf("split() ERRA %s of length %d in pieces of %d?\n",s.t,sfunc.len(s.t),num) return 0}
  } else num=0
  while (sfunc.len(s.t)>0) {
    if (vf) {
      if (split_interp) if (strm(s.t,"^[^,]+[+*/-]")) {
        if (sfunc.len(s.s)==0) s.s=s.t
        sprint(s.s,"%s.append(%s)",o,s.s) execute(s.s)
      if (!done) if (sscanf(s.t,"%lf",&x)) { 
      if (!done && split_interp) { // try to interpret as a variable
        hoc_ac_=ERR // global hoc_ac_ for execute1()
        if (sfunc.len(s.s)==0) s.s=s.t // the end
        execute1(st.t,0) // no error
        if (hoc_ac_==ERR) {
          printf("split WARNING skipping non-parsable value: %s\n",s.s)
        } else {
      if (vf==2) if (o.size==0) return ERR else return o.x[0]
    } else { // split into a list
      if (num) {
        o.append(new String2(s.s,s.s))
      } else {
        if (sfunc.len(s.s)==0) s.s=s.t // the end
        o.append(new String2(s.s,s.s))
    if (num) { // splitting equal length strings
      if (sfunc.len(s.t)<=num) s.t="" else sscanf(s.t,st.s,s.t)
    } else {
  if (vf) return o.size else return o.count

//** splitmatch(str,strlist) returns which string in strlist matches the str
func splitmatch () { local ii,x,ret localobj ll,xo
  ll=$o2 ret=-1
  for ltr(xo,ll,&x) {
    if (strm($s1,xo.s)) {ret=x
      break }
  return ret

// parsenums(STR[,VEC]) find first or all the numbers in a string
func parsenums () { print "Use split(\"str\") instead" }

// intervals(TRAIN,OUTPUT)
func intervals () { local a
  if ($o1.size<=1) { printf("%s size <2 in intervals()\n",$o1) return 0}
  return $o2.size

// invl(train,stats[,thresh])
func invl () { local a,x,sz localobj v1,v2
  if ($o1.size<=1) { printf("%s size <2 in invl()\n",$o1) 
    $o2.resize(5) $o2.fill(-1)
    return 0
  if (!$o1.ismono(2)) printf("decvec::invl() WARN: %s not sorted\n",$o1)
  if (numarg()==3) {
    if ((x=v1.w("<",$3,-1))>0) { // tag and remove all below threshold
      v1.sort v1.reverse
  return sz

// freql(train,stats)
// doesn't make much sense to take the mean of inverses 
func freql () { local a localobj v1
  if ($o1.size<=1) { printf("%s size <2 in intervals()\n",$o1) return 0}
  return v1.size

// downcase(tstr[,UPCASE]) 
obfunc downcase () { local len,ii,let,diff,min,max localobj st
  diff=32 min=65 max=90 st=new String2()
  if (argtype(1)==2) st.s=$s1 else st.s=$o1.s
  if (numarg()==2) { diff=-diff min=97 max=122 } // if flag -> upcase
  len = sfunc.len(st.s)
  for ii=1,len {
    if (x>=min&&x<=max) {
    } else sprint(st.s,"%s%c",st.s,x) // just rotate the letter
  if (argtype(1)==2) $s1=st.s
  return st

// newlst() puts a newline in the middle of a string
proc newlst () { local l
  if (numarg()>1) l=$2 else l=int(sfunc.len($s1)/2)

//* rdcol(file,vec,col#,cols): read multicolumn file
func rdcol () { local col,cols,length
  if (numarg()==0) { print "\trdcol(\"file\",vec,col#,cols) // col#=1..." return 0}
  col=$3 cols=$4 length=0
  if (! tmpfile.ropen($s1)) { printf("\tERROR: can't open file \"%s\"\n",$s1) return 0}
  while (tmpfile.gets(temp_string_) != -1) length+=1 // count lines
  print length
  if ($o2.size!=length) printf("rdcol ERR: only read %d statt %d\n",$o2.size,length)
  return length

//* rdmuniq(vec,n,rdm) -- augment vec by n unique vals from rdm
//  rdmuniq(vec,n,max) -- augment vec by n unique vals 0-max
//  rdmuniq(vec,n,min,max) -- augment vec by n unique vals min-max
// draw n numbers without replacement, only makes sense with discrete distribution
// could do something like 
// mso[a].setrand($o3) mso[d].copy(mso[a]) 
//     mso[b].indsort(mso[a]) mso[a].sort() mso[c].redundout(mso[a],1)
// to get indices of unique values but then have to back index to original
// rdmuniqm4=1 to use setrnd() statt setrand()
proc rdmuniq () { local i,max,min,n,a3,a,see localobj ro,v1,v2,vin,l
  if (numarg()==0) {
    printf("rdmuniq(vec,n,rdm) - augment vec by n unique vals from rdm\
  rdmuniq(vec,n) - augment vec by n unique vals 0-99\
  rdmuniq(vec,n,max) - augment vec by n unique vals 0-max\
  rdmuniq(vec,n,min,max) - augment vec by n unique vals min-max\
  rdmuniq(vec,n,min,max,seed) - augment vec by n unique vals min-max using seed\n") 
  return }
  if (rdmuniqm4 && argtype(5)!=0) {
    printf("flag set: rdmuniqm4==1: should use all 5 args: rdmuniq(vec,n,min,max,seed)\n") return }
  vin=$o1 min=max=0 see=0 n=int($2) // round down
  if (a3==1) {
    ro=$o3  // random previously setup, min,max unknown
  } else if (a3==-1) {
      min=0 max=99
  } else {
    if (argtype(4)==0){min=$3 max=$4}
    if (argtype(5)==0) see=$5
  if (max>0) { // else rdm was an arg with unknown min,max
    if (max-min+1==n) {
    } else if (n>max-min+1) {
      printf("rdmuniq ERR incompatible: min=%d max=%d n=%d (%g vs %d)\n",min,max,n,$2,max-min+1) 
  if (!rdmuniqm4) {
    if (ro==nil) ro=new Random()
    if (see) ro.ACG($5) // seed it
  a=allocvecs(v1,v2) l=new List() l.append(v2) l.append(vin)
  for (ii=1;vin.size<n && ii<5;ii+=1) {
    if (rdmuniqm4) { 
    } else v1.setrand(ro)
    v1.uniq(l,1) // preserve order
  if (vin.size<n) {
    printf("rdmuniq ERR unable to find %d uniq values [%d,%d] -- only \n",n,min,max,vin.size)

// rdmord (vec,n) randomly ordered numbers 0->n-1 in vec
// eg rdmord(ind,ind.size); check: for ii=0,ind.size-1 if (ind.count(ii)!=1) print ii
proc rdmord () { local n,a localobj v1
  a=allocvecs(v1)  n=$2

// shuffle(VSRC[,VDEST]) randomly rearrange elements of vec
obfunc shuffle () { local a  localobj v1,v2,oi,oo
  if (numarg()==2) {oo=$o2 oo.copy(oi)} else oo=oi
  return oo

// colshuf(ind,veclist) shuffle the 'transpose' of indexed vecs -- ie not the vecs themselves
// shuffle items from list of vectors across the list rather than across the vectors
// all vecs should be same size, eg colshuf(nq.ind,nq.fcdo) after a select
func colshuf () { local a,x,ii,cols,rows  localobj v1,v2,oi,ol
  oi=$o1 ol=$o2 cols=ol.o(oi.x[0]).size rows=oi.size
  if (rows==0 || cols==0) {printf("ERRA:a 0") return -1}
  for vtr(&x,oi) v1.append(ol.o(x))
  v1.transpose(cols) v1.mshuffle() v1.transpose() // shuffle in the other direction
  for vtr(&x,oi,&ii) ol.o(x).copy(v1,ii*cols,(ii+1)*cols-1)
  return cols

// sample(vec,beg,end,vals) pick out n integer values from given range
// sample(vec,end,vals) -- assumes 0
proc sample () { local min,max,vals
  if (numarg()==4) {min=$2 max=$3 vals=$4} else {max=$2 vals=$3}

// round() round off to nearest integer
func round () { local ii
  if (argtype(1)==1) {
    if ($o1.size==0) return 1e9
    for ii=0,$o1.size-1 {
      if ($o1.x[ii]>0) $o1.x[ii]=int($o1.x[ii]+0.5) else $o1.x[ii]=int($o1.x[ii]-0.5) 
  } else {
    if ($1>0) return int($1+0.5) else return int($1-0.5) 

// filevers() pulls out version of file from first line
func filevers () { localobj f1,s1,lx1
  f1=new File() s1=new String() lx1=new Union()
  if (! f1.ropen($s1)) { printf("filevers ERR, can't open %s\n",$s1) 
    return 0 }
  if (sscanf(s1.s,"%*s $Id: %*s %*d.%d",&lx1.x)!=1) {
    printf("filevers ERR, sscanf failed %s: %s",$s1,s1.s) }
  return lx1.x

//* hocfind(FILENAME) searches through HOC_LIBRARY_PATH and locates file
obfunc hocfind () { local done localobj f1,s1,s2
  f1=new File() s1=new String() s2=new String()
  system("echo -n $HOC_LIBRARY_PATH",s1.s)
  sprint(s1.s,"%s ",s1.s) // to look at last item
  while (sfunc.len(s1.s)>2) {
    sfunc.head(s1.s,"[ :]",s2.s)
    if (f1.ropen(s2.s)) {done=1 break}
    sfunc.tail(s1.s,"[ :]",s1.s)
  if (!done) if (f1.ropen($s1)) {sprint(s2.s,"./%s",$s1) done=1}
  if (!done) s2.s="NOT FOUND"
  return s2

//* usefiles(F1[,F2,...]) list of files returns string with list of files and versions
obfunc usefiles () { local i localobj s1,s2
  s2=new String()
  s2.s="Using "
  for i=1,numarg() {
    sprint(s2.s,"%s %s%d",s2.s,$si,filevers(s1.s))
  return s2

//* ttest(v1,v2)  student t-test
// nrniv/sync/notebook.dol:16230
// checked against http://www.physics.csbsju.edu/stats/t-test_bulk_form.html
func ttest () {  local prob,df
  t_val=($o1.mean-$o2.mean)/sqrt($o1.var/$o1.size + $o2.var/$o2.size)
  return prob

// pttest() paired t-test
func pttest () {  local prob,sd,df,cov,j,ave1,ave2,var1,var2
  n=$o1.size ave1=$o1.mean ave2=$o2.mean var1=$o1.var var2=$o2.var cov=0
  if (n!=$o2.size) {printf("pttest ERR: != sizes\n",n,$o2.size) return -1}
  for (j=0;j<n;j+=1) cov+=($o1.x[j]-ave1)*($o2.x[j]-ave2)
  cov /= (df=n-1)
  // printf("%g ",t_val)
  return prob

func howfull () { local a,min,max,bins,ret localobj v1
  min=0 bins=1e3
  if (numarg()==4){min=$2 max=$3 bins=$4} else if (numarg()==3){max=$2 bins=$3} else max=$2
  return ret

//* Matrix things
// msize() print size of a matrix
proc msize () { printf("%d x %d\n",$o1.nrow,$o1.ncol) }

//** l2m() turn a vector list into a matrix
obfunc l2m () { local ii,m,n localobj mat,l,xo
  n=l.o(0).size m=l.count // rows x cols (data in cols)
  mat=new Matrix(n,m)
  for ltr(xo,l,&ii) mat.setcol(ii,xo)
  return mat

//** m2l() turn a matrix into a vector list
obfunc m2l () { local ii,m,n localobj mat,l,xo
  l=new List() mat=$o1 m=mat.ncol n=mat.nrow
  for ii=0,m-1 l.append(mat.getcol(ii))
  return l

//** reind(ind,filter0[,ifilter1,...]) goes through a series of vectors or values 
// to translate an index if filter is a vec then get vec.x[x] else get x+val
func reind () { local i,x
  for i=2,numarg() if (argtype(i)==0) x+=$i else x=$oi.x[x]
  return x

// rmxtmp() sets xtmp string
proc rmxtmp () { localobj st
  if (wopen("xtmp")) { 
    xtmp = "xtmp" 
  } else if (wopen("/tmp/xtmp")) {
  } else {  
    if (!wopen(xtmp)) printf("Can't open an xtmp file anywhere: . /tmp ~/ \n")
  wopen() // close the file

//* matrix functions using matrix.mod stuff
//** getdiag(matvec,destvec) 
proc getdiag () { local a localobj v1

//** setdiag(matvec,value) 
proc setdiag () { local a localobj v1

func msetrc () { local x
  if ((x=sqrt($o1.size))==int(x)) ROWS=COLS=x else printf("Unable to set ROWS,COLS\n")
  return x

for scase(XO,"o","t","s","O","T","S","+") clrsym.o.append(new String(XO.s))

Neymotin SA, Lee H, Park E, Fenton AA, Lytton WW (2011) Emergence of physiological oscillation frequencies in a computer model of neocortex. Front Comput Neurosci 5:19-75[PubMed]

References and models cited by this paper

References and models that cite this paper

Attention-like modulation of hippocampus place cell discharge. J Neurosci 30:4613-25 [PubMed]

Achard S, Bullmore E (2007) Efficiency and cost of economical brain functional networks. PLoS Comput Biol 3:e17 [PubMed]

Adesnik H, Scanziani M (2010) Lateral competition for cortical space by layer-specific horizontal circuits. Nature 464:1155-60 [PubMed]

Anderson CT, Sheets PL, Kiritani T, Shepherd GM (2010) Sublayer-specific microcircuits of corticospinal and corticostriatal neurons in motor cortex. Nat Neurosci 13:739-44 [PubMed]

Baldi P, Vanier MC, Bower JM (1998) On the use of Bayesian methods for evaluating compartmental neural models. J Comput Neurosci 5:285-314 [PubMed]

Barabasi AL, Albert R (1999) Emergence of scaling in random networks Science 286:509-12 [PubMed]

Bartos M, Vida I, Jonas P (2007) Synaptic mechanisms of synchronized gamma oscillations in inhibitory interneuron networks. Nat Rev Neurosci 8:45-56 [PubMed]

Bazhenov M, Timofeev I, Steriade M, Sejnowski TJ (2002) Model of thalamocortical slow-wave sleep oscillations and transitions to activated States. J Neurosci 22:8691-704 [Journal] [PubMed]

   Sleep-wake transitions in corticothalamic system (Bazhenov et al 2002) [Model]

Binzegger T, Douglas RJ, Martin KA (2004) A quantitative map of the circuit of cat primary visual cortex. J Neurosci 24:8441-53 [PubMed]

Bollimunta A, Chen Y, Schroeder CE, Ding M (2008) Neuronal mechanisms of cortical alpha oscillations in awake-behaving macaques. J Neurosci 28:9976-88 [PubMed]

Bonifazi P, Goldin M, Picardo MA, Jorquera I, Cattani A, Bianconi G, Represa A, Ben-Ari Y, Co (2009) GABAergic hub neurons orchestrate synchrony in developing hippocampal networks. Science 326:1419-24 [PubMed]

Brown SP, Hestrin S (2009) Intracortical circuits of pyramidal neurons reflect their long-range axonal targets. Nature 457:1133-6 [PubMed]

Brunel N, Wang XJ (2003) What determines the frequency of fast network oscillations with irregular neural discharges? I. Synaptic dynamics and excitation-inhibition balance. J Neurophysiol 90:415-30 [Journal] [PubMed]

Buehlmann A, Deco G (2010) Optimal information transfer in the cortex through synchronization. PLoS Comput Biol 6:1419-24

Buxhoeveden DP, Casanova MF (2002) The minicolumn hypothesis in neuroscience. Brain 125:935-51 [PubMed]

Buzsaki G, Draguhn A (2004) Neuronal oscillations in cortical networks. Science 304:1926-9 [PubMed]

Canolty RT, Edwards E, Dalal SS, Soltani M, Nagarajan SS, Kirsch HE, Berger MS, Barbaro NM, K (2006) High gamma power is phase-locked to theta oscillations in human neocortex. Science 313:1626-8 [PubMed]

Cardin JA, Carlen M, Meletis K, Knoblich U, Zhang F, Deisseroth K, Tsai LH, Moore CI (2009) Driving fast-spiking cells induces gamma rhythm and controls sensory responses. Nature 459:663-7 [PubMed]

Carnevale NT, Hines ML (2006) The NEURON Book

Chen CC, Kiebel SJ, Friston KJ (2008) Dynamic causal modelling of induced responses. Neuroimage 41:1293-312 [PubMed]

Chen Y, Bressler SL, Knuth KH, Truccolo WA, Ding M (2006) Stochastic modeling of neurobiological time series: power, coherence, Granger causality, and separation of evoked responses from ongoing activity. Chaos 16:026113 [PubMed]

Clopath C, Busing L, Vasilaki E, Gerstner W (2010) Connectivity reflects coding: a model of voltage-based STDP with homeostasis. Nat Neurosci 13:344-52 [Journal] [PubMed]

   Voltage-based STDP synapse (Clopath et al. 2010) [Model]

Cutsuridis V, Hasselmo M (2010) Dynamics and function of a ca1 model of the hippocampus during theta and ripples Artificial Neural Networks-ICANN 2010, Part I, LNCS 6352, Diamantaras K, Duch W, Iliadis LS, ed. pp.230

da Costa NM, Martin KA (2010) Whose Cortical Column Would that Be? Front Neuroanat 4:16 [PubMed]

Daunizeau J, David O, Stephan KE (2009) Dynamic causal modelling: A critical review of the biophysical and statistical foundations. Neuroimage 41: -312

Douglas RJ, Martin KA (2004) Neuronal circuits of the neocortex. Annu Rev Neurosci 27:419-51 [PubMed]

Douglas RJ, Martin KA (2007) Recurrent neuronal circuits in the neocortex. Curr Biol 17:R496-500

Douglas RJ, Martin KA (2007) Mapping the matrix: the ways of neocortex. Neuron 56:226-38 [PubMed]

Douglas RJ, Martin KAC, Whitteridge D (1989) A canonical microcircuit for neocortex Neural Comput 1:480-488

Duzel E, Penny WD, Burgess N (2010) Brain oscillations and memory. Curr Opin Neurobiol 20:143-9 [PubMed]

Dyhrfjeld-Johnsen J, Santhakumar V, Morgan RJ, Huerta R, Tsimring L, Soltesz I (2007) Topological determinants of epileptogenesis in large-scale structural and functional models of the dentate gyrus derived from experimental data. J Neurophysiol 97:1566-87 [Journal] [PubMed]

   Dentate gyrus (Morgan et al. 2007, 2008, Santhakumar et al. 2005, Dyhrfjeld-Johnsen et al. 2007) [Model]

Eldawlatly S, Zhou Y, Jin R, Oweiss K (2008) Reconstructing functional neuronal circuits using dynamic Bayesian networks. Conf Proc IEEE Eng Med Biol Soc 2008:5531-4

Engel A, Konig P, Kreiter A, Gray C, Singer W (1991) Temporal coding by coherent oscillations as a potential solution to the binding problem: physiological evidence Nonlinear dynamics and neural networks, Schuster HG, ed.

Engel AK, Singer W (2001) Temporal binding and the neural correlates of sensory awareness. Trends Cogn Sci 5:16-25 [PubMed]

Fransen E, Lansner A (1998) A model of cortical associative memory based on a horizontal network of connected columns. Network 9:235-64 [PubMed]

Fries P, Nikolić D, Singer W (2007) The gamma cycle. Trends Neurosci 30:309-16 [PubMed]

Gansner ER, North SC (2000) An open graph visualization system and its applications to software engineering Software: practice and experience 11:1203-1233

Gourevitch B, Eggermont JJ (2007) Evaluating information transfer between auditory cortical neurons. J Neurophysiol 97:2533-43 [PubMed]

Gray CM, Singer W (1989) Stimulus-specific neuronal oscillations in orientation columns of cat visual cortex. Proc Natl Acad Sci U S A 86:1698-702 [PubMed]

Groh A, Meyer HS, Schmidt EF, Heintz N, Sakmann B, Krieger P (2010) Cell-type specific properties of pyramidal neurons in neocortex underlying a layout that is modifiable depending on the cortical area. Cereb Cortex 20:826-36 [PubMed]

   [48 reconstructed morphologies on NeuroMorpho.Org]

Hagmann P, Cammoun L, Gigandet X, Meuli R, Honey CJ, Wedeen VJ, Sporns O (2008) Mapping the structural core of human cerebral cortex. PLoS Biol 6:e159 [PubMed]

Hasselmo ME (2006) The role of acetylcholine in learning and memory. Curr Opin Neurobiol 16:710-5 [PubMed]

Heinzle J, Hepp K, Martin KA (2007) A microcircuit model of the frontal eye fields. J Neurosci 27:9341-53 [Journal] [PubMed]

   A microcircuit model of the frontal eye fields (Heinzle et al. 2007) [Model]

Hill S, Tononi G (2005) Modeling sleep and wakefulness in the thalamocortical system. J Neurophysiol 93:1671-98 [Journal] [PubMed]

Hines ML, Carnevale NT (2001) NEURON: a tool for neuroscientists. Neuroscientist 7:123-35 [Journal] [PubMed]

   Spatial gridding and temporal accuracy in NEURON (Hines and Carnevale 2001) [Model]

Iturria-Medina Y, Sotero RC, Canales-Rodríguez EJ, Aleman-Gómez Y, Melie-García L (2008) Studying the human brain anatomical network via diffusion-weighted MRI and Graph Theory. Neuroimage 40:1064-76 [PubMed]

Izhikevich EM, Edelman GM (2008) Large-scale model of mammalian thalamocortical systems. Proc Natl Acad Sci U S A 105:3593-8 [PubMed]

Jahr CE, Stevens CF (1990) A quantitative description of NMDA receptor-channel kinetic behavior. J Neurosci 10:1830-7 [PubMed]

Jahr CE, Stevens CF (1990) Voltage dependence of NMDA-activated macroscopic conductances predicted by single-channel kinetics. J Neurosci 10:3178-82 [PubMed]

Jensen O, Tesche CD (2002) Frontal theta activity in humans increases with memory load in a working memory task. Eur J Neurosci 15:1395-9 [PubMed]

Jones SR, Pritchett DL, Sikora MA, Stufflebeam SM, Hamalainen M, Moore CI (2009) Quantitative Analysis and Biophysically Realistic Neural Modeling of the MEG Mu Rhythm: Rhythmogenesis and Modulation of Sensory-Evoked Responses. J Neurophysiol 102:3554-72 [Journal] [PubMed]

   Biophysically realistic neural modeling of the MEG mu rhythm (Jones et al. 2009) [Model]

Karameh FN, Dahleh MA, Brown EN, Massaquoi SG (2006) Modeling the contribution of lamina 5 neuronal and network dynamics to low frequency EEG phenomena. Biol Cybern 95:289-310 [PubMed]

Kelemen E, Fenton AA (2010) Dynamic grouping of hippocampal neural activity during cognitive control of two spatial frames. PLoS Biol 8:e1000403 [PubMed]

Kerr CC, Neymotin SA, Chadderdon GL, Fietkiewicz CT, Francis JT, Lytton WW (2012) Electrostimulation as a prosthesis for repair of information flow in a computer model of neocortex IEEE Transactions on Neural Systems & Rehabilitation Engineering 20(2):153-60 [Journal] [PubMed]

   Prosthetic electrostimulation for information flow repair in a neocortical simulation (Kerr 2012) [Model]

Kopell N, Ermentrout GB, Whittington MA, Traub RD (2000) Gamma rhythms and beta rhythms have different synchronization properties. Proc Natl Acad Sci U S A 97:1867-72 [PubMed]

Lefort S, Tomm C, Floyd Sarria JC, Petersen CC (2009) The excitatory neuronal network of the C2 barrel column in mouse primary somatosensory cortex. Neuron 61:301-16 [PubMed]

Lehnertz K, Bialonski S, Horstmann MT, Krug D, Rothkegel A, Staniek M, Wagner T (2009) Synchronization phenomena in human epileptic brain networks. J Neurosci Methods 183:42-8 [PubMed]

Lisman J (2010) Working memory: the importance of theta and gamma oscillations. Curr Biol 20:R490-2 [PubMed]

Lisman JE, Idiart MA (1995) Storage of 7 +/- 2 short-term memories in oscillatory subcycles. Science 267:1512-5 [PubMed]

Lundqvist M, Compte A, Lansner A (2010) Bistable, irregular firing and population oscillations in a modular attractor memory network. PLoS Comput Biol 6:e1000803-6 [PubMed]

Lytton WW (1996) Optimizing synaptic conductance calculation for network simulations. Neural Comput 8:501-9 [PubMed]

Lytton WW (2002) From Computer To Brain

Lytton WW (2006) Neural Query System: Data-mining from within the NEURON simulator. Neuroinformatics 4:163-76 [Journal] [PubMed]

   Neural Query System NQS Data-Mining From Within the NEURON Simulator (Lytton 2006) [Model]

Lytton WW (2008) Computer modelling of epilepsy. Nat Rev Neurosci 9:626-37 [Journal] [PubMed]

Lytton WW, Neymotin SA, Hines ML (2008) The virtual slice setup. J Neurosci Methods 171:309-15 [Journal] [PubMed]

   The virtual slice setup (Lytton et al. 2008) [Model]

Lytton WW, Omurtag A (2007) Tonic-clonic transitions in computer simulation. J Clin Neurophysiol 24:175-81 [PubMed]

   Tonic-clonic transitions in a seizure simulation (Lytton and Omurtag 2007) [Model]

Lytton WW, Omurtag A, Neymotin SA, Hines ML (2008) Just in time connectivity for large spiking networks Neural Comput 20(11):2745-56 [Journal] [PubMed]

   JitCon: Just in time connectivity for large spiking networks (Lytton et al. 2008) [Model]

Lytton WW, Sejnowski TJ (1991) Simulations of cortical pyramidal neurons synchronized by inhibitory interneurons. J Neurophysiol 66:1059-79 [Journal] [PubMed]

Lytton WW, Stewart M (2005) A rule-based firing model for neural networks Int J Bioelectromagn 7:47-50

Lytton WW, Stewart M (2006) Rule-based firing for network simulations. Neurocomputing 69:1160-1164

Lytton WW, Stewart M (2007) Data mining through simulation. Methods Mol Biol 401:155-66 [PubMed]

Makarov VA, Panetsos F, de Feo O (2005) A method for determining neural connectivity and inferring the underlying network dynamics using extracellular spike recordings. J Neurosci Methods 144:265-79 [PubMed]

Markram H, Toledo-Rodriguez M, Wang Y, Gupta A, Silberberg G, Wu C (2004) Interneurons of the neocortical inhibitory system. Nat Rev Neurosci 5:793-807 [Journal] [PubMed]

Morgan RJ, Soltesz I (2008) Nonrandom connectivity of the epileptic dentate gyrus predicts a major role for neuronal hubs in seizures. Proc Natl Acad Sci U S A 105:6179-84 [Journal] [PubMed]

   Dentate gyrus (Morgan et al. 2007, 2008, Santhakumar et al. 2005, Dyhrfjeld-Johnsen et al. 2007) [Model]

Mountcastle VB (1997) The columnar organization of the neocortex. Brain 120 ( Pt 4):701-22 [PubMed]

Nelson S (2002) Cortical microcircuits: diverse or canonical? Neuron 36:19-27 [PubMed]

Neymotin S, Uhlrich DJ, Manning KA, Lytton WW (2008) Data mining of time-domain features from neural extracellular field data Applic. of Comput. Intel. in Bioinf. and Biomed.: Current Trends and Open Problems 151:119-140 [Journal]

   NEURON interfaces to MySQL and the SPUD feature extraction algorithm (Neymotin et al. 2008) [Model]

Neymotin SA, Jacobs KM, Fenton AA, Lytton WW (2011) Synaptic information transfer in computer models of neocortical columns. J Comput Neurosci. 30(1):69-84 [Journal] [PubMed]

   Synaptic information transfer in computer models of neocortical columns (Neymotin et al. 2010) [Model]

Neymotin SA, Lee H, Fenton AA, Lytton WW (2010) Interictal EEG discoordination in a rat seizure model. J Clin Neurophysiol 27:438-44 [PubMed]

Olypher AV, Klement D, Fenton AA (2006) Cognitive disorganization in hippocampus: a physiological model of the disorganization in psychosis. J Neurosci 26:158-68 [PubMed]

Orman R, Von Gizycki H, Lytton WW, Stewart M (2008) Local axon collaterals of area CA1 support spread of epileptiform discharges within CA1, but propagation is unidirectional. Hippocampus 18:1021-33 [PubMed]

Osterhage H, Mormann F, Staniek M, Lehnertz K (2007) Measuring synchronization in the epileptic brain: a comparison of different approaches Int J Bifurcation Chaos 17:3539

Palva JM, Palva S, Kaila K (2005) Phase synchrony among neuronal oscillations in the human cortex. J Neurosci 25:3962-72 [PubMed]

Paus T (2005) Inferring causality in brain images: a perturbation approach. Philos Trans R Soc Lond B Biol Sci 360:1109-14 [PubMed]

Petersen CC, Sakmann B (2001) Functionally independent columns of rat somatosensory barrel cortex revealed with voltage-sensitive dye imaging. J Neurosci 21:8435-46 [PubMed]

Quilodran R, Gariel MA, Markov NT, Falchier A, Vezoli J, Sallet J, Anderson JC, Dehay C, Doug (2008) Strong loops in the neocortex Society for Neuroscience Abstracts 853.4

Quinn CJ, Coleman TP, Kiyavash N, Hatsopoulos NG (2011) Estimating the directed information to infer causal relationships in ensemble neural spike train recordings. J Comput Neurosci 30:17-44 [PubMed]

Raghavachari S, Kahana MJ, Rizzuto DS, Caplan JB, Kirschen MP, Bourgeois B, Madsen JR, Lisman (2001) Gating of human theta oscillations by a working memory task. J Neurosci 21:3175-83 [PubMed]

Raghavachari S, Lisman JE, Tully M, Madsen JR, Bromfield EB, Kahana MJ (2006) Theta oscillations in human cortex during a working-memory task: evidence for local generators. J Neurophysiol 95:1630-8 [PubMed]

Rajagovindan R, Ding M (2011) From prestimulus alpha oscillation to visual-evoked response: an inverted-U function and its attentional modulation. J Cogn Neurosci 23:1379-94 [PubMed]

Rajapakse JC, Zhou J (2007) Learning effective brain connectivity with dynamic Bayesian networks. Neuroimage 37:749-60 [PubMed]

Rockland KS, Ichinohe N (2004) Some thoughts on cortical minicolumns. Exp Brain Res 158:265-77 [PubMed]

Roebroeck A, Formisano E, Goebel R (2005) Mapping directed influence over the brain using Granger causality and fMRI. Neuroimage 25:230-42 [PubMed]

Rulkov NF, Timofeev I, Bazhenov M (2004) Oscillations in large-scale cortical networks: map-based model. J Comput Neurosci 17:203-23 [Journal] [PubMed]

   Large cortex model with map-based neurons (Rulkov et al 2004) [Model]

Schindler K, Leung H, Elger CE, Lehnertz K (2007) Assessing seizure dynamics by analysing the correlation structure of multichannel intracranial EEG. Brain 130:65-77 [PubMed]

Schreiber T (2000) Measuring information transfer Phys Rev Lett 85:461-4 [PubMed]

Sejnowski TJ, Koch C, Churchland PS (1988) Computational neuroscience. Science 241:1299-306

Seth AK (2008) Causal networks in simulated neural systems. Cogn Neurodyn 2:49-64 [PubMed]

Shinomoto S, Miyazaki Y, Tamura H, Fujita I (2005) Regional and laminar differences in in vivo firing patterns of primate cortical neurons. J Neurophysiol 94:567-75 [Journal] [PubMed]

Silva LR, Amitai Y, Connors BW (1991) Intrinsic oscillations of neocortex generated by layer 5 pyramidal neurons. Science 251:432-5 [PubMed]

Bezaire MJ, Raikov I, Burk K, Vyas D, Soltesz I (2016) Interneuronal mechanisms of hippocampal theta oscillation in a full-scale model of the rodent CA1 circuit. Elife [Journal] [PubMed]

   Hippocampal CA1 NN with spontaneous theta, gamma: full scale & network clamp (Bezaire et al 2016) [Model]

Chadderdon GL, Mohan A, Suter BA, Neymotin SA, Kerr CC, Francis JT, Shepherd GM, Lytton WW (2014) Motor cortex microcircuit simulation based on brain activity mapping. Neural Comput 26:1239-62 [Journal] [PubMed]

   Motor cortex microcircuit simulation based on brain activity mapping (Chadderdon et al. 2014) [Model]

Chadderdon GL, Neymotin SA, Kerr CC, Lytton WW (2012) Reinforcement learning of targeted movement in a spiking neuronal model of motor cortex PLoS ONE 2012 7(10):e47251 [Journal]

   Reinforcement learning of targeted movement (Chadderdon et al. 2012) [Model]

Dura-Bernal S, Li K, Neymotin SA, Francis JT, Principe JC, Lytton WW (2016) Restoring behavior via inverse neurocontroller in a lesioned cortical spiking model driving a virtual arm. Front. Neurosci. Neuroprosthetics 10:28 [Journal]

   Cortical model with reinforcement learning drives realistic virtual arm (Dura-Bernal et al 2015) [Model]

Dura-Bernal S, Zhou X, Neymotin SA, Przekwas A, Francis JT, Lytton WW (2015) Cortical Spiking Network Interfaced with Virtual Musculoskeletal Arm and Robotic Arm. Front Neurorobot 9:13 [Journal] [PubMed]

   Cortical model with reinforcement learning drives realistic virtual arm (Dura-Bernal et al 2015) [Model]

Eguchi A, Neymotin SA and Stringer SM (2014) Color opponent receptive fields self-organize in a biophysical model of visual cortex via spike-timing dependent plasticity 8:16. doi: Front. Neural Circuits 8:16 [Journal]

   Simulated cortical color opponent receptive fields self-organize via STDP (Eguchi et al., 2014) [Model]

Kerr CC, Van Albada SJ, Neymotin SA, Chadderdon GL, Robinson PA, Lytton WW (2013) Cortical information flow in Parkinson's disease: a composite network-field model. Front Comput Neurosci 7:39:1-14 [Journal] [PubMed]

   Composite spiking network/neural field model of Parkinsons (Kerr et al 2013) [Model]

Lytton WW, Neymotin SA, Wester JC, Contreras D (2011) Neocortical simulation for epilepsy surgery guidance: Localization and intervention Computational Surgery and Dual Training

   Computational Surgery (Lytton et al. 2011) [Model]

Neymotin SA, Chadderdon GL, Kerr CC, Francis JT, Lytton WW (2013) Reinforcement learning of 2-joint virtual arm reaching in a computer model of sensorimotor cortex Neural Computation 25(12):3263-93 [Journal] [PubMed]

   Sensorimotor cortex reinforcement learning of 2-joint virtual arm reaching (Neymotin et al. 2013) [Model]

Neymotin SA, Dura-Bernal S, Lakatos P, Sanger TD, Lytton WW (2016) Multitarget Multiscale Simulation for Pharmacological Treatment of Dystonia in Motor Cortex. Front Pharmacol 7:157 [Journal] [PubMed]

   Multitarget pharmacology for Dystonia in M1 (Neymotin et al 2016) [Model]

Neymotin SA, Lazarewicz MT, Sherif M, Contreras D, Finkel LH, Lytton WW (2011) Ketamine disrupts theta modulation of gamma in a computer model of hippocampus Journal of Neuroscience 31(32):11733-11743 [Journal] [PubMed]

   Ketamine disrupts theta modulation of gamma in a computer model of hippocampus (Neymotin et al 2011) [Model]

Neymotin SA, McDougal RA, Bulanova AS, Zeki M, Lakatos P, Terman D, Hines ML, Lytton WW (2016) Calcium regulation of HCN channels supports persistent activity in a multiscale model of neocortex Neuroscience 316:344-366 [Journal] [PubMed]

   Ca+/HCN channel-dependent persistent activity in multiscale model of neocortex (Neymotin et al 2016) [Model]

Rowan MS, Neymotin SA, Lytton WW (2014) Electrostimulation to reduce synaptic scaling driven progression of Alzheimer's disease. Front Comput Neurosci 8:39 [Journal] [PubMed]

   Electrostimulation to reduce synaptic scaling driven progression of Alzheimers (Rowan et al. 2014) [Model]

Rowan MS,Neymotin SA (2013) Synaptic Scaling Balances Learning in a Spiking Model of Neocortex Adaptive and Natural Computing Algorithms, Tomassini M, Antonioni A, Daolio F, Buesser P, ed. pp.20 [Journal]

   Synaptic scaling balances learning in a spiking model of neocortex (Rowan & Neymotin 2013) [Model]

(114 refs)