brian-team / brian2modelfitting

Model fitting toolbox for the Brian 2 simulator
https://brian2modelfitting.readthedocs.io
Other
14 stars 6 forks source link

[MRG] Fitter.generate for multiple variables #34

Closed mstimberg closed 4 years ago

mstimberg commented 4 years ago

If you were interested in the traces of several variables after fitting (say, membrane potential and some gating variables), you had two options:

  1. Run Fitter.generate repeatedly, i.e. run the simulation several times, each time recording a different variable.
  2. Create a NeuronGroup and run the simulation yourself.

With this PR, you can simply call Fitter.generate with a list of variables, and get back a dictionary with the results:

traces = fitter.generate(['v', 'h', 'n', 'm'])
plt.plot(traces['v'][0]/mV)
plt.plot(traces['h'][0])
...
romainbrette commented 4 years ago

It seems to work, except you need to pass the params argument (the line above would not run).

mstimberg commented 4 years ago

It seems to work, except you need to pass the params argument (the line above would not run).

You only have to pass the params if you did not run the fit before. Or maybe I misunderstood your comment?

romainbrette commented 4 years ago

Ah of course, I tested it without actually doing a fitting.