brainpy.analysis package

BaseNeuronAnalyzer(model, target_vars[, …])

Dynamics Analyzer for Neuron Models.

Base1DNeuronAnalyzer(*args, **kwargs)

Neuron analysis analyzer for 1D system.

Base2DNeuronAnalyzer(*args, **kwargs)

Neuron analysis analyzer for 2D system.

PhasePlane(model, target_vars[, fixed_vars, …])

A tool class for phase plane analyzer.

_PhasePlane1D(*args, **kwargs)

Phase plane analyzer for 1D system.

_PhasePlane2D(*args, **kwargs)

Phase plane analyzer for 2D system.

Bifurcation(model, target_pars, target_vars)

A tool class for bifurcation analysis.

_Bifurcation1D(model, target_pars, target_vars)

Bifurcation analysis of 1D system.

_Bifurcation2D(model, target_pars, target_vars)

Bifurcation analysis of 2D system.

FastSlowBifurcation(model, fast_vars, slow_vars)

Fast slow analysis analysis proposed by John Rinzel 1 2 3.

_FastSlow1D(model, fast_vars, slow_vars[, …])

_FastSlow2D(model, fast_vars, slow_vars[, …])

class brainpy.analysis.BaseNeuronAnalyzer(model, target_vars, fixed_vars=None, target_pars=None, pars_update=None, numerical_resolution=0.1, options=None)[source]

Dynamics Analyzer for Neuron Models.

This class is a base class which aims for analyze the analysis in neuron models. A neuron model is characterized by a series of dynamical variables and parameters:

\[{dF \over dt} = F(v_1, v_2, ..., p_1, p_2, ...)\]

where \(v_1, v_2\) are variables, \(p_1, p_2\) are parameters.

Parameters
  • model (core.NeuType) – The neuronal type model.

  • target_vars (dict) – The target/dynamical variables.

  • fixed_vars (dict) – The fixed variables.

  • target_pars (dict, optional) – The parameters which can be dynamical varied.

  • pars_update (dict, optional) – The parameters to update.

  • numerical_resolution (float, dict) – The resolution for numerical iterative solvers. Default is 0.1. It can set the numerical resolution of dynamical variables or dynamical parameters. For example, set numerical_resolution=0.1 will generalize it to all variables and parameters; set numerical_resolution={var1: 0.1, var2: 0.2, par1: 0.1, par2: 0.05} will specify the particular resolutions to variables and parameters. Moreover, you can also set numerical_resolution={var1: np.array([...]), var2: 0.1} to specify the search points need to explore for variable var1. This will be useful to set sense search points at some inflection points.

  • options (dict, optional) –

    The other setting parameters, which includes:

    perturbation

    float. The small perturbation used to solve the function derivative.

    sympy_solver_timeout

    float, with the unit of second. The maximum time allowed to use sympy solver to get the variable relationship.

    escape_sympy_solver

    bool. Whether escape to use sympy solver, and directly use numerical optimization method to solve the nullcline and fixed points.

    lim_scale

    float. The axis limit scale factor. Default is 1.05. The setting means the axes will be clipped to [var_min * (1-lim_scale)/2, var_max * (var_max-1)/2].

class brainpy.analysis.Base1DNeuronAnalyzer(*args, **kwargs)[source]

Neuron analysis analyzer for 1D system.

It supports the analysis of 1D dynamical system.

\[{dx \over dt} = f(x, t)\]
get_f_dfdx(origin=True)[source]

Get the derivative of f by variable x.

get_f_dx()[source]

Get the derivative function of the first variable.

class brainpy.analysis.Base2DNeuronAnalyzer(*args, **kwargs)[source]

Neuron analysis analyzer for 2D system.

It supports the analysis of 2D dynamical system.

\[ \begin{align}\begin{aligned}{dx \over dt} = f(x, t, y)\\{dy \over dt} = g(y, t, x)\end{aligned}\end{align} \]
Parameters

