Ih tunes oscillations in an In Silico CA3 model (Neymotin et al. 2013)

 Download zip file   Auto-launch 
Help downloading and running models
Accession:151282
" ... We investigated oscillatory control using a multiscale computer model of hippocampal CA3, where each cell class (pyramidal, basket, and oriens-lacunosum moleculare cells), contained type-appropriate isoforms of Ih. Our model demonstrated that modulation of pyramidal and basket Ih allows tuning theta and gamma oscillation frequency and amplitude. Pyramidal Ih also controlled cross-frequency coupling (CFC) and allowed shifting gamma generation towards particular phases of the theta cycle, effected via Ih’s ability to set pyramidal excitability. ..."
Reference:
1 . Neymotin SA, Hilscher MM, Moulin TC, Skolnick Y, Lazarewicz MT, Lytton WW (2013) Ih Tunes Theta/Gamma Oscillations and Cross-Frequency Coupling In an In Silico CA3 Model PLoS ONE 8(10):e76285 [PubMed]
Model Information (Click on a link to find other models with that property)
Model Type: Realistic Network;
Brain Region(s)/Organism: Hippocampus;
Cell Type(s): Hippocampus CA3 pyramidal cell; Hippocampus CA3 basket cell; Hippocampus CA3 stratum oriens lacunosum-moleculare interneuron;
Channel(s): I Na,t; I A; I K; I K,leak; I h; I K,Ca; I Sodium; I Potassium;
Gap Junctions:
Receptor(s): GabaA; AMPA; NMDA; Glutamate;
Gene(s): HCN1; HCN2;
Transmitter(s): Gaba; Glutamate;
Simulation Environment: NEURON; Python;
Model Concept(s): Oscillations; Brain Rhythms; Conductance distributions; Multiscale;
Implementer(s): Lazarewicz, Maciej [mlazarew at gmu.edu]; Neymotin, Sam [samn at neurosim.downstate.edu];
Search NeuronDB for information about:  Hippocampus CA3 pyramidal cell; Hippocampus CA3 basket cell; GabaA; AMPA; NMDA; Glutamate; I Na,t; I A; I K; I K,leak; I h; I K,Ca; I Sodium; I Potassium; Gaba; Glutamate;
/
ca3ihdemo
readme.txt
CA3ih.mod
CA3ika.mod
CA3ikdr.mod
CA3ina.mod
caolmw.mod *
HCN1.mod
icaolmw.mod *
iholmw.mod
ihstatic.mod
kcaolmw.mod *
kdrbwb.mod *
misc.mod *
MyExp2SynBB.mod *
MyExp2SynNMDABB.mod *
nafbwb.mod *
stats.mod *
vecst.mod *
aux_fun.inc *
declist.hoc *
decmat.hoc *
decnqs.hoc *
decvec.hoc *
default.hoc *
drline.hoc *
geom.py
grvec.hoc *
init.hoc
labels.hoc *
local.hoc *
misc.h *
network.py
nqs.hoc *
nrnoc.hoc *
params.py
pyinit.py *
pywrap.hoc
run.py
sim.py
simctrl.hoc *
stats.hoc *
syncode.hoc *
xgetargs.hoc *
                            
// $Id: decmat.hoc,v 1.78 2011/07/11 05:58:31 samn Exp $ 
 
print "Loading decmat.hoc..."
 
//** mtriavg(mat,[mask]) - get average of elements in upper triangular part of matrix $o1
// mask is of same size as mat, has 0 for entries to skip
func mtriavg () { local i,j,s,c localobj mm,msk
  mm=$o1 s=c=0
  if(numarg()>1) { msk=$o2
    for i=0,mm.nrow-1 for j=i+1,mm.ncol-1 if(msk.x(i,j)) {
      s+=mm.x[i][j]
      c+=1
    }    
  } else {
    for i=0,mm.nrow-1 for j=i+1,mm.ncol-1 {
      s+=mm.x[i][j]
      c+=1
    }
  }
  if(c>0) return s/c else return 0
}

//** mltristd(mat,[mask]) - get stdev of elements in upper triangular part of matrix $o1
// mask is of same size as mat, has 0 for entries to skip
func mtristd () { local i,j,s,c,s2,tm localobj mm,msk
  mm=$o1 s=s2=c=0
  if(numarg()>1) { msk=$o2
    for i=0,mm.nrow-1 for j=i+1,mm.ncol-1 if(msk.x(i,j)) {
      s+=mm.x[i][j]
      s2+=mm.x[i][j]^2
      c+=1
    }
  } else {
    for i=0,mm.nrow-1 for j=i+1,mm.ncol-1 {
      s+=mm.x[i][j]
      s2+=mm.x[i][j]^2
      c+=1
    }
  }
  if(c>0) return sqrt(s2/c - (s/c)^2) else return 0
}

//** mltristd(mat,[mask]) - get std-error of elements in upper triangular part of matrix $o1
// mask is of same size as mat, has 0 for entries to skip
func mtristderr () { local i,j,s,c,s2,tm localobj mm,msk
  mm=$o1 s=s2=c=0
  if(numarg()>0) {
    msk=$o2
    for i=0,mm.nrow-1 for j=i+1,mm.ncol-1 if(msk.x(i,j)) {
      s+=mm.x[i][j]
      s2+=mm.x[i][j]^2
      c+=1
    }
  } else {
    for i=0,mm.nrow-1 for j=i+1,mm.ncol-1 {
      s+=mm.x[i][j]
      s2+=mm.x[i][j]^2
      c+=1
    }
  }
  if(c>0) return sqrt(s2/c - (s/c)^2)/sqrt(c) else return 0
}

//** vi2mi(ind[,COLS]) take index from vector and print out matrix indices using COLS 
obfunc vi2mi () { local x,co,r,c
  x=$1
  if (argtype(2)==0) co=$2 else co=COLS
  r=int(x/COLS) c=x%COLS
  if (verbose) print r,c
  return new Union(r,c)
}

