Skip to content

ngio.transforms API documentation

ngio.transforms

Concrete IO transformations.

ZoomTransform

ZoomTransform(
    input_image: AbstractImage,
    target_image: AbstractImage,
    order: InterpolationOrder = "nearest",
)

Bases: BaseZoomTransform

Source code in src/ngio/transforms/_zoom.py
 9
10
11
12
13
14
15
16
17
18
19
def __init__(
    self,
    input_image: AbstractImage,
    target_image: AbstractImage,
    order: InterpolationOrder = "nearest",
) -> None:
    super().__init__(
        input_dimensions=input_image.dimensions,
        target_dimensions=target_image.dimensions,
        order=order,
    )
get_as_numpy_transform
get_as_numpy_transform(
    array: ndarray,
    slicing_ops: SlicingOps,
    axes_ops: AxesOps,
) -> ndarray

Apply the scaling transformation to a numpy array.

Source code in src/ngio/io_pipes/_zoom_transform.py
140
141
142
143
144
145
146
147
def get_as_numpy_transform(
    self, array: np.ndarray, slicing_ops: SlicingOps, axes_ops: AxesOps
) -> np.ndarray:
    """Apply the scaling transformation to a numpy array."""
    target_shape = self._compute_zoom_shape(
        array_shape=array.shape, axes_ops=axes_ops, slicing_ops=slicing_ops
    )
    return self._numpy_zoom(array=array, target_shape=target_shape)
get_as_dask_transform
get_as_dask_transform(
    array: Array, slicing_ops: SlicingOps, axes_ops: AxesOps
) -> Array

Apply the scaling transformation to a dask array.

Source code in src/ngio/io_pipes/_zoom_transform.py
149
150
151
152
153
154
155
156
157
158
159
def get_as_dask_transform(
    self, array: da.Array, slicing_ops: SlicingOps, axes_ops: AxesOps
) -> da.Array:
    """Apply the scaling transformation to a dask array."""
    array_shape = tuple(int(s) for s in array.shape)
    target_shape = self._compute_zoom_shape(
        array_shape=array_shape, axes_ops=axes_ops, slicing_ops=slicing_ops
    )
    return self._dask_zoom(
        array=array, array_shape=array_shape, target_shape=target_shape
    )
set_as_numpy_transform
set_as_numpy_transform(
    array: ndarray,
    slicing_ops: SlicingOps,
    axes_ops: AxesOps,
) -> ndarray

Apply the inverse scaling transformation to a numpy array.

Source code in src/ngio/io_pipes/_zoom_transform.py
161
162
163
164
165
166
167
168
def set_as_numpy_transform(
    self, array: np.ndarray, slicing_ops: SlicingOps, axes_ops: AxesOps
) -> np.ndarray:
    """Apply the inverse scaling transformation to a numpy array."""
    target_shape = self._compute_inverse_zoom_shape(
        array_shape=array.shape, axes_ops=axes_ops, slicing_ops=slicing_ops
    )
    return self._numpy_zoom(array=array, target_shape=target_shape)
set_as_dask_transform
set_as_dask_transform(
    array: Array, slicing_ops: SlicingOps, axes_ops: AxesOps
) -> Array

Apply the inverse scaling transformation to a dask array.

Source code in src/ngio/io_pipes/_zoom_transform.py
170
171
172
173
174
175
176
177
178
179
180
def set_as_dask_transform(
    self, array: da.Array, slicing_ops: SlicingOps, axes_ops: AxesOps
) -> da.Array:
    """Apply the inverse scaling transformation to a dask array."""
    array_shape = tuple(int(s) for s in array.shape)
    target_shape = self._compute_inverse_zoom_shape(
        array_shape=array_shape, axes_ops=axes_ops, slicing_ops=slicing_ops
    )
    return self._dask_zoom(
        array=array, array_shape=array_shape, target_shape=target_shape
    )