odynn.circuit module

class odynn.circuit.Circuit(neurons, synapses={}, gaps={}, tensors=False, labels=None, sensors=set(), commands=set())[source]

Bases: object

Attributes:
init_state

(ndarray) Initial states of neurons

neurons

Neurons contained in the circuit

num

Number of circuits contained in the object, used to train in parallel

Methods

calculate(i_inj) Simulate the circuit with a given input current.
plot([show, save]) Plot the circuit using networkx :param show: If True, show the figure :type show: bool :param save: If True, save the figure :type save: bool
plots_output_mult(ts, i_inj, states[, …]) plot multiple voltages and Ca2+ concentration
step(hprev, curs) run one time step
plot_output  
calculate(i_inj)[source]

Simulate the circuit with a given input current.

Parameters:i_inj (ndarray) – input current
Returns:state vector and synaptical currents
Return type:ndarray, ndarray
init_state

(ndarray) Initial states of neurons

neurons

Neurons contained in the circuit

num

Number of circuits contained in the object, used to train in parallel

parameter_names = ['mdp', 'E', 'G', 'scale', 'G_gap']

Circuit of neurons with synapses and gap junctions

plot(show=True, save=False)[source]

Plot the circuit using networkx :param show: If True, show the figure :type show: bool :param save: If True, save the figure :type save: bool

plot_output(*args, **kwargs)[source]
plots_output_mult(ts, i_inj, states, i_syn=None, suffix='', show=True, save=False, l=1, trace=True)[source]

plot multiple voltages and Ca2+ concentration

Parameters:
  • ts (ndarray) – time sequence
  • i_inj (ndarray) – input currents
  • states (ndarray) – series of neural states
  • i_syn (ndarray, optional) – synaptic currents (Default value = None)
  • suffix (str, optional) – Suffix for the file name (Default value = “”)
  • show (bool, optional) – If True, show the figure (Default value = True)
  • save (bool, optional) – If True, save the figure (Default value = False)
step(hprev, curs)[source]

run one time step

For tensor :

Parameters:
  • hprev (ndarray or tf.Tensor) – previous state vector
  • curs (ndarray or tf.Tensor) – input currents
Returns:

updated state vector

Return type:

ndarray or tf.Tensor

class odynn.circuit.CircuitTf(neurons, synapses={}, gaps={}, labels=None, sensors=set(), commands=set())[source]

Bases: odynn.circuit.Circuit, odynn.optim.Optimized

Circuit using tensorflow

Attributes:
init_params

(dict), initial model parameters

init_state

(ndarray) Initial states of neurons

neurons

Neurons contained in the circuit

num

Number of circuits contained in the object, used to train in parallel

variables

dict, current Tf variables

Methods

apply_constraints(session) Apply the constraints and call the apply_constraints function of the neurons
build_graph([batch]) Build the tensorflow graph.
calculate(i) Iterate over i (current) and return the state variables obtained after each step
plot([show, save]) Plot the circuit using networkx :param show: If True, show the figure :type show: bool :param save: If True, save the figure :type save: bool
plot_vars(var_dic[, suffix, show, save, func]) plot variation/comparison/boxplots of synaptic variables
plots_output_mult(ts, i_inj, states[, …]) plot multiple voltages and Ca2+ concentration
reset() prepare the variables as tensors, prepare the constraints, call reset for self._neurons
settings() Returns(str): string describing the object
step(hprev, curs) run one time step
apply_init  
create_random  
plot_output  
predump  
study_vars  
__init__(neurons, synapses={}, gaps={}, labels=None, sensors=set(), commands=set())[source]
Parameters:
  • labels
  • synapses (dict) – initial parameters for the synapses
  • neurons (NeuronModel) – if not None, all other parameters except conns are ignores
apply_constraints(session)[source]

Apply the constraints and call the apply_constraints function of the neurons

Parameters:session – tensorflow session
apply_init(session)[source]
build_graph(batch=1)[source]

Build the tensorflow graph. Take care of the loop and the initial state.

calculate(i)[source]

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

Parameters:i (ndarray) – input current, [time, batch, neuron, model]
Returns:state vectors concatenated [i.shape[0], len(self.init_state)(, i.shape[1]), self.num]
Return type:ndarray
classmethod create_random(n_neuron, syn_keys={}, gap_keys={}, n_rand=10, dt=0.1, labels=None, sensors=set(), commands=set(), fixed=(), groups=None, neurons=None)[source]
init_params

(dict), initial model parameters

plot_vars(var_dic, suffix='', show=True, save=False, func=<function plot>)[source]

plot variation/comparison/boxplots of synaptic variables

Parameters:
  • var_dic (dict) – synaptic parameters, each value of size [time, n_synapse, parallelization]
  • suffix – (Default value = “”)
  • show (bool) – If True, show the figure (Default value = True)
  • save (bool) – If True, save the figure (Default value = False)
  • func – (Default value = plot)
reset()[source]

prepare the variables as tensors, prepare the constraints, call reset for self._neurons

settings()[source]

Returns(str): string describing the object

study_vars(p, loss=None, show=False, save=True)[source]
variables

dict, current Tf variables

odynn.circuit.const_E(exc=True)[source]
odynn.circuit.get_gap_rand()[source]

Give random parameters dictionnary for a gap junction

Returns:random parameters for a gap junction
Return type:dict
odynn.circuit.get_syn_rand(exc=True)[source]

Give random parameters dictionnary for a chemical synapse

Parameters:exc (bool) – If True, give an excitatory synapse (Default value = True)
Returns:random parameters for a chemical synapse
Return type:dict
odynn.circuit.give_constraints(conns)[source]

Give constraints for synaptic parameters

Parameters:conns (dict) – dictionnary of chemical synapse parameters
Returns:constraints
Return type:dict
odynn.circuit.give_constraints_gap()[source]

Give constraints for gap junction parameters

Returns:constraints
Return type:dict
odynn.circuit.give_constraints_syn(conns)[source]

Give constraints for chemical synapse parameters

Parameters:conns (dict) – dictionnary of synapse parameters
Returns:constraints
Return type:dict