{ "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 }