// Plot the network simulation results

objref gm1, gm2, gm3, g4, g5, g6, g7, g8, g9, g10

// Voltage plot
proc Fig_MC()  {
gm1 = new Graph(0)
addplot(gm1, 0)
gm1.size(0,tstop,-70,60)
gm1.view(0,-80,tstop,140, 0,400,500,200)
gm1.addvar("Mit[0][0].soma", "mit[0][0].soma.v(0.5)", 1, 1, 0.8, 0.9, 2)  //1: black; 2: red; 3: blue
gm1.addvar("Mit[1][2].soma", "mit[1][2].soma.v(0.5)", 2, 1, 0.8, 0.9, 2)  
//gm1.addvar("Mit4.soma", "mit[4].soma.v(0.5)", 3, 1, 0.8, 0.9, 2) 

/*
gm2 = new Graph(0)
addplot(gm2, 0)
gm2.size(0,tstop,-70,60)
gm2.view(0,-80,tstop,140, 500,150,500,200)
gm2.addvar("Mit[0][0].dend", "mit[0][0].dend.v(0.5)", 1, 1, 0.8, 0.9, 2)  //1: black; 2: red; 3: blue
gm2.addvar("Mit[1][2].dend", "mit[1][2].dend.v(0.5)", 2, 1, 0.8, 0.9, 2)  
//gm2.addvar("Mit4.dend", "mit[4].dend.v(0.5)", 3, 1, 0.8, 0.9, 2) 

gm3 = new Graph(0)
addplot(gm3, 0)
gm3.size(0,tstop,-70,60)
gm3.view(0,-80,tstop,140, 900,150,500,200)
gm3.addvar("Mit[0][0].tuft", "mit[0][0].tuft.v(0.5)", 1, 1, 0.8, 0.9, 2)  //1: black; 2: red; 3: blue
gm3.addvar("Mit[1][2].tuft", "mit[1][2].tuft.v(0.5)", 2, 1, 0.8, 0.9, 2)  

*/

/*
g3 = new Graph(0)
addplot(g3, 0)
//g3.size(0,tstop,0,2)
g3.view(0,0,tstop,2, 0,480,500,200)
g3.addvar("g2m[0][1].g", 1, 2, 0.8, 0.9, 2)  //1: black; 2: red; 3: blue  g2m[3][28]
//g3.addvar("mit.GABAA.g", 1, 2, 0.8, 0.9, 2)  //1: black; 2: red; 3: blue

g4 = new Graph(0)
addplot(g4, 0)
g4.size(0,tstop,0,2)
g4.view(0,0,tstop,25, 0,830,500,200)
g4.addvar("mit.GABAA.i", 2, 2, 0.8, 0.9, 2)  //1: black; 2: red; 3: blue

*/

}

proc Fig_GC()  {
g5 = new Graph(0)
addplot(g5, 0)
g5.size(0,tstop,-70,60)
g5.view(0,-80,tstop,120, 0,830,500,200)
g5.addvar("Gran[0][0].soma", "gran[0][0].soma.v(0.5)", 2, 1, 0.8, 0.9, 2)  
g5.addvar("Gran[4][4].soma", "gran[4][4].soma.v(0.5)", 3, 1, 0.8, 0.9, 2)  

g6 = new Graph(0)
addplot(g6, 0)
g6.size(0,tstop,-70,60)
g6.view(0,-80,tstop,120, 500,830,500,200)
g6.addvar("Gran[0][0].gemmbody", "gran[0][0].dend.v(0.5)", 2, 1, 0.8, 0.9, 2)  
g6.addvar("Gran[4][4].gemmbody", "gran[4][4].dend.v(0.5)", 3, 1, 0.8, 0.9, 2) 
}


proc Fig_PG()  {
g7 = new Graph(0)
addplot(g7, 0)
g7.size(0,tstop,-70,60)
g7.view(0,-80,tstop,120, 0,500,500,200)
g7.addvar("pg[0][0].soma", "pg[0][0].soma.v(0.5)", 2, 1, 0.8, 0.9, 2)  
g7.addvar("pg[1][2].soma", "pg[1][2].soma.v(0.5)", 3, 1, 0.8, 0.9, 2)  

g8 = new Graph(0)
addplot(g8, 0)
g8.size(0,tstop,-70,60)
g8.view(0,-80,tstop,120, 500,500,500,200)
g8.addvar("pg[0][0].gemmbody", "pg[0][0].dend.v(0.5)", 2, 1, 0.8, 0.9, 2)  
g8.addvar("pg[1][2].gemmbody", "pg[1][2].dend.v(0.5)", 3, 1, 0.8, 0.9, 2) 
}


proc Fig_Input() {
g9 = new Graph(0)
addplot(g9, 0)
g9.size(0,tstop,-2,2)
g9.view(0,-2,tstop,15, 450,200,400,150)
g9.addvar("Affernt input", "MCinput[3][3].i", 2, 1, 0.9, 0.9, 2)  //1: black; 2: red; 3: blue

g10 = new Graph(0)
addplot(g10, 0)
g10.size(0,tstop,-2,2)
g10.view(0,-2,tstop,15, 450,350,400,150)
g10.addvar("Background input", "MCbinput[0][0].i", 1, 1, 0.9, 0.9, 2)  //1: black; 2: red; 3: blue
}





// ==================== Raster Plots ===============================

objref gr1, gr2, gr3, yvec
proc Raster_plots() { local i,j
  yvec = new Vector()
  gr1  = new Graph(0)
  addplot(gr1, 0)
  gr1.view(0,0,tstop,nMit, 0,500,500,200)
  gr1.label(0.1,0.9,"MC spike plot")
	
  for i = 0, nmitx-1 {
      for j = 0, nmity-1 {
      yvec.resize(mit[i][j].spiketimes.size())
      yvec.fill(i*nmity+j)
      yvec.mark(gr1, mit[i][j].spiketimes,"|",2)   
     }
  }

  gr2  = new Graph(0)
  addplot(gr2, 0)
  gr2.view(0,0,tstop,nGran, 500,500,500,200)
  gr2.label(0.1,0.9,"GC spike plot")
	
  for i = 0, ngranx-1 {
      for j = 0, ngrany-1 {
      yvec.resize(gran[i][j].spiketimes.size())
      yvec.fill(i*ngrany+j)
      yvec.mark(gr2, gran[i][j].spiketimes,"|",2)   
      }
  }
  
  gr3  = new Graph(0)
  addplot(gr3, 0)
  gr3.view(0,0,tstop,nPG, 1000,500,500,200)
  gr3.label(0.1,0.9,"PG spike plot")
	
  for i = 0, npgx-1 {
      for j = 0, npgy-1 {
      yvec.resize(pg[i][j].spiketimes.size())
      yvec.fill(i*npgy+j)
      yvec.mark(gr3, pg[i][j].spiketimes,"|",2)   
      }
  }
  

}