Hi all,
I would like to import a morphology (to be more precise this one : http://cns.iaf.cnrs-gif.fr/files/CELLS/ ... al264L.geo ) inside a python script, for that I tried to use h.file_load and h.xopen method.
The problem is I can't access sections from Ipython :
When I type somaA.diam or somA.v the python interpreter returns the exception " NameError: name 'somaA' is not defined ".
so my question is how can I load this morphology ? Should I first export it in morphML format ?
Cheers,
Romain Caze
access the section after loading a morphology file
Moderator: hines
-
- Site Admin
- Posts: 6299
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
Re: access the section after loading a morphology file
Code: Select all
nrngui -python
>>> from neuron import h
>>> h.xopen("pyramidal264L.geo")
1.0
>>> h.psection()
soma { nseg=1 L=0.01 Ra=35.4
/*location 0 attached to cell 0*/
/* First segment only */
insert morphology { diam=16.81}
insert capacitance { cm=1}
}
1.0
>>> for sec in h.allsec():
... sec.name()
...
'soma'
'dend[0]'
'dend[1]'
. . . etc. . . .
>>> for sec in h.allsec():
... for seg in sec.allseg():
... print seg.diam
...
16.8099994659
16.8099994659
16.8099994659
2.97471848094
. . . etc. . . .
Re: access the section after loading a morphology file
the "for sec in h.allsec():" does the trick. Here is a loop that will make a list of tuples containing 3D points, the diameter, and the section name.
Code: Select all
points3d = []
for sec in h.allsec():
num_points = int(h.n3d()) # Get the number of 3D points in the section
for i in range(num_points):
x = h.x3d(i)
y = h.y3d(i)
z = h.z3d(i)
diam = h.diam3d(i)
points3d.append((x, y, z, d, sec.name()))
Re: access the section after loading a morphology file
Use h.somaA.diam or h.somA.v to get the middle valueWhen I type somaA.diam or somA.v the python interpreter returns the exception " NameError: name 'somaA' is not defined ".
h.somaA(x).diam to get the value of the segment containing x.
(assumes a prior
from neuron import h
)
Re: access the section after loading a morphology file
I have a question on this,
Say I' ve loaded my *.geo file which has created sections by executing hoc statements, is there a way to insert a mechanism into one of its sections through python?
So for example if I've created an "axon" section by running "h.xopen('geometryfile.geo)" right now I can't do axon.insert('hh') can I? Is there a way around this or is the best thing to do to change the morphology (*.geo) file?
Say I' ve loaded my *.geo file which has created sections by executing hoc statements, is there a way to insert a mechanism into one of its sections through python?
So for example if I've created an "axon" section by running "h.xopen('geometryfile.geo)" right now I can't do axon.insert('hh') can I? Is there a way around this or is the best thing to do to change the morphology (*.geo) file?
Re: access the section after loading a morphology file
To insert a mechanism I tried h.axon.insert('hh') and it worked well, it had also worked for pointprocesses.
I also want to thanks for the fast posted responses and for this great software !
Romain
I also want to thanks for the fast posted responses and for this great software !
Romain
Re: access the section after loading a morphology file
Thanks, I was missing the initial h.