space plot!

The basics of how to develop, test, and use models.
Post Reply
thats_karlo

space plot!

Post by thats_karlo »

Dear friends,


in the space plot we see how membrane potential changes in the space

1- i read toturial to use space plot i did every thing that they said, but i see just 2 curves and nothings more, what should i do if i like to have for example 10-20 curve ?

2-is it possible to write a code in "hoc" to save v(x,t) to a *.dat file?


thank's
ted
Site Admin
Posts: 6299
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: space plot!

Post by ted »

1- i read toturial to use space plot i did every thing that they said, but i see just 2 curves and nothings more, what should i do if i like to have for example 10-20 curve ?
There are lots of tutorials. Which one do you mean?
2-is it possible to write a code in "hoc" to save v(x,t) to a *.dat file?
Yes. Here's the outline for how you would proceed:
1. Identify all sections on the path and append them to a SectionList.
2. For each section in the SectionList, iterate over all internal nodes, creating a Vector
for each node and setting up vector record.

1 is easy. Use hoc code or the GUI to set up your shape plot, and run a simulation to
make sure that what you're seeing is what you want to record.
Then type
allobjects()
at the oc> prompt, and look for a mention of RangeVarPlot. You should see
RangeVarPlot[0] with 1 refs
Then use the RangeVarPlot class's list() method to append all of its sections to a
SectionList, like this:

Code: Select all

objref sl
sl = new SectionList()
RangeVarPlot[0].list(sl)
You can verify that this worked by typing
forsec sl print secname()
at the oc> prompt.

2 is also easy.

Code: Select all

objref veclist, tempvec
veclist = new List()
forsec sl {
  for (x,0) {
    tempvec = new Vector()
    tempvec.record(&v(x))
    veclist.append(tempvec)
  }
}
objref tempvec  // so we can't mess up the last element in veclist
The result is that, for every point along the path where NEURON computes a solution,
there is a corresponding element in veclist that is a Vector which will record the time
course of membrane potential at that point. Now, every time you run a simulation,
these Vectors will automatically capture the time course of membrane potential along
the path(s) you specified.

That will be a lot of data. What you do with it is up to you.

--Ted
kelvin
Posts: 10
Joined: Tue Jun 07, 2005 10:00 pm
Location: Edmonton, AB Canada
Contact:

syntax for printf?

Post by kelvin »

Hmmm... I'm getting rusty.

1. Started up neurondemo, chose pyramidal as example
2. Create SectionList

Code: Select all

objref pyrseclst
pyrseclst = new SectionList()
forall pyrseclst.append()
3. Use Ted's code for creating a vector for one node of every section in the model.

Code: Select all

objref veclist, tempvec
veclist = new List()
x = 0.5
forsec pyrseclst {
    tempvec = new Vector()
    tempvec.record(&v(x))
    veclist.append(tempvec)
}
objref tempvec 
4. Click the "Init & Run" button on the RunControl window
5. Typed

Code: Select all

allobjects()
at the oc> prompt and saw that there were a bunch of vectors, last one being Vector[81] with 1 refs. Since there are only 79 sections ... Ummm...what section(node=0.5) does Vector[x] refer to?
6. Typed

Code: Select all

Vector[81].printf("%4.1f\n")
at the oc> prompt. Since the default Tstop (ms) = 5 and the dt (ms) = 0.025, the number of elements in the vector, 201, is right.
7. Now to dump it in ascii to a file

Code: Select all

wopen("dump.dat")
for i = 3, 81 {
   Vector[i].fprint("%4.1f")
   fprint("\n")
}
wopen()
, where the i=3 index was picked by peaking. But this doesn't work and I get booted out with

Code: Select all

initcode failed with 1 left
Questions:
Q1. I have a gut feeling I should be referencing the vectors differently, but I'm drawing a blank. I thought it should be something like soma.Vector[0] - I'm wrong. How should I reference these new vectors from hoc for the purpose of dumping?

Q2. Why does the File class not work the same way it used to (whine)? For example,

Code: Select all

f = new File()
f.wopen("dump.dat")
Q3. Does this syntax still work?

Code: Select all

printf(fileobj, format_string)
Thanks,
Kelvin
ted
Site Admin
Posts: 6299
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: syntax for printf?

Post by ted »

Yo, Kelvin, thanks for sending us that bit of arctic blast last weekend. We needed that.
5. Typed

Code: Select all

allobjects()
at the oc> prompt and saw that there were a bunch of vectors, last one being Vector[81] with 1 refs. Since there are only 79 sections ...
Did you check to see how many Vectors existed before you created your own?
You might also want to try
print veclist.count()
to see how many elements are in veclist.
Ummm...what section(node=0.5) does Vector[x] refer to?
You can discover that by iterating over the contents of pyrseclst and printing the
name of the one in the x position.

Code: Select all

proc printsecname() { local ii
  ii = 0
  forsec $o2 {
    if (ii == $1) print secname()
  }
  ii += 1
}

printsecname(9, pyrseclst)  // prints name of the 10th section in pyrseclist
7. Now to dump it in ascii to a file

Code: Select all

wopen("dump.dat")
for i = 3, 81 {
   Vector[i].fprint("%4.1f")
   fprint("\n")
}
wopen()
The Vector class doesn't have an fprint() method. Create the file with the File class
and then use the Vector class's printf().
Q1. I have a gut feeling I should be referencing the vectors differently, but I'm drawing a blank. I thought it should be something like soma.Vector[0] - I'm wrong. How should I reference these new vectors from hoc for the purpose of dumping?
The List class's object() method lets you address any element in the List.
For example, typing
veclist.object(3)
at the oc> prompt will tell you that the 4th element in veclist is a Vector. So you can type
veclist.object(3).printf()
to dump the contents of that Vector. If you want to dump the contents of every Vector
in the List, iterate over the List:

Code: Select all

for ii = 0, veclist.count()-1 {
  veclist.object(ii).printf()  // veclist.object(ii) is a Vector
}
Q2. Why does the File class not work the same way it used to (whine)? For example,

Code: Select all

f = new File()
f.wopen("dump.dat")
This does work, as long as f is an objref. But it isn't the code you cited above as
not working.
Q3. Does this syntax still work?

Code: Select all

printf(fileobj, format_string)
If you mean vecname.printf(fileobj, format_string), the answer is yes.
In isolation, printf(fileobj, format_string) just generates an error msg.
kelvin
Posts: 10
Joined: Tue Jun 07, 2005 10:00 pm
Location: Edmonton, AB Canada
Contact:

syntax solved

Post by kelvin »

Thanks Ted, and your welcome for the blast of arctic from up North.

I have been trying to use the GUI as much as possible and forgot my hoc syntax. I learned something else from your original reply to the first post that I would like to explore more. It has to do with exploring from the command prompt what is plotted in a particular graph. But I think I will go and start a new thread in a different area other than "Getting started".

Cheers,
Kelvin
Post Reply