Compartment#

class dendrify.compartment.Compartment(name, model='passive', length=None, diameter=None, cm=None, gl=None, cm_abs=None, gl_abs=None, r_axial=None, v_rest=None, scale_factor=1.0, spine_factor=1.0)[source]#

Bases: object

A class that automatically generates and handles all differential equations and parameters needed to describe a single compartment and any currents (synaptic, dendritic, noise) passing through it.

Parameters:
  • name (str) – A unique name used to tag compartment-specific equations and parameters. It is also used to distinguish the various compartments belonging to the same NeuronModel.

  • model (str, optional) – A keyword for accessing Dendrify’s library models. Custom models can also be provided but they should be in the same formattable structure as the library models. Available options: 'passive' (default), 'adaptiveIF', 'leakyIF', 'adex'.

  • length (Quantity, optional) – A compartment’s length.

  • diameter (Quantity, optional) – A compartment’s diameter.

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

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

  • cm_abs (Quantity, optional) – Absolute capacitance (usually pF).

  • gl_abs (Quantity, optional) – Absolute leakage conductance (usually nS).

  • 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.

Examples

>>> # specifying equations only:
>>> compX = Compartment('nameX', 'leakyIF')
>>> # specifying equations and ephys properties:
>>> compY = Compartment('nameY', 'adaptiveIF', length=100*um, diameter=1*um,
>>>                     cm=1*uF/(cm**2), gl=50*uS/(cm**2))
>>> # specifying equations and absolute ephys properties:
>>> compY = Compartment('nameZ', 'adaptiveIF', cm_abs=100*pF, gl_abs=20*nS)

Attributes:

area

Returns a compartment's surface area (open cylinder) based on its length and diameter.

capacitance

Returns a compartment's absolute capacitance.

dimensionless

Checks if a compartment has been flagged as dimensionless.

equations

Returns all differential equations that describe a single compartment and the mechanisms that have been added to it.

g_leakage

A compartment's absolute leakage conductance.

parameters

Returns all the parameters that have been generated for a single compartment.

Methods:

connect

Connects two compartments (electrical coupling).

g_norm_factor

Calculates the normalization factor for synaptic conductance with t_rise and t_decay kinetics.

noise

Adds a stochastic noise current.

synapse

Adds synaptic currents equations and parameters.

property area#

Returns a compartment’s surface area (open cylinder) based on its length and diameter.

Return type:

Quantity

property capacitance#

Returns a compartment’s absolute capacitance.

Return type:

Quantity

connect(other, g='half_cylinders')[source]#

Connects two compartments (electrical coupling).

Parameters:
  • other (Compartment) – Another compartment.

  • g (str or Quantity, optional) – The coupling conductance. It can be set explicitly or calculated automatically (provided all necessary parameters exist). Available options: 'half_cylinders' (default), 'cylinder_<compartment name>'.

Warning

The automatic approaches require that both compartments to be connected have specified length, diameter and axial resistance.

Examples

>>> compX, compY = Compartment('x', **kwargs), Compartment('y', **kwargs)
>>> # explicit approach:
>>> compX.connect(compY, g=10*nS)
>>> # half cylinders (default):
>>> compX.connect(compY)
>>> # cylinder of one compartment:
>>> compX.connect(compY, g='cylinder_x')
property dimensionless#

Checks if a compartment has been flagged as dimensionless.

Return type:

bool

property equations#

Returns all differential equations that describe a single compartment and the mechanisms that have been added to it.

Return type:

str

property g_leakage#

A compartment’s absolute leakage conductance.

Return type:

Quantity

static g_norm_factor(t_rise, t_decay)[source]#

Calculates the normalization factor for synaptic conductance with t_rise and t_decay kinetics.

Parameters: t_rise (Quantity): The rise time of the function. t_decay (Quantity): The decay time of the function.

Returns: float: The normalization factor for the g function.

noise(tau=20. * msecond, sigma=1. * pamp, mean=0. * amp)[source]#

Adds a stochastic noise current. For more information see the Noise section: of Models and neuron groups

Parameters:
  • tau (Quantity, optional) – Time constant of the Gaussian noise, by default 20*ms

  • sigma (Quantity, optional) – Standard deviation of the Gaussian noise, by default 3*pA

  • mean (Quantity, optional) – Mean of the Gaussian noise, by default 0*pA

property parameters#

Returns all the parameters that have been generated for a single compartment.

Return type:

dict

synapse(channel, tag, g=None, t_rise=None, t_decay=None, scale_g=False)[source]#

Adds synaptic currents equations and parameters. When only the decay time constant t_decay is provided, the synaptic model assumes an instantaneous rise of the synaptic conductance followed by an exponential decay. When both the rise t_rise and decay t_decay constants are provided, synapses are modelled as a sum of two exponentials. For more information see: Modeling Synapses by Arnd Roth & Mark C. W. van Rossum

Parameters:
  • channel (str) – Synaptic channel type. Available options: 'AMPA', 'NMDA', 'GABA'.

  • tag (str) – A unique name to distinguish synapses of the same type.

  • g (Quantity) – Maximum synaptic conductance

  • t_rise (Quantity) – Rise time constant

  • t_decay (Quantity) – Decay time constant

  • scale_g (bool, optional) – Option to add a normalization factor to scale the maximum conductance at 1 when synapses are modelled as a difference of exponentials (have both rise and decay kinetics), by default False.

Examples

>>> comp = Compartment('comp')
>>> # adding an AMPA synapse with instant rise & exponential decay:
>>> comp.synapse('AMPA', tag='X', g=1*nS, t_decay=5*ms)
>>> # same channel, different conductance & source:
>>> comp.synapse('AMPA', tag='Y', g=2*nS, t_decay=5*ms)
>>> # different channel with both rise & decay kinetics:
>>> comp.synapse('NMDA', tag='X' g=1*nS, t_rise=5*ms, t_decay=50*ms)