Question about rewriting the equation of the LIF neuron model

43 views
Skip to first unread message

Qianhui Liu

unread,
Aug 6, 2017, 2:33:13 AM8/6/17
to Brian



Hi all,
I need to create a neuron that uses the model showed in the picture below (extract from a paper). 
I wondered how to write the equations in brian2?
I am trying to figure out, but I am not sure whether my code is right.
dV/dt = (Vrest - V) + K    
    for each spike: V += w
dK/dt = -K / (ts - tf)  
   for each spike: K += V0

Any help would be appreciated,

Thanks all




Dan Goodman

unread,
Aug 7, 2017, 8:23:18 AM8/7/17
to brians...@googlegroups.com
Hi,

These types of kernel basd synaptic equations can be converted into ODE
form fairly straightforwardly. We should write a short guide on this,
but for the moment take a look at section 2.2 in our paper "Vectorised
algorithms for spiking neural network simulation":

http://www.briansimulator.org/WordPress/wp-content/uploads/2010/10/algorithms-preprint.pdf

Dan

On 06/08/2017 07:33, Qianhui Liu wrote:
>
>
> Hi all,
> I need to create a neuron that uses the model showed in the picture
> below (extract from a paper).
> <https://lh3.googleusercontent.com/-5CTQJq9_Vu4/WYa1R4pzWbI/AAAAAAAAAA8/7CB0GJ3CCQwHy2J0n_c-q_WsqwWMnV4MQCLcBGAs/s1600/WechatIMG31.jpeg>
> <https://lh3.googleusercontent.com/-g-XmAQh5IBc/WYa1gQsGXFI/AAAAAAAAABA/Yn8tPuTAuIQZZK9o4r4dYCVwPSl09Z8xwCLcBGAs/s1600/WechatIMG30.jpeg>
> I wondered how to write the equations in brian2?
> I am trying to figure out, but I am not sure whether my code is right.
> dV/dt = (Vrest - V) + K
> for each spike: V += w
> dK/dt = -K / (ts - tf)
> for each spike: K += V0
>
> Any help would be appreciated,
>
> Thanks all
>
>
>
>
> --
> http://www.facebook.com/briansimulator
> https://twitter.com/briansimulator
>
> New paper about Brian 2: Stimberg M, Goodman DFM, Benichoux V, Brette R
> (2014).Equation-oriented specification of neural models for simulations.
> Frontiers Neuroinf, doi: 10.3389/fninf.2014.00006.
> ---
> You received this message because you are subscribed to the Google
> Groups "Brian" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to briansupport...@googlegroups.com
> <mailto:briansupport...@googlegroups.com>.
> To post to this group, send email to brians...@googlegroups.com
> <mailto:brians...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/briansupport.
> For more options, visit https://groups.google.com/d/optout.
Message has been deleted

Dan Goodman

unread,
Aug 8, 2017, 4:01:46 PM8/8/17
to brians...@googlegroups.com
Not sure, but if you have multiple neuron groups that you're storing in
a dictionary then they might not be simulated if you call run(). You
might need to explicitly construct a Network object and then call
Network.run.

http://brian2.readthedocs.io/en/stable/user/running.html#networks

Dan

