Export to .hoc with CellBuilder from Python

When Python is the interpreter, what is a good
design for the interface to the basic NEURON
concepts.

Moderator: hines

Post Reply
vogdb
Posts: 23
Joined: Sun Aug 13, 2017 9:51 am

Export to .hoc with CellBuilder from Python

Post by vogdb » Tue Sep 10, 2019 12:32 pm

Hi! I'm trying now for a week to properly export the currently loaded neuron model. There is only one loaded model in my namespace that I loaded like this.

Code: Select all

h.load_file('Cell_Scnn1a.hoc')
cell_hoc = h.Cell_Scnn1a('/morphologies', 'Scnn1a_473845048_m.swc')
It is absolutely properly exported to nml by

Code: Select all

h.load_file("mview.hoc")
mv = h.ModelView(0)
mv_xml = h.ModelViewXML(mv)
export_filepath = os.path.join('.', 'test.nml')
mv_xml.exportNeuroML(export_filepath, 2)
but when I try

Code: Select all

bld = h.CellBuild(0)
mng = h.CellManage(bld)
f = h.File()
f.wopen('test.hoc')
mng.toplevel = 1 // i tried  toplevel=0 as well
mng.pr(f)
I receive an empty cell in test.hoc. The same output is when I use Cell Builder from GUI. How can I export with CellBuild/CellManage properly from Python?

Code: Select all

proc celldef() {
  topol()
  subsets()
  geom()
  biophys()
  geom_nseg()
}


proc topol() { local i
  basic_shape()
}
proc basic_shape() {
}

objref all
proc subsets() { local i
  objref all
  all = new SectionList()

}
proc geom() {
}
proc geom_nseg() {
}
proc biophys() {
}
celldef()

ted
Site Admin
Posts: 5592
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Export to .hoc with CellBuilder from Python

Post by ted » Wed Sep 11, 2019 11:40 am

but when I try
. . .
I receive an empty cell in test.hoc.
You're starting with a model created by executing statements in Cell_Scnn1a.hoc. Where did the CellBuilder referenced by h.CellBuild() come from? If you created it yourself, it's "empty" (except for a soma section). It's not going to know anything about the model that was created by executing statements in Cell_Scnn1a.hoc. And even if you "imported" that model into the CellBuilder, the CellBuilder would only know about the anatomy of that model--its branched architecture, and the geometry of each section.

So even though it is true that the code in

Code: Select all

bld = h.CellBuild(0)
. . .
mng.pr(f)
does not generate a hoc file that, when executed, will recreate the model specified by h.Cellbuild(), fixing it won't be useful to you anyway.

vogdb
Posts: 23
Joined: Sun Aug 13, 2017 9:51 am

Re: Export to .hoc with CellBuilder from Python

Post by vogdb » Wed Sep 11, 2019 12:07 pm

Thank you for the response.

Post Reply