ants.deeplearn.data_augmentation
- data_augmentation(input_image_list, segmentation_image_list=None, pointset_list=None, number_of_simulations=10, reference_image=None, transform_type='affineAndDeformation', noise_model='additivegaussian', noise_parameters=(0.0, 0.05), sd_simulated_bias_field=1.0, sd_histogram_warping=0.05, sd_affine=0.05, sd_deformation=0.2, output_numpy_file_prefix=None, verbose=False)[source]
Randomly transform image data.
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
histogram warping
- Parameters:
input_image_list (
listoflistsofANTsImages) – List of lists of input images to warp. The internal list sets contain 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.segmentation_image_list (
listofANTsImages) – List of segmentation images corresponding to the input image list (optional).pointset_list (
listofpointsets) – Numpy arrays corresponding to the input image list (optional). If using this option, the transform_type must be invertible.number_of_simulations (
int) – Number of simulated output image sets. Default = 10.reference_image (
ants.core.ANTsImage) – Defines the spatial domain for all output images. If one is not specified, we used the first image in the input image list.transform_type (
str) – One of the following options: “translation”, “rigid”, “scaleShear”, “affine”, “deformation”, “affineAndDeformation”.noise_model (
str) – ‘additivegaussian’, ‘saltandpepper’, ‘shot’, and ‘speckle’. Alternatively, one can specify a tuple 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.noise_parameters (
tupleornumpy.ndarrayorfloat) – ‘additivegaussian’: (mean, standardDeviation) ‘saltandpepper’: (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].sd_simulated_bias_field (
float) – Characterize the standard deviation of the amplitude.sd_histogram_warping (
float) – Determines the strength of the bias field.sd_affine (
float) – Determines the amount of affine transformation.sd_deformation (
float) – Determines the amount of deformable transformation.output_numpy_file_prefix (
str) – Filename of output numpy array containing all the simulated images and segmentations.
- Return type:
listoflistsoftransformed images and/or outputstoa numpy array.
Example
>>> image1_list = list() >>> image1_list.append(ants.image_read(ants.get_ants_data("r16"))) >>> image2_list = list() >>> image2_list.append(ants.image_read(ants.get_ants_data("r64"))) >>> segmentation1 = ants.threshold_image(image1_list[0], "Otsu", 3) >>> segmentation2 = ants.threshold_image(image2_list[0], "Otsu", 3) >>> input_segmentations = list() >>> input_segmentations.append(segmentation1) >>> input_segmentations.append(segmentation2) >>> points1 = ants.get_centroids(segmentation1)[:,0:2] >>> points2 = ants.get_centroids(segmentation2)[:,0:2] >>> input_points = list() >>> input_points.append(points1) >>> input_points.append(points2) >>> input_images = list() >>> input_images.append(image1_list) >>> input_images.append(image2_list) >>> data = data_augmentation(input_images, input_segmentations, input_points, tranform_type="scaleShear")