Code: Select all
from neuron import h
a = h.Section()
b = h.Section()
b.connect(a)
c = h.Section()
c.connect(a)
h.topology()
h.delete_section(c)
Code: Select all
h.delete_section(c.name())
Code: Select all
c.push()
h.delete_section()
Moderator: hines
Code: Select all
from neuron import h
a = h.Section()
b = h.Section()
b.connect(a)
c = h.Section()
c.connect(a)
h.topology()
h.delete_section(c)
Code: Select all
h.delete_section(c.name())
Code: Select all
c.push()
h.delete_section()
Code: Select all
c = None
Code: Select all
from neuron import h
h('create a, b, c')
h.topology()
c = h.c
print c, c.name()
h.delete_section(sec=c)
h.topology()
Code: Select all
neuron.h.load_file('file.hoc')
Code: Select all
h('forall delete_section)')
#and check that they are gone with
h.topology()
Code: Select all
for sec in h.reg_soma:
sec.insert(mechanism)
Code: Select all
NEURON: Accessing a deleted section
near line 0
forall delete_section()
^
Segmentation fault
Code: Select all
proc celldef() {
topol()
subsets()
geom()
biophys()
geom_nseg()
}
create soma[3]
create dend_contra[3]
create dend_ipsi[3]
proc topol_0() {
connect soma[1](0),soma[0](1)
connect soma[2](0),soma[0](1)
connect dend_contra[0](0),soma[1](1)
connect dend_contra[1](0),dend_contra[0](1)
connect dend_contra[2](0),dend_contra[1](1)
connect dend_ipsi[0](0),soma[2](1)
connect dend_ipsi[1](0),dend_ipsi[0](1)
connect dend_ipsi[2](0),dend_ipsi[1](1)
}
proc topol() {
topol_0()
basic_shape()
}
proc shape3d_0() {
soma[0] {pt3dclear()
pt3dadd(265.213004248, 82.7914962769, 1.9536999464, 2.0)
pt3dadd(265.213104248, 82.7914962769, 1.9536999464, 2.0)
}
soma[1] {pt3dclear()
pt3dadd(265.213104248, 82.7914962769, 1.9536999464, 2.0)
pt3dadd(265.213500977, 83.2928009033, 1.9536999464, 2.0)
}
soma[2] {pt3dclear()
pt3dadd(265.213104248, 82.7914962769, 1.9536999464, 2.0)
pt3dadd(265.212585449, 82.2902984619, 1.9536999464, 2.0)
}
dend_contra[0] {pt3dclear()
pt3dadd(265.213500977, 83.2928009033, 1.9536999464, 2.0)
pt3dadd(265.213897705, 83.7939987183, 1.9536999464, 2.0)
}
dend_contra[1] {pt3dclear()
pt3dadd(265.213897705, 83.7939987183, 1.9536999464, 2.0)
pt3dadd(265.214294434, 84.2951965332, 1.9536999464, 2.0)
}
dend_contra[2] {pt3dclear()
pt3dadd(265.214294434, 84.2951965332, 1.9536999464, 2.0)
pt3dadd(265.214691162, 84.7964019775, 1.9536999464, 2.0)
}
dend_ipsi[0] {pt3dclear()
pt3dadd(265.212585449, 82.2902984619, 1.9536999464, 2.0)
pt3dadd(265.212188721, 81.789100647, 1.9536999464, 2.0)
}
dend_ipsi[1] {pt3dclear()
pt3dadd(265.212188721, 81.789100647, 1.9536999464, 2.0)
pt3dadd(265.211914062, 81.287902832, 1.9536999464, 2.0)
}
dend_ipsi[2] {pt3dclear()
pt3dadd(265.211914062, 81.287902832, 1.9536999464, 2.0)
pt3dadd(265.211395264, 80.7865982056, 1.9536999464, 2.0)
}
}
proc basic_shape() {
shape3d_0()
}
objref reg_all
objref reg_soma
objref reg_dend_contra
objref reg_dend_ipsi
proc subsets() { local ii
reg_all = new SectionList()
reg_soma = new SectionList()
for ii = 0, 2 soma[ii] {
reg_soma.append()
reg_all.append()
}
reg_dend_contra = new SectionList()
for ii = 0, 2 dend_contra[ii] {
reg_dend_contra.append()
reg_all.append()
}
reg_dend_ipsi = new SectionList()
for ii = 0, 2 dend_ipsi[ii] {
reg_dend_ipsi.append()
reg_all.append()
}
}
proc geom() {
}
proc geom_nseg() {
}
proc biophys() {
}
access soma
celldef()
Code: Select all
import neuron
import nrn
STDGUI = 'stdgui.hoc'
LIBNRNMECH = 'NEURON/i686/.libs/libnrnmech.so'
hoc_file = 'little_model.hoc'
neuron.h.load_file(STDGUI)
neuron.h.nrn_load_dll(LIBNRNMECH)
neuron.h.load_file(hoc_file)
neuron.h.topology()
# Output:
# < tree >
neuron.h.reg_dend_contra.printnames()
# Output:
# dend_contra[0]
# dend_contra[1]
# dend_contra[2]
neuron.h('forall delete_section()')
neuron.h.topology()
# Output:
# < nothing >
neuron.h.reg_dend_contra.printnames()
# Output:
# < nothing >
# Now I try to delete the section list:
neuron.h('delete reg_dend_contra')
# Output:
# NEURON: syntax error
# near line 0
# delete reg_dend_contra
# ^
neuron.h.reg_dend_contra.remove()
# Output:
# NEURON: Accessing a deleted section
# near line 0
# ^
# SectionList[2].remove()
# oc_restore_code tobj_count=1 should be 0
# ...
del(neuron.h.reg_dend_contra)
# Output:
# TypeError: function takes at least one argument
# ... doesn't work
# Now I load the morphology again:
neuron.h.load_file(hoc_file)
neuron.h.topology()
# Output:
# < nothing >
neuron.h.reg_dend_contra.printnames()
# Output:
# < nothing >
# the morphology seems not to be loaded again (and therefore the section list
# seems to point to the old deleted sections)
Code: Select all
neuron.h('objref reg_dend_contra')
Code: Select all
neuron.h.load_file(1, hoc_file)
Code: Select all
from neuron import gui
Code: Select all
NEURON: point process not located in a section
...
Code: Select all
from neuron import h
soma = h.Section()
axon = h.Section()
dendrite = h.Section()
def check():
print '-------'
for sec in h.allsec():
print sec
print '-------'
check()
soma = None
check()
for section in h.allsec():
section = None
print section
check()