//** symmclean(vec[,COLS]) remove redundant entries from vector representing a symm matrix
proc vimiclean() {print "Use symmclean() statt vimiclean()"}
func symmclean () { local ix,dg,cols,ii,n,flag localobj v1
  v1=$o1 
  if (argtype(2)==0) cols=$2 else cols=COLS
  if (argtype(3)==0) flag=$3 else flag=0 // flag gets rid of the diagonal as well
  for ii=0,v1.size-1 { ix=v1.x[ii]
    dg=(n=int(ix/(cols+1)))*(cols+1)
    if (ix<dg || ix>=dg+(cols-n)) v1.x[ii]=-1
    if (flag && ix==dg) v1.x[ii]=-1
  }
  v1.where(">",-1)
  return v1.size
}

//** msqdif(m1,m2) - get matrix with elements squared difference of m1-m2
obfunc msqdif () { local i,j localobj m1,m2,md
  m1=$o1 m2=$o2
  md=new Matrix(m1.nrow,m1.ncol)
  for i=0,m1.nrow-1 for j=0,m1.ncol-1 md.x[i][j]=(m1.x[i][j]-m2.x[i][j])^2
  return md
}

//** mthresh(mat,th) - get matrix with mat elements thresholded : values < t set to 0, >= t to 1
obfunc mthresh () { local i,j,t localobj mi,mo
  mi=$o1 t=$2
  mo=new Matrix(mi.nrow,mi.ncol)
  for i=0,mo.nrow-1 for j=0,mo.ncol-1 if(mi.x[i][j]>=t) mo.x[i][j]=1 else mo.x[i][j]=0
  return mo
}

//** mdif(m1,m2) - get matrix with elements difference of m1-m2
obfunc mdif () { local i,j localobj m1,m2,md
  m1=$o1 m2=$o2
  md=new Matrix(m1.nrow,m1.ncol)
  for i=0,m1.nrow-1 for j=0,m1.ncol-1 md.x[i][j]=(m1.x[i][j]-m2.x[i][j])
  return md
}

//** getttmat(nqs,[column-name]) - uses NQS $o1 to make time-time correlation matrix
//optional $s2 , otherwise default column-name = 'vc'.
//column $s2 must be .odec with Vector objects
obfunc getttmat () { local i,j,inc,szm localobj mc,nq,v1,v2,str,lc
  {nq=$o1    str=new String()}
  if(numarg()>1)str.s=$s2 else str.s="vc"
  {szm=nq.v.size()  mc=new Matrix(szm,szm)  lc=new List()}
  for i=0,szm-1 lc.append(nq.get(str.s,i).o)
  for i=0,szm-1 {
    mc.x(i,i)=1
    v1=lc.o(i) 
    for j=i+1,szm-1 {
      v2=lc.o(j) 
      mc.x(i,j)=mc.x(j,i)=v1.pcorrel(v2)
    }
  }
  return mc
}

//** svmat(matrix,path,[writesz,binary]) - save a matrix to file as ascii, each row on new line
//$o1==matrix, $s2==file path -- will overwrite!! , $3 = optional == 1 to include nrows,ncols
// writesz = write rows,cols . binary - use binary output format, this will write using vwrite
// and first two elements of written vector will have rows,cols (so writesz arg is ignored)
func svmat () { local pr,bin,a localobj m,f,myv1,myv2,mt
  {m=$o1 a=allocvecs(myv1,myv2) f=new File() f.wopen($s2)}
  if(!f.isopen()) {
    printf("svmat ERRA: couldnt open output file %s\n",$s2)
    return 0
  }
  if(numarg()>2)pr=$3 else pr=0
  if(numarg()>3)bin=$4 else bin=0
  if(bin) {
    mt=$o1.transpose()
    mt.to_vector(myv1)
    myv2.append($o1.ncol,$o1.nrow)
    myv2.append(myv1)
    myv2.vwrite(f)
  } else {
    if(pr) m.fprint(f) else m.fprint(0,f)
  }
  {f.close() dealloc(a)}
  return 1
}

//obfunc rdmat () { local pr localobj m,f
// m=$o1
// f=new File()
// f.wopen($s2)
// if(!f.isopen()) {
//   printf("svmat ERRA: couldnt open output file %s\n",$s2)
//   return 0
// }
// if(numarg()>2)pr=$3 else pr=0
// if(pr) m.fprint(f) else m.fprint(0,f)
// f.close()
// return 1
//}

//** matimagesc - display a matrix ($o1) in matlab using matimgsc program
// or a text file $s1 , $2 = min scale value , $3 = max scale value, $4 optional
// binary input flag
func matimagesc () { local x,binflag localobj str
  if(numarg()>3) binflag=$4 else binflag=1
  str=new String2()
  if(argtype(1)==2) {
    str.s=$s1
  } else {
    str.s="__tmp__mat__ml__.txt"
    if(!svmat($o1,str.s,1,binflag)) return 0
  }
  sprint(str.t,"/usr/site/nrniv/local/matlab/matimgsc %s %g %g %d",str.s,$2,$3,binflag)
  x = system(str.t)
  return x
}

//** pyimagesc - display a matrix ($o1) in python's matplotlib or a text file $s1
//opt:[$2=min scaling for colors, $3=max scaling for colors, [$s4=title,$s5=xlabel,$s6=ylabel]
func pyimagesc () { local i,minc,maxc localobj str,cmd,strout,strt,strl,fp
  str=new String2()
  strout=new String()//collect stdout from script
  if(argtype(1)==2) {
    str.s=$s1
  } else {
    str.s="__tmp__mat__py__.txt"
    if(!svmat($o1,str.s)) return 0
  }
  if(numarg()>1)minc=$2 else minc=-1
  if(numarg()>2)maxc=$3 else maxc=1  
  if(numarg()>3) { //write title,xlabel,ylabel for pyimgsc.py
    {strl=new String() strl.s="__tmp__str__py__.txt"    fp=new File()}
    fp.wopen(strl.s)
    if(!fp.isopen()){
      printf("pyimagesc ERRB: couldnt save tmp file %s\n",strl.s)
      return 0
    }
    for i=4,numarg() fp.printf("%s\n",$si)
    fp.close()
    sprint(str.t,"/u/samn/python/pyimgsc.py %s %g %g %s",str.s,minc,maxc,strl.s)
  } else {
    sprint(str.t,"/u/samn/python/pyimgsc.py %s %g %g",str.s,minc,maxc)
  }
  return system(str.t,strout.s)
}

