webknossos.dataset_properties
¶
AffineCoordinateTransformation
¶
Bases: CoordinateTransformation
An affine transformation, given as a 4x4 homogeneous matrix.
The matrix uses the usual mathematical convention, i.e. matrix[row][column] with
the translation in the last column. Applied to a point p, it yields
matrix[:3, :3] @ p + matrix[:3, 3]. For example, the matrix
[[1, 0, 0, 10],
[0, 1, 0, 20],
[0, 0, 1, 30],
[0, 0, 0, 1]]
translates the layer by (10, 20, 30).
Instead of writing the matrix by hand, it can be built up from the identity,
from_translation, from_scale and from_rotation constructors together with the
translate, scale, rotate, flip and chain methods. Those methods return a
new transformation and never modify the one they are called on. Each of them is
applied after the transformation it is called on, so
AffineCoordinateTransformation.identity().rotate("z", 90).translate((5, 0, 0))
rotates the layer first and translates the result afterwards.
matrix
class-attribute
instance-attribute
¶
matrix: ndarray = field(
converter=_as_matrix,
eq=cmp_using(eq=array_equal),
on_setattr=frozen,
)
The 4x4 homogeneous transformation matrix as a read-only float64 numpy array.
chain
¶
chain(
other: AffineCoordinateTransformation,
) -> AffineCoordinateTransformation
Returns a new transformation that applies this one first and other afterwards.
flip
¶
flip(axis: Axis) -> AffineCoordinateTransformation
Returns a new transformation that additionally mirrors along axis.
The layer is mirrored at the origin, i.e. the coordinates along axis change
their sign.
from_rotation
classmethod
¶
from_rotation(
axis: Axis, angle: float
) -> AffineCoordinateTransformation
Creates a transformation that rotates the layer around the origin.
Parameters:
-
axis(Axis) –The axis to rotate around, one of
"x","y"or"z". -
angle(float) –The rotation angle in degrees, counter-clockwise when looking from the positive end of
axistowards the origin.
from_scale
classmethod
¶
from_scale(
scale: Vec3FloatLike,
) -> AffineCoordinateTransformation
Creates a transformation that scales the layer by scale around the origin.
from_translation
classmethod
¶
from_translation(
translation: Vec3FloatLike,
) -> AffineCoordinateTransformation
Creates a transformation that translates the layer by translation.
identity
classmethod
¶
identity() -> AffineCoordinateTransformation
Creates a transformation that leaves the layer where it is.
rotate
¶
rotate(
axis: Axis, angle: float
) -> AffineCoordinateTransformation
Returns a new transformation that additionally rotates by angle degrees around axis.
See from_rotation for the orientation of the rotation.
scale
¶
scale(
scale: Vec3FloatLike,
) -> AffineCoordinateTransformation
Returns a new transformation that additionally scales by scale around the origin.
translate
¶
translate(
translation: Vec3FloatLike,
) -> AffineCoordinateTransformation
Returns a new transformation that additionally translates by translation.
CoordinateTransformation
¶
Bases: ABC
Base class of the coordinate transformations of a layer.
Transformations are immutable values: their arrays are read-only and their
attributes cannot be reassigned. To change a transformation, build a new one and
assign it to Layer.coordinate_transformations. Copying one therefore hands back
the very same object.
ThinPlateSplineCoordinateTransformation
¶
Bases: CoordinateTransformation
A non-linear transformation defined by pairs of corresponding landmarks.
source[i] is mapped onto target[i]; in between, the layer is warped smoothly by
a thin plate spline. Both arrays must have the same length.
pairs
property
¶
The correspondences as (source, target) pairs.
source
class-attribute
instance-attribute
¶
source: ndarray = field(
converter=_as_points,
eq=cmp_using(eq=array_equal),
on_setattr=frozen,
)
The landmarks in the layer's own coordinate space, as a read-only (N, 3) float64 array.
target
class-attribute
instance-attribute
¶
target: ndarray = field(
converter=_as_points,
eq=cmp_using(eq=array_equal),
on_setattr=frozen,
)
The landmarks in the target coordinate space, as a read-only (N, 3) float64 array.
from_pairs
classmethod
¶
from_pairs(
pairs: Sequence[Sequence[Vec3FloatLike]],
) -> ThinPlateSplineCoordinateTransformation
Creates a transformation from (source, target) correspondence pairs.
Parameters:
-
pairs(Sequence[Sequence[Vec3FloatLike]]) –The correspondences, each a pair of a source and a target point. The points may be
Vec3Int, tuples, numpy arrays or any other iterable of three numbers.
- Get Help
- Community Forums
- Email Support