Deep learning for NeuroImaging in Python.
Note
This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the gallery for the big picture.
- class nidl.volume.transforms.preprocessing.spatial.resize.Resize(target_shape: int | tuple[int, int, int], interpolation: str = 'linear', **kwargs)[source]¶
Bases:
Resample
Resize a 3d volume to match a target shape.
This transformation resizes a 3d volume to a new target shape, implicitely modifying the physical spacing. Internally, it uses SimpleITK for fast and robust resampling. It handles
np.ndarray
ortorch.Tensor
as input and returns a consistent output (same type). Input shape must beor
.
- Parameters:
target_shape : int or tuple of (int, int, int)
Output shape
. If int is given, it sets
.
interpolation : str in {‘nearest’, ‘linear’, ‘bspline’, ‘cubic’, ‘gaussian’, ‘label_gaussian’, ‘hamming’, ‘cosine’, ‘welch’, ‘lanczos’, ‘blackman’}, default=’linear’
Interpolation techniques available in ITK. linear, the default in nidl for scalar images, offers a good compromise between image quality and speed and is a solid choice for data augmentation during training. Methods such as bspline or lanczos produce high-quality results but are slower and best used during offline preprocessing. nearest is very fast but gives poorer results for scalar images; however, it is the default for label maps, as it preserves categorical values. For a full comparison of interpolation methods, see [R14]. Descriptions of available methods:
nearest: Nearest-neighbor interpolation.
linear: Linear interpolation.
bspline: B-spline of order 3 (cubic).
cubic: Alias for bspline.
gaussian: Gaussian interpolation
.
label_gaussian: Gaussian interpolation for label maps (
).
hamming: Hamming-windowed sinc kernel.
cosine: Cosine-windowed sinc kernel.
welch: Welch-windowed sinc kernel.
lanczos: Lanczos-windowed sinc kernel.
blackman: Blackman-windowed sinc kernel.
**kwargs : dict
Keyword arguments given to
nidl.transforms.Transform
.
References
- apply_transform(data: ndarray | Tensor) ndarray | Tensor [source]¶
Resize the input volume.
- Parameters:
data : np.ndarray or torch.Tensor
The input data with shape
or
. The channel dimension is never resized.
- Returns:
data : np.ndarray or torch.Tensor
Resampled data with shape
or
and same type as input.
Follow us