//** matgcspks(vec1,vec2,samplingrate,pathin1,pathin2,pathout,pid])
// this function calls /usr/site/nrniv/local/matlab/callmatgcspks to send a signal to
// /usr/site/nrniv/local/matlab/matgcspks and run MZD's granger causality on spike trains
// this function returns an NQS with 1 row containing output
// vec1,vec2 are binned spike trains (spikes per time)
// returns a vector containing vec1->vec2,  vec2->vec1 granger causality
obfunc matgcspks () { local sampr,pid localobj vspks1,vspks2,fpin1,fpin2,fpout,str,vop,strin,strout
  if(numarg()==0) {printf("matgcspks(vec1,vec2,samplingrate)\nvec1,2 are binned spike trains\n") return nil}
  vspks1=$o1 vspks2=$o2 sampr=$3 vop=new Vector(2)
  fpin1=new File() fpin2=new File() fpout=new File() str=new String() strin=new String2() strout=new String()  
  {strin.s=$s4 strin.t=$s5 strout.s=$s6 pid=$7}
  {fpin1.wopen(strin.s) fpin2.wopen(strin.t)}
  if(!fpin1.isopen()) {printf("matgcspks ERRA: couldn't open %s for writing\n",strin.s)  return nil}
  if(!fpin2.isopen()) {printf("matgcspks ERRA: couldn't open %s for writing\n",strin.t)  return nil}
  {vspks1.vwrite(fpin1)  fpin1.close() vspks2.vwrite(fpin2)  fpin2.close()}
  sprint(str.s,"/usr/site/nrniv/local/matlab/callmatgcspks %d",pid)
  {printf("%s\n",str.s) system(str.s)}
  fpout.ropen(strout.s)
  while(!fpout.isopen()){
    printf("matgcspks ERRB: couldn't open %s for reading\n",strout.s)
    fpout.ropen(strout.s)
  }
  vop.vread(fpout)
  return vop
}

//** matspecgram(vec,samplingrate,maxfrequency,fftwinsz,[,dodraw,mincolor,maxcolor])
// if fftwinsz <= 0, matspecgram will pick a WINDOW size for STFT
obfunc matspecgram () { local a,sampr,maxfreq,dodraw,rows,cols,x,y,minc,maxc,fftwinsz\
                       localobj vin,fpin,fpout,str,vop,vof,nqo,strin,strout,vtmp,strd
  vin=$o1 sampr=$2 maxfreq=$3 fftwinsz=$4 fpin=new File() fpout=new File()
  str=new String() strin=new String() strout=new String() strd=new String()
  a=allocvecs(vtmp,vop,vof)  if(numarg()>4)dodraw=$5 else dodraw=1  
  if(!fpin.mktemp || !fpout.mktemp) {
    print "matspecgram ERR0: couldn't make temp files!"
    {dealloc(a) return nil}
  }  
  {strin.s=fpin.getname strout.s=fpout.getname strd.s="/usr/site/nrniv/local/matlab" fpin.wopen(strin.s)}
  if(!fpin.isopen()){printf("matspecgram ERRA: couldn't open %s for writing\n",strin.s) dealloc(a) return nil}
  {vin.vwrite(fpin)  fpin.close()}
  if(dodraw && numarg()>=7) {
    sprint(str.s,"%s/matspecgram %s %g %g %d %d %s %g %g",strd.s,strin.s,sampr,maxfreq,fftwinsz,dodraw,strout.s,$6,$7)
  } else {
    sprint(str.s,"%s/matspecgram %s %g %g %d %d %s",strd.s,strin.s,sampr,maxfreq,fftwinsz,dodraw,strout.s)
  }
  print str.s
  system(str.s)
  fpout.ropen(strout.s) 
  if(!fpout.isopen()){printf("matspecgram ERRB: couldn't open %s for reading\n",strout.s) dealloc(a) return nil}
  {vop.vread(fpout) vof.vread(fpout)}  
  {nqo=new NQS("f","pow")  nqo.odec("pow")}
  {rows=vof.size() cols=vop.size()/rows x=0}
  for y=0,rows-1 { vtmp.resize(0)
    vtmp.copy(vop,x,x+cols-1)
    nqo.append(vof.x(y),vtmp)
    x+=cols
  }
  {fpin.unlink() fpout.unlink()}
  {dealloc(a) return nqo}
}

//** matmodind(vec,samplingrate,lohz1,lohz2,hihz1,hihz2)
// this function calls /usr/site/nrniv/local/matlab/matmodindex to run Canolty's modulation index with Matlab
// returns an NQS with 1 row containing output
obfunc matmodind () { local a,sampr,lohz1,lohz2,hihz1,hihz2\
                       localobj vin,fpin,fpout,str,vop,nqo,strin,strout
  if(numarg()==0) {printf("matmodind(vec,samplingrate,lohz1,lohz2,hihz1,hihz2)\n") return nil}
  vin=$o1 sampr=$2 lohz1=$3 lohz2=$4 hihz1=$5 hihz2=$6
  fpin=new File() fpout=new File() str=new String() strin=new String() strout=new String()
  a=allocvecs(vop)
  if(!fpin.mktemp || !fpout.mktemp) {
    print "matmodind ERR0: couldn't make temp files!"
    {dealloc(a) return nil}
  }
  {strin.s=fpin.getname strout.s=fpout.getname}
  {fpin.wopen(strin.s)}
  if(!fpin.isopen()) {printf("matmodind ERRA: couldn't open %s for writing\n",strin.s) dealloc(a) return nil}
  {vin.vwrite(fpin)  fpin.close()}
  sprint(str.s,"/usr/site/nrniv/local/matlab/matmodindex %s %g %g %g %g %g %s",strin.s,sampr,lohz1,lohz2,hihz1,hihz2,strout.s)
  print str.s
  system(str.s)
  fpout.ropen(strout.s) 
  if(!fpout.isopen()){printf("matmodind ERRB: couldn't open %s for reading\n",strout.s) dealloc(a) return nil}
  {vop.vread(fpout) nqo=new NQS("modind","phase","lohz1","lohz2","hihz1","hihz2")}
  nqo.append(vop.x(0),vop.x(1),lohz1,lohz2,hihz1,hihz2)
  {dealloc(a) fpin.unlink() fpout.unlink()}
  return nqo
}