On 08/08/2017 06:26, Qianhui Liu wrote:
> Hi Dan,
> Thanks. I wonder to check whether my expression is right. I now record
> the variable v like this:
> mon = b2.StateMonitor(neuron_groups['Ae'],'v',record=range(5))
>
> and after run(0.15 * b2.second)
>
> to check the mon value:
> print mon.v
>
> It prints out :
>
> [] V
>
>
> I puzzled over it, any question to my code? In which condition the mon.v
> will be Null?
>
> Thanks
>
> Qianhui
>
> 在 2017年8月7日星期一 UTC+8下午8:23:18,Dan Goodman写道:
>
> Hi,
>
> These types of kernel basd synaptic equations can be converted into ODE
> form fairly straightforwardly. We should write a short guide on this,
> but for the moment take a look at section 2.2 in our paper "Vectorised
> algorithms for spiking neural network simulation":
>
> http://www.briansimulator.org/WordPress/wp-content/uploads/2010/10/algorithms-preprint.pdf
> <http://www.briansimulator.org/WordPress/wp-content/uploads/2010/10/algorithms-preprint.pdf>
>
>
> Dan
>
> On 06/08/2017 07:33, Qianhui Liu wrote:
> >
> >
> > Hi all,
> > I need to create a neuron that uses the model showed in the picture
> > below (extract from a paper).
> >
> <https://lh3.googleusercontent.com/-5CTQJq9_Vu4/WYa1R4pzWbI/AAAAAAAAAA8/7CB0GJ3CCQwHy2J0n_c-q_WsqwWMnV4MQCLcBGAs/s1600/WechatIMG31.jpeg
> <https://lh3.googleusercontent.com/-5CTQJq9_Vu4/WYa1R4pzWbI/AAAAAAAAAA8/7CB0GJ3CCQwHy2J0n_c-q_WsqwWMnV4MQCLcBGAs/s1600/WechatIMG31.jpeg>>
>
> >
> <https://lh3.googleusercontent.com/-g-XmAQh5IBc/WYa1gQsGXFI/AAAAAAAAABA/Yn8tPuTAuIQZZK9o4r4dYCVwPSl09Z8xwCLcBGAs/s1600/WechatIMG30.jpeg
> <https://lh3.googleusercontent.com/-g-XmAQh5IBc/WYa1gQsGXFI/AAAAAAAAABA/Yn8tPuTAuIQZZK9o4r4dYCVwPSl09Z8xwCLcBGAs/s1600/WechatIMG30.jpeg>>
>
> > I wondered how to write the equations in brian2?
> > I am trying to figure out, but I am not sure whether my code is
> right.
> > dV/dt = (Vrest - V) + K
> > for each spike: V += w
> > dK/dt = -K / (ts - tf)
> > for each spike: K += V0
> >
> > Any help would be appreciated,
> >
> > Thanks all
> >
> >
> >
> >
> > --
> > http://www.facebook.com/briansimulator
> <http://www.facebook.com/briansimulator>
> > https://twitter.com/briansimulator
> <https://twitter.com/briansimulator>
> >
> > New paper about Brian 2: Stimberg M, Goodman DFM, Benichoux V,
> Brette R
> > (2014).Equation-oriented specification of neural models for
> simulations.
> > Frontiers Neuroinf, doi: 10.3389/fninf.2014.00006.
> > ---
> > You received this message because you are subscribed to the Google
> > Groups "Brian" group.
> > To unsubscribe from this group and stop receiving emails from it,
> send
> > an email to briansupport...@googlegroups.com <javascript:>
> > <mailto:briansupport...@googlegroups.com <javascript:>>.
> > To post to this group, send email to brians...@googlegroups.com
> <javascript:>
> > <mailto:brians...@googlegroups.com <javascript:>>.
> <https://groups.google.com/group/briansupport>.
> > For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.

Qianhui Liu

unread,
Aug 9, 2017, 12:29:01 PM8/9/17
to Brian


Hi,Dan
I have found the mistake.  I forgot to add the monitor to the network, so the monitor does not record the network's performance.、
Back to the original question, I have not quite understood the equation conversion.I wonder to rewrite this:
O(t) is the Heaviside step function with O() = 1 for > 0 and O() = 0 else. 
I puzzled about rewriting these equations with Heaviside step function and integral functionAt your convenience, I would really appreciate you giving some more hints to me.
Thanks!
Qianhui







在 2017年8月9日星期三 UTC+8上午4:01:46,Dan Goodman写道:
>     > <mailto:briansupport+unsub...@googlegroups.com <javascript:>>.
>     > To post to this group, send email to brians...@googlegroups.com
>     <javascript:>
>     > <mailto:brians...@googlegroups.com <javascript:>>.
>     > Visit this group at https://groups.google.com/group/briansupport
>     <https://groups.google.com/group/briansupport>.
>     > For more options, visit https://groups.google.com/d/optout
>     <https://groups.google.com/d/optout>.
>
> --
> http://www.facebook.com/briansimulator
> https://twitter.com/briansimulator
>
> New paper about Brian 2: Stimberg M, Goodman DFM, Benichoux V, Brette R
> (2014).Equation-oriented specification of neural models for simulations.
> Frontiers Neuroinf, doi: 10.3389/fninf.2014.00006.
> ---
> You received this message because you are subscribed to the Google
> Groups "Brian" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to briansupport...@googlegroups.com

