getinfoneuroml.py 1001 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/env python3
  2. """
  3. Get info from generated NEURON files.
  4. This *must* be run after the NEURON files have been generated from the NeuroML.
  5. File: neuroConstruct/getinfo.py
  6. Copyright 2022 Ankur Sinha
  7. Author: Ankur Sinha <sanjay DOT ankur AT gmail DOT com>
  8. """
  9. import sys
  10. import yaml
  11. from pyneuroml.neuron import morphinfo, getinfo, load_hoc_or_python_file
  12. from neuron import h
  13. if len(sys.argv) != 2:
  14. print("Error: only takes one argument")
  15. sys.exit(-1)
  16. cell = sys.argv[1]
  17. load_hoc_or_python_file(f"HL23{cell}.hoc")
  18. h("celsius = 34")
  19. h("objectvar mycell")
  20. h("strdef reference")
  21. h('reference = "acell"')
  22. h(f'mycell = new HL23{cell}(reference, "HL23{cell}", "A cell")')
  23. with open(f"NeuroML-morphinfo-{cell}.yaml", "w") as f:
  24. retval = morphinfo()
  25. print(yaml.dump(retval, sort_keys=True, indent=4), file=f, flush=True)
  26. with open(f"NeuroML-info-{cell}.yaml", "w") as f:
  27. retval = getinfo(h.allsec())
  28. print(yaml.dump(retval, sort_keys=True, indent=4), file=f, flush=True)