Closed irahulsonkar closed 1 year ago
Thanks @irahulsonkar . Looks good. Tested it out and works well too. :+1:
I think another future work is to generalise all of this in the same way as nwbwidgets. The idea is that there will be a nml2widget(nml_model)
function that will take any NeuroML class object (python object) and generate widgets, sort of as a general front end to info()
. So users can use it to inspect individual components, or the whole document (for larger models, the whole document may not work---I tried it with one and it was taking forever so I had to kill it). We can then leave the reading of the file etc. to the user---as long as it's a NeuroML object, it will be converted to a/multiple widgets. This way, it doesn't have to be a NeuroML file that is read in---it can be me writing my model in NeuroML using Python, and then calling the nml2widget
function later to see it all (similar to how we use info
).
While we modularise this, it'll be good to split out nm2widget
and lemssimulation2widget
because users may only want to inspect the model, and not the associated lems simulation or vice-versa.
similar to nwbwidgets, we can then create "dashboards" (and allow users to create dashboards for their projects). The default can be what you have here---shows everything in a nice structured way
as you've noted, the LEMS bits need a little tweaking.
possible improvement: replace the text boxes with file selectors if possible (just so that users can use a portal to select the file instead of having to write the path there manually)
So, this is all a very very useful starting point. I think we'll create a new python package, nmlwidgets
or something, and refactor the code here to follow the nwbwidgets model.
@sanjayankur31 Thanks for the review and nice suggestions.
Regarding the first point, taking any NeuroML class object and generating widget. It is already there in the notebook as an example, I think in the last cell (Exploring Sub-Models
) where you can pass any python object on which info
works, say pulse generator
or ion channel
.
The notebook by default passes full NeuroML class object which is read from the file but the user can modify it similar to example in last cells, presently commented out.
runner.createAccordions(nml_doc.networks[0],'Networks')) #pass the object and a tittle for parent accordion
This will create only accordions for the given object. Similarly, if user wants first level as tabs then accordions following can be used, (probably this function should be renamed something to createTabWithAccordions())
runner.generateDashboard(nml_doc.networks[0]) #pass the object (tittle not required)
Yes, loading full nml_doc
for larger models gets very slow. I was thinking to include a progress bar so the user atleast know its running and loading models.
For replacing the text boxes with file selectors, I planned to used FileUpload
widget of jupyter-notebook
but during testing/development phase i found text boxes to be easier/faster, maybe later you can consider using this kind of widget.
I'll merge this now. Thanks again @irahulsonkar
Edit: can't yet, dont have permissions, will merge when we have that sorted out :)
Generic notebook for loading existing NeuroML models and run interactively.
Current Status:
info
method andread_neuroml2_file()
tabs
andaccordions
)Update Model
button in notebook which callswriters.NeuroMLWriter.write()
Validate Model
button can be used to validate the file against NeuroML2 schema usingpynml.validate_neuroml2()
Run NeuroML
button in notebook which callspynml.run_lems_with_jneuroml()
matplotlib
widget usingPlot Outptut
buttonTest Models: 1. Hodgkin Huxley Tutorial: LEMS - https://github.com/openworm/hodgkin_huxley_tutorial/blob/master/Tutorial/Source/LEMS_HH_Simulation.xml Network - https://github.com/openworm/hodgkin_huxley_tutorial/blob/master/Tutorial/Source/HHCellNetwork.net.nml
2. BahlEtAl2012_ReducedL5PyrCell: LEMS - https://github.com/OpenSourceBrain/BahlEtAl2012_ReducedL5PyrCell/blob/master/NeuroML2/LEMS_pyr_single_comp.xml Network - https://github.com/OpenSourceBrain/BahlEtAl2012_ReducedL5PyrCell/blob/master/NeuroML2/pyr_soma.net.nml
3. AllenInstituteNeuroML: LEMS - https://github.com/OpenSourceBrain/AllenInstituteNeuroML/blob/master/CellTypesDatabase/models/NeuroML2/LEMS_SomaTest.xml Network - https://github.com/OpenSourceBrain/AllenInstituteNeuroML/blob/master/CellTypesDatabase/models/NeuroML2/Soma_Test.net.nml
Future Work:
parent_id
)Update Model
button since that writes the values from loaded neuroml object in python and not from the widget values