Flickering Graph

Using the graphical user interface to build and exercise models. Includes customizing the GUI by writing a little bit of hoc or Python
Post Reply
AlisonM

Flickering Graph

Post by AlisonM »

Has anyone experienced problems with certain graphs flickering (this is the best way I can describe it) while the simulation is running, but as soon as it stops running, whatever has been plotted on the graph shows up normally? When the graph flickers, it is as though you can see a trace of whatever is being plotted, but no lines are left behind. However, when the simulation stops running, everything shows up on the graph properly. Is there anything to do allow the graph to plot normally?

The weird part is, it is only happening for me when I try to plot one specific ion current - other ion currents have no problem being graphed, and it only happens when I load a hoc file that is coded to create the graph; if I use the GUI main menu to make a graph plotting exactly the same thing, it plots just fine without the flickering problem.

Thanks for any suggestions.
ted
Site Admin
Posts: 6300
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Flickering Graph

Post by ted »

Generally it is necessary to reproduce a problem in order to diagnose the cause, but in this case it may be sufficient to see the user-written hoc code that creates the graph--which should be sufficiently brief that it can be posted on the forum.
AlisonM

Re: Flickering Graph

Post by AlisonM »

Sure thing. The code for the flickering graph in my hoc file is as follows:

Code: Select all

objref curgraph

curgraph=new Graph(0)
	curgraph.size(0,10000,-0.07,0.05)
	{curgraph.view(0, -0.07, tstop, 0.12, 651, 890, 360.9, 200.8)}
	graphList[2].append(curgraph)
	curgraph.save_name("graphList[2].")
	curgraph.addvar("Neuron 0 Ih current", "soma[0].ih_Ih( 0.5 )", 2, 1, 0.8, 0.9, 2)
	curgraph.addexpr("Neuron 1 Ih current", "soma[1].ih_Ih( 0.5 )", 3, 1, 0.8, 0.9, 2)
I have other graphs with (I believe) almost identical callings to creation that print without problem, such as:

Code: Select all

objref neuron0graph

neuron0graph=new Graph(0)
	neuron0graph.size(0,500,-80,40)
	{neuron0graph.view(0, -80, tstop, 120, 913, 862, 358.2, 196.3)}
	graphList[0].append(neuron0graph)
	neuron0graph.save_name("graphList[0].")
	neuron0graph.addexpr("Neuron 0 Voltage (mv)", "soma[0].v( 0.5 )", 2, 1, 0.8, 0.9, 2)
Again, thanks for any thoughts that you have.
ted
Site Admin
Posts: 6300
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Flickering Graph

Post by ted »

Nothing jumps out as a likely culprit. You might try using addvar() instead of addexpr(), in case the problem is extra overhead resulting from the use of addexpr(). All of the items to be plotted are mere variables, not "expressions" in the sense that x+1 and 3*b are.

Other comments:

Unless you're using Crank-Nicholson (secondorder = 2), you might as well append all graphs to graphlist[0]. That will result in each variable being plotted vs. t. graphlist[1] ([2]) offsets plotted points by -0.5*dt (0.5*dt), which is when currents (voltages) are second order correct if secondorder = 2. The offsets are meaningless when secondorder = 0 (default implicit Euler) or 1, and are 0 when adaptive integration ("cvode") is used.
AlisonM

Re: Flickering Graph

Post by AlisonM »

Thanks for the suggestions (and information about various pieces of graph syntax). Changing to addvar didn't do the trick, but I recreated a copy of the graph from the GUI menu, saved the session, and re-stole the pieces of code for size and view of the graph, which were slightly different than the graph in my hoc code. I now have:

Code: Select all

curgraph.size(-100,3000,-0.1,0.06)
	{curgraph.view(-100, -0.1, tstop, 0.16, 519, 338, 357.3, 200.8)}
For whatever reason, that did the trick, and at least currently, the graph is displaying properly now.
ted
Site Admin
Posts: 6300
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Flickering Graph

Post by ted »

Magic. Computers have become the last source of magic in our lives.

My "other comments" contained a sentence of near-oracular obscurity. Here is a revision that should be more legible:

Unless you're using Crank-Nicholson (secondorder = 2), you might as well append all graphs to graphlist[0]. That will result in each variable being plotted vs. t. graphlist[1] offsets plotted points by -0.5*dt, which is when currents are second order correct if secondorder = 2; for graphlist[2] the offset is 0.5*dt, which is when voltages are second order correct. The offsets are meaningless when secondorder = 0 (default implicit Euler) or 1, and are 0 when adaptive integration ("cvode") is used.
Post Reply