How to delete NetCon objects?
Posted: Thu Nov 10, 2016 10:24 am
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:
There must be a better way to delete the old NetCons in the list.
I would appreciate your help
Thanks!!!
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.0 # set NetCon to zero? use del?
else:
mysyn = mylist
for _ in range(n):
myNetCon = h.NetCon(target, source, sec) # pseudo-code
myNetCon.weight[0] = 1e-4
mysyn.append( myNetCon )
return( mysyn )
# Simulation
mylist = create_netcons(3) # create 3 NetCons
mylist = create_netcons(5, mylist) # create 5 new NetCons, set the old ones to zero
I would appreciate your help
Thanks!!!