Morphology class

(Shortest import: from brian2 import Morphology)

class brian2.spatialneuron.morphology.Morphology(filename=None, n=None)[source]

Bases: object

Neuronal morphology (=tree of branches).

The data structure is a tree where each node is a segment consisting of a number of connected compartments, each one defined by its geometrical properties (length, area, diameter, position).

Parameters:

filename : str, optional

The name of a swc file defining the morphology. If not specified, makes a segment (if n is specified) or an empty morphology.

n : int, optional

Number of compartments.

Methods

compress(morphology_data[, origin]) Compresses the tree by changing the compartment vectors to views on a matrix (or vectors).
create_from_segments(segments[, origin]) Recursively create the morphology from a list of segments.
loadswc(filename) Reads a SWC file containing a neuronal morphology.
plot([axes, simple, origin]) Plots the morphology in 3D.
set_area() Sets the area of compartments according to diameter and length
set_coordinates() Sets the coordinates of compartments according to their lengths (taking
set_distance() Sets the distance to the soma (or more generally start point of the
set_length() Sets the length of compartments according to their coordinates

Details

compress(morphology_data, origin=0)[source]

Compresses the tree by changing the compartment vectors to views on a matrix (or vectors). The morphology cannot be changed anymore but all other functions should work normally. Units are discarded in the process.

origin : offset in the base matrix

create_from_segments(segments, origin=0)[source]

Recursively create the morphology from a list of segments. Each segments has attributes: x,y,z,diameter,area,length (vectors) and children (list). It also creates a dictionary of names (_namedkid).

loadswc(filename)[source]

Reads a SWC file containing a neuronal morphology. Large database at http://neuromorpho.org/neuroMorpho Information below from http://www.mssm.edu/cnic/swc.html

SWC File Format

The format of an SWC file is fairly simple. It is a text file consisting of a header with various fields beginning with a # character, and a series of three dimensional points containing an index, radius, type, and connectivity information. The lines in the text file representing points have the following layout. n T x y z R P n is an integer label that identifies the current point and increments by one from one line to the next. T is an integer representing the type of neuronal segment, such as soma, axon, apical dendrite, etc. The standard accepted integer values are given below: * 0 = undefined * 1 = soma * 2 = axon * 3 = dendrite * 4 = apical dendrite * 5 = fork point * 6 = end point * 7 = custom

x, y, z gives the cartesian coordinates of each node. R is the radius at that node. P indicates the parent (the integer label) of the current point or -1 to indicate an origin (soma).

By default, the soma is assumed to have spherical geometry. If several compartments

plot(axes=None, simple=True, origin=None)[source]

Plots the morphology in 3D. Units are um.

Parameters:

axes : Axes3D

the figure axes (new figure if not given)

simple : bool, optional

if True, the diameter of branches is ignored (defaults to True)

set_area()[source]

Sets the area of compartments according to diameter and length (assuming cylinders)

set_coordinates()[source]

Sets the coordinates of compartments according to their lengths (taking a random direction)

set_distance()[source]

Sets the distance to the soma (or more generally start point of the morphology)

set_length()[source]

Sets the length of compartments according to their coordinates