morph_tool.transform¶
Tools for morphology geometric transformations (translation, rotation, etc).
Functions
|
Rotate a section (and all its descendents) so its initial segment is along |
|
In-place alignment of a morphology towards a 'direction'. |
|
Apply rotation matrix A to a given morphology object. |
|
Find the rotation matrix that aligns vec1 to vec2. |
|
Apply transformation matrix A to a given morphology object. |
|
Apply translation to a given morphology object. |
Classes
|
Contains possible align methods for align_morphology. |
- class morph_tool.transform.AlignMethod(value)¶
Contains possible align methods for align_morphology.
- classmethod values()¶
Get all possible values.
- morph_tool.transform.align(section, direction)¶
Rotate a section (and all its descendents) so its initial segment is along
direction
.
- morph_tool.transform.align_morphology(morph, direction=None, method='whole', neurite_type='apical', target_point=None)¶
In-place alignment of a morphology towards a ‘direction’.
The base algorithm is based on eigenvalue decomposition of the correlation matrix obtained from points in specified neurites, giving the principal axis of the neurite, centered at soma. Currently, five algorithms are implemented, differing in the choice of points:
with method=’whole’: All the points in the apical dendrite are used.
with method=’trunk’: Points in section up to the target points are used.
with method=’first_section’: Only the points in the first section are used.
with method=’first_segment’: Only the points in the first segment are used.
with method an ndarray or list, we will use it as the direction directly
If no neurite is present, no rotation is applied, and the identity rotation is returned. If two neurites of same types are present, the first accessed by Morphio will be used.
- Parameters:
morph (morphio.Morphology) – morphology to align
direction (ndarray) – 3-vector for final direction, if None, [0, 1, 0] will be used
method (str|ndarray) – method for alignment.
neurite_type (str) – neurite to consider, can only be apical or axon
target_point (ndarray) – position of target point for method=’trunk’, if None and neurite_type=’apical’, it will be estimated
- Returns:
3x3 array with applied rotation matrix, 3 array with center of rotation
- morph_tool.transform.rotate(obj, A, origin=(0, 0, 0))¶
Apply rotation matrix A to a given morphology object.
- Parameters:
obj – Morphology / Section
A – rotation matrix (3 x 3 NumPy array)
origin (3D point) – the origin of the rotation
- morph_tool.transform.rotation_matrix_from_vectors(vec1, vec2)¶
Find the rotation matrix that aligns vec1 to vec2.
Picked from: https://stackoverflow.com/a/59204638/3868743 :param vec1: A 3d “source” vector :param vec2: A 3d “destination” vector
- Returns:
A transform matrix (3x3) which when applied to vec1, aligns it with vec2.
- morph_tool.transform.transform(obj, A)¶
Apply transformation matrix A to a given morphology object.
- Parameters:
obj – Morphology / Section
A – rotation matrix (4 x 4 NumPy array)
- morph_tool.transform.translate(obj, shift)¶
Apply translation to a given morphology object.
- Parameters:
obj – Morphology / Section
shift – shift vector ((x, y, z) NumPy array)