Save in a vector the Range graph that ModelView displays

The basics of how to develop, test, and use models.
Post Reply
lmediavilla
Posts: 3
Joined: Thu May 17, 2018 12:11 pm

Save in a vector the Range graph that ModelView displays

Post by lmediavilla »

Dear all,

I am an amateur user of NEURON and I am having problems to figure out how to do what I think it should a very easy thing.

I am using a model I downloaded from ModelDB (any model would work for my question), and I am visualizing the different channel distributions going to Tools -> Model View. Here it automatically plots a Range Graph for each of the mechanisms inserted in the model, using a Shape plot where the distribution is seen in different colors on top of the morphology, and a regular graph below the ShapePlot that shows the value of the conductance vs. the path length. I would like to extract this information of conductance value and path length in a vector and save it in my computer (to be able to use those vectors to make the plot it using other programs, for example). Is there an easy way to do that?

Thank you so much in advance for the help!
Best,
Laura :)
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Save in a vector the Range graph that ModelView displays

Post by ted »

Try the RangeVarPlot's to_vector method--see
https://www.neuron.yale.edu/neuron/stat ... .to_vector
lmediavilla
Posts: 3
Joined: Thu May 17, 2018 12:11 pm

Re: Save in a vector the Range graph that ModelView displays

Post by lmediavilla »

Dear Ted,

Thank you for you kind and quick reply. I tried to save the data using the "to_vector" method you suggested. However, I am just able to save empty .dat files.

The code is very simple, maybe it is easy to spot the mistake:

**************************************************************
//Initialize the CA1 cell morphology, axon and mechanisms
load_file("nrngui.hoc")
nrnmainmenu()
xopen("Jarsky_Gating_Morphology.nrn")
xopen("Jarsky_Gating_Axon.nrn")
xopen("Jarsky_Gating_Init.hoc")

initchannels()

//The distribution depending on path distance of all the channels is initialized
// Saving the sodium channel conductance -> linear increase of the conductance when increasing the distance from the soma

objectvar rvp
rvp = new RangeVarPlot("gbar_nax") // sodium channel conductance

objref densvec, pathvec, savedens, savepath
densvec = new Vector()
pathvec = new Vector()

rvp.to_vector(densvec, pathvec)

savedens = new File()
savepath = new File()

savedens.wopen("gbarnax.dat")
savepath.wopen("path.dat")

densvec.printf(savedens)
pathvec.printf(savepath)

************************************************************************
I also tried it defining a begin,origin, and end for rvp, for one of the sections of the cell, but it did not work either. But either way, I would like to have the density distribution of that conductance in all the sections that form the cell. I am sure there is a basic command I am missing.

Thank you so much again for the help.

Best regards
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Save in a vector the Range graph that ModelView displays

Post by ted »

I just did this now, starting with a graph that I created with the GUI that shows a plot of v vs. distance along a path in a model cell. First step was to discover the name of the RangeVarPlot. Big clue: it's not the name of the graph that shows the plot of v vs. distance--that's just an instance of the Graph class. Insted, I had to save that graph to a ses file and then examine the ses file's contents.

Code: Select all

objectvar save_window_, rvp_
 . . . a bunch of statements . . .
objectvar rvp_
rvp_ = new RangeVarPlot("v")
dendrite_5[0] rvp_.begin(1)
dendrite_1[29] rvp_.end(1)
rvp_.origin(18.5505)
save_window_.addobject(rvp_, 2, 1, 0.8, 0.9)
 . . . some more statements . . .
{doNotify()}
rvp_ looks like a "discardable" variable name to me, since the RangeVarPlot that it points to is appended to a computer-generated list called save_window_. My guess is that rvp_ refers to the last RangeVarPlot that was created.

I confirmed that rvp_ referred to an instance of the RangeVarPlot class by entering its name at the oc> prompt and pressing return:

Code: Select all

oc>rvp_
	RangeVarPlot[0]
Check.

Next, at the oc> prompt, I executed these commands:

Code: Select all

oc>objref xvec,yvec
oc>xvec = new Vector()
oc>yvec = new Vector()
oc>rvp_.to_vector(yvec,xvec)
And finally, proof of success:

Code: Select all

oc>xvec.printf
-324.012	-299.544	-250.606	-201.668	-152.731	
 . . . many more numbers . . .
874.207	915.757	957.308	978.083	
	44 
oc>yvec.printf
15.3814	15.3814	29.7931	31.1528	22.1211	
 . . . many more numbers . . .
-64.8621	-64.9039	-64.9225	-64.9225	
	44

So it works. Now I'll look at your code.
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Save in a vector the Range graph that ModelView displays

Post by ted »

Here's a working example that should help you discover and fix the problem with your own code.

Code: Select all

load_file("nrngui.hoc")
create soma, dend
access soma
connect dend(0), soma(1)
soma.L = 12
dend.L = 60
forall nseg = 3
soma for (x,0) diam(x) = x*L
dend for (x,0) diam(x) = x*L/10

objref rvp
rvp = new RangeVarPlot("diam")
soma rvp.begin(0)
dend rvp.end(1)

objref g
g = new Graph()
g.addobject(rvp)
g.exec_menu("View = plot")

objref xvec,yvec
xvec = new Vector()
yvec = new Vector()
rvp.to_vector(yvec,xvec)

xvec.printf()
yvec.printf()
lmediavilla
Posts: 3
Joined: Thu May 17, 2018 12:11 pm

Re: Save in a vector the Range graph that ModelView displays

Post by lmediavilla »

Dear Ted,

Thank you so much for your help! I made it work, extracting the density distribution of the channels for all the sections in the model cell, and asigning the soma as the origin for all calculations.

Probably there is a nicier way to do it, but I will post it here in case anyone would need something similar :)

*************************************************************************************************************************************************
// Saving the sodium channel conductance -> linear increase of the conductance when increasing the distance from the soma
objectvar rvp, yvec, xvec, saveval, savepath
rvp = new RangeVarPlot("gbar_nax") // sodium channel conductance
densvec = new Vector()
pathvec = new Vector()
saveval = new File()
savepath = new File()

strdef filename1, filename2

forall{
soma rvp.begin(0)
print secname() rvp.end(1)
rvp.to_vector(yvec, xvec)
xvec.printf()
yvec.printf()

sprint(filename1, "Nax_%s.dat", secname())
sprint(filename2, "Naxpath_%s.dat", secname())

saveval.wopen("gbarnax.dat")
savepath.wopen("path.dat")

densvec.printf(saveval)
pathvec.printf(savepath)
}
saveval.close()
savepath.close()
*************************************************************************************************************************************************
Post Reply