Python API¶
Immutable objects¶
- class morphio.Annotation¶
Class that holds service information about a warning.
- property details¶
Returns the details
- property diameters¶
Returns the list of diameters of annotated points
- property line_number¶
Returns the lineNumber
- property perimeters¶
Returns the list of perimeters of annotated points
- property points¶
Returns the list of coordinates of annotated points
- property section_id¶
Returns the sectionId
- property type¶
Returns the type
- class morphio.AnnotationType¶
Members:
single_child : Indicates that a section has only one child
- property name¶
- class morphio.CellLevel¶
Service information that is available at the Morphology level (morphology version, morphology family, soma type, etc.)
- property cell_family¶
Returns the cell family (neuron or glia)
- property soma_type¶
Returns the soma type
- property version¶
Returns the version
- class morphio.Collection¶
A collection of morphologies
- argsort(morphology_names: list[str]) list[int] ¶
Argsort morphology_names by optimal access order.
Note: This API is ‘experimental’, meaning it might change in the future.
- close() None ¶
- load(morph_name: str, options: int = <Option.no_modifier: 0>, mutable: bool = False, warning_handler: morphio.WarningHandler = None) object ¶
Load the morphology named ‘morph_name’ form the collection.
- load_unordered(morphology_names: list[str], options: int = <Option.no_modifier: 0>, mutable: bool = False, warning_handler: morphio.WarningHandler = None) object ¶
Create an iterable of loop index and morphology.
When reading from containers, the order in which morphologies are read can have a large impact on the overall time to load those morphologies.
This iterator provides means of reordering loops to optimize the access pattern. Loops such as the following
- for k, morph_name in enumerate(morphology_names):
morph = collection.load(morphology_names[k]) f(k, morph)
can be replaced with
- for k, morph in collection.load_unordered(morphology_names):
assert collection.load(morphology_names[k]) == morph f(k, morph)
The order in which the morphologies are returned in unspecified, but the loop index k can be used to retrieve the correct state corresponding to iteration k of the original loop.
The iterable returned by Collection.load_unordered should only be used while collection is valid, e.g. within its context or before calling Collection.close.
Note: This API is ‘experimental’, meaning it might change in the future.
- class morphio.DendriticSpine¶
Class to represent morphologies of dendritic spines
- property cell_family¶
Return the cell family (neuron or glia)
- property connectivity¶
Return the graph connectivity of the morphology where each section is seen as a node Note: -1 is the soma node
- property diameters¶
Return a vector with all diameters from all sections (soma points are not included)
- iter(iter_type: morphio.IterType = <IterType.depth_first: 0>) Iterator[morphio.Section] ¶
Section iterator that runs successively on every neurite
iter_type controls the order of iteration on sections of a given neurite. 2 values can be passed:
morphio.IterType.depth_first
(default)morphio.IterType.breadth_first
- property points¶
Return a vector with all points from all sections (soma points are not included)
- property root_sections¶
Return a vector of all root sections (sections whose parent ID are -1)
- section(section_id: int) morphio.Section ¶
Return the Section with the given id.
- Raises:
RawDataError if the id is out of range
- property section_offsets¶
Returns a list with offsets to access data of a specific section in the points and diameters arrays.
Example: accessing diameters of n’th section will be located in the Morphology::diameters array from diameters[sectionOffsets(n)] to diameters[sectionOffsets(n+1)-1]
Note: for convenience, the last point of this array is the points() array size so that the above example works also for the last section.
- property section_types¶
Return a vector with the section type of every section
- property sections¶
Return a vector containing all section objects
Notes: Soma is not included
- property version¶
Return the version
- write(filename: object) None ¶
- class morphio.EndoplasmicReticulum¶
The entry-point class to access endoplasmic reticulum data
Spec https://bbpteam.epfl.ch/documentation/projects/Morphology%20Docum entation/latest/h5v1.html
- property filament_counts¶
Returns the number of filaments for each neuronal section
- property section_indices¶
Returns the list of neuronal section indices
- property surface_areas¶
Returns the surface areas for each neuronal section
- property volumes¶
Returns the volumes for each neuronal section
- class morphio.GlialCell¶
Class to represent morphologies of glial cells
- exception morphio.IDSequenceError¶
- exception morphio.MissingParentError¶
- class morphio.MitoSection¶
Class representing a Mitochondrial Section
- property children¶
Return a list of children sections
- property diameters¶
Returns list of section’s point diameters
- has_same_shape(arg0: morphio.MitoSection) bool ¶
Returns list of relative distances between the start of the neuronal section and each point of the mitochondrial sectionn Note: - a relative distance of 0 means the mitochondrial point is at the beginning of the neuronal section - a relative distance of 1 means the mitochondrial point is at the end of the neuronal section
- property id¶
Return the ID of this section.
- property is_root¶
Return true if this section is a root section (parent ID == -1)
- iter(iter_type: morphio.IterType = <IterType.depth_first: 0>) Iterator[morphio.MitoSection] ¶
Depth first iterator starting at a given section id
If id == -1, the iteration will be successively performed starting at each root section
- property neurite_section_ids¶
Returns list of neuronal section IDs associated to each point
- property parent¶
Return the parent section of this section
- Raises:
MissingParentError is the section doesn’t have a parent.
- property relative_path_lengths¶
Returns list of relative distances between the start of the neuronal section and each point of the mitochondrial sectionn Note: - a relative distance of 0 means the mitochondrial point is at the beginning of the neuronal section - a relative distance of 1 means the mitochondrial point is at the end of the neuronal section
- class morphio.Mitochondria¶
The entry-point class to access mitochondrial data
By design, it is the equivalent of the Morphology class but at the mitochondrial level. As the Morphology class, it implements a section accessor and a root section accessor returning views on the Properties object for the queried mitochondrial section.
- property root_sections¶
Return a vector of all root sections
- section(section_id: int) morphio::MitoSection ¶
Return the Section with the given id.
- property sections¶
Return a vector containing all section objects
Notes: Soma is not included
- class morphio.MitochondriaPointLevel¶
Information that is available at the mitochondrial point level (enclosing neuronal section, relative distance to start of neuronal section, diameter)
- exception morphio.MorphioError¶
- class morphio.Morphology¶
Class that gives read access to a Morphology file.
Following RAII, this class is ready to use after the creation and will ensure release of resources upon destruction.
- property annotations¶
Return the annotation object
- as_mutable() morphio::mut::Morphology ¶
- property cell_family¶
Return the cell family (neuron or glia)
- property connectivity¶
Return the graph connectivity of the morphology where each section is seen as a node Note: -1 is the soma node
- property diameters¶
Return a vector with all diameters from all sections (soma points are not included)
- property endoplasmic_reticulum¶
Return the endoplasmic reticulum object
- iter(iter_type: morphio.IterType = <IterType.depth_first: 0>) Iterator[morphio::Section] ¶
Section iterator that runs successively on every neurite
iter_type controls the order of iteration on sections of a given neurite. 2 values can be passed:
morphio.IterType.depth_first
(default)morphio.IterType.breadth_first
- property markers¶
Return the markers
- property mitochondria¶
Return the mitochondria object
- property n_points¶
Returns the number of points from all sections (soma points are not included)
- property perimeters¶
Return a vector with all perimeters from all sections
- property points¶
Return a vector with all points from all sections (soma points are not included)
- property root_sections¶
Return a vector of all root sections (sections whose parent ID are -1)
- section(section_id: int) morphio::Section ¶
Return the Section with the given id.
- Raises:
RawDataError if the id is out of range
- property section_offsets¶
Returns a list with offsets to access data of a specific section in the points and diameters arrays.
Example: accessing diameters of n’th section will be located in the Morphology::diameters array from diameters[sectionOffsets(n)] to diameters[sectionOffsets(n+1)-1]
Note: for convenience, the last point of this array is the points() array size so that the above example works also for the last section.
- property section_types¶
Return a vector with the section type of every section
- property sections¶
Return the Section with the given id.
- Raises:
RawDataError if the id is out of range
- property soma¶
Return the soma object
- property soma_type¶
Return the soma type
- property version¶
Return the version
- exception morphio.MultipleTrees¶
- class morphio.Option¶
Members:
no_modifier
two_points_sections
soma_sphere
no_duplicates
nrn_order
allow_unifurcated_section_change
- property name¶
- class morphio.PointLevel¶
Information that is available at the point level (point coordinate, diameter, perimeter)
- property diameters¶
Returns the list of diameters
- property perimeters¶
Returns the list of perimeters
- property points¶
Returns the list of point coordinates
- class morphio.Properties¶
The higher level container structure is Property::Properties
- property cell_level¶
Returns the structure that stores information at the cell level
- property point_level¶
Returns the structure that stores information at the point level
- property section_level¶
Returns the structure that stores information at the section level
- exception morphio.RawDataError¶
- class morphio.Section¶
Class representing a Section
- property children¶
Return a list of children sections
- property diameters¶
Return a view (https://github.com/isocpp/CppCoreGuidelines/blob/master/docs/gsl- intro.md#gslspan-what-is-gslspan-and-what-is-it-for) to this section’s point diameters
- has_same_shape(arg0: morphio.Section) bool ¶
Return true if the both sections have the same points, diameters and perimeters
- property id¶
Return the ID of this section.
- is_heterogeneous(downstream: bool = True) bool ¶
Return true if the sections of the tree downstream (downstream = true) or upstream (donwstream = false) have the same section type as the current section.
- property is_root¶
Return true if this section is a root section (parent ID == -1)
- iter(iter_type: morphio.IterType = <IterType.depth_first: 0>) Iterator[morphio.Section] ¶
Section iterator
iter_type controls the iteration order. 3 values can be passed:
morphio.IterType.depth_first
(default)morphio.IterType.breadth_first
morphio.IterType.upstream
- property n_points¶
Returns the number of points in section
- property parent¶
Return the parent section of this section
- Raises:
MissingParentError is the section doesn’t have a parent.
- property perimeters¶
Return a view (https://github.com/isocpp/CppCoreGuidelines/blob/master/docs/gsl- intro.md#gslspan-what-is-gslspan-and-what-is-it-for) to this section’s point perimeters
- property points¶
Return a view (https://github.com/isocpp/CppCoreGuidelines/blob/master/docs/gsl- intro.md#gslspan-what-is-gslspan-and-what-is-it-for) to this section’s point coordinates
- property type¶
Return the morphological type of this section (dendrite, axon, …)
- exception morphio.SectionBuilderError¶
- class morphio.SectionLevel¶
Information that is available at the section level (section type, parent section)
- property children¶
Returns a dictionary where key is a section ID and value is the list of children section IDs
- property section_types¶
Returns the list of section types
- property sections¶
Returns a list of [offset, parent section ID]
- class morphio.SectionType¶
Members:
undefined
soma
axon
basal_dendrite
apical_dendrite
custom5
custom6
custom7
custom8
custom9
custom10
custom11
custom12
custom13
custom14
custom15
custom16
custom17
custom18
custom19
glia_perivascular_process
glia_process
spine_head
spine_neck
all
- property name¶
- class morphio.Soma¶
A class to represent a neuron soma.
This class provides functions to query information about the soma of a neuron.
Typically the soma is described as the poly-line of the projection of the soma onto a plane, where the plane normal points in the vertical direction in the local coordinate system of the morphology. In other cases the poly-line is not projected onto a plane, but is an approximation of the countour of the soma as seen in an orhogonal projection down the vertical axis (this is basically the same as before, but the vertical coordinate is not 0 for all the points). This class can also be used for both descriptions as well as somas simply approximated as spheres.
The coordinates system used by a soma will be in the same as the brain::Morphology from where it comes.
@version unstable
- property center¶
Return the center of gravity of the soma points
- property diameters¶
Return the diameters of all soma points
- property max_distance¶
Return the maximum distance between the center of gravity and any of the soma points
- property points¶
Return the coordinates (x,y,z) of all soma points
- property surface¶
the soma surface computation depends on the soma type
- Type:
Return the soma surfacen” Note
- property type¶
Return the soma type
- exception morphio.SomaError¶
- class morphio.SomaType¶
Members:
SOMA_UNDEFINED
SOMA_SINGLE_POINT
SOMA_NEUROMORPHO_THREE_POINT_CYLINDERS
SOMA_CYLINDERS
SOMA_SIMPLE_CONTOUR
- property name¶
- exception morphio.UnknownFileType¶
- class morphio.VasculatureSectionType¶
Members:
undefined
vein
artery
venule
arteriole
venous_capillary
arterial_capillary
transitional
- property name¶
- class morphio.Warning¶
Members:
undefined
mitochondria_write_not_supported
write_no_soma
soma_non_conform
no_soma_found
disconnected_neurite
wrong_duplicate
appending_empty_section
wrong_root_point
only_child
write_empty_morphology
zero_diameter
soma_non_contour
soma_non_cylinder_or_point
type_changed_within_section
- property name¶
- class morphio.WarningHandlerCollector¶
WarningHandler base
- get_all() list[morphio::WarningHandlerCollector::Emission] ¶
ibid
- reset() None ¶
ibid
- exception morphio.WriterError¶
- morphio.set_ignored_warning(*args, **kwargs)¶
Overloaded function.
set_ignored_warning
(warning: morphio.Warning, ignore: bool = True) → NoneSet a warning to ignore
set_ignored_warning
(warning: list[morphio.Warning], ignore: bool = True) → NoneSet a warning to ignore
- morphio.set_maximum_warnings(arg0: int) None ¶
Set the maximum number of warnings to be printed; -1 for unlimited
- morphio.set_raise_warnings(arg0: bool) None ¶
Set whether to interpet warning as errors
Mutable objects¶
- class morphio.mut.DendriticSpine¶
Mutable(editable) morphio::DendriticSpine
- append_root_section(*args, **kwargs)¶
Overloaded function.
append_root_section
(point_level_properties: morphio.PointLevel, section_type: morphio.SectionType) → morphio.mut.SectionAppend the existing morphio::Section as a root section
If recursive == true, all descendent will be appended as well
append_root_section
(immutable_section: morphio.Section, recursive: bool = False) → morphio.mut.SectionAppend an existing Section as a root section
If recursive == true, all descendent will be appended as well
- property cell_family¶
The cell family represented by morphio::Morphology.
- property post_synaptic_density¶
Returns the post synaptic density values
- property root_sections¶
Returns all section ids at the tree root
- property sections¶
Returns the dictionary id -> Section for this tree
- write(filename: object) None ¶
- class morphio.mut.EndoplasmicReticulum¶
Mutable(editable) morphio::EndoplasmicReticulum
- property filament_counts¶
Returns the number of filaments for each neuronal section
- property section_indices¶
Returns the list of neuronal section indices
- property surface_areas¶
Returns the surface areas for each neuronal section
- property volumes¶
Returns the volumes for each neuronal section
- class morphio.mut.GlialCell¶
Mutable(editable) morphio::GlialCell
- class morphio.mut.MitoSection¶
Mutable(editable) morphio::MitoSection
- append_section(*args, **kwargs)¶
Overloaded function.
append_section
(point_level_properties: morphio.MitochondriaPointLevel) → morphio.mut.MitoSectionAppend a MitoSection
append_section
(section: morphio.mut.MitoSection, recursive: bool = False) → morphio.mut.MitoSectionAppend a MitoSection
If recursive == true, all descendent mito sections will be appended as well
append_section
(immutable_section: morphio.MitoSection, recursive: bool = False) → morphio.mut.MitoSectionAppend a MitoSection
If recursive == true, all descendent mito sections will be appended as well
- property diameters¶
Returns the diameters of all points of this section
- has_same_shape(arg0: morphio.mut.MitoSection) bool ¶
Return true if the both sections have the same neuriteSectionIds, diameters and pathLengths
- property id¶
Return the section ID
- property neurite_section_ids¶
Returns the neurite section Ids of all points of this section
- property relative_path_lengths¶
Returns the relative distance (between 0 and 1) between the start of the neuronal section and each point of this mitochondrial section
- class morphio.mut.Mitochondria¶
Mutable(editable) morphio::Mitochondria
- append_root_section(*args, **kwargs)¶
Overloaded function.
append_root_section
(point_level_properties: morphio.MitochondriaPointLevel) → morphio::mut::MitoSectionAppend a new root MitoSection
append_root_section
(immutable_section: morphio.MitoSection, recursive: bool = True) → morphio::mut::MitoSectionAppend a root MitoSection
If recursive == true, all descendent mito sections will be appended as well
append_root_section
(section: morphio::mut::MitoSection, recursive: bool = True) → morphio::mut::MitoSectionAppend a root MitoSection
If recursive == true, all descendent mito sections will be appended as well
- breadth_begin(section_id: morphio::mut::MitoSection = -1) Iterator[morphio::mut::MitoSection] ¶
Breadth first iterator
If id == -1, the iteration will be successively performed starting at each root section
- children(section_id: morphio::mut::MitoSection) list[morphio::mut::MitoSection] ¶
Get the Section children
- depth_begin(section_id: morphio::mut::MitoSection = -1) Iterator[morphio::mut::MitoSection] ¶
Depth first iterator starting at a given section id
If id == -1, the iteration will start at each root section, successively
- is_root(section_id: morphio::mut::MitoSection) bool ¶
Return true if section is a root section
- parent(section_id: morphio::mut::MitoSection) morphio::mut::MitoSection ¶
Return the parent mithochondrial section ID
- property root_sections¶
Return the list of IDs of all mitochondrial root sections (sections whose parent ID are -1)
- section(section_id: int) morphio::mut::MitoSection ¶
Get the shared pointer for the given section
Note: multiple morphologies can share the same Section instances.
- property sections¶
Returns the dictionary id -> Section for this tree
- upstream_begin(section_id: morphio::mut::MitoSection = -1) Iterator[morphio::mut::MitoSection] ¶
Upstream first iterator
If id == -1, the iteration will be successively performed starting at each root section
- class morphio.mut.Morphology¶
Class representing a mutable Morphology
- property annotations¶
Return the annotation objects
- append_root_section(*args, **kwargs)¶
Overloaded function.
append_root_section
(point_level_properties: morphio.PointLevel, section_type: morphio.SectionType) → morphio::mut::SectionAppend the existing morphio::Section as a root section
If recursive == true, all descendent will be appended as well
append_root_section
(immutable_section: morphio.Section, recursive: bool = False) → morphio::mut::SectionAppend the existing morphio::Section as a root section
If recursive == true, all descendent will be appended as well
append_root_section
(mutable_section: morphio::mut::Section, recursive: bool = False) → morphio::mut::SectionAppend the existing morphio::Section as a root section
If recursive == true, all descendent will be appended as well
- as_immutable() morphio.Morphology ¶
- build_read_only() morphio.Properties ¶
Return the data structure used to create read-only morphologies
- property cell_family¶
Return the cell family (neuron or glia)
- property connectivity¶
Return the graph connectivity of the morphology where each section is seen as a node Note: -1 is the soma node
- delete_section(section: morphio::mut::Section, recursive: bool = True) None ¶
Delete the given section
Will silently fail if the section is not part of the tree
If recursive == true, all descendent sections will be deleted as well Else, children will be re-attached to their grand-parent
- property endoplasmic_reticulum¶
Return the endoplasmic reticulum container class
- iter(iter_type: morphio.IterType = <IterType.depth_first: 0>) Iterator[morphio::mut::Section] ¶
Section iterator that runs successively on every neurite
iter_type controls the order of iteration on sections of a given neurite. 2 values can be passed:
morphio.IterType.depth_first
(default)morphio.IterType.breadth_first
- property markers¶
Return the markers from the ASC file
- property mitochondria¶
Return the mitochondria container class
- remove_unifurcations() None ¶
Fixes the morphology single child sections and issues warnings if the section starts and ends are inconsistent
- property root_sections¶
Returns all section ids at the tree root
- section(section_id: int) morphio::mut::Section ¶
Get the shared pointer for the given section
Note: multiple morphologies can share the same Section instances.
- property sections¶
Returns the dictionary id -> Section for this tree
- property soma¶
Returns a shared pointer on the Soma
Note: multiple morphologies can share the same Soma instance
- property soma_type¶
Return the soma type
- property version¶
Return the version
- write(filename: object) None ¶
Write file to H5, SWC, ASC format depending on filename extension
- class morphio.mut.Section¶
Class representing a mutable Section
- append_section(*args, **kwargs)¶
Overloaded function.
append_section
(point_level_properties: morphio.PointLevel, section_type: morphio.SectionType = <SectionType.undefined: 0>) → morphio.mut.Sectionappend_section
(immutable_section: morphio.Section, recursive: bool = False) → morphio.mut.Sectionappend_section
(mutable_section: morphio.mut.Section, recursive: bool = False) → morphio.mut.Section
- property children¶
Return a vector of children IDs
- property diameters¶
@{ Return the diameters of all points of this section
- has_same_shape(arg0: morphio.mut.Section) bool ¶
Return true if the both sections have the same points, diameters and perimeters
- property id¶
Return the section ID
- is_heterogeneous(downstream: bool = True) bool ¶
Return true if the sections of the tree downstream (downstream = true) or upstream (donwstream = false) have the same section type as the current section.
- property is_root¶
Return true if section is a root section
- iter(iter_type: morphio.IterType = <IterType.depth_first: 0>) Iterator[morphio.mut.Section] ¶
Section iterator
iter_type controls the iteration order. 3 values can be passed:
morphio.IterType.depth_first
(default)morphio.IterType.breadth_first
morphio.IterType.upstream
- property parent¶
Get the parent ID
Note: Root sections return -1
- property perimeters¶
@{ Return the perimeters of all points of this section
- property points¶
@{ Return the coordinates (x,y,z) of all points of this section
- property type¶
@{ Return the morphological type of this section (dendrite, axon, …)
- class morphio.mut.Soma¶
Mutable(editable) morphio::Soma
- property center¶
Return the center of gravity of the soma points
- property diameters¶
Return the diameters of all soma points
- property max_distance¶
Return the maximum distance between the center of gravity and any of the soma points
- property points¶
Return the coordinates (x,y,z) of all soma points
- property surface¶
the soma surface computation depends on the soma type
- Type:
Return the soma surface Note
- property type¶
Return the soma type