niftynet.network.unet module

class UNet3D(num_classes, w_initializer=None, w_regularizer=None, b_initializer=None, b_regularizer=None, acti_func='prelu', name='UNet')[source]

Bases: niftynet.layer.base_layer.TrainableLayer

### Description
reimplementation of 3D U-net
Çiçek et al., “3D U-Net: Learning dense Volumetric segmentation from sparse annotation”, MICCAI ‘16

### Building blocks [dBLOCK] - Downsampling UNet Block [uBLOCK] - Upsampling UNet Block [nBLOCK] - UNet Block with no final operation [CROP] - Cropping layer

### Diagram

INPUT –> [dBLOCK] - - - - - - - - - - - - - - - - [nBLOCK] –> [CROP] –> OUTPUT
[dBLOCK] - - - - - - - - - - - - [uBLOCK]
[dBLOCK] - - - - - - - [uBLOCK]

——–[uBLOCk] ——

### Constraints
  • Image size - 4 should be divisible by 8
  • Label size should be more than 88
  • border is 44
__init__(num_classes, w_initializer=None, w_regularizer=None, b_initializer=None, b_regularizer=None, acti_func='prelu', name='UNet')[source]
Parameters:
  • num_classes – int, number of final output channels
  • w_initializer – weight initialisation for network
  • w_regularizer – weight regularisation for network
  • b_initializer – bias initialisation for network
  • b_regularizer – bias regularisation for network
  • acti_func – activation function to use
  • name – layer name
layer_op(images, is_training=True, layer_id=-1, **unused_kwargs)[source]
Parameters:
  • images – tensor, input to the network
  • is_training – boolean, True if network is in training mode
  • layer_id – int, not in use
  • unused_kwargs – other arguments, not in use
Returns:

tensor, output of the network

class UNetBlock(func, n_chns, kernels, w_initializer=None, w_regularizer=None, with_downsample_branch=False, acti_func='relu', name='UNet_block')[source]

Bases: niftynet.layer.base_layer.TrainableLayer

__init__(func, n_chns, kernels, w_initializer=None, w_regularizer=None, with_downsample_branch=False, acti_func='relu', name='UNet_block')[source]
Parameters:
  • func – string, type of operation to perform after convolution (Downsampling, Upsampling, None)
  • n_chns – array, number of output channels for each convolutional layer of the block
  • kernels – array, kernel sizes for each convolutional layer of the block
  • w_initializer – weight initialisation of convolutional layers
  • w_regularizer – weight regularisation of convolutional layers
  • with_downsample_branch – boolean, returns also the tensor before func is applied
  • acti_func – activation function to use
  • name – layer name
layer_op(input_tensor, is_training)[source]
Parameters:
  • input_tensor – tensor, input to the UNet block
  • is_training – boolean, True if network is in training mode
Returns:

output tensor of the UNet block and branch before downsampling (if required)