Creates a keras model of the U-net + ResNet deep learning architecture for image segmentation and regression with the paper available here:

createResUnetModel3D(
  inputImageSize,
  numberOfOutputs = 1,
  numberOfFiltersAtBaseLayer = 32,
  bottleNeckBlockDepthSchedule = c(3, 4),
  convolutionKernelSize = c(3, 3, 3),
  deconvolutionKernelSize = c(2, 2, 2),
  dropoutRate = 0,
  weightDecay = 0.0001,
  mode = c("classification", "regression")
)

Arguments

inputImageSize

Used for specifying the input tensor shape. The shape (or dimension) of that tensor is the image dimensions followed by the number of channels (e.g., red, green, and blue). The batch size (i.e., number of training images) is not specified a priori.

numberOfOutputs

Meaning depends on the mode. For 'classification' this is the number of segmentation labels. For 'regression' this is the number of outputs.

numberOfFiltersAtBaseLayer

number of filters at the beginning and end of the 'U'. Doubles at each descending/ascending layer.

bottleNeckBlockDepthSchedule

vector that provides the encoding layer schedule for the number of bottleneck blocks per long skip connection.

convolutionKernelSize

2-d vector defining the kernel size during the encoding path

deconvolutionKernelSize

2-d vector defining the kernel size during the decoding

dropoutRate

float between 0 and 1 to use between dense layers.

weightDecay

weighting parameter for L2 regularization of the kernel weights of the convolution layers. Default = 0.0.

mode

'classification' or 'regression'.

Value

a res/u-net keras model

Details

    \url{https://arxiv.org/abs/1608.04117}

This particular implementation was ported from the following python implementation:

    \url{https://github.com/veugene/fcn_maker/}

Author

Tustison NJ

Examples

library( ANTsRNet ) library( keras ) model <- createResUnetModel3D( c( 64, 64, 64, 1 ) )
#> Error in py_discover_config(required_module, use_environment): Python specified in RETICULATE_PYTHON (/Users/ntustison/anaconda3/envs/antsx/bin/python3) does not exist
metric_multilabel_dice_coefficient <- custom_metric( "multilabel_dice_coefficient", multilabel_dice_coefficient )
#> Error in value[[3L]](cond): The R function's signature must not contains esoteric Python-incompatible constructs. Detailed traceback: #> Python specified in RETICULATE_PYTHON (/Users/ntustison/anaconda3/envs/antsx/bin/python3) does not exist
loss_dice <- function( y_true, y_pred ) { -multilabel_dice_coefficient(y_true, y_pred) } attr(loss_dice, "py_function_name") <- "multilabel_dice_coefficient" model %>% compile( loss = loss_dice, optimizer = optimizer_adam( lr = 0.0001 ), metrics = c( metric_multilabel_dice_coefficient, metric_categorical_crossentropy ) )
#> Error in compile(., loss = loss_dice, optimizer = optimizer_adam(lr = 1e-04), metrics = c(metric_multilabel_dice_coefficient, metric_categorical_crossentropy)): object 'model' not found
print( model )
#> Error in print(model): object 'model' not found