-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MRG + 1] ENH: try making HNN GUI with ipywidgets #76
Conversation
Codecov Report
@@ Coverage Diff @@
## master #76 +/- ##
==========================================
- Coverage 90.69% 90.43% -0.27%
==========================================
Files 14 14
Lines 2365 2425 +60
==========================================
+ Hits 2145 2193 +48
- Misses 220 232 +12
Continue to review full report at Codecov.
|
Now that HNN-core is cleaned up, I'd like to revisit this for 0.2. A dashboard-GUI might be much easier to maintain in the long run. |
@stephanie-r-jones @ntolley @rythorpe @cjayb related to today's discussion, I want to bring to your attention this GUI code I wrote long time ago. It's less than 100 lines of code at the moment and can already do this: I'm sure the left panel can be modified to add some tabs for modifying different kinds of parameters. And then you can use voila to hide the code. If someone wants to pair up and try to improve this, I'd be up for it. Clone this branch and give it a shot I would say! |
@jasmainak this is awesome! Once I wrap up my open PR's I'd be interested in testing this out. Given the simplicity of ipywidgets, I think it will provide a nice space to improve on the essential functionality for the GUI (taking a lot from the existing version). |
wonderful, thanks for the encouragement! I pushed another tiny update to the UI |
1533641
to
1e5dbca
Compare
Codecov Report
@@ Coverage Diff @@
## master #76 +/- ##
==========================================
- Coverage 90.51% 87.63% -2.89%
==========================================
Files 18 19 +1
Lines 3415 3792 +377
==========================================
+ Hits 3091 3323 +232
- Misses 324 469 +145
Continue to review full report at Codecov.
|
4356129
to
259d7c5
Compare
hnn_core/gui.py
Outdated
sliders = list() | ||
for d in param_keys: | ||
slider = FloatLogSlider( | ||
value=params[d], min=-5, max=1, step=0.2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dynamic range may differ between neurotransmitters, might be worth considering different min/maxes for GABA vs. AMPA
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note this in log scale! But yes totally open to suggestions to improve the interface here
hnn_core/gui.py
Outdated
_get_sliders(params, | ||
['gbar_L2Pyr_L5Pyr', 'gbar_L2Basket_L5Pyr'])] | ||
|
||
# accordians to group local-connectivity by cel type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# accordians to group local-connectivity by cel type | |
# accordians to group local-connectivity by cell type |
yeah, it's a bit intentional for now. You need to change the dropdown for a drive to be added. I think we need to change it ultimately to be a radio + "add" button. I'm just trying to get an MVP working first. Did you try the mybinder link above?? |
Just tried it now! Really awesome to have that working on binder. The barrier for entry is getting even lower now that there is a |
This is super cool @jasmainak! +100 for the dashboard GUI configuration. The code is a lot simpler with a modular design. When X-forwarding the current hnn-gui hosted on a computing cluster, I've often noticed that having multiple application windows open can cause my system to freeze up with fluctuations in my internet speed/bandwidth. I'm curious to see if using ipywidgets will improve this. |
You should give it a try! Here are two links to get you started: https://docs.anaconda.com/anaconda/user-guide/tasks/remote-jupyter-notebook/ I think it should also be pretty doable to configure it for an entire class. I have worked with Isabel for the MNE workshops and she set up a JupyterHub in Brown. It worked pretty well. |
c0db431
to
353d8c0
Compare
hnn_core/gui.py
Outdated
variables['net'].connectivity = list() | ||
# XXX: hack until there is a proper API | ||
variables['net'].self._set_default_connections() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ntolley food for thought for you what should be the right API here
EDIT: maybe Network
shouldn't be instantiated in GUI until the run
button is clicked ?
okay I'm done for now. Let me know once the error is fixed and I'll do another round :) |
Fixed in 3d9082d |
Sure, as you like :) |
default_data = { | ||
'weights_ampa': { | ||
'L5_pyramidal': 0., | ||
'L2_pyramidal': 0., | ||
'L5_basket': 0., | ||
'L2_basket': 0. | ||
}, | ||
'weights_nmda': { | ||
'L5_pyramidal': 0., | ||
'L2_pyramidal': 0., | ||
'L5_basket': 0., | ||
'L2_basket': 0. | ||
}, | ||
'delays': { | ||
'L5_pyramidal': 0.1, | ||
'L2_pyramidal': 0.1, | ||
'L5_basket': 0.1, | ||
'L2_basket': 0.1 | ||
}, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is perhaps opening a large can of worms, but what happens when we want to add an hnn-core model that contain more or less cell types than the ones we currently have? Will we need to update the hardcoded cell types here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep. But the widgets will also need to be updated ... no point in generalizing just this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless I'm missing something crucial here, I feel like the GUI code should be as independent from specific network attributes as possible. If we hardcode these values in now, we're just repeating the same mistakes of the past GUI.
As a solution, I propose that we first have the user specify which network model to load into the GUI environment, and then instantiate cell specific widgets based on the cell types and properties contained in that Network
instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that would be a great feature to have ... at the moment, we don't yet allow the user to modify cell properties (e.g., the constants in the mechanisms). I think we should discuss what would be a reasonable and "easy" thing to fix in the code. I propose that we merge this PR and after that spend a week on maintenance -- writing tests, refactoring, making it more future proof etc. I highly recommend pulling the PR and trying to play around with the code to get a sense of what is possible and what is not.
@chenghuzi I still have this problem: Note how the button next to proximal can't be selected. Make sure to pull my last commit before fixing it. |
we're close @chenghuzi ! I can see the light for this PR :) Just some more tweaks and we can merge. Also please set the PR title to MRG when it's ready on your end |
I tried on a very small browser window and it didn't happen. This is weird... Anyway, I'll change the alignment from HBox to Vbox, which should provide enough width for each of them. |
I'll give it another run through and (hopefully!) rebase and merge by this afternoon. Stay tuned! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great @chenghuzi and @jasmainak! I've created a follow issue with some enhancement nitpicks that we can discuss and/or address in the next few PRs.
Thanks @chenghuzi and @jasmainak for pushing this forward. We've now got ourselves a new GUI 🎉 |
Great work @chenghuzi ! 🥳 🥳 🥳 |
Here is a demo of the GUI with ipywidgets.
Try on Mybinder!!!
Some advantages of this approach:
To run this example, you'll need
ipywidgets
andvoila
. First make sure you have the latest version ofjupyter
Then install the dependencies:
Finally do:
voila
is not strictly necessary. You can also do:and run the first cell.
You should see:
PS: If we want interactive plots, we could potentially leverage ipympl but I would say, let's start with something simple
HNN-core examples tested
TODO / Wishlist
Network
untilrun
button is pressed?