NeuroML exporter does not honor the section name

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

Moderator: hines

Post Reply
mattions
Posts: 65
Joined: Tue Jul 15, 2008 11:21 am
Location: EMBL-EBI Cambridge UK

NeuroML exporter does not honor the section name

Post by mattions » Fri Apr 09, 2010 7:51 am

I've tried to export a model in neuroML but I just noticed that the name of the sections change
http://www.neuron.yale.edu/hg/neuron/nr ... l.hoc#l301

I think would be better if the real name of the section will be exported, so it's possible to attach to it any kind of information and, when the model is reloaded, we have the same nomenclature for the section.

Is that possible?

hines
Site Admin
Posts: 1577
Joined: Wed May 18, 2005 3:32 pm

Re: NeuroML exporter does not honor the section name

Post by hines » Fri Apr 09, 2010 1:15 pm

neuroml has no notion of arrays. Hence dend[2] gets translated to dend_2 as a distinct name.

mattions
Posts: 65
Joined: Tue Jul 15, 2008 11:21 am
Location: EMBL-EBI Cambridge UK

Re: NeuroML exporter does not honor the section name

Post by mattions » Fri Apr 09, 2010 1:42 pm

Consider this code:

Code: Select all

from neuron import h
import neuron.gui # To not freeze the GUI
h.load_file('mview.hoc')

# Bunch of sections, just for testing purpose.
sec1 = h.Section()
sec2 = h.Section()
sec2.diam=1000
sec1.connect(sec2)

print sec1.name(), sec2.name()


h.define_shape()
modelView = h.ModelView(0)
modelXml = h.ModelViewXML(modelView)
modelXml.xportLevel1("temp.xml")
this is the output:

Code: Select all

NEURON -- VERSION 7.2 (436:cbc0331180f8) 2010-04-05
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2008
See http://www.neuron.yale.edu/credits.html

	1 
PySec_b77c1440 PySec_b77c1428

|-|       PySec_b77c1428(0-1)
   `|       PySec_b77c1440(0-1)

1.0

Then try to re read the file:

Code: Select all

from neuron import h
h.load_file('celbild.hoc')
cb = h.CellBuild(0)
cb.manage.neuroml('temp.xml')
cb.cexport(1)
print h.topology()
This is the output:

Code: Select all

NEURON -- VERSION 7.2 (436:cbc0331180f8) 2010-04-05
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2008
See http://www.neuron.yale.edu/credits.html

defer PySec_b77c1428
defer PySec_b77c1440
defer all

|-|       d[0](0-1)
   `|       d[1](0-1)

1.0
So the actual name of the section is there, but is not used to re-instantiate the model. I'm wondering if that is possible to do.

hines
Site Admin
Posts: 1577
Joined: Wed May 18, 2005 3:32 pm

Re: NeuroML exporter does not honor the section name

Post by hines » Fri Apr 09, 2010 2:42 pm

Sorry. I misunderstood the context.
The implmentation for reading is incomplete as I see in nrn/share/lib/hoc/celbild/celtopol.hoc
that the name is ignored and substituted with "d" in
sscanf(cab.name_, "%s[%d]", s.s, &nx)
//printf("i=%d id=%d %s[%d]\n", i, cab.id_, s.s, nx)
cbs = new CellBuildSection("d", i, 0, pcbs, cab.px_)
uncommenting the printf shows that the name is known. (although in this case they are just
python object names that are meaningless anyway).
Try subsituting s.s for "d" and you should get the names from the xml file.

mattions
Posts: 65
Joined: Tue Jul 15, 2008 11:21 am
Location: EMBL-EBI Cambridge UK

Re: NeuroML exporter does not honor the section name

Post by mattions » Sat Apr 10, 2010 5:44 am

It is also possible to put the name of the cell in front of it?

This is my system:

Code: Select all

In [3]: h.topology()

