The morphology module

dense.morphology.NeuronStructure([gid, ...])

Return the structure of the neurons.

dense.morphology.SpatialMultiNetwork(*args, ...)

Backup class to store network information

dense.morphology.SpatialNetwork(*args, **kwargs)

Class containing the information about the connections between neurons in a simplified manner (keeping only one equivalent synapse to represent all the connections between two neurons).

dense.morphology.generate_network([...])

Create the graph based on the neuron shapes, the spine density, and a connection probability.

dense.morphology.get_connections([...])

Obtain connection between source_neurons and target_neurons through

dense.morphology.tree_asymmetry(neurite[, ...])

Return the tree-assymetry of a neurite.

Tools relaetd to neuronal structure

dense.morphology.NeuronStructure(gid=None, downsample=False)[source]

Return the structure of the neurons.

Parameters
  • gid (int or list, optional (default: all neurons)) – Neuron(s) whose structure will be returned.

  • downsample (int, optional (default: all points are returned)) – Downsample the structure by returning only a fraction of the points.

class dense.morphology.SpatialMultiNetwork(*args, **kwargs)[source]

Backup class to store network information

edge_id(edge, return_set=False)[source]

Id of an edge

edge_nb()[source]

Number of edges in the network

property edges_array

Edges of the graph, sorted by order of creation, as an array of shape (edge_nb, 2).

get_edge_attributes(edges=None, name=None)[source]

Attributes of the network’s edges.

Parameters
  • edge (tuple or list of tuples, optional (default: None)) – Edge whose attribute should be displayed.

  • name (str, optional (default: None)) – Name of the desired attribute.

Returns

  • Dict containing all graph’s attributes (synaptic weights, delays…)

  • by default. If edge is specified, returns only the values for these

  • edges. If name is specified, returns value of the attribute for each

  • edge.

Note

The attributes values are ordered as the edges in edges_array() if edges is None.

has_edge(edge)[source]

Return True if the edge is in the graph, else False

is_multigraph()[source]

Whether duplicate edges are supported

is_weighted()[source]

Whether the graph has weights or not

new_edge(source, target, attributes=None, **kwargs)[source]

Adding a connection to the network.

Parameters
  • source (int/node) – Source node.

  • target (int/node) – Target node.

  • attributes (dict, optional (default: {})) – Dictionary containing optional edge properties. If the graph is weighted, defaults to {"weight": 1.}, the unit weight for the connection.

Returns

Return type

The new connection.

new_edges(edge_list, attributes=None, **kwargs)[source]

Add a list of edges to the graph.

Parameters
  • edge_list (list of 2-tuples or np.array of shape (edge_nb, 2)) – List of the edges that should be added as tuples (source, target)

  • attributes (dict, optional (default: {})) – Dictionary containing optional edge properties. If the graph is weighted, defaults to {"weight": ones}, where ones is an array the same length as the edge_list containing a unit weight for each connection.

Returns

Return type

Returns new edges only.

node_nb()[source]

Number of nodes in the network

property population

The neuronal population

set_edge_attribute(attribute, values=None, val=None, value_type=None, edges=None)[source]

Set attributes to the connections between neurons.

Parameters
  • attribute (str) – The name of the attribute.

  • value_type (str, optional (default: None)) – Type of the attribute, among ‘int’, ‘double’, ‘string’

  • values (array, optional (default: None)) – Values with which the edge attribute should be initialized. (must have one entry per node in the graph)

  • val (int, float or str , optional (default: None)) – Identical value for all edges.

  • value_type – Type of the attribute, among ‘int’, ‘double’, ‘string’. Only used if the attribute does not exist and must be created.

  • edges (list of edges or array of shape (E, 2), optional (default: all)) – Edges whose attributes should be set. Others will remain unchanged.

class dense.morphology.SpatialNetwork(*args, **kwargs)[source]

Class containing the information about the connections between neurons in a simplified manner (keeping only one equivalent synapse to represent all the connections between two neurons).

new_edge(source, target, attributes=None, **kwargs)[source]

Adding a connection to the graph, with optional properties.

Parameters
  • source (int/node) – Source node.

  • target (int/node) – Target node.

  • attributes (dict, optional (default: {})) – Dictionary containing optional edge properties. If the graph is weighted, defaults to {"weight": 1.}, the unit weight for the connection (synaptic strength in NEST).

Returns

Return type

The new connection.

new_edges(edge_list, attributes=None, unit_strength=1.0, **kwargs)[source]

Add a list of edges to the network.

Parameters
  • edge_list (list of 2-tuples or np.array of shape (edge_nb, 2)) – List of the edges that should be added as tuples (source, target)

  • attributes (dict, optional (default: {})) – Dictionary containing optional edge properties. If the graph is weighted, defaults to {"weight": ones}, where ones is an array the same length as the edge_list containing a unit weight for each connection (synaptic strength in NEST).

  • unit_strength (double, optional (default: 1.)) – Default weight associated to one synapse; neurons having multiple synapses connecting them will get an equivalent connection of strength unit_strength*num_synapses.

Returns

Return type

Returns new edges only.

property population

The neuronal population

dense.morphology.generate_network(source_neurons=None, target_neurons=None, method='intersections', spine_density=<Quantity(0.5, '1 / micrometer ** 2')>, connection_probability=0.2, default_synaptic_strength=1.0, only_new_connections=False, autapse_allowed=False, multigraph=False, **kwargs)[source]

