Page 1 of 1

Problem with saving Vector of spike train

Posted: Mon Oct 14, 2013 3:49 pm
by ps0322
Hello,
I have some problem with saving vector.
I have a Vector called "spktrain" which get values from the code "spktrain.spikebin(vvec, thre)" where vvec is the recorded voltage at soma center and thre is threshold potential.
Each bin of spktrain thus have the value of either 0 or 1. I've check it with sum function that there are 25 spikes.
When I try to save the spike train to a file with this code

Code: Select all

objref fout
fout = new File()
fout.wopen("testspk.txt")
spktrain.printf(fout,"%d\n")
fout.close()
There is no error when I code. However, when I import the file to MATLAB I found that all the values are 0. Even in the bin that suppose to be 1.(i.e. I have check that spktrain.x(120) is 1 but when I check spktrain(121) in MATLAB it equal to 0. Summation of the imported variables in MATLAB is 0)

I have try many ways and found that I could successfully export the spike train to a file using the following code

Code: Select all

wopen("f.out")
for i = 0, spktrain.size-1{
	fprint("%d\n",spktrain.x(i))
}
wopen()
After I imported the created file to MATLAB, I'm able to get the values I am expected.(i.e. the spktain(121) in MATLAB is equal to 1)
Using this method is OK for now with one variable, however, it will be bulky in the future if I want to export many vectors.
Note that this is just a single cell.(I'm trying to make a plot of single neuron response function) I found that with network cells, we can use Netcon.record to save variable.(I couldn't find how to use the function with single cell)
Do you have any suggestion to improve the code? I'd really appreciate it.

Re: Problem with saving Vector of spike train

Posted: Mon Oct 14, 2013 5:42 pm
by ted

Code: Select all

oc>for i=0,3 print i, i%2
0 0 
1 1 
2 0 
3 1 
oc>objref vec
oc>vec = new Vector(4)
oc>for i=0,3 vec.x[i]=i%2
oc>vec.printf
0	1	0	1	
So far so good.

Code: Select all

oc>vec.printf("%d\n")
0
0
0
0
So the Vector is OK, but Vector.printf with %d format may a problem. What about %g?

Code: Select all

oc>vec.printf("%g\n")
0
1
0
1
That works. Suggest you change the format to %g.
Note that this is just a single cell.(I'm trying to make a plot of single neuron response function) I found that with network cells, we can use Netcon.record to save variable
If you assign each spiking cell its own unique identfying number (a whole number like 0, 1, 2 etc.; this is easiest to do when you first create the cell instance), then you can use NetCon record to capture all spike times to one Vector and the corresponding cell identifiers to another Vector. Once you have those two Vectors it is very easy to generate raster plots (use the Vector class's "mark" method) or apply any kind of analysis you want to the recorded spike trains. For examples of code that assigns a unique identifier to each cell instance, see
Hines ML, Carnevale NT.
Translating network models to parallel hardware in NEURON.
J Neurosci Methods. 2008 Apr 30;169(2):425-55.
and ModelDB entry 96444
https://senselab.med.yale.edu/modeldb/S ... odel=96444

Re: Problem with saving Vector of spike train

Posted: Tue Oct 15, 2013 2:33 am
by ps0322
That works. Suggest you change the format to %g.
Oh, I did not aware of the usefulness of %g. It works!
If you assign each spiking cell its own unique identfying number ...
Ok, I'll try.

Thank you so much, Ted!