Brian running locally in the browser via Javascript using pyodide

[edited]
thank you! I used p5.js for interactivity for that application, mostly because it’s what i was familiar with.


I suppose it’s useful to think of multiple use-cases for Brian in the browser:
1. Script Exploration: Allowing students to interactively change parameters within a “standard” python script / notebook
- this is mostly to facilitate “oh that’s what effect that value has” and understand the script and the parameters better
2. Data Viz/Exploration: Allowing researchers to dig deeper into factors affecting a simulation, perhaps as a prototyping step before launching a large automated parameter sweep. Or data vis / exploration after a sweep is complete.

Both of these start from a script and want to add interactivity to certain pieces. I think these could be partially addressed with interactive plotting libraries (altair, d3, bokeh) within standard jupyter notebooks, but I suppose the benefits of moving to the browser are:

  • reducing the install / setup burden for the student
  • easier hosting / distribution
  • potentially richer interactivity
    Solutions like jupyterlite / starboard / observable seem like promising solutions to move in that direction.

But use case 3 starts from one central interactive element first, then add the Brian2 / python scripting pieces to support it:

3. System Exploration / Showcase: A demonstration of an interactive neural system either to demonstrate concepts in a way that abstracts away the code implementation, or break the inputs and outputs from the confines of a jupyter cell.
This would be less useful for teaching people how to write code with Brian, but could demonstrate bigger concepts well. I think of the dynamics visualizer as falling under this category, but without the python.
I think this use case requires a somewhat different implementation where python / Brian is being called from within a larger html + js canvas (likely using pyodide)


I think a minimal-dependency “lite” version of Brian2 would be useful for sure. The other feature which would be useful would be to pull outputs from a simulation as it’s running. It looks like based on the discussion here:

there are some ways to achieve this already, but I might need to follow up with you about how best to do that without writing to files

1 Like