0

I have 2 questions. (1) I have a requirement to solve a differential equation where:

    from time = [t0, t1, ...., tn]
    for excitatory neurons = [u1, u2, ...., um]
    for inhibitory neurons = [v1, v2, ...., vm]

where,

with the initial value for all u's and v's = numpy.zeros([m, 2]) for the first time step, I need to solve the differential equation du/dt = f(u, v) and dv/dt = g(u, v) for all u's and v's; take this response as the initial value for the next time step, solve the differential equations for all u's and v's; .... until the last time step, to which the initial values will be the neuronal response (or result from the differential equation) for time step tn-1.

I am not sure how to do this with odeint in python. Please clarify.

(2) I think (1) is possible in a much easier way using Brian but I am really not able to understand Brian from its documentation alone. Are there any tutorials available for Brian? Please advice.

I was asked for what I tried before posting my question here. For my requirement, I tried adding a for loop for each time step and another for loop for each neuron:

    state = np.zeros([25, 2]) # one for excitatory and one for inhibitory 
                              # neurons
    for i in range(len(timeStep)):
        for j in range(len(state)):
            state[j] = odeint(derivativeFunc, state[j], timeStep[i])

This doesn't even go into my solver function! I then understood that the time step needs to be an array of at least 2 elements in it! Now if I give like, [timeStep[i], 0] for the time step, which I feel is really stupid and weird, I don't know which value to consider from the solver response since I get a [[0.0, 0.0], [x, y]] where x and y are floating-point response values. If I consider the first value [0.0, 0.0], then the response is always 0.0! and if I consider the second value [x, y], then I do get some response but I am not sure if I should be considering this since my actual time-step is the 1st value in the time step array and not the second value!

I am totally confused and really need help. I am sure I am not the first person facing this problem and hence, if anybody out there has found a way to solve this problem in python (as it is already there in Matlab), please help me (since I really don't want to rewrite my whole implementation in Matlab in the last minute now, unless that's the only choice I have!).

Really, thanks a lot, in advance.

Esash

Esash
  • 155
  • 2
  • 13
  • 1
    Ironically, I have two comments, (1) don't ask more than one question and (2) asking for tutorials is considered [off-topic](https://stackoverflow.com/help/on-topic). – Reti43 Oct 14 '17 at 19:46
  • Also, solving for one time step and passing that as the initial value for the next one is pretty much what the integration method does for you. You haven't explained what confused you, nor shown explicit code of your attempts/equations, so we have nothing concrete to help you with. – Reti43 Oct 14 '17 at 19:52
  • (1) I asked for Brian tutorials since it is really difficult for me to learn it from the documentation alone and didn't know where else to ask. (2) I agree the odeint function does solve for each time step and passes the initial value to the next one. But, it does this for one input alone. When I have an array of inputs which needs to be differentiated at once for each time step before moving on to the next time step, this is not done by odeint. The exact behaviour is done by Matlab's ode45 which I am not sure how to implement in python. – Esash Oct 15 '17 at 10:44
  • As Reti43 has asked, I have updated my question with what I tried. Please help. – Esash Oct 15 '17 at 10:55
  • You do have expressions for `f` and `g`, don't you? And are they same same for each neuron? Regardless, if you have expressions for `f`, `g` and the initial values for `u` and `v`, which you seem to do, that's all you need to solve the problem. Is there something that you don't understand from here https://stackoverflow.com/questions/27820725/how-to-solve-diff-eq-using-scipy-integrate-odeint? – Reti43 Oct 15 '17 at 11:29
  • I know the solver can solve for each neuron for all time steps.But what I want is, for the solver to solve for all neurons for every time step "at once" before proceeding to the next time step.I need the result of all neurons for "each" time step to get the correct solution in the next time step. This way all neurons are at the same time step at any time. This is not possible with the current odeint function.With the current odeint function, only one neuron can be fully solved for all time steps at once, keeping the rest of the neurons stale. I need an alternate way to solve the ode in python. – Esash Oct 15 '17 at 22:02
  • Then shows us your code, because I'm fairly certain odeint can solve for as many functions as you input, e.g., 10 initial conditions, 10 rates of changes, 10 outputs. Simple as. Just show us what you've done so we can understand your confusion. – Reti43 Oct 15 '17 at 22:21
  • Great! you are right. I for putting the for loop for all neuron calculations before calling the solver. I tried putting it inside the solver and now, I have the [#ofTimeSteps x #ofNeurons] array as the output! Thanks a lot :). I understood my mistake. :) – Esash Oct 15 '17 at 23:04

0 Answers0