Page 1 of 1

Export to .hoc with CellBuilder from Python

Posted: Tue Sep 10, 2019 12:32 pm
by vogdb
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()

Re: Export to .hoc with CellBuilder from Python

Posted: Wed Sep 11, 2019 11:40 am
by ted
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.

Re: Export to .hoc with CellBuilder from Python

Posted: Wed Sep 11, 2019 12:07 pm
by vogdb
Thank you for the response.