Compare Manual Euler with Brian2 Code

Hi everyone,
I have a Jupyter Notebook with Python code at the following link:
https://github.com/nematiftm/Brian2-Testing/blob/d29614b28602fc394158974c17a7db9621682b9a/LIF_Euler.ipynb

I’m trying to replicate manual Euler method using brian2. However, when I change the time step (dt), I notice that the synaptic currents should have a slight delay so that the membrane potential

Could anyone help me identify where in my synapse implementation I need to make adjustments to ensure the results match exactly?

Thanks!

Hi @elnaz91. I only had a cursory look at your notebook, but I think the reason has to do with the scheduling of events within a single time step, see Running a simulation — Brian 2 2.8.0.4 documentation

E.g. if you have equations for the membrane potential and the synaptic currents, you have to decide whether you apply the update from the equations before or after you increase the synaptic current for an incoming spike (I think your code does it after, but Brian by default does it before). Also, what you measure with a StateMonitor depends on whether you measure at the beginning or at the end (or at another time) during the time step. You might be interested in these two related blog posts (and potentially their screencast videos):

Hope that helps!

1 Like

Hi Marcel, Thanks for your reply! That actually helps. When I changed the monitor to before_threshold, they matched again. Thanks!

1 Like