objref tmpx, tmpy
tmpx = new Vector()
tmpy = new Vector()

//graph the vectors of interest//
proc graph_light(){
  num_of_points = light1_events.size()
  points_per_burst = ThetaStim[2].number // for light stimulation of mitral 1
  // print "note that light1_events contains:"
  {light1_events.printf()}
  for (i=0; i<num_of_points; i = i+ points_per_burst) {
    tmpx = new Vector()
    tmpx.append(light1_events.x[i],light1_events.x[i+points_per_burst-1])
    tmpy = new Vector()
    tmpy.append(-90,-90)
    tmpy.line(v_graph, tmpx, 4, 1)
    // print "attempted to graph a light stimulus bar"
    // print "y coords:"
    {tmpy.printf()}
    // print "x coords:"
    {tmpx.printf()}
    // print "i = ", i, ", i+points_per_burst-1 = ", i+points_per_burst-1
  }
}
  
proc graph_breath1(){
  num_of_points = OSN1_events.size()
  points_per_burst = ThetaStim[0].number // for light stimulation of mitral 1
  // print "note that OSN1_events contains:"
  {OSN1_events.printf()}
  for (i=0; i<num_of_points; i = i+ points_per_burst) {
    tmpx = new Vector()
    tmpx.append(OSN1_events.x[i],OSN1_events.x[i+points_per_burst-1])
    tmpy = new Vector()
    tmpy.append(-85,-85)
    tmpy.line(v_graph, tmpx, 5, 1)
    // print "attempted to graph a light stimulus bar"
    // print "y coords:"
    {tmpy.printf()}
    // print "x coords:"
    {tmpx.printf()}
    // print "i = ", i, ", i+points_per_burst-1 = ", i+points_per_burst-1
  }
}
  

proc graph_breath2(){
  num_of_points = OSN2_events.size()
  points_per_burst = ThetaStim[1].number // for light stimulation of mitral 1
  // print "note that OSN1_events contains:"
  {OSN1_events.printf()}
  for (i=0; i<num_of_points; i = i+ points_per_burst) {
    tmpx = new Vector()
    tmpx.append(OSN1_events.x[i],OSN1_events.x[i+points_per_burst-1])
    tmpy = new Vector()
    tmpy.append(-87.5,-87.5)
    tmpy.line(v_graph, tmpx, 7, 1)
    // print "attempted to graph a light stimulus bar"
    // print "y coords:"
    {tmpy.printf()}
    // print "x coords:"
    {tmpx.printf()}
    // print "i = ", i, ", i+points_per_burst-1 = ", i+points_per_burst-1
  }
}
  
proc regraph_stims() {
  graph_light()
  graph_breath1()
  graph_breath2()
}

strdef tmpstr
objref tmpfile
tmpfile = new File()
proc write_vec() { // $s1 is filename, $o2 is vector to write
  tmpstr = $s1
///  print "In write_vec here comes pwd and ls before writing file: ",tmpstr
///  system("pwd")
///  system("ls")
  tmpfile.wopen(tmpstr)
  for i=0, $o2.size()-1 {
    tmpfile.printf("%g\n",$o2.x[i])
  }
  tmpfile.close()
}

strdef filename
proc write_selected_vecs() {
  write_vec("OSN1_events.dat", OSN1_events)
  write_vec("OSN2_events.dat", OSN2_events)
  write_vec("light_events.dat", light1_events)
  write_vec("gc1_events1.dat", gc1_events1)
  write_vec("gc1_events2.dat", gc1_events2)
  write_vec("gc2_events1.dat", gc2_events1)
  write_vec("gc2_events2.dat", gc2_events2)

  write_vec("t.dat",t_vec)
  write_vec("m1_soma_v.dat", m1_v_vec)
  write_vec("m2_soma_v.dat", m2_v_vec)

}

objref tmpy_vec, null
tmpy_vec = new Vector()
proc graph_poisson() { // graph representative poisson rates and spikes
 
  if (breath_poisson_rate_for_mc1 == null) {
    breath_poisson_rate_for_mc1 = gen_poisson(tstop, breathing_period, breath_gauss_center, breath_half_width, breath_peak_rate)
  }

  if (light_poisson_rate_for_mc1 == null) {
    light_poisson_rate_for_mc1 = gen_poisson(tstop, light_period, light_gauss_center, light_half_width, light1_peak_rate)
  }
  if (light_poisson_rate_for_mc2 == null) {
    light_poisson_rate_for_mc2 = gen_poisson(tstop, light_period, light_gauss_center, light_half_width, light2_peak_rate)
  }

  breath_poisson_rate_for_mc1.c.div(breath_peak_rate).mul(20).line(Graph[0], t_vec,2 , 2) //2 is red
  light_poisson_rate_for_mc1.c.div(light1_peak_rate).mul(20).line(Graph[0], t_vec,7 , 2) // 7 is purple
  light_poisson_rate_for_mc2.c.div(light2_peak_rate).mul(20).line(Graph[0], t_vec,4 , 2) // 4 is green

  // note in below marks O, S are filled circles and squares, o, s are open circles, squares
  // mc1 breath events
  tmpy_vec = new Vector(breath_events_for_mc1.size())
  tmpy_vec.fill(20) // arbitrary height for synaptic events on voltage graph
  tmpy_vec.mark(Graph[0], breath_events_for_mc1, "O", 8, 2, 2) // 2 is red ( ..., size, color, brush)

  // mc2 breath events
  tmpy_vec = new Vector(breath_events_for_mc2.size())
  tmpy_vec.fill(19.75) // arbitrary height for synaptic events on voltage graph
  tmpy_vec.mark(Graph[0], breath_events_for_mc2, "o", 8, 5, 2) // 5 is orangish

  // mc1 light events
  tmpy_vec = new Vector(light_events_for_mc1.size())
  tmpy_vec.fill(19.25) // arbitrary height for synaptic events on voltage graph
  tmpy_vec.mark(Graph[0], light_events_for_mc1, "S", 8, 7, 2) // 7 is blue

  // mc2 light events
  tmpy_vec = new Vector(light_events_for_mc2.size())
  tmpy_vec.fill(19.00) // arbitrary height for synaptic events on voltage graph
  tmpy_vec.mark(Graph[0], light_events_for_mc2, "s", 8, 3, 2) // 3 is blue
}