File size: 3,648 Bytes
0558c72 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | {
"cells": [
{
"cell_type": "markdown",
"id": "789a1930",
"metadata": {},
"source": [
"# Generic Notebook for NeuroML Models"
]
},
{
"cell_type": "markdown",
"id": "20c97415",
"metadata": {},
"source": [
"## *Source path and filename*"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ce7cc8dd",
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"import ipywidgets\n",
"import ui_widget\n",
"from importlib.machinery import SourceFileLoader\n",
"%matplotlib widget\n",
"\n",
"#widget to read input files\n",
"display(ui_widget.header,ui_widget.loader)"
]
},
{
"cell_type": "markdown",
"id": "8f2d35a3",
"metadata": {},
"source": [
"## *Read NeuroML files and build dashboard*"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "079c703a",
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"# get path and filename from above widget----------------------------------------------------#\n",
"path2source = ui_widget.loader.result[0]\n",
"fname_LEMS = ui_widget.loader.result[1]\n",
"fname_net = ui_widget.loader.result[2]\n",
"\n",
"# imports the python module-----------------------------------------------------------------#\n",
"nmlPython = SourceFileLoader(\"nml2jupyter_ver3.py\",\"nml2jupyter_ver3.py\").load_module()\n",
"runner = nmlPython.nml2jupyter(path2source, fname_LEMS, fname_net)\n",
"\n",
"nml_doc=runner.loadnml()\n",
"runner.createTabWithAccordions(nml_doc) #create GUI with tabs (including LEMS) and nested accordions\n",
"#display(runner.createAccordions(nml_doc,'NML Document')) #create only nested accordions\n",
"runner.loadGUI(nml_doc) #load buttons and log/plot window"
]
},
{
"cell_type": "markdown",
"id": "aa709aa7",
"metadata": {},
"source": [
"## *INFO method output*"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7989feba",
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"#for key,values in nml_doc.cells[0].info(True,'dict').items():\n",
"# if values['members'] is None or (isinstance(values['members'], list) and len(values['members']) == 0): continue\n",
"# print(key,' = ', values['members'])"
]
},
{
"cell_type": "markdown",
"id": "219b7931",
"metadata": {},
"source": [
"## *Exploring sub-model (examples)*"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "02d4dbdc",
"metadata": {},
"outputs": [],
"source": [
"#with first tab as LEMS simulation parameters (default)\n",
"#runner.createTabWithAccordions(nml_doc.networks[0]) #pass NeuroML class object"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "79f7b597",
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"#only NeuroML model (no LEMS details included)\n",
"#runner.createAccordions(nml_doc.networks[0],'Networks') #pass NeuroML class object and a title for parent accordion"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
|