Dan Goodman

unread,
Aug 9, 2017, 12:35:37 PM8/9/17
to brians...@googlegroups.com
Hi,

I'm afraid I don't have time to go into mathematical details. I suggest
you look at the section of the paper I mentioned before which contains
some details and references to read on this issue.

Dan

On 09/08/2017 17:29, Qianhui Liu wrote:
>
> Hi,Dan
> I have found the mistake. I forgot to add the monitor to the network,
> so the monitor does not record the network's performance.、
> Back to the original question, I have not quite understood the equation
> conversion.I wonder to rewrite this:
> <https://lh3.googleusercontent.com/-AtpNSJ7R-VA/WYszPSl6w-I/AAAAAAAAABQ/4-HSdgHkgyUqyluLKCj5-92TG65WT9S8wCLcBGAs/s1600/WechatIMG36.jpeg>
> <https://lh3.googleusercontent.com/-odLhnPvTBrU/WYszWUtIUHI/AAAAAAAAABU/IEt6O5xf2VI7xf3U8-f6T9ykljVaHOgBACLcBGAs/s1600/WechatIMG37.jpeg>O(t) is
> the Heaviside step function with O(t ) = 1 for t > 0 and O(t ) = 0 else.
> <https://lh3.googleusercontent.com/-WIwWgMaHXh4/WYszcuCeztI/AAAAAAAAABY/D60P8i2ByGguk2pANUCj_llGQeIxmbt1QCLcBGAs/s1600/WechatIMG38.jpeg>
> > > <mailto:briansupport...@googlegroups.com
> <javascript:> <javascript:>>.
> <http://www.facebook.com/briansimulator>
> > https://twitter.com/briansimulator
> <https://twitter.com/briansimulator>
> >
> > New paper about Brian 2: Stimberg M, Goodman DFM, Benichoux V,
> Brette R
> > (2014).Equation-oriented specification of neural models for
> simulations.
> > Frontiers Neuroinf, doi: 10.3389/fninf.2014.00006.
> > ---
> > You received this message because you are subscribed to the Google
> > Groups "Brian" group.
> > To unsubscribe from this group and stop receiving emails from it,
> send
> > an email to briansupport...@googlegroups.com <javascript:>
> > <mailto:briansupport...@googlegroups.com <javascript:>>.
> > To post to this group, send email to brians...@googlegroups.com
> <javascript:>
> > <mailto:brians...@googlegroups.com <javascript:>>.
> > Visit this group at https://groups.google.com/group/briansupport
> <https://groups.google.com/group/briansupport>.
> > For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
> --
> http://www.facebook.com/briansimulator
> https://twitter.com/briansimulator
>
> New paper about Brian 2: Stimberg M, Goodman DFM, Benichoux V, Brette R
> (2014).Equation-oriented specification of neural models for simulations.
> Frontiers Neuroinf, doi: 10.3389/fninf.2014.00006.
> ---
> You received this message because you are subscribed to the Google
> Groups "Brian" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to briansupport...@googlegroups.com
> <mailto:briansupport...@googlegroups.com>.

Qianhui Liu

unread,
Aug 16, 2017, 4:21:44 AM8/16/17
to Brian
Hi, DAN
Thanks. I will look into it. 
I have one more question. I have 6 million NeuronGroup in the input layer and 80 NeuronGroup in the first layer. I use  'connListSparse = zip(conn.i, conn.j, conn.w)' to save this large weight matrix, but it is too slow. Do you have suggestions?

Best regards,
Qianhui

