niftynet.layer.affine_augmentation module

class AffineAugmentationLayer(scale, interpolation='linear', boundary='zero', transform=None, name='AffineAugmentation')[source]

Bases: niftynet.layer.base_layer.Layer

This layer applies a small random (per-iteration) affine transformation to an image. The distribution of transformations generally results in scaling the image up, with minimal sampling outside the original image.

__init__(scale, interpolation='linear', boundary='zero', transform=None, name='AffineAugmentation')[source]
Parameters:
  • scale – how extreme the perturbation is, with 0. meaning no perturbation and 1.0 giving largest perturbations.
  • interpolation – the image value interpolation used by the resampling.
  • boundary – the boundary handling used by the resampling
  • name – string name of the layer.
layer_op(input_tensor)[source]
inverse(interpolation=None, boundary=None, name=None)[source]

create a new layer that will apply the inversed version of self._transform. This function write this instance members. (calling self() after self.inverse() might give unexpected results.)

Parameters:
  • interpolation
  • boundary
  • name
Returns:

a niftynet layer that inverses the transformation of self.

get_relative_corners(spatial_rank)[source]

compute relative corners of the spatially n-d tensor:

1-D: [[-1], [1]]
2-D: [[-1, -1], [-1, 1], [1, -1], [1, 1]]
3-D: [[-1, -1, -1], [-1, -1, 1],
      [-1, 1, -1],  [-1, 1, 1],
      [1, -1, -1],  [1, -1, 1],
      [1, 1, -1],   [1, 1, 1]]
Parameters:spatial_rank – integer of number of spatial dimensions
Returns:[2**spatial_rank, spatial_rank] matrix