Brian2 is an improved and partly rewritten version of Brian, the spiking neural network simulator (see http://briansimulator.org). For the documentation, see http://brian2.readthedocs.org
mstimberg on function_compiler_kwds
Add .c and .pxd to the list of … Make Cython compilation quiet a… (compare)
mstimberg on function_compiler_kwds
Document the new features for u… (compare)
mstimberg on function_compiler_kwds
Include external source files a… (compare)
mstimberg on function_compiler_kwds
Minor bug-fixes for new additio… Support external source files f… Add tests for functions with ex… (compare)
Thanks @mstimberg I meant for ">" on equation. exc_neurons.v_thr ='v>-65' is it correct ? and should it be defined as constant ?
No, this is not correct. Your threshold condition in the neuron group should be v > v_thr
and v_thr : volt (constant)
should be in your equations (as in the example in the documentation: https://brian2.readthedocs.io/en/stable/user/models.html#threshold-and-reset). Then, you can set exc_neurons.v_thr = -65*mV
.
when I was using :exc_neurons.v_reset = -65mV or exc_neurons.v_reset='v=-65mV' , for both , I recieve this error over simulation : Parsing the statement failed: v_reset
I am a bit confused: in addition to the threshold, you also want to set the reset differently for excitatory and inhibitory neurons, right? These lines will not give that error, but I guess you made an error elsewhere? E.g. did you write reset='v_reset'
in the NeuronGroup
definition, instead of `reset='v = v_reset'?
I tried to install Brian2 with the following command:
pip3 install --target=/home/wxie/Brian2/pkgs --upgrade brian2 pytest sphinx docutils mpi4py
when importing brian2, it shows the following errors:
from brian2 import *
/home/wxie/Brian2/pkgs/_distutils_hack/init.py:17: UserWarning: Distutils was imported before Setuptools, but importing Setuptools also replaces thedistutils
module insys.modules
. This may lead to undesirable behaviors or errors. To avoid these issues, avoid using distutils directly, ensure that setuptools is installed in the traditional way (e.g. not an editable install), and/or make sure that setuptools is always imported before distutils.
warnings.warn(
/home/wxie/Brian2/pkgs/_distutils_hack/init.py:30: UserWarning: Setuptools is replacing distutils.
warnings.warn("Setuptools is replacing distutils.")
any hints are appreciated
setuptools
. Could you check that you are using a recent setuptools
version, or simply update it to the latest version?
Hi @Willam_Xavier. This project is about working on the Brian2GeNN interface so that it supports more of GeNN’s features. Except for unforeseen bug fixes, etc., it should not involve changing anything on GeNN’s side. All that said, please note that the application deadline for this year’s Google Summer of Code was on April 19th…
Hi @mstimberg , I thought GeNN doesn't support heterogeneous synapses delays. Is that right GeNN actually does support the feature and one just need to add another interface to bridge Brian2 and GeNN?
The message from @neworderofjamie in this thread is a bit confusing:
brian-team/brian2genn#109
Does that mean the delay in GeNN are dendritic instead of axonal? He also mentioned that "they don't necessarily play well with STDP as back-propogating postsynaptic spikes can't be delayed heterogeneosuly to match". Would you please clarify that a bit?
I always find "axonal" and "dendritic" delays a bit confusing, since in most models, e.g. something like on_pre='ge_post += w'
, it does not change anything. In Brian, if you set a delay, it is axonal in the sense that we wait for that time before applying the statement. This also means that if your on_pre
refers to some pre-synaptic neuronal variable, this is taken at the time when the spike arrives, i.e. after the delay. You'd have to apply a workaround to describe something where it should store a pre-synaptic variable at the spike time and only apply it after a delay on the post-synaptic side. I'm actually not quite sure what it means in GeNN that the delay is dendritic, since AFAICT the synaptic model with delay does not support any access to neuronal variables, so all this should not matter.
For STDP, things are very different. The effictive time difference between the pre- and post-synaptic spike depends on the difference between the axonal delay (time after which the pre-synaptic spike arrives at the synapse) and the dendritic delay (time after with the post-synaptic spike arrives at the synapse). In Brian, you can set synapses.pre.delay
and synapses.post.delay
independently, but GeNN does not have such a mechanism.
Hi there, I have some doubts about usage of "summed" . Consider a simple example : syn=Synapse(G,G, 'v_post=v_pre :1 (summed) , syn.i=[0,0,1] , syn.j=[1,2,2] . 1)Here, is v for neuron 2 the sum of v for neuron 0 and v for neuron 1 ? 2)
Hi. Yes, the summed variable here means that at every time step, you sum over all v_pre
values for the neurons connecting to a neuron. So with your connection pattern, neuron 0 does not receive any input, its v
will therefore set to 0, neuron 1 receives input from neuron 0 and its v
will therefore be set to the same value, and v
for neuron 1 is the sum of v for neurons 1 and 2. The situation is a bit odd, though, normally you do not tuse he same variable of the same group on the left- and the right-hand side. Basically, here inevitably everything will be 0.
If I remove "summed", how v_2 is interpreted? Thank in advance.
What is v_2
? You cannot remove (summed)
in the above equations, just stating v_post = v_pre : 1
is not allowed/meaningful.
summed
in that example either. It says Y_S_post = Y_S_pre
, but in general there is more than one pre-synaptic Y_S
for each post-synaptic Y_S
, since more than one neuron on the pre-synaptic side can be connected to a post-synaptic neuron (in that example, it is synapses and astrocytes, but the same reasoning applies). So Y_S_post = Y_S_pre
does not make sense. With (summed)
it is interpreted as Y_S_post = sum(Y_S_pre)
, where the sum is over all the pre-synaptic elements connecting to the post-synaptic element. This is defined regardless of how many connections there are.
Y_S
variable, how can it treat the two synapses differently? I mean, you can for example multiply the Y_S
on the pre-synaptic side with a weight to have one of them influence the Y_S
of the astrocyte more strongly than the other, but in the end the two values need to be combined into a single value, no?
pip
asking it to not use binary wheels and use an option like --ignore-python-requires
.
Hello there, I am trying right now to fit some VC data I have to model using the brian2 modelfitter, however it fails to find good solutions (that might have many reasons). I cam across the following in the docs
Reference the target values in the equations
"A model can refer to the target output values within the equations. For example, if you are fitting a membrane potential trace v (i.e. output_var='v'), then the equations can refer to the target trace as v_target. This allows you for example to add a coupling term like coupling*(v_target - v) to the equation for v, pulling the trajectory towards the correct solution."
This seems like something that could increase my chances however I do not understand where and how in a model this term would be included and how the fitter would refer to it.
Can somebody enlighten me with an example on how these coupling terms can work?
Thank you so much in advance.
hh_nevergrad_runtime.py
example:
v
to the target v. In the first iterations, this coupling is very strong (i.e. the simulated v
will be close to the target v, even for bad parameter values), and then the coupling conductance gets weaker and weaker:dv/dt = (gl*(El-v) - g_na*(m*m*m)*h*(v-ENa) - g_kd*(n*n*n*n)*(v-EK) + I + g_coupling*(v_target - v))/Cm : volt
g_coupling = 100*nS/(iteration + 1) : siemens
v_target
is provided by brian2modelfitting
and equal to the target v
for every time step, and iteration
is automatically set to the iteration of the fitting algorithm (starting with 0).
generate
function you have to be a bit careful, since it does not exactly correspond to what the fitting algorithm did. In generate
, the iteration
variable is set to 1e9 by default (i.e. in the above example, g_coupling
would be basically 0). The idea is that for the "real" result you are interested in you want to ignore the coupling term, but it would be annoying if you would have to change the model equations to deal with this. If you want to generate
exactly the trace that the fitting algorithm used, then you have to set its iteration
argument to the corresponding value (e.g. 49 if you wan the fitting for 50 iterations). Hope that makes things a bit clearer!
S = Synapses(..., delay=1*ms)
.
from brian2 import *
set_device('cpp_standalone', directory='standalone')
@implementation('cpp', '''
double piecewise_linear(double I) {
if (I < 1e-9)
return 0;
if (I > 3e-9)
return 100;
return (I/1e-9 - 1) * 50;
}
''')
@check_units(I=amp, result=Hz)
def piecewise_linear(I):
raise NotImplementedError('use standalone mode')
##
input = PoissonGroup(10, rates=piecewise_linear(10*amp))
run(1*second, report='text')
Hi @wxie2013: the way you called piecewise_linear
, it will be directly executed in Python instead of being integrated into the generated code. It needs to be in a string, i.e. use
input = PoissonGroup(10, rates='piecewise_linear(10*amp)')
Of course, it would make only really sense if the expression was a function of time or of some variable changing with time.
:point_up: Edit: Hi wxie2013 (wxie2013): the way you called piecewise_linear
, it will be directly executed in Python instead of being integrated into the generated code. It needs to be in a string, i.e. use
input = PoissonGroup(10, rates='piecewise_linear(10*amp)')
Of course, it would make only really sense if the expression was a function of time or of some variable changing with time.
what's the difference between "when=end" and "when=before_end". I'm going through the example:
https://brian.discourse.group/t/changing-stimuli-programmatically-in-c-standalone/748
by changing the "when=before_end" to "when=end"
in "stimulus_control.run_regularly()", the results are quite different