NeuronModel#

class dendrify.neuronmodel.NeuronModel(connections, cm=None, gl=None, r_axial=None, v_rest=None, scale_factor=None, spine_factor=None)[source]#

Bases: object

Creates a multicompartmental neuron model by connecting individual compartments and merging their equations, parameters and custom events.This model can then be used for creating a population of neurons through Brian’s NeuronGroup. This class also contains useful methods for managing model properties and for automating the initialization of custom events and simulation parameters.

Tip

Dendrify aims to facilitate the development of reduced, few-compartmental I&F models that help us study how key dendritic properties may affect network-level functions. It is not designed to substitute morphologically and biophysically detailed neuron models, commonly used for highly-accurate, single-cell simulations. If you are interested in the latter category of models, please see Brian’s SpatialNeuron.

Parameters:
  • connections (list[tuple[Compartment, Compartment, str | Quantity]]) – A description of how the various compartments belonging to the same neuron model should be connected.

  • cm (Quantity, optional) – Specific capacitance (usually μF / cm^2).

  • gl (Quantity, optional) – Specific leakage conductance (usually μS / cm^2).

  • r_axial (Quantity, optional) – Axial resistance (usually Ohm * cm).

  • v_rest (Quantity, optional) – Resting membrane voltage.

  • scale_factor (float, optional) – A global area scale factor, by default 1.0.

  • spine_factor (float, optional) – A dendritic area scale factor to account for spines, by default 1.0.

Warning

Parameters set here affect all model compartments and can override any compartment-specific parameters.

Example

>>> # Valid format: [*(x, y, z)], where
>>> # x -> Soma or Dendrite object
>>> # y -> Soma or Dendrite object other than x
>>> # z -> 'half_cylinders' or 'cylinder_ + name' or brian2.nS unit
>>> #      (by default 'half_cylinders')
>>> soma = Soma(...)
>>> prox = Dendrite(...)
>>> dist = Dendrite(...)
>>> connections = [(soma, prox, 15*nS), (prox, dist, 10*nS)]
>>> model = NeuronModel(connections)

Methods:

add_equations

Allows adding custom equations.

add_params

Allows specifying extra/custom parameters.

as_graph

Plots a graph-like representation of a NeuronModel using the Graph class and the Fruchterman-Reingold force-directed algorithm from Networkx.

config_dspikes

Configure the parameters for dendritic spiking.

make_neurongroup

Returns a Brian2 NeuronGroup object from a NeuronModel.

Attributes:

equations

Returns a string containing all model equations.

event_actions

Returns a dictionary containing all event actions for dendritic spiking.

event_names

Returns a list of all event names for dendritic spiking.

events

Returns a dictionary containing all model custom events for dendritic spiking.

parameters

Returns a dictionary containing all model parameters.

add_equations(eqs)[source]#

Allows adding custom equations.

Parameters:

eqs (str) – A string of Brian-compatible equations.

add_params(params_dict)[source]#

Allows specifying extra/custom parameters.

Parameters:

params_dict (dict) – A dictionary of parameters.

as_graph(figsize=[6, 4], fontsize=10, fontcolor='white', scale_nodes=1, color_soma='#4C6C92', color_dendrites='#A7361C', alpha=1, scale_edges=1, seed=None)[source]#

Plots a graph-like representation of a NeuronModel using the Graph class and the Fruchterman-Reingold force-directed algorithm from Networkx.

Parameters:
  • fontsize (int, optional) – The size in pt of each node’s name, by default 10.

  • fontcolor (str, optional) – The color of each node’s name, by default 'white'.

  • scale_nodes (float, optional) – Percentage change in node size, by default 1.

  • color_soma (str, optional) – Somatic node color, by default '#4C6C92'.

  • color_dendrites (str, optional) – Dendritic nodes color, by default '#A7361C'.

  • alpha (float, optional) – Nodes color opacity, by default 1.

  • scale_edges (float, optional) – The percentage change in edges length, by default 1.

  • seed (int, optional) – Set the random state for deterministic node layouts, by default None. .

config_dspikes(event_name, threshold=None, duration_rise=None, duration_fall=None, reversal_rise=None, reversal_fall=None, offset_fall=None, refractory=None)[source]#

Configure the parameters for dendritic spiking.

Parameters:
  • event_name (str) – A unique name referring to a specific dSpike type.

  • threshold (Quantity, optional) – The membrane voltage threshold for dendritic spiking.

  • duration_rise (Quantity, optional) – The duration of g_rise staying open.

  • duration_fall (Quantity, optional) – The duration of g_fall staying open.

  • reversal_rise ((Quantity, str), optional) – The reversal potential of the channel that is activated during the rise (depolarization) phase.

  • reversal_fall ((Quantity, str), optional) – The reversal potential of the channel that is activated during the fall (repolarization) phase.

  • offset_fall (Quantity, optional) – The delay for the activation of g_rise.

  • refractory (Quantity, optional) – The time interval required before dSpike can be activated again.

property equations#

Returns a string containing all model equations.

Returns:

All model equations.

Return type:

str

property event_actions#

Returns a dictionary containing all event actions for dendritic spiking.

Returns:

All event actions for dendritic spiking

Return type:

list

property event_names#

Returns a list of all event names for dendritic spiking.

Returns:

All event names for dendritic spiking

Return type:

list

property events#

Returns a dictionary containing all model custom events for dendritic spiking.

Returns:

All model custom events for dendritic spiking.

Return type:

dict

make_neurongroup(N, method='euler', threshold=None, reset=None, second_reset=None, spike_width=None, refractory=False, init_rest=True, init_events=True, show=False, **kwargs)[source]#

Returns a Brian2 NeuronGroup object from a NeuronModel. If a second reset is provided, it also returns a Synapses object to implement somatic action potentials with a more realistic shape which also unlocks dendritic backpropagation. This method can also take all parameters that are accepted by Brian’s NeuronGroup.

Parameters:
  • N (int) – The number of neurons in the group.

  • method (str, optional) – The numerical integration method. Either a string with the name of a registered method (e.g. “euler”) or a function that receives an Equations object and returns the corresponding abstract code, by default 'euler'.

  • threshold (str, optional) – The condition which produces spikes. Should be a single line boolean expression.

  • reset (str, optional) – The (possibly multi-line) string with the code to execute on reset.

  • refractory ((Quantity, str), optional) – Either the length of the refractory period (e.g. 2*ms), a string expression that evaluates to the length of the refractory period after each spike (e.g. '(1 + rand())*ms'), or a string expression evaluating to a boolean value, given the condition under which the neuron stays refractory after a spike (e.g. 'v > -20*mV').

  • second_reset (str, optional) – Option to include a second reset for more realistic somatic spikes.

  • spike_width (Quantity, optional) – The time interval between the two resets.

  • init_rest (bool, optional) – Option to automatically initialize the voltages of all compartments at the specified resting potentials, by default True.

  • init_events (bool, optional) – Option to automatically initialize all custom events that required for dendritic spiking, by default True.

  • show (bool, optional) – Option to print the automatically initialized parameters, by default False.

  • **kwargs (optional) – All other parameters accepted by Brian’s NeuronGroup.

Returns:

If no second reset is added, it returns a NeuronGroup object. Otherwise, it returns a tuple of (NeuronGroup, Synapses) objects.

Return type:

Union[NeuronGroup, Tuple]

property parameters#

Returns a dictionary containing all model parameters.

Returns:

All model parameters.

Return type:

dict