//** matpmtm(vec,samplingrate)
// this function calls /usr/site/nrniv/local/matlab/matpmtm to run multitaper power spectra using matlab, returns an nqs
obfunc matpmtm () { local a,sampr,rows,cols,x,y\
                       localobj vin,fpin,fpout,str,vop,vof,nqo,strin,strout
  if(numarg()==0) {printf("%s\n","matpmtm(vec,samplingrate)") return nil}
  vin=$o1 sampr=$2 fpin=new File() fpout=new File() str=new String() strin=new String() strout=new String()
  a=allocvecs(vop,vof)  
  if(!fpin.mktemp || !fpout.mktemp) {
    print "matpmtm ERR0: couldn't make temp files!"
    {dealloc(a) return nil}
  }
  {strin.s=fpin.getname strout.s=fpout.getname}
  {fpin.wopen(strin.s)}
  if(!fpin.isopen()) {printf("matpmtm ERRA: couldn't open %s for writing\n",strin.s) dealloc(a) return nil}
  {vin.vwrite(fpin)  fpin.close()}
  sprint(str.s,"/usr/site/nrniv/local/matlab/matpmtm %s %g %s",strin.s,sampr,strout.s)
  print str.s
  system(str.s)
  fpout.ropen(strout.s) 
  if(!fpout.isopen()){printf("matpmtm ERRB: couldn't open %s for reading\n",strout.s) dealloc(a) return nil}
  {vop.vread(fpout) vof.vread(fpout) nqo=new NQS("f","pow")}
  {nqo.v[0].copy(vof) nqo.v[1].copy(vop) dealloc(a) fpin.unlink() fpout.unlink()}
  return nqo
}

//** matfftpow(vec,samplingrate,maxfrequency,[dodraw,dosmooth,smoothwindowsz])
// this function calls /usr/site/nrniv/local/matlab/matfftpow to run power spectra using matlab, returns an nqs
// dosmooth controls whether to smooth output, is OFF by default
// smoothwindowsz controls size of running average smoothing of power spectra output
obfunc matfftpow () { local a,sampr,maxfreq,dodraw,rows,cols,x,y,dosmooth\
                       localobj vin,fpin,fpout,str,vop,vof,nqo,strin,strout
  if(numarg()==0) {printf("%s\n","matfftpow(vec,samplingrate,maxfrequency,[dodraw,dosmooth,smoothwindowsz])") return nil}
  vin=$o1 sampr=$2 maxfreq=$3 fpin=new File() fpout=new File() str=new String() strin=new String() strout=new String()
  a=allocvecs(vop,vof)  if(numarg()>3)dodraw=$4 else dodraw=1
  if(numarg()>4)dosmooth=$5 else dosmooth=0
  if(!fpin.mktemp || !fpout.mktemp) {
    print "matfftpow ERR0: couldn't make temp files!"
    {dealloc(a) return nil}
  }
  {strin.s=fpin.getname strout.s=fpout.getname}
  {fpin.wopen(strin.s)}
  if(!fpin.isopen()) {printf("matfftpow ERRA: couldn't open %s for writing\n",strin.s) dealloc(a) return nil}
  {vin.vwrite(fpin)  fpin.close()}
  if(numarg()>5) {
    sprint(str.s,"/usr/site/nrniv/local/matlab/matfftpow %s %g %d %d %s %d %d",strin.s,sampr,maxfreq,dodraw,strout.s,dosmooth,$6)
  } else sprint(str.s,"/usr/site/nrniv/local/matlab/matfftpow %s %g %d %d %s %d",strin.s,sampr,maxfreq,dodraw,strout.s,dosmooth)
  print str.s
  system(str.s)
  fpout.ropen(strout.s) 
  if(!fpout.isopen()){printf("matfftpow ERRB: couldn't open %s for reading\n",strout.s) dealloc(a) return nil}
  {vop.vread(fpout) vof.vread(fpout) nqo=new NQS("f","pow")}
  {nqo.v[0].copy(vof) nqo.v[1].copy(vop) dealloc(a) fpin.unlink() fpout.unlink()}
  return nqo
}

//** mathilbert(vec,samplingrate,minfrequency,maxfrequency)
obfunc mathilbert () { local a,sampr,minfreq,maxfreq\
                       localobj vin,fp,str,vfilt,vph,vamp,nqo,strin,strout
  vin=$o1 sampr=$2 minfreq=$3 maxfreq=$4 fp=new File() str=new String() strin=new String() strout=new String()
  a=allocvecs(vfilt,vph,vamp) 
  {sprint(strin.s,"__tmp__mat__hilbert__input__vec__.vec")  sprint(strout.s,"__tmp__mat__hilbert_output__vec__.vec")}
  {fp.wopen(strin.s)}
  if(!fp.isopen()) {
    printf("mathilbert ERRA: couldn't open %s for writing\n",strin.s)
    dealloc(a)
    return nil
  }
  {vin.vwrite(fp)  fp.close()}
  sprint(str.s,"/usr/site/nrniv/local/matlab/mathilbert %s %g %g %g %s",strin.s,sampr,minfreq,maxfreq,strout.s)
  print str.s
  system(str.s)
  fp.ropen(strout.s) 
  if(!fp.isopen()) {
    printf("mathilbert ERRB: couldn't open %s for reading\n",strout.s)
    dealloc(a)
    return nil
  }
  {vfilt.vread(fp) vph.vread(fp) vamp.vread(fp) nqo=new NQS("filt","phase","amp","t")}
  {nqo.v[0].copy(vfilt) nqo.v[1].copy(vph) nqo.v[2].copy(vamp)}
  {nqo.v[3].indgen(0,1e3*nqo.v[2].size/sampr,1e3/sampr)  nqo.v[3].resize(nqo.v[2].size)}
  dealloc(a)
  return nqo
}

