Raised when transformed coordinates are refer to out-of-bounds areas.
This is expected to happen a lot when using random warping, but is caught early on before reading data. The dataset iterator is expected to handle this exception by just retrying the same call again, which will re-randomize the transformation.
get_warped_coord_transform(inp_src_shape, patch_shape, aniso_factor=2, sample_aniso=True, warp_amount=1.0, lock_z=True, no_x_flip=False, perspective=False, target_src_shape=None, target_patch_shape=None)¶
Generates the warping transformation parameters and composes them into a single 4D homogeneous transformation matrix
M. Assumes 3-dimensional (volumetric) source data with shape (D, H, W) or (…, D, H, W). Preceding dimensions before the last three dimensions are ignored, if there are any (e.g. a C dimension that contains input channels).
ndarray]) – Input data source shape
ndarray]) – Patch shape (spatial shape of the neural network’s input node)
int) – Anisotropy factor that determines an additional scaling in
bool) – Scale
1 / aniso_factorwhile warping.
float) – Strength of the random warping transformation. A lower
warp_amountwill lead to less distorted images.
bool) – Exclude
zcoordinates from the random warping transformations.
bool) – Don’t flip
xaxis during random warping.
bool) – Apply perspective transformations (in addition to affine ones).
None]) – Target data source shape
None]) – Target patch shape
Coordinate transformation matrix.
- Return type
warp_slice(inp_src, patch_shape, M, target_src=None, target_patch_shape=None, target_discrete_ix=None, debug=False)¶
Cuts a warped slice out of the input image and out of the target_src image. Warping is applied by multiplying the original source coordinates with the inverse of the homogeneous (forward) transformation matrix
“Source coordinates” (
src_coords) signify the coordinates of voxels in
target_srcthat are used to compose their respective warped versions. The idea here is that not the images themselves, but the coordinates from where they are read are warped. This allows for much higher efficiency for large image volumes because we don’t have to calculate the expensive warping transform for the whole image, but only for the voxels that we eventually want to use for the new warped image. The transformed coordinates usually don’t align to the discrete voxel grids of the original images (meaning they are not integers), so the new voxel values are obtained by linear interpolation.
DataSource) – Input image source (in HDF5)
ndarray]) – (spatial only) Patch shape
(D, H, W)(spatial shape of the neural network’s input node)
ndarray) – Forward warping tansformation matrix (4x4). Must contain translations in source and target_src array.
DataSource]) – Optional target source array to be extracted from in the same way.
None]) – Patch size for the
int]]) – List of target channels that contain discrete values. By default (
None), every channel is is seen as discrete (this is generally the case for classification tasks). This information is used to decide what kind of interpolation should be used for reading target data: - discrete targets are obtained by nearest-neighbor interpolation - non-discrete (continuous) targets are linearly interpolated.
True(default), enable additional sanity checks to catch) – warping issues early.
- Return type
inp – Warped input image slice
target – Warped target_src image slice or
target_src is None.