convert_cells_to_neuroml.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/bin/bash
  2. # Copyright 2022 Ankur Sinha
  3. # Author: Ankur Sinha <sanjay DOT ankur AT gmail DOT com>
  4. # File : NeuroML2/scripts/convert_cells_to_neuroml.sh
  5. #
  6. #
  7. # Script to convert cells to NeuroML.
  8. function convert_morphologies() {
  9. # we must use a shell script to iterate because Neuron needs to be
  10. # repeatedly quit after each cell. If it isn't quite and restarted, it
  11. # keeps previous cells around and so each subsequent export also includes
  12. # all previous cells.
  13. for cell in "HL23PV" "HL23PYR" "HL23SST" "HL23VIP"
  14. do
  15. python cellmorph2nml.py ${cell}
  16. #pynml-plotmorph -plane2d "xy" -nogui -saveToFile "${cell}.xy.png" "${cell}.morph.cell.nml"
  17. done
  18. }
  19. function postprocess () {
  20. python postprocess_cells.py
  21. }
  22. function clean() {
  23. echo "Removing: *.hoc *.mod LEMS* *.dat *.nrn.py x86_64 iv*nml"
  24. rm *.hoc iv*nml
  25. rm -f *.mod LEMS* *.dat *nrn.py
  26. rm -rf x86_64
  27. }
  28. function setup () {
  29. libnrnmechdir="$(dirname $(find . -maxdepth 2 -name "libnrnmech*" ))"
  30. echo "Removing ${libnrnmechdir}"
  31. rm -rf "${libnrnmechdir}"
  32. echo "Compiling mods"
  33. nrnivmodl mod
  34. }
  35. # Do everything without any arguments
  36. if [ $# -lt 1 ]
  37. then
  38. setup
  39. convert_morphologies
  40. postprocess
  41. exit 0
  42. fi
  43. # parse options
  44. while getopts "csm" OPTION
  45. do
  46. case $OPTION in
  47. c)
  48. clean
  49. exit 0
  50. ;;
  51. s)
  52. setup
  53. exit 0
  54. ;;
  55. m)
  56. clean
  57. setup
  58. convert_morphologies
  59. exit 0
  60. ;;
  61. ?)
  62. echo "Error: unrecognised option"
  63. exit 1
  64. ;;
  65. esac
  66. done