//** matprincomp(input Matrix object)
// returns list with : eigenvectors as Vector, scores as Vector, eigenvalues as Vector, scores as Matrix
// scores has same size as $o1, eigenvectors is $o1.ncols^2, eigenvalues is $o1.ncols
// input matrix has rows as observations and columns as dimensions
obfunc matprincomp () { local i,j,k localobj mcin,fp,str,strin,strout,lsout,vcoeff,vscore,vlat,mscore
  mcin=$o1 fp=new File() str=new String() strin=new String() strout=new String() lsout=new List()
  {vcoeff=new Vector() vscore=new Vector() vlat=new Vector()}
  {sprint(strin.s,"__tmp__mat__princomp__input__mat__.txt")  sprint(strout.s,"__tmp__mat__princomp_output__vec__.vec")}
  if(!svmat(mcin,strin.s,1)) {
    printf("matprincomp ERRA: couldn't open %s for writing\n",strin.s)
    return nil
  }
  sprint(str.s,"/usr/site/nrniv/local/matlab/matprincomp %s %s",strin.s,strout.s)
  print str.s
  system(str.s)
  fp.ropen(strout.s) 
  if(!fp.isopen()) {
    printf("matprincomp ERRB: couldn't open %s for reading\n",strout.s)
    return nil
  }
  {vcoeff.vread(fp) vscore.vread(fp) vlat.vread(fp) fp.close()}
  mscore=new Matrix(mcin.nrow,mcin.ncol)
  mscore.from_vector(vscore) //reads it in in column major order
  {lsout.append(vcoeff) lsout.append(vscore) lsout.append(vlat) lsout.append(mscore)}
  return lsout
}

//** matmin(mat) - return min element of mat
func matmin () { local i,j,me,tmp localobj m
  m=$o1 
  me=m.getrow(0).min()
  for i=1,m.nrow-1 if((tmp=m.getrow(i).min)<me) me=tmp
  return me
}

//** matmax(mat) - return max element of mat
func matmax () { local i,j,me,tmp localobj m
  m=$o1 
  me=m.getrow(0).max()
  for i=1,m.nrow-1 if((tmp=m.getrow(i).max)>me) me=tmp
  return me
}

//** mlk(mat) - use vlk to print rows of matrix
// a matrix will have it's lower/smaller rows printed first:
//    1 2 3 
//    4 5 6 
//    7 8 9 
proc mlk () { local i localobj m
  m=$o1
  for i=0,m.nrow-1 vlk(m.getrow(i))
}

//** mateq(mat1,mat2) - return 1 iff matrix row Vectors are eq, 0 otherwise
func mateq () { local i localobj m1,m2
  m1=$o1 m2=$o2
  if(m1.nrow!=m2.nrow || m1.ncol!=m2.ncol) return 0
  for i=0,m1.nrow-1 if(m1.getrow(i).eq(m2.getrow(i))==0) return 0
  return 1
}

//** matavg - return average value in Matrix $o1
func matavg () { local i,s localobj m
  m=$o1
  if(m.nrow<1 || m.ncol<1) {
    printf("matavg ERRA: empty matrix!\n")
    return 0
  }
  s=0
  for i=0,m.nrow-1 s += m.getrow(i).sum()
  return s/(m.nrow*m.ncol)
}

//** avgmat(list of Matrix) - return Matrix that has its elements avg of elements in $o1 List
obfunc avgmat () { local sz,i localobj ma
  sz=$o1.count
  if(sz<1) return nil
  ma=new Matrix($o1.o(0).nrow,$o1.o(0).ncol)
  for i=0,sz-1 ma.add($o1.o(i))
  ma.muls(1.0/sz)
  return ma
}

//** stdmat(list of Matrix) - return Matrix that has its elements stdev of elements in $o1 List
obfunc stdmat () {  local sz,i,j,k localobj ms,ma
  sz=$o1.count
  if(sz<1) return nil
  ma=new Matrix($o1.o(0).nrow,$o1.o(0).ncol)
  ms=new Matrix($o1.o(0).nrow,$o1.o(0).ncol)
  for i=0,sz-1 for j=0,ma.nrow-1 for k=0,ma.ncol-1 {
    ms.x(j,k) += $o1.o(i).x(j,k)^2
    ma.x(j,k) += $o1.o(i).x(j,k)
  }
  ma.muls(1.0/sz)
  ms.muls(1.0/sz)  
  for j=0,ma.nrow-1 for k=0,ma.ncol-1 {
    ms.x(j,k) -= ma.x(j,k)^2
    if(ms.x(j,k) > 1e-9) ms.x(j,k) = sqrt(ms.x(j,k)) else ms.x(j,k) = 0
  }
  return ms
}

//** chgmat(list of before Matrices, list of after Matrices) - returns change in each entry in units of std-dev
obfunc chgmat () { local szbef,szaft,i,j,k localobj lbef,laft,mavg,mstd,lchg,mchg,mt
  lbef=$o1 laft=$o2
  szbef=lbef.count szaft=laft.count
  lchg=new List()
  mavg=avgmat(lbef)
  mstd=stdmat(lbef)
  mchg=new Matrix(mavg.nrow,mavg.ncol)
  for i=0,szaft-1 {
    mt=laft.o(i)
    for j=0,mt.nrow-1 for k=0,mt.ncol-1 {
      if(mstd.x(j,k)>1e-9) {
        mchg.x(j,k) += ( mt.x(j,k) - mavg.x(j,k) ) / mstd.x(j,k)
      } else if(szbef==1) {
        mchg.x(j,k) += ( mt.x(j,k) - mavg.x(j,k) ) 
      }
    }
  }
  return mchg
}

