Morphology class
(Shortest import: from brian2 import Morphology)
- class brian2.spatialneuron.morphology.Morphology(**kwds)[source]
Bases:
object
Neuronal morphology (tree structure).
The data structure is a tree where each node is an un-branched section consisting of a number of connected compartments, each one defined by its geometrical properties (length, area, diameter, position).
Notes
You cannot create objects of this class, create a
Soma
, aSection
, or aCylinder
instead.Attributes
The membrane surface area of each compartment in this section.
The children (as a
Children
object) of this section.Array with all coordinates at the start- and end-points of each compartment in this section.
Array with all coordinates (as unitless floating point numbers) at the start- and end-points of each compartment in this section.
The diameter at the middle of each compartment in this section.
The total distance between the midpoint of each compartment and the root of the morphology.
The distance to the root of the morphology at the end of this section.
The x coordinate at the end of each compartment.
The x coordinate (as a unitless floating point number) at the end of each compartment.
The y coordinate at the end of each compartment.
The y coordinate (as a unitless floating point number) at the end of each compartment.
The z coordinate at the end of each compartment.
The z coordinate (as a unitless floating point number) at the end of each compartment.
The length of each compartment in this section.
The number of compartments in this section.
The parent section of this section.
The geometry-dependent term to calculate the conductance between the start and the midpoint of each compartment.
The geometry-dependent term to calculate the conductance between the midpoint and the end of each compartment.
The x coordinate at the beginning of each compartment.
The x coordinate (as a unitless floating point number) at the beginning of each compartment.
The y coordinate at the beginning of each compartment.
The y coordinate (as a unitless floating point number) at the beginning of each compartment.
The z coordinate at the beginning of each compartment.
The z coordinate (as a unitless floating point number) at the beginning of each compartment.
The total number of compartments in this subtree (i.e. the number of compartments in this section plus all the compartments in the sections deeper in the tree).
The total number of sections in this subtree.
The volume of each compartment in this section.
The x coordinate at the midpoint of each compartment.
The x coordinate (as a unitless floating point number) at the midpoint of each compartment.
The y coordinate at the midpoint of each compartment.
The y coordinate (as a unitless floating point number) at the midpoint of each compartment.
The y coordinate at the midpoint of each compartment.
The z coordinate (as a unitless floating point number) at the midpoint of each compartment.
Methods
Create a copy of the current section (attributes of this section only, not re-creating the parent/children relation)
from_file
(filename[, spherical_soma])Convencience method to load a morphology from a given file.
from_points
(points[, spherical_soma])Create a morphology from a sequence of points (similar to the
SWC
format, seeMorphology.from_swc_file
).from_swc_file
(filename[, spherical_soma])Load a morphology from a
SWC
file.generate_coordinates
([section_randomness, ...])Create a new
Morphology
, with coordinates filled in place where the previous morphology did not have any.topology
()Return a representation of the topology
Details
- area
The membrane surface area of each compartment in this section.
- coordinates
Array with all coordinates at the start- and end-points of each compartment in this section. The array has size \((n+1) \times 3\), where \(n\) is the number of compartments in this section. Each row is one point (start point of first compartment, end point of first compartment, end point of second compartment, …), with the columns being the x, y, and z coordinates. Returns
None
for morphologies without coordinates.
- coordinates_
Array with all coordinates (as unitless floating point numbers) at the start- and end-points of each compartment in this section. The array has size \((n+1) \times 3\), where \(n\) is the number of compartments in this section. Each row is one point (start point of first compartment, end point of first compartment, end point of second compartment, …), with the columns being the x, y, and z coordinates. Returns
None
for morphologies without coordinates.
- diameter
The diameter at the middle of each compartment in this section.
- distance
The total distance between the midpoint of each compartment and the root of the morphology.
- end_distance
The distance to the root of the morphology at the end of this section.
- end_x
The x coordinate at the end of each compartment. Returns
None
for morphologies without coordinates.
- end_x_
The x coordinate (as a unitless floating point number) at the end of each compartment. Returns
None
for morphologies without coordinates.
- end_y
The y coordinate at the end of each compartment. Returns
None
for morphologies without coordinates.
- end_y_
The y coordinate (as a unitless floating point number) at the end of each compartment. Returns
None
for morphologies without coordinates.
- end_z
The z coordinate at the end of each compartment. Returns
None
for morphologies without coordinates.
- end_z_
The z coordinate (as a unitless floating point number) at the end of each compartment. Returns
None
for morphologies without coordinates.
- length
The length of each compartment in this section.
- n
The number of compartments in this section.
- parent
The parent section of this section.
- r_length_1
The geometry-dependent term to calculate the conductance between the start and the midpoint of each compartment. Dividing this value by the Intracellular resistivity gives the conductance.
- r_length_2
The geometry-dependent term to calculate the conductance between the midpoint and the end of each compartment. Dividing this value by the Intracellular resistivity gives the conductance.
- start_x
The x coordinate at the beginning of each compartment. Returns
None
for morphologies without coordinates.
- start_x_
The x coordinate (as a unitless floating point number) at the beginning of each compartment. Returns
None
for morphologies without coordinates.
- start_y
The y coordinate at the beginning of each compartment. Returns
None
for morphologies without coordinates.
- start_y_
The y coordinate (as a unitless floating point number) at the beginning of each compartment. Returns
None
for morphologies without coordinates.
- start_z
The z coordinate at the beginning of each compartment. Returns
None
for morphologies without coordinates.
- start_z_
The z coordinate (as a unitless floating point number) at the beginning of each compartment. Returns
None
for morphologies without coordinates.
- total_compartments
The total number of compartments in this subtree (i.e. the number of compartments in this section plus all the compartments in the sections deeper in the tree).
- total_sections
The total number of sections in this subtree.
- volume
The volume of each compartment in this section.
- x
The x coordinate at the midpoint of each compartment. Returns
None
for morphologies without coordinates.
- x_
The x coordinate (as a unitless floating point number) at the midpoint of each compartment. Returns
None
for morphologies without coordinates.
- y
The y coordinate at the midpoint of each compartment. Returns
None
for morphologies without coordinates.
- y_
The y coordinate (as a unitless floating point number) at the midpoint of each compartment. Returns
None
for morphologies without coordinates.
- z
The y coordinate at the midpoint of each compartment. Returns
None
for morphologies without coordinates.
- z_
The z coordinate (as a unitless floating point number) at the midpoint of each compartment. Returns
None
for morphologies without coordinates.
- abstract copy_section()[source]
Create a copy of the current section (attributes of this section only, not re-creating the parent/children relation)
- Returns:
copy :
Morphology
A copy of this section (without the links to the parent/children)
- static from_file(filename, spherical_soma=True)[source]
Convencience method to load a morphology from a given file. At the moment, only
SWC
files are supported, calling this function is therefore equivalent to callingMorphology.from_swc_file
directly.- Parameters:
filename : str
The name of a file storing a morphology.
spherical_soma : bool, optional
Whether to model the soma as a sphere.
Returns :
——- :
morphology :
Morphology
The morphology stored in the given file.
- static from_points(points, spherical_soma=True)[source]
Create a morphology from a sequence of points (similar to the
SWC
format, seeMorphology.from_swc_file
). Each point has to be a 7-tuple:(index, name, x, y, z, diameter, parent)
Note that the values should not use units, but are instead all taken to be in micrometers.
- Parameters:
points : sequence of 7-tuples
The points of the morphology.
spherical_soma : bool, optional
Whether to model a soma as a sphere.
Returns :
——- :
morphology :
Morphology
Notes
This format closely follows the SWC format (see
Morphology.from_swc_file
) with two differences: thetype
should be a string (e.g.'soma'
) instead of an integer and the 6-th element should be the diameter and not the radius.
- static from_swc_file(filename, spherical_soma=True)[source]
Load a morphology from a
SWC
file. A large database of morphologies in this format can be found at http://neuromorpho.orgThe format consists of an optional header of lines starting with
#
(ignored), followed by a sequence of points, each described in a line following the format:index type x y z radius parent
index
is an integer label (starting at 1) that identifies the current point and increases by one each line.type
is an integer representing the type of the neural segment. The only type that changes the interpretation by Brian is the type1
which signals a soma. Types2
(axon),3
(dendrite), and4
(apical dendrite) are used to give corresponding names to the respective sections. All other types are ignored.x
,y
, andz
are the cartesian coordinates at each point andr
is its radius.parent
refers to the index of the parent point or is-1
for the root point.- Parameters:
filename : str
The name of the
SWC
file.spherical_soma : bool, optional
Whether to model the soma as a sphere.
- Returns:
morpho :
Morphology
The morphology stored in the given file.
- generate_coordinates(section_randomness=0.0, compartment_randomness=0.0, overwrite_existing=False)[source]
Create a new
Morphology
, with coordinates filled in place where the previous morphology did not have any. This is mostly useful for plotting a morphology, it does not affect its electrical properties.- Parameters:
section_randomness : float, optional
The randomness when deciding the direction vector for each new section. The given number is the \(\beta\) parameter of an exponential distribution (in degrees) which will be used to determine the deviation from the direction of the parent section. If the given value equals 0 (the default), then a deterministic algorithm will be used instead.
compartment_randomness : float, optional
The randomness when deciding the direction vector for each compartment within a section. The given number is the \(\beta\) parameter of an exponential distribution (in degrees) which will be used to determine the deviation from the main direction of the current section. If the given value equals 0 (the default), then all compartments will be along a straight line.
overwrite_existing : bool, optional
Whether to overwrite existing coordinates in the morphology. This is by default set to
False
, meaning that only sections that do not currently have any coordinates set will get new coordinates. This allows to conveniently generate a morphology that can be plotted for a morphology that is based on points but also has artificially added sections (the most common case: an axon added to a reconstructed morphology). If set toTrue
, all sections will get new coordinates. This can be useful to either get a schematic representation of the morphology (withsection_randomness
andcompartment_randomness
both 0) or to simply generate a new random variation of a morphology (which will still be electrically equivalent, of course).- Returns:
morpho_with_coordinates :
Morphology
The same morphology, but with coordinates
Tutorials and examples using this
Example compartmental/bipolar_cell
Example compartmental/cylinder
Example compartmental/infinite_cable
Example compartmental/morphotest
Example compartmental/rall
Example compartmental/spike_initiation
Example frompapers/Brette_2012/Fig1
Example frompapers/Brette_2012/Fig3AB
Example frompapers/Brette_2012/Fig3CF
Example frompapers/Brette_2012/Fig4
Example frompapers/Brette_2012/Fig5A