options (dict, optional) –

The other setting parameters, which includes:

shgo_args

dict. Arguments of shgo optimization method, which can be used to set the fields of: constraints, n, iters, callback, minimizer_kwargs, options, sampling_method.

show_shgo

bool. whether print the shgo’s value.

fl_tol

float. The tolerance of the function value to recognize it as a condidate of function root point.

xl_tol

float. The tolerance of the l2 norm distances between this point and previous points. If the norm distances are all bigger than xl_tol means this point belong to a new function root point.

get_f_dfdy(origin=True)[source]

Get the derivative of f by variable y.

get_f_dgdx(origin=True)[source]

Get the derivative of g by variable x.

get_f_dgdy(origin=True)[source]

Get the derivative of g by variable y.

get_f_dy()[source]

Get the derivative function of the second variable.

get_f_fixed_point()[source]

Get the function to solve the fixed point.

get_f_jacobian()[source]

Get the function to solve jacobian matrix.

get_x_by_y_in_x_eq()[source]

Get the expression of “x_by_y_in_x_eq”.

Specifically, self.analyzed_results['x_by_y_in_x_eq'] is a Dict, with the following keywords:

  • status : ‘sympy_success’, ‘sympy_failed’, ‘escape’

  • subs : substituted expressions (relationship) of x_by_y

  • f : function of x_by_y

get_x_by_y_in_y_eq()[source]

Get the expression of “x_by_y_in_y_eq”.

Specifically, self.analyzed_results['x_by_y_in_y_eq'] is a Dict, with the following keywords:

  • status : ‘sympy_success’, ‘sympy_failed’, ‘escape’

  • subs : substituted expressions (relationship) of x_by_y

  • f : function of x_by_y

get_y_by_x_in_x_eq()[source]

Get the expression of “y_by_x_in_x_eq”.

Specifically, self.analyzed_results['y_by_x_in_x_eq'] is a Dict, with the following keywords:

  • status : ‘sympy_success’, ‘sympy_failed’, ‘escape’

  • subs : substituted expressions (relationship) of y_by_x

  • f : function of y_by_x

get_y_by_x_in_y_eq()[source]

Get the expression of “y_by_x_in_y_eq”.

Specifically, self.analyzed_results['y_by_x_in_y_eq'] is a Dict, with the following keywords:

  • status : ‘sympy_success’, ‘sympy_failed’, ‘escape’

  • subs : substituted expressions (relationship) of y_by_x

  • f : function of y_by_x

class brainpy.analysis.PhasePlane(model, target_vars, fixed_vars=None, pars_update=None, numerical_resolution=0.1, options=None)[source]

A tool class for phase plane analyzer.

PhasePlaneAnalyzer is used to analyze the phase portrait of 1D or 2D dynamical systems. It can also be used to analyze the phase portrait of high-dimensional system but with the fixation of other variables to preserve only one/two dynamical variables.

Parameters
  • model (NeuType) – The neuron model which defines the differential equations by using brainpy.integrate.

  • target_vars (dict) – The target variables to analyze, with the format of {‘var1’: [var_min, var_max], ‘var2’: [var_min, var_max]}.

  • fixed_vars (dict, optional) – The fixed variables, which means the variables will not be updated.

  • pars_update (dict, optional) – The parameters in the differential equations to update.

  • numerical_resolution (float, dict) – The variable resolution for numerical iterative solvers. This variable will be useful in the solving of nullcline and fixed points by using the iterative optimization method. It can be a float, which will be used as numpy.arange(var_min, var_max, resolution). Or, it can be a dict, with the format of {'var1': resolution1, 'var2': resolution2}. Or, it can be a dict with the format of {'var1': np.arange(x, x, x), 'var2': np.arange(x, x, x)}.

  • options (dict, optional) –

    The other setting parameters, which includes:

    lim_scale

    float. The axis limit scale factor. Default is 1.05. The setting means the axes will be clipped to [var_min * (1-lim_scale)/2, var_max * (var_max-1)/2].

    sympy_solver_timeout

    float, with the unit of second. The maximum time allowed to use sympy solver to get the variable relationship.

    escape_sympy_solver

    bool. Whether escape to use sympy solver, and directly use numerical optimization method to solve the nullcline and fixed points.

    shgo_args

    dict. Arguments of shgo optimization method, which can be used to set the fields of: constraints, n, iters, callback, minimizer_kwargs, options, sampling_method.

    show_shgo

    bool. whether print the shgo’s value.

    perturbation

    float. The small perturbation used to solve the function derivative.

    fl_tol

    float. The tolerance of the function value to recognize it as a condidate of function root point.

    xl_tol

    float. The tolerance of the l2 norm distances between this point and previous points. If the norm distances are all bigger than xl_tol means this point belong to a new function root point.

