Brian simulations can currently only run in a web browser if a server runs the code. Due to recent improvements in browser technology such as WebAssembly, browser are however capable of executing computationally complex code themselves, directly on the client machine.
The emscripten project is a compiler toolchain that compiles C++ code into WebAssembly, which can then be executed in the browser. It is therefore possible to use Brian’s existing C++ compilation framework to run a Brian simulation in the browser, but there are still a number of obstacles to overcome before this can be useful in practice. The specific aims of this project are:
- Adapt Brian’s C++ standalone mode so that it can compile to WebAssembly. In particular, this requires to replace the current mechanism that relies on files on disk to initialize values and return the results of a simulation.
- create convenient methods to display simulation results in the browser
- investigate integrating this with the current Brian examples and/or on a dedicated “showcase” website
- [for a 6 months project]: create a mechanism to specify model parameters that a user should be able to interactively modify when running a simulation, and expose convenient access to these controls from the HTML interface.
- [for a 6 months project (alternative)]: enhance the display methods so that they can display simulation results continuously, instead of requiring for the simulation to end.
Planned effort: 175h or 350h (350h preferred)
Skill level: intermediate
Mentors: Marcel Stimberg @mstimberg, Dan Goodman @d.goodman
Hello @mstimberg and @d.goodman,
It would be great if you could guide me to the first steps so that I can start contributing.
Hi @satvik7reborn , happy to hear you are interested in the project. It’s still early in the process, and we will give some more detailed information on what we expected for the proposal, etc. later. For now, I’d recommend you to get a bit familiar with Brian itself (via the documentation, tutorials, etc.), and then to try to understand the ideas and approach behind its “code generation” mechanism (e.g. by reading our 2014 and 2019 papers). All links on the web site: https://briansimulator.org Let us know if you run into any issues or have any questions!
As you said, I installed, read the documentation, and went through the tutorials of Brian. I skimmed the 2014 paper. I also got familiar with emscripten. Can you tell me the next steps towards contributing? Information about the proposal would be great too
Hi @satvik7reborn. Apologies, I am a bit behind with regards to all this. I will provide you with some more specific information this Thursday, please ping me again if I don’t. Until then, I’d suggest to have a look at Brian’s “standalone mode” which will be the base for this project (see documentation here: Computational methods and efficiency — Brian 2 220.127.116.11 documentation). Try running a very simple Brian example that uses this mode, e.g. this one: Example: simple_case — Brian 2 18.104.22.168 documentation and try to get an idea of how it works from the code that it generates in the
output directory. The generated code in this directory is in C++, but understanding this code in detail is not essential for this project.
Hello @mstimberg I went through the “standalone mode” and will further play around and familiarize myself
Do you have any specific information for me? You told me to remind you
I am looking to start my proposal early so that we can have a discussion and improve it later on
Your feedback would be really useful for me
Sorry again for the delay, and thanks for the reminder.
We have now posted some general recommendations for GSoC applications to our website, please have a look: Recommendations for GSoC 2022 applications | The Brian spiking neural network simulator
More specifically for this project, please have a look at the emscripten documentation at Building Projects — Emscripten 3.1.8-git (dev) documentation and describe how this procedure could be used to achieve the goals of this project. Ideally, you’d then use a “hack” (e.g. some manual editing of the files that Brian’s standalone mode generates) to quickly apply the described procedure in Brian (developing a “clean” solution is one of the goals of this project!), and document what you did and how it worked/failed.