Destroy a vector in order to restart recording
Posted: Wed Apr 18, 2012 6:10 pm
I'm using Python to record from all currents in a model (for example, I record neuron.h.soma.ik_SK which is k-current in the soma). This is quite memory-intensive when for >100 compartments and when running the model for more than a second or so.
As I'm actually interested in the total current of each kind, so I figured I can run the simulation for 100ms, calculate the total current, and resume for another 100ms, and so on.
The part I'm missing is how to restart recording using vectors. Documentation say (in http://www.neuron.yale.edu/neuron/stati ... tml#record) that recording works until the vector is destroyed, so I thought you may just create a new vector and remove the reference for the previous one, and python's gc will do the rest:
Where my_variables is a dictionary of dictionaries which hold all 'active' vectors. This code is broken- it succeed to record the first 100ms, but then the second vector and up (of a given section and variable) are all empty.
What do I miss here? Is the old vec which was in my_variables[sec][var] still alive, preventing me from recording the same variable into the new vector?
As I'm actually interested in the total current of each kind, so I figured I can run the simulation for 100ms, calculate the total current, and resume for another 100ms, and so on.
The part I'm missing is how to restart recording using vectors. Documentation say (in http://www.neuron.yale.edu/neuron/stati ... tml#record) that recording works until the vector is destroyed, so I thought you may just create a new vector and remove the reference for the previous one, and python's gc will do the rest:
Code: Select all
def record_var(sec, var):
vec = neuron.h.Vector()
varRef = '_ref_' + var
vec.record(getattr(sec, varRef))
my_variables[sec][var] = vec
What do I miss here? Is the old vec which was in my_variables[sec][var] still alive, preventing me from recording the same variable into the new vector?