Given an input image list (possibly multi-modal) and an optional corresponding segmentation image list, this function will perform data augmentation with the following augmentation possibilities: spatial transformations, added image noise, simulated bias field, and histogram warping.

dataAugmentation(
  inputImageList,
  segmentationImageList = NULL,
  pointsetList = NULL,
  numberOfSimulations = 10,
  referenceImage = NULL,
  transformType = "affineAndDeformation",
  noiseModel = "additivegaussian",
  noiseParameters = c(0, 0.05),
  sdSimulatedBiasField = 1,
  sdHistogramWarping = 0.05,
  sdAffine = 0.05,
  outputNumpyFilePrefix = NULL,
  verbose = FALSE
)

Arguments

inputImageList

list of lists of input images to warp. The internal list sets contains one or more images (per subject) which are assumed to be mutually aligned. The outer list contains multiple subject lists which are randomly sampled to produce output image list.

segmentationImageList

list of segmentation images corresponding to the input image list (optional).

pointsetList

list of pointsets (matrices) corresponding to the input image list (optional). If using this option, the transformType must be invertible.

numberOfSimulations

number of output images. Default = 10.

referenceImage

defines the spatial domain for all output images. If the input images do not match the spatial domain of the reference image, we internally resample the target to the reference image. This could have unexpected consequences. Resampling to the reference domain is performed by testing using antsImagePhysicalSpaceConsistency then calling resampleImageToTarget upon failure.

transformType

one of the following options c( "translation", "rigid", "scaleShear", "affine"," deformation" , "affineAndDeformation" ).

noiseModel

one of the following options c( "additivegaussian", "saltandpepper", "shot", "speckle", or "random" ). Alternatively, one can specify an array or list of one or more of the options and one is selected at random with reasonable, randomized parameters. Note that the "speckle" model takes much longer than the others. #' @param noiseParameters 'additivegaussian': c( mean, standardDeviation ), 'saltandpepper': c( probability, saltValue, pepperValue) , 'shot': scale, 'speckle': standardDeviation. Note that the standard deviation, scale, and probability values are max values and are randomly selected in the range 0, noise_parameter. Also, the "mean", "saltValue" and pepperValue" are assumed to be in the intensity normalized range of 0, 1.

sdSimulatedBiasField

Characterize the standard deviation of the amplitude.

sdHistogramWarping

Determines the strength of the histogram transformation.

sdAffine

Determines the amount of transformation based change.

outputNumpyFilePrefix

Filename of output numpy array containing all the simulated images and segmentations.

Value

list of lists of transformed images and/or outputs to a numpy array.

Author

Tustison NJ

Examples

library( ANTsR ) image1 <- antsImageRead( getANTsRData( "r16" ) ) image2 <- antsImageRead( getANTsRData( "r64" ) ) segmentation1 <- thresholdImage( image1, "Otsu", 3 ) segmentation2 <- thresholdImage( image2, "Otsu", 3 ) points1 = getCentroids( segmentation1 )[,1:2] points2 = getCentroids( segmentation2 )[,1:2] data <- dataAugmentation( list( list( image1 ), list( image2 ) ), list( segmentation1, segmentation2 ), list( points1, points2 ), transformType = 'scaleShear' )
#> Error in py_discover_config(required_module, use_environment): Python specified in RETICULATE_PYTHON (/Users/ntustison/anaconda3/envs/antsx/bin/python3) does not exist
rm(segmentation1); gc()
#> used (Mb) gc trigger (Mb) limit (Mb) max used (Mb) #> Ncells 2544371 135.9 4570014 244.1 NA 4570014 244.1 #> Vcells 4491876 34.3 12255594 93.6 65536 12254504 93.5
rm(segmentation2); gc()
#> used (Mb) gc trigger (Mb) limit (Mb) max used (Mb) #> Ncells 2544143 135.9 4570014 244.1 NA 4570014 244.1 #> Vcells 4491532 34.3 12255594 93.6 65536 12254504 93.5
rm(image1); gc()
#> used (Mb) gc trigger (Mb) limit (Mb) max used (Mb) #> Ncells 2544133 135.9 4570014 244.1 NA 4570014 244.1 #> Vcells 4491537 34.3 12255594 93.6 65536 12254504 93.5
rm(image2); gc()
#> used (Mb) gc trigger (Mb) limit (Mb) max used (Mb) #> Ncells 2544123 135.9 4570014 244.1 NA 4570014 244.1 #> Vcells 4491542 34.3 12255594 93.6 65536 12254504 93.5