odynn.models.model module

class odynn.models.model.BioNeuron(init_p=None, tensors=False, dt=0.1)[source]

Bases: odynn.models.model.Neuron

Abstract class to implement for using a new biological model All methods and class variables have to be implemented in order to have the expected behavior

Attributes:
default_init_state
default_params
init_state

ndarray, Initial state vector

num

int, Number of neurons being modeled in this object

parameter_names

Methods

calculate(i_inj) Simulate the neuron with input current i_inj and return the state vectors
get_random() Return a dictionnary with the same keys as default_params and random values
parallelize(n) Add a dimension of size n in the initial parameters and initial state
plot_output(ts, i_inj, states[, y_states, …]) Plot voltage and ion concentrations, potentially compared to a target model
plot_results(*args, **kwargs) Function for plotting detailed results of some experiment
step(X, i) Integrate and update state variable (voltage and possibly others) after one time step
__init__(init_p=None, tensors=False, dt=0.1)[source]

Reshape the initial state and parameters for parallelization in case init_p is a list

Parameters:
  • init_p (dict or list of dict) – initial parameters of the neuron(s). If init_p is a list, then this object will model n = len(init_p) neurons
  • tensors (bool) – used in the step function in order to use tensorflow or numpy
  • dt (float) – time step
calculate(i_inj)[source]

Simulate the neuron with input current i_inj and return the state vectors

Parameters:i_inj – input currents of shape [time, batch]
Returns:series of state vectors of shape [time, state, batch]
Return type:ndarray
default_params = None

dict, Default set of parameters for the model, of the form {<param_name> – value}

static get_random()[source]

Return a dictionnary with the same keys as default_params and random values

parallelize(n)[source]

Add a dimension of size n in the initial parameters and initial state

Parameters:n (int) – size of the new dimension
parameter_names = None

names of parameters from the model

static plot_results(*args, **kwargs)[source]

Function for plotting detailed results of some experiment

class odynn.models.model.Neuron(dt=0.1)[source]

Bases: abc.ABC

Attributes:
default_init_state
init_state

ndarray, Initial state vector

num

int, Number of neurons being modeled in this object

Methods

calculate(i) Iterate over i (current) and return the state variables obtained after each step
plot_output(ts, i_inj, states[, y_states, …]) Plot voltage and ion concentrations, potentially compared to a target model
step(X, i) Integrate and update state variable (voltage and possibly others) after one time step
V_pos = 0

int, Default position of the voltage in state vectors

calculate(i)[source]

Iterate over i (current) and return the state variables obtained after each step

Parameters:i (ndarray) – input current, dimension [time, (batch, (self.num))]
Returns:state vectors concatenated [i.shape[0], len(self.init_state)(, i.shape[1], (i.shape[2]))]
Return type:ndarray
default_init_state = None

array, Initial values for the vector of state variables

init_state

ndarray, Initial state vector

ions = {}
num

int, Number of neurons being modeled in this object

classmethod plot_output(ts, i_inj, states, y_states=None, suffix='', show=True, save=False, l=1, lt=1, targstyle='-')[source]

Plot voltage and ion concentrations, potentially compared to a target model

Parameters:
  • ts (ndarray of dimension [time]) – time steps of the measurements
  • i_inj (ndarray of dimension [time]) – input current
  • states (ndarray of dimension [time, state_var, nb_neuron]) –
  • y_states (list of ndarray [time, nb_neuron], optional) – list of values for the target model, each element is an ndarray containing the recordings of one state variable (Default value = None)
  • suffix (str) – suffix for the name of the saved file (Default value = “”)
  • show (bool) – If True, show the figure (Default value = True)
  • save (bool) – If True, save the figure (Default value = False)
  • l (float) – width of the main lines (Default value = 1)
  • lt (float) – width of the target lines (Default value = 1)
  • targstyle (str) – style of the target lines (Default value = ‘-‘)
step(X, i)[source]

Integrate and update state variable (voltage and possibly others) after one time step

Parameters:
  • X (ndarray) – State variables
  • i (float) – Input current
Returns:

updated state vector

Return type:

ndarray