|-|       MSP_Cell[0].soma(0-1)
   `|       MSP_Cell[0].dend1(0-1)
     `|       MSP_Cell[0].dend1_1[0](0-1)
       `----------|       MSP_Cell[0].dend1_1[1](0-1)
       `----------|       MSP_Cell[0].dend1_1[2](0-1)
     `|       MSP_Cell[0].dend1_2[0](0-1)
       `----------|       MSP_Cell[0].dend1_2[1](0-1)
       `----------|       MSP_Cell[0].dend1_2[2](0-1)
   `|       MSP_Cell[0].dend2(0-1)
     `|       MSP_Cell[0].dend2_1[0](0-1)
       `----------|       MSP_Cell[0].dend2_1[1](0-1)
       `----------|       MSP_Cell[0].dend2_1[2](0-1)
     `|       MSP_Cell[0].dend2_2[0](0-1)
       `----------|       MSP_Cell[0].dend2_2[1](0-1)
       `----------|       MSP_Cell[0].dend2_2[2](0-1)
 `|       MSP_Cell[0].dend3(0-1)
   `|       MSP_Cell[0].dend3_2[0](0-1)
     `----------|       MSP_Cell[0].dend3_2[1](0-1)
     `----------|       MSP_Cell[0].dend3_2[2](0-1)
   `|       MSP_Cell[0].dend3_1[0](0-1)
     `----------|       MSP_Cell[0].dend3_1[1](0-1)
           `--|       spine2_neck(0-1)
               `------|       spine2_head(0-1)
                       `|       spine2_psd(0-1)
         `--|       spine1_neck(0-1)
             `------|       spine1_head(0-1)
                     `|       spine1_psd(0-1)
     `----------|       MSP_Cell[0].dend3_1[2](0-1)
 `|       MSP_Cell[0].dend4(0-1)
   `|       MSP_Cell[0].dend4_1[0](0-1)
     `----------|       MSP_Cell[0].dend4_1[1](0-1)
     `----------|       MSP_Cell[0].dend4_1[2](0-1)
   `|       MSP_Cell[0].dend4_2[0](0-1)
     `----------|       MSP_Cell[0].dend4_2[1](0-1)
     `----------|       MSP_Cell[0].dend4_2[2](0-1)
So I can access to the section using h.MSP_Cell[0].soma

This is instead what I read back:

Code: Select all

In [5]: h.topology()

|-|       soma(0-1)
   `|       dend2(0-1)
     `|       dend2_2_0(0-1)
       `------|       dend2_2_2(0-1)
       `------|       dend2_2_1(0-1)
     `|       dend2_1_0(0-1)
       `------|       dend2_1_2(0-1)
       `------|       dend2_1_1(0-1)
   `|       dend1(0-1)
     `|       dend1_2_0(0-1)
       `------|       dend1_2_2(0-1)
       `------|       dend1_2_1(0-1)
     `|       dend1_1_0(0-1)
       `------|       dend1_1_2(0-1)
       `------|       dend1_1_1(0-1)
 `|       dend4(0-1)
   `|       dend4_2_0(0-1)
     `------|       dend4_2_2(0-1)
     `------|       dend4_2_1(0-1)
   `|       dend4_1_0(0-1)
     `------|       dend4_1_2(0-1)
     `------|       dend4_1_1(0-1)
 `|       dend3(0-1)
   `|       dend3_1_0(0-1)
     `------|       dend3_1_2(0-1)
     `------|       dend3_1_1(0-1)
         `|       spine2_neck(0-1)
           `|       spine2_head(0-1)
             `|       spine2_psd(0-1)
        `|       spine1_neck(0-1)
          `|       spine1_head(0-1)
            `|       spine1_psd(0-1)
   `|       dend3_2_0(0-1)
     `------|       dend3_2_2(0-1)
     `------|       dend3_2_1(0-1)
so now I have to access to the section with h.soma.

How can I include the name of the cell as well so I have a complete match?

Thanks

hines
Site Admin
Posts: 1577
Joined: Wed May 18, 2005 3:32 pm

Re: NeuroML exporter does not honor the section name

Post by hines » Mon Apr 12, 2010 7:28 am

Cells in objects have not been implemented in the neuroml reader.
It would be easy but highly unsatisfying to modify the reader so that the cell name information, e.g.
<cells>
<cell name="deepaxax_0">
is used as a prefix to each section. It is more problematic at present to make the connection from one
instantiated cell to another.

mattions
Posts: 65
Joined: Tue Jul 15, 2008 11:21 am
Location: EMBL-EBI Cambridge UK

Re: NeuroML exporter does not honor the section name

Post by mattions » Mon Apr 12, 2010 7:54 am

There are any plans to support multiple cells?
For now I have only one cell in my model, so that would be good enough for the time being.

How can I accomplish that?

hines
Site Admin
Posts: 1577
Joined: Wed May 18, 2005 3:32 pm

Re: NeuroML exporter does not honor the section name

Post by hines » Mon Apr 12, 2010 9:55 am

If you import into a cell builder you can use the cell builder to construct a cell class
and then later instantiate the cell.
See CellBuild/Management/CellType
You can specify the class name and save the class to a hoc file.

mattions
Posts: 65
Joined: Tue Jul 15, 2008 11:21 am
Location: EMBL-EBI Cambridge UK

Re: NeuroML exporter does not honor the section name

Post by mattions » Mon Apr 12, 2010 10:18 am

I just want to make clear what I'm looking for:

my goal is to save all the info about the geometry in the NeuroML format and write them on a file.
Then I want to reload the geometry info in memory, using the NeuroML file as the source of my model.

The model back in memory and loaded in NEURON should have the same structure/geometry and names of the one that I saved in the NeuroML file.

All this process is done using only the python interface, not using the UI, because the final idea is to reload anyfile in memory, without knowing what was in the file, so I can't really write the name of the cell through hoc.