在 2017年8月10日星期四 UTC+8上午12:35:37,Dan Goodman写道:
>      >     > <mailto:briansupport+unsub...@googlegroups.com
>      > <mailto:briansupport+unsub...@googlegroups.com <javascript:>>.
>      > To post to this group, send email to brians...@googlegroups.com
>     <javascript:>
>      > <mailto:brians...@googlegroups.com <javascript:>>.
>      > Visit this group at https://groups.google.com/group/briansupport
>     <https://groups.google.com/group/briansupport>.
>      > For more options, visit https://groups.google.com/d/optout
>     <https://groups.google.com/d/optout>.
>
> --
> http://www.facebook.com/briansimulator
> https://twitter.com/briansimulator
>
> New paper about Brian 2: Stimberg M, Goodman DFM, Benichoux V, Brette R
> (2014).Equation-oriented specification of neural models for simulations.
> Frontiers Neuroinf, doi: 10.3389/fninf.2014.00006.
> ---
> You received this message because you are subscribed to the Google
> Groups "Brian" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to briansupport...@googlegroups.com

Dan Goodman

unread,
Aug 16, 2017, 5:30:20 AM8/16/17
to brians...@googlegroups.com
Hi Qianhui

Save (conn.i, conn.j, conn.w) instead, it will be fast. Well, if your
connectivity is reasonably dense it will still take a while because
that'll be up to a 5GB file.

Dan

On 16/08/2017 09:21, Qianhui Liu wrote:
> Hi, DAN
> Thanks. I will look into it.
> I have one more question. I have 6 million NeuronGroup in the input
> layer and 80 NeuronGroup in the first layer. I use 'connListSparse =
> zip(conn.i, conn.j, conn.w)' to save this large weight matrix, but it is
> too slow. Do you have suggestions?
>
> Best regards,
> Qianhui
>
> 在 2017年8月10日星期四 UTC+8上午12:35:37,Dan Goodman写道:
>
> Hi,
>
> I'm afraid I don't have time to go into mathematical details. I suggest
> you look at the section of the paper I mentioned before which contains
> some details and references to read on this issue.
>
> Dan
>
> On 09/08/2017 17:29, Qianhui Liu wrote:
> >
> > Hi,Dan
> > I have found the mistake. I forgot to add the monitor to the
> network,
> > so the monitor does not record the network's performance.、
> > Back to the original question, I have not quite understood the
> equation
> > conversion.I wonder to rewrite this:
> >
> <https://lh3.googleusercontent.com/-AtpNSJ7R-VA/WYszPSl6w-I/AAAAAAAAABQ/4-HSdgHkgyUqyluLKCj5-92TG65WT9S8wCLcBGAs/s1600/WechatIMG36.jpeg
> <https://lh3.googleusercontent.com/-AtpNSJ7R-VA/WYszPSl6w-I/AAAAAAAAABQ/4-HSdgHkgyUqyluLKCj5-92TG65WT9S8wCLcBGAs/s1600/WechatIMG36.jpeg>>
>
> >
> <https://lh3.googleusercontent.com/-odLhnPvTBrU/WYszWUtIUHI/AAAAAAAAABU/IEt6O5xf2VI7xf3U8-f6T9ykljVaHOgBACLcBGAs/s1600/WechatIMG37.jpeg
> > > > <mailto:briansupport...@googlegroups.com
> <javascript:>
> > <http://www.facebook.com/briansimulator
> <http://www.facebook.com/briansimulator>>
> > > https://twitter.com/briansimulator
> <https://twitter.com/briansimulator>
> > <https://twitter.com/briansimulator
> <https://twitter.com/briansimulator>>
> > >
> > > New paper about Brian 2: Stimberg M, Goodman DFM,
> Benichoux V,
> > Brette R
> > > (2014).Equation-oriented specification of neural models for
> > simulations.
> > > Frontiers Neuroinf, doi: 10.3389/fninf.2014.00006.
> > > ---
> > > You received this message because you are subscribed to
> the Google
> > > Groups "Brian" group.
> > > To unsubscribe from this group and stop receiving emails
> from it,
> > send
> > > an email to briansupport...@googlegroups.com <javascript:>
> > > <mailto:briansupport...@googlegroups.com
> > <mailto:briansupport...@googlegroups.com <javascript:>>.
> > To post to this group, send email to brians...@googlegroups.com
> <javascript:>
> > <mailto:brians...@googlegroups.com <javascript:>>.
> > Visit this group at https://groups.google.com/group/briansupport
> <https://groups.google.com/group/briansupport>.
> > For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
> --
> http://www.facebook.com/briansimulator
> https://twitter.com/briansimulator
>
> New paper about Brian 2: Stimberg M, Goodman DFM, Benichoux V, Brette R
> (2014).Equation-oriented specification of neural models for simulations.
> Frontiers Neuroinf, doi: 10.3389/fninf.2014.00006.
> ---
> You received this message because you are subscribed to the Google
> Groups "Brian" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to briansupport...@googlegroups.com
> <mailto:briansupport...@googlegroups.com>.