Create the graph based on the neuron shapes, the spine density, and a connection probability.

The number of connection made will depend on the number of contacts between an axon and a dendrite. At each contact site, the number of potential synapses is computed as:

\[n_{s, p} = \rho_s \cdot A_I\]

with \(\rho_s\) the spine_density and \(A_I\) the intersection area.

And the number of actual synapses is then:

\[N_s = n_{s,p} \cdot p_c\]

with \(p_c\) the connection probability.

Parameters
  • source_neurons (list of neurons, optional (default: all neurons)) – Neurons which will possess the pre-synaptic compartments of the connections (i.e. be connected through their axons).

  • target_neurons (list of neurons, optional (default: all neurons)) – Neurons which will possess the post-synaptic compartments of the connections (i.e. be connected through their dendrites or soma)

  • method (str, optional (default: "intersection")) – Method which use to generate synapses. Either “intersections” (synapses can be generated only when neurites overlap) or “spines” (neurites can be connected if they are closer than a certain distance max_spine_length).

  • spine_density (float (quantity), optional (default: \(0.5 \\mu m^{-2}\))) – Number of spines per unit area, determines how many synapses are possible given an area of interaction.

  • connection_probability (float, optional (default: 0.2)) – Probability of making a synapse for each spine/axon interaction which has been found geometrically.

  • default_synaptic_strength (float, optional (default: 1.)) – Number caracterizing the default strength of a synapse. If multigraph is False, equivalent connections will always have a strength which is a multiple of this value.

  • only_new_connections (bool, optional (default: False)) – If true, only the potential synapses that have been found during the last simulation run will be used; otherwise, all potential sites found since time 0 will be used.

  • autapse_allowed (bool, optional (default: False)) – Whether connection from a neuron onto itself are generated if possible.

  • multigraph (bool, optional (default: False)) – Whether the graph returned is simple (only one connection between each pair of neurons) or a multigraph (multiple connections can exist between every two neurons). If false, multiple connections which may exist between two neurons are merged into one equivalent connection with an increased synaptic strength and the average properties of the real connections (e.g. from three synapses of strength 1. and soma-to-soma distances \(120 \\mu m\), \(140 \\mu m\), and \(160 \\mu m\), one will get a single connection of strength 3. and of average length \(140 \\mu m\)).

  • **kwargs (optional arguments) – When using the “spines” method, an additional argument max_spine_length must be passed, specifying the maximum length at which neighboring neurites can still be connected through a spine (must be a dimensioned quantity, a length). If get_connections() has been called before, the network can be directly created from the returned data by passsing data=data in the call to generate_network.

See also

get_connections(), Details, page

dense.morphology.get_connections(source_neurons=None, target_neurons=None, method='intersections', spine_density=<Quantity(0.5, '1 / micrometer ** 2')>, connection_probability=0.2, autapse_allowed=False, **kwargs)[source]

Obtain connection between source_neurons and target_neurons through a given method for synapse generation.

The number of connection made will depend on the number of contacts between an axon and a dendrite. At each contact site, the number of potential synapses is computed as:

\[n_{s, p} =\]

ho_s cdot A_I

with :math:`

ho_s` the spine_density and \(A_I\) the intersection

area.

And the number of actual synapses is then:

\[N_s = n_{s,p} \cdot p_c\]

with \(p_c\) the connection probability.

source_neuronslist of neurons, optional (default: all neurons)

Neurons which will possess the pre-synaptic compartments of the connections (i.e. be connected through their axons)

target_neuronslist of neurons, optional (default: all neurons)

Neurons which will possess the post-synaptic compartments of the connections (i.e. be connected through their dendrites or soma)

methodstr, optional (default: “intersections”)

Method which use to generate synapses. Either “intersections” (synapses can be generated only when neurites overlap) or “spines” (neurites can be connected if they are closer than a certain distance max_spine_length).

spine_densityfloat (quantity), optional (default: \(0.5 \mu m^{-2}\))

Number of spines per unit area, determines how many synapses are made given an area of interaction.

connection_probabilityfloat, optional (default: 0.2)

Probability of making a synapse for each spine/axon interaction which has been found geometrically.

only_new_connectionsbool, optional (default: False)

If true, only the potential synapses that have been found during the last simulation run will be used; otherwise, all potential sites found since time 0 will be used.

autapse_allowedbool, optional (default: False)

Whether connection from a neuron onto itself are generated if possible.

**kwargsoptional arguments

When using the “spines” method, an additional argument max_spine_length must be passed, specifying the maximum length at which neighboring neurites can still be connected through a spine (must be a dimensioned quantity, a length).

edgeslist of edges of shape (e, 2)

The edges created.

positionslist of points of shape (e, 2)

The position of each synapse created.

distanceslist of float of length e

Approximation of the cable distance between the neurons, given by the sum of the distances between the somas and the synapse.

dense.morphology.tree_asymmetry(neurite, neuron=None)[source]

Return the tree-assymetry of a neurite.

Parameters
  • neurite (Neurite object or str) – Neurite to analyze.

  • neuron (int, optional (default: None)) – GID of the neuron if the neurite was passed as a str and not as an object.