neuron_morphology.transforms.affine_transform module¶
-
class
neuron_morphology.transforms.affine_transform.AffineTransform(affine: Optional[Any] = None)[source]¶ Bases:
neuron_morphology.transforms.transform_base.TransformBaseHandles transformations to a pia/wm aligned coordinate frame.
Methods
from_dict(affine_dict, float])Create an AffineTransform from a dict with keys and values. from_list(affine_list)Create an Affine Transform from a list to_dict(self)Create dictionary defining the transformation. to_list(self)Create a list defining the transformation. transform(self, vector)Apply this transform to (3,) point or (n,3) array-like of points. transform_morphology(self, morphology, clone)Apply this transform to all nodes in a morphology. -
classmethod
from_dict(affine_dict: Dict[str, float])[source]¶ Create an AffineTransform from a dict with keys and values.
Parameters: - affine_dict: keys and values corresponding to the following
- [[tvr_00 tvr_01 tvr_02 tvr_09]
[tvr_03 tvr_04 tvr_05 tvr_10] [tvr_06 tvr_07 tvr_08 tvr_11] [0 0 0 1]]
Returns: - AffineTransform object
-
classmethod
from_list(affine_list: List[float])[source]¶ Create an Affine Transform from a list
Parameters: - affine_list: list of tvr values corresponding to:
- [[tvr_00 tvr_01 tvr_02 tvr_09]
[tvr_03 tvr_04 tvr_05 tvr_10] [tvr_06 tvr_07 tvr_08 tvr_11] [0 0 0 1]]
Returns: - AffineTransform object
-
to_dict(self) → Dict[source]¶ Create dictionary defining the transformation.
Returns: - Dict with keys and values corresponding to the following:
- [[tvr_00 tvr_01 tvr_02 tvr_09]
[tvr_03 tvr_04 tvr_05 tvr_10] [tvr_06 tvr_07 tvr_08 tvr_11] [0 0 0 1]]
-
to_list(self) → List[source]¶ Create a list defining the transformation.
Returns: - List with values corresponding to the following:
- [[tvr_00 tvr_01 tvr_02 tvr_09]
[tvr_03 tvr_04 tvr_05 tvr_10] [tvr_06 tvr_07 tvr_08 tvr_11] [0 0 0 1]]
-
classmethod
-
neuron_morphology.transforms.affine_transform.affine_from_transform(transform: Any)[source]¶ Create affine transformation.
Parameters: - transformation: (3, 3) row major array-like transformation
Returns: - (4, 4) numpy.ndarray affine matrix
-
neuron_morphology.transforms.affine_transform.affine_from_transform_translation(transform: Union[Any, NoneType] = None, translation: Union[Any, NoneType] = None, translate_first: bool = False)[source]¶ Create affine from linear transformation and translation.
Affine transformation of vector x -> Ax + b in 3D: [A, b
0, 0, 0, 1]A is a 3x3 linear tranformation b is a 3x1 translation
Parameters: - transform: linear transformation (3, 3) array-like
- translation: linear translation (3,) array-like
- translate_first: apply the translation before the transform
Returns: - (4, 4) numpy.ndarray affine matrix
-
neuron_morphology.transforms.affine_transform.affine_from_translation(translation: Any)[source]¶ Create an affine translation.
Parameters: - translation: array-like vector of x, y, and z translations
Returns: - (4, 4) numpy.ndarray affine matrix
-
neuron_morphology.transforms.affine_transform.rotation_from_angle(angle: float, axis: int = 2)[source]¶ Create an affine matrix from a rotation about a specific axis.
Parameters: - angle: rotation angle in radians
- axis: axis to rotate about, 0=x, 1=y, 2=z (default z axis)
Returns: - (3, 3) numpy.ndarray rotation matrix