Python API¶
Immutable objects¶
- class morphio.Annotation¶
Container class for information about anomalies detected while parsing the file (no soma, section with a single child…)
- 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¶
Container class for information available at the cell level (cell type, file version, soma type)
- 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) 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) 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 representing a Dendritic Spine
- property cell_family¶
Returns the cell family (neuron or glia)
- property connectivity¶
Return the graph connectivity of the DendriticSpine where each section is seen as a node Note: -1 is the soma node
- property diameters¶
Returns a list with all diameters from all sections Note: diameters belonging to the n’th section are located at indices: [DendriticSpine.sectionOffsets(n), DendriticSpine.sectionOffsets(n+1)[
- iter(iter_type: morphio.IterType = <IterType.depth_first: 0>) Iterator ¶
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¶
Returns a list with all points from all sections Note: points belonging to the n’th section are located at indices: [DendriticSpine.sectionOffsets(n), DendriticSpine.sectionOffsets(n+1)[
- property post_synaptic_density¶
Returns the post synaptic density values
- property root_sections¶
Returns a list of all root sections (sections whose parent ID are -1)
- section(section_id: int) morphio.Section ¶
Returns the Section with the given id throw 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 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¶
Returns a vector with the section type of every section
- property sections¶
Returns a vector containing all sections objects
Notes: - Soma is not included - First section ID is 1 (0 is reserved for the soma) - To select sections by ID use: DendriticSpine::section(id)
- property version¶
Returns 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%20Documentation/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 list of neuronal section indices
- class morphio.GlialCell¶
Class representing a Glial Cell
- exception morphio.IDSequenceError¶
- exception morphio.MissingParentError¶
- class morphio.MitoSection¶
Class representing a Mitochondrial Section
- property children¶
Returns a list of children mitochondrial sections
- property diameters¶
Returns list of section’s point diameters
- has_same_shape(arg0: morphio.MitoSection) bool ¶
- property id¶
Returns the section ID The section ID can be used to query sections via Mitochondria::section(uint32_t id)
- property is_root¶
Returns true if this section is a root section (parent ID == -1)
- iter(iter_type: morphio.IterType = <IterType.depth_first: 0>) Iterator ¶
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 of this mitochondrial section
- property parent¶
Returns the parent mitochondrial section of this section throw 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 section
- 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¶
Returns a list of all root sections (section whose parent ID is -1)
- section(section_id: int) morphio.MitoSection ¶
Returns the mithochondrial section with the given ID
- property sections¶
Returns a list of all mitochondrial sections
- class morphio.MitochondriaPointLevel¶
Container class for the information available at the mitochondrial point level (enclosing neuronal section, relative distance to start of neuronal section, diameter)
- exception morphio.MorphioError¶
- class morphio.Morphology¶
Class representing a complete morphology
- property annotations¶
Returns a list of annotations
- as_mutable() morphio.mut.Morphology ¶
- property cell_family¶
Returns 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¶
Returns a list with all diameters from all sections (soma points are not included) Note: diameters belonging to the n’th section are located at indices: [Morphology.sectionOffsets(n), Morphology.sectionOffsets(n+1)[
- property endoplasmic_reticulum¶
Returns the endoplasmic reticulum object
- iter(iter_type: morphio.IterType = <IterType.depth_first: 0>) Iterator ¶
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¶
Returns the list of NeuroLucida markers
- property mitochondria¶
Returns the soma object
- property n_points¶
Returns the number of points from all sections (soma points are not included)
- property perimeters¶
Returns a list with all perimeters from all sections (soma points are not included) Note: perimeters belonging to the n’th section are located at indices: [Morphology.sectionOffsets(n), Morphology.sectionOffsets(n+1)[
- property points¶
Returns a list with all points from all sections (soma points are not included) Note: points belonging to the n’th section are located at indices: [Morphology.sectionOffsets(n), Morphology.sectionOffsets(n+1)[
- property root_sections¶
Returns a list of all root sections (sections whose parent ID are -1)
- section(section_id: int) morphio.Section ¶
Returns the Section with the given id throw RawDataError if the id is out of range
- property section_offsets¶
Returns a list with N+1 offsets to access data of a specific section in the points and diameters arrays (size N).
Example: accessing diameters of n’th section will be located in the diameters array: diameters[section_offsets[n]: section_offsets[n + 1]]
Note: for convenience, the last element of this array is equal to the length of the points/diameters arrays so that the above example works also for the last section.
- property section_types¶
Returns a vector with the section type of every section
- property sections¶
Returns a vector containing all sections objects
Notes: - Soma is not included - First section ID is 1 (0 is reserved for the soma) - To select sections by ID use: Morphology::section(id)
- property soma¶
Returns the soma object
- property soma_type¶
Returns the soma type
- property version¶
Returns the version
- exception morphio.MultipleTrees¶
- class morphio.Option¶
Members:
no_modifier
two_points_sections
soma_sphere
no_duplicates
nrn_order
- property name¶
- class morphio.PointLevel¶
Container class for information 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.PostSynapticDensity¶
DendriticSpine post-synaptic density
- property offset¶
Returns offset of post-synaptic density
- property section_id¶
Returns sectionId of post-synaptic density
- property segment_id¶
Returns segmentId of post-synaptic density
- 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¶
Returns a list of children sections
- property diameters¶
Returns list of section’s point diameters
- has_same_shape(arg0: morphio.Section) bool ¶
- property id¶
Returns the section ID The section ID can be used to query sections via Morphology::section(uint32_t id)
- is_heterogeneous(downstream: bool = True) bool ¶
Returns true if the tree downtream (downstream = true) or upstream (downstream = false) has the same type as the current section.
- property is_root¶
Returns true if this section is a root section (parent ID == -1)
- iter(iter_type: morphio.IterType = <IterType.depth_first: 0>) Iterator ¶
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¶
Returns the parent section of this section throw MissingParentError is the section doesn’t have a parent
- property perimeters¶
Returns list of section’s point perimeters
- property points¶
Returns list of section’s point coordinates
- property type¶
Returns the morphological type of this section (dendrite, axon, …)
- exception morphio.SectionBuilderError¶
- class morphio.SectionLevel¶
Container class for information 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
glia_perivascular_process
glia_process
spine_head
spine_neck
all
- property name¶
- class morphio.Soma¶
Class representing a Soma
- property center¶
Returns the center of gravity of the soma points
- property diameters¶
Returns 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¶
Returns the coordinates (x,y,z) of all soma point
- property surface¶
Returns the soma surface
Note: the soma surface computation depends on the soma type
- property type¶
Returns 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
write_empty_morphology
soma_non_conform
no_soma_found
disconnected_neurite
wrong_duplicate
appending_empty_section
wrong_root_point
only_child
zero_diameter
- property name¶
- exception morphio.WriterError¶
- morphio.set_ignored_warning(*args, **kwargs)¶
Overloaded function.
set_ignored_warning
(warning: morphio::enums::Warning, ignore: bool = True) → NoneIgnore/Unignore a specific warning message
set_ignored_warning
(warning: List[morphio::enums::Warning], ignore: bool = True) → NoneIgnore/Unignore a list of warnings
- morphio.set_maximum_warnings(arg0: int) None ¶
Set the maximum number of warnings to be printed on screen 0 will print no warning -1 will print them all
- morphio.set_raise_warnings(arg0: bool) None ¶
Whether to raise warning as errors
Mutable objects¶
- class morphio.mut.DendriticSpine¶
Class representing a mutable Dendritic Spine
- append_root_section(*args, **kwargs)¶
Overloaded function.
append_root_section
(point_level_properties: morphio.PointLevel, section_type: morphio.SectionType) → morphio.mut.SectionAppend a root Section
append_root_section
(immutable_section: morphio.Section, recursive: bool = False) → morphio.mut.SectionAppend the existing immutable Section as a root section If recursive == true, all descendent will be appended as well
- property cell_family¶
Returns the cell family
- property post_synaptic_density¶
Returns the post synaptic density values
- property root_sections¶
Returns a list of all root sections IDs (sections whose parent ID are -1)
- property sections¶
Returns a list containing IDs of all sections.
- write(filename: object) None ¶
- class morphio.mut.EndoplasmicReticulum¶
Class representing a mutable Endoplasmic Reticulum
- 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¶
Class representing a mutable Glial Cell
- class morphio.mut.MitoSection¶
Class representing a mutable Mitochondrial Section
- append_section(*args, **kwargs)¶
Overloaded function.
append_section
(point_level_properties: morphio.MitochondriaPointLevel) → morphio.mut.MitoSectionAppend a new MitoSection to this mito section
append_section
(section: morphio.mut.MitoSection, recursive: bool = False) → morphio.mut.MitoSectionAppend a copy of the section to this section If recursive == true, all descendent will be appended as well
append_section
(immutable_section: morphio.MitoSection, recursive: bool = False) → morphio.mut.MitoSectionAppend the existing immutable MitoSection to this section If recursive == true, all descendent will be appended as well
- property diameters¶
Returns the diameters of all points of this section
- has_same_shape(arg0: morphio.mut.MitoSection) bool ¶
- 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¶
Class representing a mutable 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 new root MitoSection (if recursive == true, all descendent will be appended as well)
append_root_section
(section: morphio.mut.MitoSection, recursive: bool = True) → morphio.mut.MitoSectionAppend a new root MitoSection (if recursive == true, all descendent will be appended as well)
- breadth_begin(section_id: morphio.mut.MitoSection = -1) Iterator ¶
Breadth first iterator starting at a given section id
If id == -1, the iteration will be successively performed starting at each root section
- children(section_id: morphio.mut.MitoSection) List[morphio.mut.MitoSection] ¶
- depth_begin(section_id: morphio.mut.MitoSection = -1) Iterator ¶
Depth first iterator starting at a given section id
If id == -1, the iteration will be successively performed starting at each root section
- 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 ¶
Returns the parent mithochondrial section ID
- property root_sections¶
Returns a list of all root sections IDs (sections whose parent ID are -1)
- section(section_id: int) morphio.mut.MitoSection ¶
Get a reference to the given mithochondrial section
Note: multiple mitochondria can shared the same references
- property sections¶
Return a dict where key is the mitochondrial section ID and value is the mithochondrial section
- upstream_begin(section_id: morphio.mut.MitoSection = -1) Iterator ¶
Upstream iterator starting at a given section id
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¶
Returns a list of annotations
- append_root_section(*args, **kwargs)¶
Overloaded function.
append_root_section
(point_level_properties: morphio.PointLevel, section_type: morphio.SectionType) → morphio.mut.SectionAppend a root Section
append_root_section
(immutable_section: morphio.Section, recursive: bool = False) → morphio.mut.SectionAppend the existing immutable 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 mutable Section as a root section If recursive == true, all descendent will be appended as well
- as_immutable() morphio.Morphology ¶
- build_read_only() morphio.Properties ¶
Returns the data structure used to create read-only morphologies
- property cell_family¶
Returns 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¶
Returns a reference to the endoplasmic reticulum container class
- iter(iter_type: morphio.IterType = <IterType.depth_first: 0>) Iterator ¶
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¶
Returns the list of NeuroLucida markers
- property mitochondria¶
Returns a reference to the mitochondria container class
- remove_unifurcations() None ¶
Fixes the morphology single child sections and issues warningsif the section starts and ends are inconsistent
- property root_sections¶
Returns a list of all root sections IDs (sections whose parent ID are -1)
- section(section_id: int) morphio.mut.Section ¶
Returns the section with the given id
Note: multiple morphologies can share the same Section instances
- property sections¶
Returns a list containing IDs of all sections. The first section of the vector is the soma section
- property soma¶
Returns a reference to the soma object
Note: multiple morphologies can share the same Soma instance
- property soma_type¶
Returns the soma type
- property version¶
Returns 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
(immutable_section: morphio.Section, recursive: bool = False) → morphio.mut.SectionAppend the existing immutable Section to this sectionIf recursive == true, all descendent will be appended as well
append_section
(mutable_section: morphio.mut.Section, recursive: bool = False) → morphio.mut.SectionAppend the existing mutable Section to this section If recursive == true, all descendent will be appended as well
append_section
(point_level_properties: morphio.PointLevel, section_type: morphio.SectionType = <SectionType.undefined: 0>) → morphio.mut.Section- Append a new Section to this section
If section_type is omitted or set to ‘undefined’ the type of the parent section will be used
- property children¶
Returns a list of children IDs
- property diameters¶
Returns the diameters of all points of this section
- has_same_shape(arg0: morphio.mut.Section) bool ¶
- property id¶
Return the section ID
- is_heterogeneous(downstream: bool = True) bool ¶
Returns true if the tree downtream (downstream = true) or upstream (downstream = false) has the same 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 ¶
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¶
Returns the perimeters of all points of this section
- property points¶
Returns the coordinates (x,y,z) of all points of this section
- property type¶
Returns the morphological type of this section (dendrite, axon, …)
- class morphio.mut.Soma¶
Class representing a mutable Soma
- property center¶
Returns the center of gravity of the soma points
- property diameters¶
Returns 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¶
Returns the coordinates (x,y,z) of all soma point
- property surface¶
Returns the soma surface
Note: the soma surface computation depends on the soma type
- property type¶
Returns the soma type