start GUI with graph that contain many variables

The basics of how to develop, test, and use models.
Post Reply
oren
Posts: 55
Joined: Fri Mar 22, 2013 1:03 am

start GUI with graph that contain many variables

Post by oren »

Hello,
I'm trying to investigate a model form modeldb. The model contain a network of cells.
I want to do the investigation with the GUI, and I'm trying to plot in a graph the voltage of all the neruon's soma's.
I can just start Neuron and do Graph/Voltage axis... and add all cells soma's. but this will take allot of time.

I'm trying to start Neuron GUI with a graph that contain all the voltages that I want. Then when I'll via the GUI IClamp and SEclamp I will see what is the voltage change in all the cells.

I tried by adding this code

Code: Select all

objref Gra
Gra = new Graph()
Gra.size(0,355,-80,40)
Gra.addvar("Layer2_Fast[0].soma.v(0.5)",1,1,0.6,0.9,2)
Gra.addvar("Layer2_Fast[1].soma.v(0.5)",2,1,0.6,0.9,2)
Gra.addvar("Layer2_Fast[2].soma.v(0.5)",3,1,0.6,0.9,2)
Gra.addvar("Layer2_Fast[3].soma.v(0.5)",4,1,0.6,0.9,2)
Gra.addvar("Layer2_Fast[4].soma.v(0.5)",5,1,0.6,0.9,2)
Gra.addvar("Layer2_Fast[5].soma.v(0.5)",6,1,0.6,0.9,2)
But in the GUI, When I add IClamp and run the model, the voltages are not present in the graph.

Is it possible ? Can I do such a mix of hoc graph and GUI manipulation ? Or do I have to write the point processers also in hoc?


Thank You
ted
Site Admin
Posts: 5786
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: start GUI with graph that contain many variables

Post by ted »

Suppose that
all cells have been created
each cell is an instance of a class
each cell class has a public member called soma
each cell instance has been appended to a List called cells
you want to plot soma.v(0.5) for the first NUMTOPLOT cells in the List called cells

You could use the GUI to create a Voltage axis graph, then delete the "v(.5)" from that graph, and then manually do this:

Code: Select all

for i = 0,NUMTOPLOT-1
  use Plot what? to add cells.o(i).soma.v(0.5)
(in fact you should probably do this once for two or three cells, just to make sure that you know the names of the variables you want to plot).

Or you could do it algorithmically.

First design the algorithm. You'll want a procedure that
1. spawns a Graph
2. adds the desired variables to the Graph's plot list
3. then adds the graph to graphList[0] so it will be automatically updated on each fadvance(), and that updating will plot the value of each variable in its plotlist vs. t at the end of fadvance().

This is easy.

Code: Select all

objref g
proc spawng() {
  g = new Graph()
  addtog($1, g) // $1 tells how many variables to add to g's plotlist
  addplot(g,0) // make sure g updates automatically on each fadvance()
}
addplot() is part of NEURON's standard run system. addplot(g, 0) tells it to add g to graphList[0]. Suggest you look in NEURON's hoc library and examine proc addplot() in stdrun.hoc

Now we need to invent proc addtog(). This is only a bit more difficult than inventing spawng.

Code: Select all

proc addtog() {
  if ($1>cells.count()) { // prevent errors
    print "doit() argument ", $1, "is too big"
  } else {
    for ii=0,$1-1 {
      makevarname(ii) // build a string that is the name of the variable to be plotted
      $o2.addvar(varname) // add the variable called "varname" to $o2's plotlist
    }
  }
}
Finally we need makevarname.

Code: Select all

strdef varname
proc makevarname() {
  sprint(varname, "cells.o(%d).soma.v(0.5)", $1)
  // to see the name of each plotted variable, uncomment the next line
//  print varname
}
The whole thing is

Code: Select all

strdef varname
proc makevarname() {
  sprint(varname, "cells.o(%d).soma.v(0.5)", $1)
//  print varname
}
proc addtog() {
  if ($1>cells.count()) {
    print "doit() argument ", $1, "is too big"
  } else {
    for ii=0,$1-1 {
      makevarname(ii)
      $o2.addvar(varname)
    }
  }
}
objref g
proc spawng() {
  g = new Graph()
  addtog($1, g)
  addplot(g,0) // update g automatically on each fadvance()
}
Put this in a hoc file by itself. In your main program, after model setup is complete but before the run() statement is called, execute
load_file("name of the file") // substitute with the name of the hoc file that contains the above code
and then execute
spawng(NUMTOPLOT)
where NUMTOPLOT is the number of cells whose soma.v(0.5) you want to add to the graph.
Post Reply