randomImageTransformBatchGenerator: Random image transformation batch generator

randomImageTransformBatchGeneratorR Documentation

Random image transformation batch generator

Description

This R6 class can be used to generate affine and other transformations of an input image predictor and outcome population. It currently works for single predictor and single outcome modalities but will be extended in the future. The class calls randomImageTransformAugmentation.

Usage

bgen = randomImageTransformBatchGenerator$new( ... )

bgen$generate( batchSize = 32L )

Arguments

imageList List of lists where the embedded list contains k images.

outcomeImageList List of outcome images.

transformType random transform type to generate; one of the following options c("Translation","Rigid","ScaleShear","Affine","Deformation", "AffineAndDeformation")

imageDomain defines the spatial domain for all images. NOTE: if the input images do not match the spatial domain of the domain image, we internally resample the target to the domain. This may have unexpected consequences if you are not aware of this. This operation will test antsImagePhysicalSpaceConsistency then call resampleImageToTarget upon failure.

sdAffine roughly controls deviation from identity matrix

nControlPoints number of control points for simulated deformation

spatialSmoothing spatial smoothing for simulated deformation

toCategorical boolean vector denoting whether the outcome class is categorical or not imageDomainY optional domain for outcome images normalization optional intensity normalization either none, standardize or 01

Methods

$new() Initialize the class in default empty or filled form.

$generate generate the batch of samples with given batch size

See Also

randomImageTransformAugmentation

Examples


library( ANTsR )
i1 = antsImageRead( getANTsRData( "r16" ) )
i2 = antsImageRead( getANTsRData( "r64" ) )
s1 = thresholdImage( i1, "Otsu", 3 )
s2 = thresholdImage( i2, "Otsu", 3 )
# see ANTsRNet randomImageTransformAugmentation
predictors = list( list(i1), list(i2), list(i1), list(i2) )
outcomes = list( s1, s2,  s1, s2 )
trainingData <- randomImageTransformBatchGenerator$new(
  imageList = predictors,
  outcomeImageList = outcomes,
  transformType = "Affine",
  imageDomain = i1,
  toCategorical = TRUE
  )
testBatchGenFunction = trainingData$generate( 2 )
myout = testBatchGenFunction( )


ANTsX/ANTsRNet documentation built on Nov. 21, 2024, 4:07 a.m.