BhallaLab / moose

MOOSE simulator.
http://moose.ncbs.res.in
GNU General Public License v3.0
26 stars 19 forks source link

Support of NeuroML2.0? #253

Closed lungsi closed 4 years ago

lungsi commented 5 years ago

Hi, I currently have MOOSE 3.1.4. I tried loading NML2_SingleCompHHCell.nml using the steps shown in moose-example

filename = "NML2_SingleCompHHCell.nml"
reader = moose.mooseReadNML2( filename )

which resulted in

AttributeError                            Traceback (most recent call last)
<ipython-input-6-4765915052fc> in <module>
      1 filename = "NML2_SingleCompHHCell.nml"
----> 2 reader = moose.mooseReadNML2( filename )

AttributeError: module 'moose' has no attribute 'mooseReadNML2'

I noticed that this version of moose no longer has the method mooseReadNML2 but I see moose.mooseReadSBML.

Have you stopped supporting NeuroML2.0?

dilawar commented 5 years ago

This version is very old and unfortunately we havn't yet pushed the nightly version to stable. You can install it pip install pymoose --pre --upgrade.

The neuronml2 support is in beta. There are issues with nml2 reader but I will be happy to sort them on out on priority basis.

lungsi commented 5 years ago

Thanks @dilawar With the above pip command I now have '3.2.0.dev20190402

After running

filename = "NML2_SingleCompHHCell.nml"
reader = moose.mooseReadNML2( filename )

I got

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-7bc31305e264> in <module>
      1 filename = "NML2_SimpleMorphology.nml" #"NML2_SingleCompHHCell.nml"
----> 2 reader = moose.mooseReadNML2( filename )

/envs/py3-moose/lib/python3.6/site-packages/moose/moose.py in mooseReadNML2(modelpath, verbose)
    276 
    277     reader = _neuroml2.NML2Reader( verbose = verbose )
--> 278     reader.read( modelpath )
    279     return reader
    280 

/envs/py3-moose/lib/python3.6/site-packages/moose/neuroml2/reader.py in read(self, filename, symmetric)
    215 
    216         for cell in self.doc.cells:
--> 217             self.createCellPrototype(cell, symmetric=symmetric)
    218 
    219         if len(self.doc.networks)>=1:

/envs/py3-moose/lib/python3.6/site-packages/moose/neuroml2/reader.py in createCellPrototype(self, cell, symmetric)
    277         nrn = moose.element(ep) if moose.exists(ep) else moose.Neuron(ep)
    278         self.proto_cells[cell.id] = nrn
--> 279         self.nml_to_moose[cell] = nrn
    280         self.moose_to_nml[nrn] = cell
    281         self.createMorphology(cell, nrn, symmetric=symmetric)

TypeError: unhashable type: 'Cell'

PS: On a different issue, with the current version (unlike before), this

cell = moose.Neutral("/cell")
soma = moose.Compartment(cell.path + "/soma")

resulted in

/envs/py3-moose/lib/python3.6/site-packages/ipykernel_launcher.py:1: DeprecationWarning: Accessing existing paths using object constrcutors has been deprecated. Use  moose.element to access existing object. In future  this will be an error.

  """Entry point for launching an IPython kernel.
/envs/py3-moose/lib/python3.6/site-packages/ipykernel_launcher.py:2: DeprecationWarning: Accessing existing paths using object constrcutors has been deprecated. Use  moose.element to access existing object. In future  this will be an error.

Should I be concerned with this warning?

dilawar commented 5 years ago

You've run into https://github.com/NeuroML/NeuroML2/issues/116 (unhashable type). Till this is resolved, you have to use python2 :-(.

You can replace moose.Compartment with moose.element to remove this warning. If an object/path has already been created before then moose.element is the way to access it.

dilawar commented 4 years ago

This has been fixed and will be available in nightly package after https://github.com/BhallaLab/moose-core/pull/395 is merged.

NML2 support is still beta.

In [1]: import moose                                                                                           
moos
In [2]: moose.mooseReadNML2('./NML2_SingleCompHHCell.nml')                                                     
INFO:moose.nml2:Parsed NeuroML2 file: /home1/dilawars/Work.HG/GITHUB/DILAWAR/moose-examples/neuroml2/NML2_SingleCompHHCell.nml
INFO:moose.nml2:/home1/dilawars/Work.HG/GITHUB/DILAWAR/moose-examples/neuroml2/NML2_SingleCompHHCell.nml: Importing the ion channels
INFO:moose.nml2:/home1/dilawars/Work.HG/GITHUB/DILAWAR/moose-examples/neuroml2/NML2_SingleCompHHCell.nml: Created /library[0]/passiveChan[0] for passiveChan
INFO:moose.nml2:/home1/dilawars/Work.HG/GITHUB/DILAWAR/moose-examples/neuroml2/NML2_SingleCompHHCell.nml: Created ion channel /library[0]/passiveChan[0] for None passiveChan
/usr/lib64/python3.6/importlib/_bootstrap.py:219: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility. Expected 192 from C header, got 216 from PyObject
  return f(*args, **kwds)
/usr/lib64/python3.6/importlib/_bootstrap.py:219: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility. Expected 192 from C header, got 216 from PyObject
  return f(*args, **kwds)
/usr/lib64/python3.6/importlib/_bootstrap.py:219: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility. Expected 192 from C header, got 216 from PyObject
  return f(*args, **kwds)
/usr/lib64/python3.6/re.py:212: FutureWarning: split() requires a non-empty pattern match.
  return _compile(pattern, flags).split(string, maxsplit)
INFO:moose.nml2:/home1/dilawars/Work.HG/GITHUB/DILAWAR/moose-examples/neuroml2/NML2_SingleCompHHCell.nml: Created /library[0]/naChan[0] for naChan
INFO:moose.nml2:/home1/dilawars/Work.HG/GITHUB/DILAWAR/moose-examples/neuroml2/NML2_SingleCompHHCell.nml: Created ion channel /library[0]/naChan[0] for None naChan
INFO:moose.nml2:/home1/dilawars/Work.HG/GITHUB/DILAWAR/moose-examples/neuroml2/NML2_SingleCompHHCell.nml: Created /library[0]/kChan[0] for kChan
INFO:moose.nml2:/home1/dilawars/Work.HG/GITHUB/DILAWAR/moose-examples/neuroml2/NML2_SingleCompHHCell.nml: Created ion channel /library[0]/kChan[0] for None kChan
INFO:moose.nml2:Creating 0/1 instances of hhcell under <moose.Neutr

Or run the example script http://github.com/dilawar/moose/raw/master/neuroml2/run_hhcell.py

$ python3 run_hhcell.py

image

image