//** getlv(rows,cols) - make a List of Vectors as 2D array
//$1 == # of rows (vectors), $2 == # of cols (size of vectors)
obfunc getlv () { local idx,rows,cols localobj ls
  ls=new List()
  rows=$1 cols=$2
  for idx=0,rows-1 ls.append(new Vector(cols))
  return ls
}

//** vec2mat(vec,rows) - get a matrix from a vec -- row major order
obfunc vec2mat () { local i,j,k,rows,cols localobj vin,mout
  vin=$o1 rows=$2 cols=vin.size/rows mout=new Matrix(rows,cols) k=0
  for i=0,rows-1 for j=0,cols-1 {
    mout.x(i,j)=vin.x(k)
    k+=1
  }
  return mout
}

//** mat2vec(mat) - get a vec from a matrix -- row major order 
obfunc mat2vec () { local i,j,k,rows,cols localobj mat,vout
  mat=$o1 rows=mat.nrow cols=mat.ncol i=j=k=0 vout=new Vector(rows*cols)
  for i=0,rows-1 for j=0,cols-1 {
    vout.x(k)=mat.x(i,j)
    k+=1
  }
  return vout
}
//** mltmed(mat) - get median values from lower-triangular portion - lower triang. means smaller rows
// this matrix printed as (with printf or mlk):
//    1 2 3 
//    4 5 6 
//    7 8 9 
// will have mltmed of 3, since uses 2,3,6 from bottom of matrix to get median
func mltmed () { local i,j,a localobj m,vo
  a=allocvecs(vo) m=$o1
  for i=0,m.nrow-1 for j=i+1,m.ncol-1 vo.append(m.x(i,j))
  return vo.median()
}
//** mzerout(mat) - zero out everything >= diagonal
// a matrix printed as (with printf or mlk):
//    1 2 3 
//    4 5 6 
//    7 8 9 
// will end up as:
//    0 2 3 
//    0 0 6 
//    0 0 0 
proc mzerout () { local i,j,a localobj m,vo
  a=allocvecs(vo) m=$o1
  for i=0,m.nrow-1 for j=0,i m.x(i,j)=0
}
//** matsqsymm(matrix) - return 1 iff matrix is square and symmetric
func matsqsymm () { local i,j localobj mc
  mc=$o1  if(mc.nrow!=mc.ncol) return 0
  for i=0,mc.nrow-1 for j=i+1,mc.ncol-1 if(mc.x(i,j)!=mc.x(j,i)) return 0
  return 1
}
//** getsubmat(matrix,startx,endx,starty,endy) - copy subsection of matrix
// and return in new output matrix
obfunc getsubmat () { local x,y,startx,endx,starty,endy localobj m1,msub
  m1=$o1
  startx=$2 endx=$3 starty=$4 endy=$5
  msub=new Matrix(endy-starty+1,endx-startx+1)
  for y=starty,endy for x=startx,endx msub.x(y-starty,x-startx)=m1.x(y,x)
  return msub
}

Neymotin SA, Hilscher MM, Moulin TC, Skolnick Y, Lazarewicz MT, Lytton WW (2013) Ih Tunes Theta/Gamma Oscillations and Cross-Frequency Coupling In an In Silico CA3 Model PLoS ONE 8(10):e76285[PubMed]

References and models cited by this paper

References and models that cite this paper

Accili EA, Proenza C, Baruscotti M, DiFrancesco D (2002) From funny current to HCN channels: 20 years of excitation. News Physiol Sci 17:32-7 [PubMed]

Aponte Y, Lien CC, Reisinger E, Jonas P (2006) Hyperpolarization-activated cation channels in fast-spiking interneurons of rat hippocampus. J Physiol 574:229-43 [PubMed]

Arnsten AF, Paspalas CD, Gamo NJ, Yang Y, Wang M (2010) Dynamic Network Connectivity: A new form of neuroplasticity. Trends Cogn Sci 14:365-75 [PubMed]

Belluscio MA, Mizuseki K, Schmidt R, Kempter R, Buzsaki G (2012) Cross-frequency phase-phase coupling between theta¸ and gamma oscillations in the hippocampus. J Neurosci 32:423-35 [PubMed]

Bender RA, Brewster A, Santoro B, Ludwig A, Hofmann F, Biel M, Baram TZ (2001) Differential and age-dependent expression of hyperpolarization-activated, cyclic nucleotide-gated cation channel isoforms 1-4 suggests evolving roles in the developing rat hippocampus. Neuroscience 106:689-98 [PubMed]

Borgers C, Kopell N (2003) Synchronization in networks of excitatory and inhibitory neurons with sparse, random connectivity. Neural Comput 15:509-38 [PubMed]

Buzsaki G, Wang XJ (2012) Mechanisms of gamma oscillations. Annu Rev Neurosci 35:203-25 [PubMed]

Caixeta FV, Cornelio AM, Scheffer-Teixeira R, Ribeiro S, Tort AB (2013) Ketamine alters oscillatory coupling in the hippocampus. Sci Rep 3:2348-35 [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]

Canolty RT, Knight RT (2010) The functional role of cross-frequency coupling. Trends Cogn Sci 14:506-15 [PubMed]

Carnevale NT, Hines ML (2006) The NEURON Book

Carr DB, Andrews GD, Glen WB, Lavin A (2007) alpha2-Noradrenergic receptors activation enhances excitability and synaptic integration in rat prefrontal cortex pyramidal neurons via inhibition of HCN currents. J Physiol 584:437-50 [PubMed]

