niftynet.layer.pad module

class PadLayer(image_name, border, name='pad', mode='minimum', pad_to=(0, ))[source]

Bases: niftynet.layer.base_layer.Layer, niftynet.layer.base_layer.Invertible

This class defines a padding operation: pad 2*border pixels from spatial dims of the input (numpy array), and return the padded input.

This function is used at volume level (as a preprocessor in image reader) therefore assumes the input has at least three spatial dims.

__init__(image_name, border, name='pad', mode='minimum', pad_to=(0, ))[source]
Parameters:
  • image_name – the name of the relevant key in the data dictionary
  • border – the dimensions of the desired border around the image.
  • name – name of the PadLayer in the tensorflow graph.
  • mode – how to choose the padding values for the np.pad operation.
  • pad_to – this determines a desired size of the padded image (useful for inconsistent input sizes or for making inference efficient). If it == (0, ) (DEFAULT), it will use the constant padding mode determined by ‘border’
layer_op(input_image, mask=None)[source]
inverse_op(input_image, mask=None)[source]