NeuroML / pyNeuroML

A single package in Python unifying scripts and modules for reading, writing, simulating and analysing NeuroML2/LEMS models.
https://docs.neuroml.org/Userdocs/Software/pyNeuroML.html
GNU Lesser General Public License v3.0
36 stars 30 forks source link

Export to NeuroML2 #60

Open asanin-epfl opened 4 years ago

asanin-epfl commented 4 years ago

Hi! I'm trying to export my .hoc file to NML2. I receive these errors. Basically it tries to load erev for the mechanism that does not have it.

Traceback (most recent call last):
  File "/home/sanin/workspace/sonata-network-reduction/venv/lib/python3.6/site-packages/pyneuroml/neuron/nrn_export_utils.py", line 43, in get_erev_for_mechanism
    return mechs_vs_erevs[mech]
KeyError: 'CaDynamics'
NEURON: PyObject method call failed: get_erev_for_mechanism
 near line 0
 {hoc_ac_ = zTau_SK}
                    ^
        ModelViewNeuroML2[0].parmiter(File[0])
      ModelViewNeuroML2[0].parmiter(ModelViewDParmElm[20])
    ModelViewNeuroML2[0].parmiter(File[0])
  ModelViewNeuroML2[0].parmiter(ModelViewDParm[20])
and others
Traceback (most recent call last):
  File "/home/sanin/workspace/sonata-network-reduction/sonata_network_reduction/deleteme.py", line 39, in <module>
    mv_xml.exportNeuroML2(export_filepath, 2, 0)
RuntimeError: hoc error

My question. May I fix those errors and patch the library or I better use another library? Just here nrn/issues/173 you mentioned that pyNeuroML is the most up to date library to export to NML2.

Please share your wisdom @pgleeson.

asanin-epfl commented 4 years ago

In this fork /asanin-epfl/pyNeuroML/nml2-biophysics I've put an example of such model. I took it from modeldb/L5bPCmodelsEH/L5PCbiophys4.hoc

pgleeson commented 4 years ago

@asanin-epfl Yes, that is the latest version of the file for exporting NeuroML from NEURON morphologies.

Have you tried providing an override parameter for the reversal potential, as in: https://github.com/OpenSourceBrain/SmithEtAl2013-L23DendriticSpikes/blob/3a0cb68b48d74d537e6999bb003515f96c2b5560/NeuroML2/export_nml2.py#L12

You could try in your patch to use a None value for mechanisms which don't have a reversal potential and catch that at the appropriate line.

asanin-epfl commented 4 years ago

@pgleeson thank you for your response. It has been very helpful. Can you please help me to clarify. For example a have a .hoc file with a single Im.mod mechanism.

begintemplate L4PCbiophys
public biophys

proc biophys() {
  forsec $o1.all {
    insert pas
      Ra = 138.28
      e_pas = -92.4991149902

    cm = 1.0
    ena = 53.0
    ek = -107.0
    g_pas = 5.71881e-06

    insert Im
      gbar_Im = 0.00120212
 }
}

endtemplate L4PCbiophys

Im.mod does not specify any reverse potential inside itself. It uses external general definition of ek. Now I have to set it like this known_rev_potentials={"Im":-107} in order to work. It looks a bit misleading as it is a rev potential for K not Im.

Can I export from such files as above without usage of known_rev_potentials? or at least known_rev_potentials={"ek_Im":-107} or something like that?