The elements module

dense.elements.Branch(neurite_path[, ...])

Container to facilitate post processing of SWC files branch path is a tuple with (xy, r, theta, diameter)

dense.elements.FormattedQuantity()

dense.elements.Neurite(branches, neurite_type)

Container to allow direct access to neurites.

dense.elements.Neuron(gid, **kwargs)

Container allowing direct access to a neuron.

dense.elements.Node(node_id[, tree, parent, ...])

Container to facilitate drawing of dendrograms

dense.elements.Population([population, ...])

Stores all the neurons in an unique object.

dense.elements.Q_

alias of dense.units.FormattedQuantity

dense.elements.Tree(neuron, neurite)

dense.elements.UnitRegistry(*args, **kwargs)

The unit registry stores the definitions and relationships between units.

dense.elements.get_application_registry()

Return the application registry.

dense.elements.set_application_registry(registry)

Set the application registry, which is used for unpickling operations and when invoking pint.Quantity or pint.Unit directly.

Containers for Neuronal shapes

class dense.elements.Neurite(branches, neurite_type, name='neurite', parent=None)[source]

Container to allow direct access to neurites.

Also facilitates post processing of SWC files. branch path is a tuple with (xy, r, theta, diameter)

property branches

Return the branches composing the neurite

property branching_points

Return the B locations of the branching points, shape (B, 2)

property diameter

Diameter of the different segments along the neurite

property empty

Whether the neurite is empty or not

get_properties(property_name=None, level=None)[source]

Get the object’s properties.

Parameters
  • property_name (str, optional (default: None)) – Name of the property that should be queried. By default, the full dictionary is returned.

  • level (str, optional (default: highest)) – Level at which the status should be obtained. Should be among “neurite”, or “growth_cone”.

Returns

status – Properties of the objects’ status: a single value if property_name was specified, the full status dict otherwise.

Return type

variable

get_state(observable=None)[source]

Return the values of all or one state observable of the neurite.

Parameters

observable (str, optional (default: all observables)) – Observable to query.

Returns

state

Return type

dict or scalar value

get_tree()[source]
property name

Name of the neurite

property neuron

Name of the parent neuron

plot_dendrogram(axis=None, show_node_id=False, aspect_ratio=None, vertical_diam_frac=0.2, ignore_diameter=False, show=True, **kwargs)[source]

Plot the dendrogram of a neurite.

Parameters
  • neurite (Neurite object) – Neurite for which the dendrogram should be plotted.

  • axis (matplotlib.Axes.axis object, optional (default: new one)) – Axis on which the dendrogram should be plotted.

  • show_node_id (bool, optional (default: False)) – Display each node number on the branching points.

  • aspect_ratio (float, optional (default: variable)) – Whether to use a fixed aspect ratio. Automatically set to 1 if show_node_id is True.

  • vertical_diam_frac (float, optional (default: 0.2)) – Fraction of the vertical spacing taken by the branch diameter.

  • ignore_diameter (bool, optional (default: False)) – Plot all the branches with the same width.

  • show (bool, optional (default: True)) – Whether the figure should be shown right away.

  • **kwargs (arguments for matplotlib.patches.Rectangle) – For instance facecolor or edgecolor.

Returns

Return type

The axis on which the plot was done.

property r

Length of the different segments along the neurite

set_properties(params)[source]

Update the neuronal parameters using the entries contained in params.

Parameters

params (dict) – New neurite parameters.

property single_branch

Whether the neurite is composed of a single branch

property taper_rate
property theta

Angles of the different segments along the neurite

property total_length

Total length of the neurite

property xy

Points constituting the different segments along the neurite

class dense.elements.Neuron(gid, **kwargs)[source]

Container allowing direct access to a neuron.

property axon

Return the Neurite container for the axon.

create_neurites(num_neurites=1, params=None, angles=None, names=None)[source]

Create new neurites.

Neurite types (axon or dendrite) are based on the neurite names: axon must always be named “axon”, all other names will be associated to a dendrite.

Parameters
  • num_neurites (int, optional (default: 1)) – Number of neurites that will be added to the neuron.

  • params (dict, optional (default: None)) – Parameters of the neurites.

  • angle (list, optional (default: automatically positioned)) – Angles of the newly created neurites.

  • names (str or list, optional (default: "axon" and "dendrite_X")) – Names of the created neurites, if not provided, will an “axon” or a dendrite with default name “dendrite_X” (X being a number) will be created, depending on whether the neuron is supposed to have an axon or not, and depending on the number of pre-existing neurites.

