brian-team / brian2modelfitting

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

Multiple output var support #59

Closed akapet00 closed 3 years ago

akapet00 commented 3 years ago

Resolves #53.

This PR introduces slight changes in API: instead of providing list of functions that will be used to extract relevant features from the simulated traces, the dictionary should be provided instead. Keys should be names of output variables as defined in the model equations, while values should be lists (with the same number of elements) where each element of the list is callable that returns a summary feature. So instead of:

inferencer = Inferencer(dt=dt, model=eqs,
                        input={'I': inp_traces*amp},
                        output={'v': out_traces*mV},
                        features=[lambda x: x[(t > 5) & (t < 10)].mean(),
                                  lambda x: x[(t > 5) & (t < 10)].std(),
                                  lambda x: x.max()],
                        method='exponential_euler',
                        threshold='m > 0.5',
                        refractory='m > 0.5',
                        param_init={'v': 'VT'})

goes:

inferencer = Inferencer(dt=dt, model=eqs,
                        input={'I': inp_traces*amp},
                        output={'v': out_traces*mV},
                        features={'v': [lambda x: x[(t > 5) & (t < 10)].mean(),
                                        lambda x: x[(t > 5) & (t < 10)].std(),
                                        lambda x: x.max()]},
                        method='exponential_euler',
                        threshold='m > 0.5',
                        refractory='m > 0.5',
                        param_init={'v': 'VT'})

This enables the user to simultaneously infer unknown parameters from different output variables.

Additional updates:

akapet00 commented 3 years ago

Awesome, thanks.