-
Notifications
You must be signed in to change notification settings - Fork 239
Macro definitions in equations #378
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
Comments
@thesamovar I am interested in working on the issue. How do I start? |
Thanks for offering to be involved! For something like this, we normally start with a discussion of use cases, then proposals for the syntax, and then finally move on to implementation. So I'd start by coming up with some suggestions as to how this feature might be used, and ideas for what the user syntax might look like. |
Hi! I was hoping to continue with this. |
I think the best thing for now would be to come up with a concrete use case, and show how the new syntax would make things clearer. For example, take the equations from one of the Brian examples and show how a macro definition would make them clearer/more readable. Note that there is potential for confusion what this issue is about: this is not about having a system just to change constants in equations (we already have several mechanisms for that, see e.g. http://brian2.readthedocs.io/en/stable/user/equations.html#equation-objects and http://brian2.readthedocs.io/en/stable/advanced/namespaces.html). It is rather about shortening/cleaning up equation strings by having a macro for expressions that occur repeatedly (with small variations such as changed constants) across several equations of an equations string. Oh, and I edited Dan's example in the initial post, it used "x" instead of "vT" by mistake. |
Hello! taking into account rate constants equations from 'COBAHH' example https://brian2.readthedocs.io/en/stable/examples/COBAHH.html: I am not sure it is small enough changes between three repeated equations, but may be it is useful to use macro in situations with 'exprel' function. before:
after:
Also possible usage with gate dynamics: before:
after:
Hope I understood properly. upd: Shorter but more tricky with parameters version of R:
|
Hi @thesamovar , @mstimberg , I would like to propose a macro feature for brian2, with the HH model as a compelling use case due to its repeated exponential patterns in the rate equations (alpham, betam, alphan). Also, I think reusable activation functions(like sigmoids) can also be an use case because they have reusable expressions. I have taken hodgkin_huxley_model (it is an ideal example and also because I was reading the tutorial_3 last week, so this struck me) This is how the simplified equation string would look like:
I feel the code looks more clear now, after using a shared form across the equations. Any thoughts / feedback? |
Hi @maverick4code, this would indeed be a useful feature to have, and as you can see from the date when this issue was opened, we've been interested in adding this for a long time 😉 I actually did quite a bit of work on this a while ago, to figure out the best way to implement things – unfortunately, I never completely finished it. I'll need to read up on things myself (it's been a few years), but here are a few pointers to previous (long)discussions and code: |
Uh oh!
There was an error while loading. Please reload this page.
e.g. define
E(vT)=exp((E-v+vT)/tau)
and then useE(15*mV)
,E(40*mV)
in the rest of the equations.The text was updated successfully, but these errors were encountered: