Creates a keras model of the dense U-net deep learning architecture for image segmentation

createDenseUnetModel3D(
  inputImageSize,
  numberOfOutputs = 1L,
  numberOfLayersPerDenseBlock = c(3, 4, 12, 8),
  growthRate = 48,
  initialNumberOfFilters = 96,
  reductionRate = 0,
  depth = 7,
  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).

numberOfOutputs

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

numberOfLayersPerDenseBlock

number of dense blocks per layer.

growthRate

number of filters to add for each dense block layer (default = 48).

initialNumberOfFilters

number of filters at the beginning (default = 96).

reductionRate

reduction factor of transition blocks

depth

number of layers---must be equal to 3 * N + 4 where N is an integer (default = 7).

dropoutRate

drop out layer rate (default = 0.2).

weightDecay

weight decay (default = 1e-4).

mode

A switch to determine the activation function to use. If classification, then sigmoid or softmax depending on the numberOfOutputs, and if mode = "regression" then function is linear

Value

an DenseUnet keras model

Details

X. Li, H. Chen, X. Qi, Q. Dou, C.-W. Fu, P.-A. Heng. H-DenseUNet: Hybrid Densely Connected UNet for Liver and Tumor Segmentation from CT Volumes

available here:

    https://arxiv.org/pdf/1709.07330.pdf

with the author's implementation available at:

    https://github.com/xmengli999/H-DenseUNet

Author

Tustison NJ

Examples

library( ANTsRNet ) library( keras ) model <- createDenseUnetModel3D( 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
rm(model); gc()
#> Warning: object 'model' not found
#> used (Mb) gc trigger (Mb) limit (Mb) max used (Mb) #> Ncells 2513106 134.3 4570014 244.1 NA 4570014 244.1 #> Vcells 4426777 33.8 12255594 93.6 65536 10006078 76.4