If I understood correctly could be a strategy to instantiate the cellbuilder cell name using the name coming from the neuroml, then applying the classic reconstruction of the model already present ?

hines
Site Admin
Posts: 1577
Joined: Wed May 18, 2005 3:32 pm

Re: NeuroML exporter does not honor the section name

Post by hines » Tue Apr 13, 2010 10:32 am

The implementation of the reader is not quite adequate to what you want to do unless you restrict yourself to a single cell.
Although hoc templates are powerful enough so that different instances of a cell class can have different morphology (e.g
different array sizes for the dendrite names) new section names cannot be created. At any rate, the xml reader cannot
presently fill in an already constructed cell instance with new morphology and biophysics information.
Also it is not possible to demand that
a newly constructed instance have the same instance index of the cell that was written in some previous launch context.
And it seems unlikely that a separate class for every cell is useful in the long run.

Within the context of the present implementation, I could fill in the cell builder management cell type classname
from the xml file's
<cell name="PySec_1ff450f0">
(the name is currently ignored so nrn/share/lib/python/rdxml along with
nrn/share/lib/hoc/celbild/celmang.hoc has to be modified). I'm not too keen on doing this because I plan on
discarding the current implementation of rdxml.py entirely in favor of using the elementtree python module
to allow easier maintenence of synchronization with the changing neuroml specification.

hines
Site Admin
Posts: 1577
Joined: Wed May 18, 2005 3:32 pm

Re: NeuroML exporter does not honor the section name

Post by hines » Tue Apr 13, 2010 11:04 am

It turned out to be quite straightforward to fill in the cell builder class name with the xml cell name. The diff is

Code: Select all

$ hg diff
diff -r cbc0331180f8 share/lib/hoc/celbild/celmang.hoc
--- a/share/lib/hoc/celbild/celmang.hoc Mon Apr 05 10:50:31 2010 -0400
+++ b/share/lib/hoc/celbild/celmang.hoc Tue Apr 13 10:55:04 2010 -0400
@@ -324,6 +324,9 @@
        bild.subsets.neuroml($o1)
        bild.geom.neuroml($o1)
        bild.memb.neuroml($o1)
+       if (strcmp($o1.cellname, "") != 0) {
+               classname = $o1.cellname
+       }
 }
 
 func warn3d() {
diff -r cbc0331180f8 share/lib/python/rdxml.py
--- a/share/lib/python/rdxml.py Mon Apr 05 10:50:31 2010 -0400
+++ b/share/lib/python/rdxml.py Tue Apr 13 10:55:04 2010 -0400
@@ -110,6 +110,9 @@
 
   def cell(self, attrs):
     self.biomechs_ = []
+    self.cellname = ""
+    if attrs.has_key('name'):
+        self.cellname = str(attrs['name'])
     if debug: 
         print "cell"
         self.prattrs(attrs)

However creating the class (apart from a hoc file) was done only in the context of a network ready cell which adds various useful methods
and fiels that make the cell class useful for instantiating cells in a network. And that is not the end since a network ready cell is finally
instantiated as a templage only after the 'create' button is pressed in a NetGUI tool.
I suggest you save the hoc file.

mattions
Posts: 65
Joined: Tue Jul 15, 2008 11:21 am
Location: EMBL-EBI Cambridge UK

Re: NeuroML exporter does not honor the section name

Post by mattions » Tue Apr 13, 2010 4:14 pm

Are you going to apply this modification (and the one before) to the source of NEURON?

I'm saving only the anatomy and working on the single cell right now so NeuroML should be enough for the time being.

hines
Site Admin
Posts: 1577
Joined: Wed May 18, 2005 3:32 pm

Re: NeuroML exporter does not honor the section name

Post by hines » Tue Apr 13, 2010 4:41 pm


mattions
Posts: 65
Joined: Tue Jul 15, 2008 11:21 am
Location: EMBL-EBI Cambridge UK

Re: NeuroML exporter does not honor the section name

Post by mattions » Tue Apr 13, 2010 5:30 pm

hines wrote:Sorry. I misunderstood the context.
The implmentation for reading is incomplete as I see in nrn/share/lib/hoc/celbild/celtopol.hoc
that the name is ignored and substituted with "d" in
sscanf(cab.name_, "%s[%d]", s.s, &nx)
//printf("i=%d id=%d %s[%d]\n", i, cab.id_, s.s, nx)
cbs = new CellBuildSection("d", i, 0, pcbs, cab.px_)
uncommenting the printf shows that the name is known. (although in this case they are just
python object names that are meaningless anyway).
Try subsituting s.s for "d" and you should get the names from the xml file.
it would be great if also this change can be committed to the repo

hines
Site Admin
Posts: 1577
Joined: Wed May 18, 2005 3:32 pm

Re: NeuroML exporter does not honor the section name

Post by hines » Tue Apr 13, 2010 6:02 pm


Post Reply