When Python is the interpreter, what is a good
design for the interface to the basic NEURON
- Posts: 41
- Joined: Thu May 03, 2007 4:04 pm
- Location: Institute of Science and Technology (IST Austria)
I'm collecting a list of NetCon objects in a Python list. I do it to remove old synaptic connections after a simulation and create new ones. I was wondering what is the best way to delete old NetCon objects and substitute them with new NetCon objects. I provide a basic example:
Code: Select all
def create_netcons(n, mylist=None):
create a list with <n> number of NetCon objects
if mylist is not None:
for nc in mylist:
nc.weight = 0.0 # set NetCon to zero? use del?
mysyn = mylist
for _ in range(n):
myNetCon = h.NetCon(target, source, sec) # pseudo-code
myNetCon.weight = 1e-4
mysyn.append( myNetCon )
return( mysyn )
mylist = create_netcons(3) # create 3 NetCons
mylist = create_netcons(5, mylist) # create 5 new NetCons, set the old ones to zero
There must be a better way to delete the old NetCons in the list.
I would appreciate your help
- Site Admin
- Posts: 5771
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
Sorry this reply is so delayed.
I think your basic example looks entirely sufficient for the task. You're replacing the contents of a list with new contents. As long as that reduces the reference count to 0 for each of the objects (NetCons) that had previously been in the list, that should be all it takes to get rid of them. Is it the absolutely fastest way to do this? I suspect it is, but even if there is some way that is a bit faster, the difference is probably much smaller than the time required to create all the cell and synapse instances in the first place, not to mention how long it takes to execute a simulation and store or analyze results.