plot_fixed_point(*args, **kwargs)[source]

Plot fixed points.

plot_nullcline(*args, **kwargs)[source]

Plot nullcline (only supported in 2D system).

plot_trajectory(*args, **kwargs)[source]

Plot trajectories (only supported in 2D system).

plot_vector_field(*args, **kwargs)[source]

Plot vector filed of a 2D/1D system.

class brainpy.analysis.Bifurcation(model, target_pars, target_vars, fixed_vars=None, pars_update=None, numerical_resolution=0.1, options=None)[source]

A tool class for bifurcation analysis.

The bifurcation analyzer is restricted to analyze the bifurcation relation between membrane potential and a given model parameter (co-dimension-1 case) or two model parameters (co-dimension-2 case).

Externally injected current is also treated as a model parameter in this class, instead of a model state.

Parameters

model (NeuType) – An abstract neuronal type defined in BrainPy.

class brainpy.analysis._Bifurcation1D(model, target_pars, target_vars, fixed_vars=None, pars_update=None, numerical_resolution=0.1, options=None)[source]

Bifurcation analysis of 1D system.

Using this class, we can make co-dimension1 or co-dimension2 bifurcation analysis.

class brainpy.analysis._Bifurcation2D(model, target_pars, target_vars, fixed_vars=None, pars_update=None, numerical_resolution=0.1, options=None)[source]

Bifurcation analysis of 2D system.

Using this class, we can make co-dimension1 or co-dimension2 bifurcation analysis.

class brainpy.analysis.FastSlowBifurcation(model, fast_vars, slow_vars, fixed_vars=None, pars_update=None, numerical_resolution=0.1, options=None)[source]

Fast slow analysis analysis proposed by John Rinzel 1 2 3.

(J Rinzel, 1985, 1986, 1987) proposed that in a fast-slow dynamical system, we can treat the slow variables as the bifurcation parameters, and then study how the different value of slow variables affect the bifurcation of the fast sub-system.

References

1(1,2)

Rinzel, John. “Bursting oscillations in an excitable membrane model.” In Ordinary and partial differential equations, pp. 304-316. Springer, Berlin, Heidelberg, 1985.

2(1,2)

Rinzel, John , and Y. S. Lee . On Different Mechanisms for Membrane Potential Bursting. Nonlinear Oscillations in Biology and Chemistry. Springer Berlin Heidelberg, 1986.

3(1,2)

Rinzel, John. “A formal classification of bursting mechanisms in excitable systems.” In Mathematical topics in population biology, morphogenesis and neurosciences, pp. 267-281. Springer, Berlin, Heidelberg, 1987.

class brainpy.analysis._FastSlow1D(model, fast_vars, slow_vars, fixed_vars=None, pars_update=None, numerical_resolution=0.1, options=None)[source]
class brainpy.analysis._FastSlow2D(model, fast_vars, slow_vars, fixed_vars=None, pars_update=None, numerical_resolution=0.1, options=None)[source]