Qianhui Liu

unread,
Aug 17, 2017, 4:05:12 AM8/17/17
to Brian
Hi Dan,
I wrote like this:
def save_connections(ending = ''):
    print 'save connections'
    for connName in save_conns:
        conn = connections[connName]
        connListSparse = b2.Save(conn.i, conn.j, conn.w)
        np.save(data_path + 'weights/' + connName + ending, connListSparse)

but it  says'module' object has no attribute 'Save'
I replace 'connListSparse = b2.Save(conn.i, conn.j, conn.w)'
by  'connListSparse = Save(conn.i, conn.j, conn.w)'
but it says NameError: global name 'Save' is not defined
Would it possible to show me how to use Save concretely.

Best regards,
Qianhui

在 2017年8月16日星期三 UTC+8下午5:30:20,Dan Goodman写道:
>      >      >     > <mailto:briansupport+unsub...@googlegroups.com
>      >      > <mailto:briansupport+unsub...@googlegroups.com
>      > <mailto:briansupport+unsub...@googlegroups.com <javascript:>>.
>      > To post to this group, send email to brians...@googlegroups.com
>     <javascript:>
>      > <mailto:brians...@googlegroups.com <javascript:>>.
>      > Visit this group at https://groups.google.com/group/briansupport
>     <https://groups.google.com/group/briansupport>.
>      > For more options, visit https://groups.google.com/d/optout
>     <https://groups.google.com/d/optout>.
>
> --
> http://www.facebook.com/briansimulator
> https://twitter.com/briansimulator
>
> New paper about Brian 2: Stimberg M, Goodman DFM, Benichoux V, Brette R
> (2014).Equation-oriented specification of neural models for simulations.
> Frontiers Neuroinf, doi: 10.3389/fninf.2014.00006.
> ---
> You received this message because you are subscribed to the Google
> Groups "Brian" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to briansupport...@googlegroups.com

Dan Goodman

unread,
Aug 17, 2017, 6:30:23 AM8/17/17
to brians...@googlegroups.com
Hi,

I'm afraid we can't answer general questions on Python, only on Brian,
and you need to put some effort in to try to work out the solution on
your own first using the documentation.

Numpy has a save function with a different name (check their
documentation), but Brian does not. It does have a store/restore
mechanism that you might be able to use, see
brian2.readthedocs.io/en/stable/user/running.html. You might also want
to look up Python's pickle module.

Dan

On 17/08/2017 09:05, Qianhui Liu wrote:
> Hi Dan,
> <mailto:briansupport...@googlegroups.com <javascript:>
> > > > <mailto:briansupport...@googlegroups.com
> > > <mailto:briansupport...@googlegroups.com
> > <mailto:briansupport...@googlegroups.com <javascript:>>.
> > To post to this group, send email to brians...@googlegroups.com
> <javascript:>
> > <mailto:brians...@googlegroups.com <javascript:>>.
> > Visit this group at https://groups.google.com/group/briansupport
> <https://groups.google.com/group/briansupport>.
> > For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
> --
> http://www.facebook.com/briansimulator
> https://twitter.com/briansimulator
>
> New paper about Brian 2: Stimberg M, Goodman DFM, Benichoux V, Brette R
> (2014).Equation-oriented specification of neural models for simulations.
> Frontiers Neuroinf, doi: 10.3389/fninf.2014.00006.
> ---
> You received this message because you are subscribed to the Google
> Groups "Brian" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to briansupport...@googlegroups.com
> <mailto:briansupport...@googlegroups.com>.
Reply all
Reply to author
Forward
0 new messages