Chen S, Wang J, Siegelbaum SA (2001) Properties of hyperpolarization-activated pacemaker current defined by coassembly of HCN1 and HCN2 subunits and basal modulation by cyclic nucleotide. J Gen Physiol 117:491-504 [PubMed]

de Almeida L, Idiart M, Lisman JE (2009) A second function of gamma frequency oscillations: an E%-max winner-take-all mechanism selects which cells fire. J Neurosci 29:7497-503 [PubMed]

Destexhe A, Rudolph M, Pare D (2003) The high-conductance state of neocortical neurons in vivo. Nat Rev Neurosci 4:739-51 [PubMed]

Dyhrfjeld-Johnsen J, Morgan RJ, Foldy C, Soltesz I (2008) Upregulated H-current in hyperexcitable CA1 dendrites after febrile seizures. Front Cell Neurosci 2:2 [Journal] [PubMed]

Dyhrfjeld-Johnsen J, Morgan RJ, Soltesz I (2009) Double Trouble? Potential for Hyperexcitability Following Both Channelopathic up- and Downregulation of I(h) in Epilepsy. Front Neurosci 3:25-33 [PubMed]

El Khoury N, Mathieu S, Marger L, Ross J, El Gebeily G, Ethier N, Fiset C (2013) Upregulation of the hyperpolarization-activated current increases pacemaker activity of the sinoatrial node and heart rate during pregnancy in mice. Circulation 127:2009-20 [PubMed]

Freund TF, Buzsaki G (1996) Interneurons of the hippocampus. Hippocampus 6:347-470 [PubMed]

Hagiwara N, Irisawa H (1989) Modulation by intracellular Ca2+ of the hyperpolarization-activated inward current in rabbit single sino-atrial node cells. J Physiol 409:121-41 [PubMed]

Heys JG, Hasselmo ME (2012) Neuromodulation of I(h) in layer II medial entorhinal cortex stellate cells: a voltage-clamp study. J Neurosci 32:9066-72 [PubMed]

Hilscher MM, Leão KE, Leão RN (2013) Synchronization through nonreciprocal connections in a hybrid hippocampus microcircuit. Front Neural Circuits 7:120-503 [PubMed]

Hines ML, Davison AP, Muller E (2009) NEURON and Python Frontiers in Neuroinformatics 3:1 [Journal] [PubMed]

   NEURON + Python (Hines et al. 2009) [Model]

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

Kramer MA, Tort AB, Kopell NJ (2008) Sharp edge artifacts and spurious coupling in EEG frequency comodulation measures. J Neurosci Methods 170:352-7 [PubMed]

Lakatos P, Karmos G, Mehta AD, Ulbert I, Schroeder CE (2008) Entrainment of neuronal oscillations as a mechanism of attentional selection. Science 320:110-3 [PubMed]

Lee H, Dvorak D, Kao HY, Duffy ÁM, Scharfman HE, Fenton AA (2012) Early cognitive experience prevents adult deficits in a neurodevelopmental schizophrenia model. Neuron 75:714-24 [PubMed]

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

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, Sejnowski TJ (1991) Simulations of cortical pyramidal neurons synchronized by inhibitory interneurons. J Neurophysiol 66:1059-79 [Journal] [PubMed]

Marcelin B, Chauviere L, Becker A, Migliore M, Esclapez M, Bernard C (2009) h channel-dependent deficit of theta oscillation resonance and phase shift in temporal lobe epilepsy. Neurobiol Dis 33(3):436-447 [Journal] [PubMed]

   CA1 pyramidal neuron: h channel-dependent deficit of theta oscill. resonance (Marcelin et al. 2008) [Model]

McCormick DA, Huguenard JR (1992) A model of the electrophysiological properties of thalamocortical relay neurons. J Neurophysiol 68:1384-400 [Journal] [PubMed]

Migliore M, Messineo L, Ferrante M (2004) Dendritic Ih selectively blocks temporal summation of unsynchronized distal inputs in CA1 pyramidal neurons. J Comput Neurosci 16:5-13 [Journal] [PubMed]

   CA1 pyramidal neuron: effects of Ih on distal inputs (Migliore et al 2004) [Model]

Migliore M, Migliore R (2012) Know your current I: interaction with a shunting current explains the puzzling effects of its pharmacological or pathological modulations PLoS One 7(5):e36867 [Journal] [PubMed]

   CA1 pyramidal neuron: Ih current (Migliore et al. 2012) [Model]

Newman E, Gillet S, Climer J, Hasselmo M (2012) Effects of cholinergic modulation on interactions of entorhinal cortex and hippocampus as measured by theta modulation of high and low gamma in the rat Society for Neuroscience Abstracts 42

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, 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]

O'Keefe J, Recce ML (1993) Phase relationship between hippocampal place units and the EEG theta rhythm. Hippocampus 3:317-30 [PubMed]

Oppenheim AV, Schafer RW, Buck JR (1999) Discrete-time signal processing

Poolos NP, Bullis JB, Roth MK (2006) Modulation of h-channels in hippocampal pyramidal neurons by p38 mitogen-activated protein kinase. J Neurosci 26:7995-8003 [PubMed]

Poolos NP, Migliore M, Johnston D (2002) Pharmacological upregulation of h-channels reduces the excitability of pyramidal neuron dendrites. Nat Neurosci 5:767-74 [PubMed]

   CA1 pyramidal neuron: effects of Lamotrigine on dendritic excitability (Poolos et al 2002) [Model]

Robinson RB, Siegelbaum SA (2003) Hyperpolarization-activated cation currents: from molecules to physiological function. Annu Rev Physiol 65:453-80 [PubMed]

Santoro B, Baram TZ (2003) The multiple personalities of h-channels. Trends Neurosci 26:550-4 [PubMed]

Schroeder CE, Lakatos P (2009) The gamma oscillation: master or slave? Brain Topogr 22:24-6 [PubMed]

Stacey WC, Lazarewicz MT, Litt B (2009) Synaptic noise and physiological coupling generate high-frequency oscillations in a hippocampal computational model. J Neurophysiol 102:2342-57 [Journal] [PubMed]

   High frequency oscillations in a hippocampal computational model (Stacey et al. 2009) [Model]

