snake.core.transform
#
Mathematical transformations of data.
Module Contents#
Functions#
Compute the effective affine transformation between two affine matrices. |
|
Check if we can use the affine_transform from cupy. |
|
Apply the new affine on the data. |
|
Apply the new affine on 4D data. |
|
Serialize the array for mrd compatible format. |
|
Unserialize the array for mrd compatible format. |
Data#
API#
- snake.core.transform.effective_affine(old: numpy.typing.NDArray, new: numpy.typing.NDArray) numpy.typing.NDArray [source]#
Compute the effective affine transformation between two affine matrices.
- snake.core.transform._validate_gpu_affine(use_gpu: bool = True) tuple[bool, collections.abc.Callable, types.ModuleType] [source]#
Check if we can use the affine_transform from cupy.
- snake.core.transform.apply_affine(data: numpy.typing.NDArray[numpy.float32], old_affine: numpy.typing.NDArray[numpy.float32], new_affine: numpy.typing.NDArray[numpy.float32], new_shape: snake._meta.ThreeInts, output: numpy.typing.NDArray[numpy.float32] = None, transform_affine: numpy.typing.NDArray[numpy.float32] = None, use_gpu: bool = True, **kwargs: Any) numpy.typing.NDArray[numpy.float32] [source]#
Apply the new affine on the data.
- Parameters:
data (NDArray) β Data to be transformed. 3D Array.
old_affine (NDArray) β Affine of the original data
new_affine (NDArray) β Affine of the new data
new_shape (ThreeInts) β Shape of the new data
transform_affine (NDArray, optional) β Transformation affine, by default None
use_gpu (bool, optional) β Try to use GPU, by default True
output (NDArray, optional) β Output array, by default None
- Returns:
NDArray
Resampled data with
new_affine
orientation andnew_shape
shape.
- snake.core.transform.__apply_affine(x: numpy.typing.NDArray, output: numpy.typing.NDArray, i: int, *args: Any, **kwargs: Any) numpy.typing.NDArray [source]#
- snake.core.transform.apply_affine4d(data: numpy.typing.NDArray, old_affine: numpy.typing.NDArray, new_affine: numpy.typing.NDArray, new_shape: snake._meta.ThreeInts, use_gpu: bool = False, n_jobs: int = -1, axis: int = 0, **kwargs: Any) numpy.typing.NDArray [source]#
Apply the new affine on 4D data.
- Parameters:
data (NDArray) β Data to be transformed. 3D Array.
old_affine (NDArray) β Affine of the original data
new_affine (NDArray) β Affine of the new data
new_shape (ThreeInts) β Shape of the new data
transform_affine (NDArray, optional) β Transformation affine, by default None
use_gpu (bool, optional)
- Returns:
Resampled data with
new_affine
orientation andnew_shape
shape.- Return type:
NDArray
See also