delete_neurites(neurite_names=None)[source]

Delete neurites.

Parameters

neurite_names (str or list, optional (default: all neurites)) – Neurites which will be deleted.

property dendrites

Return a dict containing one Neurite container for each dendrite, with its name as key.

get_neurite(neurite)[source]

Returns the required neurite.

get_properties(property_name=None, level=None, neurite=None)[source]

Get the neuron’s properties.

Parameters
  • property_name (str, optional (default: None)) – Name of the property that should be queried. By default, the full dictionary is returned.

  • level (str, optional (default: highest)) – Level at which the status should be obtained. Should be among “neuron”, “neurite”, or “growth_cone”.

  • neurite (str optional (default: None)) – Neurite that should be queried (either axon or dendrites). By default, both dictionaries are returned inside the neuronal status dictionary. If neurite is specified, only the parameters of this neurite will be returned.

Returns

status – Properties of the objects’ status: a single value if property_name was specified, the full status dict otherwise.

Return type

variable

get_state(observable=None)[source]

Return the values of all or one state observable of the neuron.

Parameters

observable (str, optional (default: all observables)) – Observable to query.

Returns

state

Return type

dict or scalar value

See also

get_state(), get_properties()

property neurites

Return a dict containing one Neurite container for each neurite, with its name as key.

set_properties(params=None, neurite_params=None)[source]

Update the neuronal (and optionaly neurite) parameters.

Parameters
  • params (dict) – New neuron parameters.

  • neurite_params (dict, optional (default: None)) – New neurite parameters.

to_neuroml(filename, resolution=10, write=True)[source]

Save the neuron as a NeuroML (.nml) object.

Parameters
  • filename (str) – Name of the MNL file to write.

  • resolution (int, optional (default: 10)) – Coarse-graining factor of the structure: only one point every resolution will be kept.

  • write (bool, optional (default: True)) – Write the file.

Returns

Return type

neuroml.Cell object.

to_swc(filename, resolution=10)[source]

Save the neuron as a SWC file.

Parameters
  • filename (str) – Name of the SWC to write.

  • resolution (int, optional (default: 10)) – Coarse-graining factor of the structure: only one point every resolution will be kept.

property total_length

Total arbor length of the neuron

class dense.elements.Node(node_id, tree=None, parent=None, diameter=None, dist_to_parent=None, pos=None)[source]

Container to facilitate drawing of dendrograms

add_child(child)[source]
distance_to_soma()[source]
class dense.elements.Population(population=None, info=None, name='no_name')[source]

Stores all the neurons in an unique object. Keeps data and info on each neuron. Each neuron is identified with its gid. Ensemble keeps the info.json file. In case the info.json is absent it’s possile to pass a description with a dictionary with name and description

append(val)[source]

Append object to the end of the list.

axon_all_points(center_zero=False)[source]
dendrites_all_points(center_zero=False)[source]
extend(values)[source]

Extend list by appending elements from the iterable.

classmethod from_gids(gids, name='no_name')[source]

Create a population from a set of neurons.

Parameters
  • gids (list) – Gids of the neurons to include in the population.

  • name (str, optional (default: "no_name")) – Name of the population.

classmethod from_structure(structure, info=None)[source]
classmethod from_swc(population, info=None)[source]
get_properties(property_name=None, level=None, neurite=None)[source]

Get the neurons’s properties.

Parameters
  • property_name (str, optional (default: None)) – Name of the property that should be queried. By default, the full dictionary is returned.

  • level (str, optional (default: highest)) – Level at which the status should be obtained. Should be among “neuron”, “neurite”, or “growth_cone”.

  • neurite (str optional (default: None)) – Neurite that should be queried (either axon or dendrites). By default, both dictionaries are returned inside the neuronal status dictionary. If neurite is specified, only the parameters of this neurite will be returned.

Returns

status – Properties of the objects’ status: a single value if property_name was specified, the full status dict otherwise.

Return type

variable

property ids
property positions
set_properties(params=None, axon_params=None, dendrites_params=None)[source]

Update the neuronal parameters using the entries contained in params.

Parameters
  • params (dict) – New neuron parameters.

  • axon_params (dict, optional (default: None)) – New axon parameters.

  • dendrites_params (dict, optional (default: None)) – New dendrites parameters.

property size

Number of neurons in the Population

class dense.elements.Tree(neuron, neurite)[source]
property neurite
neurom_tree()[source]
property neuron
property root
property tips
update_tips()[source]