Tort AB, Komorowski RW, Manns JR, Kopell NJ, Eichenbaum H (2009) Theta-gamma coupling increases during the learning of item-context associations. Proc Natl Acad Sci U S A 106:20942-7 [PubMed]

Tort AB, Kramer MA, Thorn C, Gibson DJ, Kubota Y, Graybiel AM, Kopell NJ (2008) Dynamic cross-frequency couplings of local field potential oscillations in rat striatum and hippocampus during performance of a T-maze task. Proc Natl Acad Sci U S A 105:20517-22 [PubMed]

Tort AB, Rotstein HG, Dugladze T, Gloveli T, Kopell NJ (2007) On the formation of gamma-coherent cell assemblies by oriens lacunosum-moleculare interneurons in the hippocampus. Proc Natl Acad Sci U S A 104:13490-5 [Journal] [PubMed]

   Gamma and theta rythms in biophysical models of hippocampus circuits (Kopell et al. 2011) [Model]

Tsuno Y, Schultheiss NW, Hasselmo ME (2013) In vivo cholinergic modulation of the cellular properties of medial entorhinal cortex neurons. J Physiol 591:2611-27 [PubMed]

Wahl-Schott C, Biel M (2009) HCN channels: structure, cellular regulation and physiological function. Cell Mol Life Sci 66:470-94 [PubMed]

Wang J, Chen S, Nolan MF, Siegelbaum SA (2002) Activity-Dependent Regulation of HCN Pacemaker Channels by Cyclic AMP: Signaling through Dynamic Allosteric Coupling Neuron 36:451-61 [Journal] [PubMed]

   Activity dependent regulation of pacemaker channels by cAMP (Wang et al 2002) [Model]

Wang M, Ramos BP, Paspalas CD, Shu Y, Simen A, Duque A, Vijayraghavan S, Brennan A, Dudley A, (2007) Alpha2A-adrenoceptors strengthen working memory networks by inhibiting cAMP-HCN channel signaling in prefrontal cortex. Cell 129:397-410 [PubMed]

Wang XJ (2002) Pacemaker neurons for the theta rhythm and their synchronization in the septohippocampal reciprocal loop. J Neurophysiol 87:889-900 [PubMed]

Wang XJ, Buzsaki G (1996) Gamma oscillation by synaptic inhibition in a hippocampal interneuronal network model. J Neurosci 16:6402-13 [Journal] [PubMed]

   Gamma oscillations in hippocampal interneuron networks (Wang, Buzsaki 1996) [Model]

White JA, Banks MI, Pearce RA, Kopell NJ (2000) Networks of interneurons with fast and slow gamma-aminobutyric acid type A (GABAA) kinetics provide substrate for mixed gamma-theta rhythm. Proc Natl Acad Sci U S A 97:8128-33 [PubMed]

Winograd M, Destexhe A, Sanchez-Vives MV (2008) Hyperpolarization-activated graded persistent activity in the prefrontal cortex. Proc Natl Acad Sci U S A 105:7298-303 [Journal] [PubMed]

   Hodgkin-Huxley model of persistent activity in prefrontal cortex neurons (Winograd et al. 2008) [Model]
   Hodgkin-Huxley model of persistent activity in PFC neurons (Winograd et al. 2008) (NEURON python) [Model]

Zemankovics R, Kali S, Paulsen O, Freund TF, Hajos N (2010) Differences in subthreshold resonance of hippocampal pyramidal cells and interneurons: the role of h-current and passive membrane characteristics. J Physiol 588:2109-32 [PubMed]

Zong X, Krause S, Chen CC, Kruger J, Gruner C, Cao-Ehlker X, Fenske S, Wahl-Schott C, Biel M (2012) Regulation of hyperpolarization-activated cyclic nucleotide-gated (HCN) channel activity by cCMP. J Biol Chem 287:26506-12

Aumentado-Armstrong T, Metzen MG, Sproule MKJ, Chacron MJ (2015) Electrosensory midbrain neurons display feature invariant responses to natural communication stimuli PLoS Computational Biology 11(10):e1004430 [Journal] [PubMed]

   Midbrain torus semicircularis neuron model (Aumentado-Armstrong et al. 2015) [Model]

Avella Gonzalez OJ, Mansvelder HD, van Pelt J, van Ooyen A (2015) H-Channels Affect Frequency, Power and Amplitude Fluctuations of Neuronal Network Oscillations. Front Comput Neurosci 9:141 [Journal] [PubMed]

   H-currents effect on the fluctuation of gamma/beta oscillations (Avella-Gonzalez et al., 2015) [Model]

Chehelcheraghi M, van Leeuwen C, Steur E, Nakatani C (2017) A neural mass model of cross frequency coupling. PLoS One 12:e0173776 [Journal] [PubMed]

   A neural mass model of cross frequency coupling (Chehelcheraghi et al 2017) [Model]

Hummos A, Nair SS (2017) An integrative model of the intrinsic hippocampal theta rhythm. PLoS One 12:e0182648 [Journal] [PubMed]

   Role for short term plasticity and OLM cells in containing spread of excitation (Hummos et al 2014) [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, 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]

Neymotin SA, McDougal RA, Sherif MA, Fall CP, Hines ML, Lytton WW (2015) Neuronal calcium wave propagation varies with changes in endoplasmic reticulum parameters: a computer model Neural Computation 27(4):898-924 [Journal] [PubMed]

   Neuronal dendrite calcium wave model (Neymotin et al, 2015) [Model]

Neymotin SA, Suter BA, Dura-Bernal S, Shepherd GM, Migliore M, Lytton WW (2017) Optimizing computer models of corticospinal neurons to replicate in vitro dynamics. J Neurophysiol 117(1):148-162 [Journal] [PubMed]

   Computer models of corticospinal neurons replicate in vitro dynamics (Neymotin et al. 2017) [Model]

(66 refs)